myask 0.0.1 → 1.0.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.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/bin/myask +1 -1
  4. data/html/App.html +116 -0
  5. data/html/MyAsk/Api/Helper.html +207 -0
  6. data/html/MyAsk/Api/Invitation.html +212 -0
  7. data/html/MyAsk/Api/Project.html +355 -0
  8. data/html/MyAsk/Api/ProjectHelper.html +299 -0
  9. data/html/MyAsk/Api/Question.html +261 -0
  10. data/html/MyAsk/Api.html +120 -0
  11. data/html/MyAsk/Config.html +195 -0
  12. data/html/MyAsk/ConfigHelper.html +251 -0
  13. data/html/MyAsk/Prompt.html +221 -0
  14. data/html/MyAsk/PromptHelper.html +330 -0
  15. data/html/MyAsk.html +114 -0
  16. data/html/README_rdoc.html +394 -0
  17. data/html/created.rid +14 -0
  18. data/html/css/fonts.css +167 -0
  19. data/html/css/rdoc.css +681 -0
  20. data/html/fonts/Lato-Light.ttf +0 -0
  21. data/html/fonts/Lato-LightItalic.ttf +0 -0
  22. data/html/fonts/Lato-Regular.ttf +0 -0
  23. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  24. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  25. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  26. data/html/images/add.png +0 -0
  27. data/html/images/arrow_up.png +0 -0
  28. data/html/images/brick.png +0 -0
  29. data/html/images/brick_link.png +0 -0
  30. data/html/images/bug.png +0 -0
  31. data/html/images/bullet_black.png +0 -0
  32. data/html/images/bullet_toggle_minus.png +0 -0
  33. data/html/images/bullet_toggle_plus.png +0 -0
  34. data/html/images/date.png +0 -0
  35. data/html/images/delete.png +0 -0
  36. data/html/images/find.png +0 -0
  37. data/html/images/loadingAnimation.gif +0 -0
  38. data/html/images/macFFBgHack.png +0 -0
  39. data/html/images/package.png +0 -0
  40. data/html/images/page_green.png +0 -0
  41. data/html/images/page_white_text.png +0 -0
  42. data/html/images/page_white_width.png +0 -0
  43. data/html/images/plugin.png +0 -0
  44. data/html/images/ruby.png +0 -0
  45. data/html/images/tag_blue.png +0 -0
  46. data/html/images/tag_green.png +0 -0
  47. data/html/images/transparent.png +0 -0
  48. data/html/images/wrench.png +0 -0
  49. data/html/images/wrench_orange.png +0 -0
  50. data/html/images/zoom.png +0 -0
  51. data/html/index.html +403 -0
  52. data/html/js/darkfish.js +120 -0
  53. data/html/js/navigation.js +105 -0
  54. data/html/js/navigation.js.gz +0 -0
  55. data/html/js/search.js +110 -0
  56. data/html/js/search_index.js +1 -0
  57. data/html/js/search_index.js.gz +0 -0
  58. data/html/js/searcher.js +229 -0
  59. data/html/js/searcher.js.gz +0 -0
  60. data/html/table_of_contents.html +257 -0
  61. data/lib/myask/version.rb +1 -1
  62. data/pkg/myask-0.0.1/Gemfile +10 -0
  63. data/pkg/myask-0.0.1/Gemfile.lock +70 -0
  64. data/pkg/myask-0.0.1/README.rdoc +6 -0
  65. data/pkg/myask-0.0.1/Rakefile +21 -0
  66. data/pkg/myask-0.0.1/bin/myask +101 -0
  67. data/pkg/myask-0.0.1/lib/myask/api/api_helper.rb +45 -0
  68. data/pkg/myask-0.0.1/lib/myask/api/invitation.rb +49 -0
  69. data/pkg/myask-0.0.1/lib/myask/api/project.rb +193 -0
  70. data/pkg/myask-0.0.1/lib/myask/api/project_helper.rb +46 -0
  71. data/pkg/myask-0.0.1/lib/myask/api/question.rb +99 -0
  72. data/pkg/myask-0.0.1/lib/myask/config.rb +37 -0
  73. data/pkg/myask-0.0.1/lib/myask/config_helper.rb +28 -0
  74. data/pkg/myask-0.0.1/lib/myask/prompt.rb +63 -0
  75. data/pkg/myask-0.0.1/lib/myask/prompt_helper.rb +80 -0
  76. data/pkg/myask-0.0.1/lib/myask/version.rb +3 -0
  77. data/pkg/myask-0.0.1/lib/myask.rb +28 -0
  78. data/pkg/myask-0.0.1/myask.gemspec +22 -0
  79. data/pkg/myask-0.0.1/myask.rdoc +138 -0
  80. data/pkg/myask-0.0.1/test/default_test.rb +14 -0
  81. data/pkg/myask-0.0.1/test/test_helper.rb +4 -0
  82. data/pkg/myask-0.0.1.gem +0 -0
  83. metadata +79 -1
@@ -0,0 +1,28 @@
1
+ module MyAsk
2
+ class ConfigHelper
3
+
4
+ def initialize(global_options, options, args)
5
+ @global_options = global_options
6
+ @options = options
7
+ @args = args
8
+ @rc_file_path = File.expand_path("~/.myask.rc")
9
+ @config_data = YAML.load_file(@rc_file_path)
10
+ end
11
+
12
+ def get_config
13
+ @config_data.reject { |key, _| ["commands", "version", "s", "help"].include?(key.to_s) }.to_json
14
+ end
15
+
16
+ def save_config
17
+ @config_data[:api_key] = @options[:api_key] if @options[:api_key]
18
+ @config_data[:api_host] = @options[:api_host] if @options[:api_host]
19
+ @config_data[:project] = @options[:project] if @options[:project]
20
+
21
+ File.open(@rc_file_path, "w") do |file|
22
+ file.write(@config_data.to_yaml)
23
+ end
24
+ @config_data.reject { |key, _| ["commands", "version", "s", "help"].include?(key.to_s) }.to_json
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,63 @@
1
+ module MyAsk
2
+ class Prompt
3
+
4
+ def initialize(c)
5
+ c.desc "Skip Follow-Up Question"
6
+ c.switch [:no_followup]
7
+
8
+ c.desc "Project ID"
9
+ c.flag [:project]
10
+
11
+ c.desc "Prompt to send"
12
+ c.flag [:p, :prompt]
13
+
14
+ c.desc "Question IDs to include in prompt context"
15
+ c.flag [:c, :context_ids], multiple: true
16
+
17
+ c.desc "Path to source file(s)"
18
+ c.flag [:F, :input_file], multiple: true
19
+
20
+ c.action do |global_options, options, args|
21
+ helper = MyAsk::PromptHelper.new(global_options, options, args)
22
+
23
+ config = global_options
24
+ auth_token = config[:api_key]
25
+ project = options[:project] || config[:project]
26
+
27
+ content = helper.get_initial_question
28
+ context_ids = options[:"context_ids"]
29
+
30
+ loop do
31
+ begin
32
+ question_id = helper.submit_question(config[:api_host], auth_token, project, content, context_ids)
33
+ abort if question_id.nil?
34
+
35
+ context_ids << question_id
36
+
37
+ response = helper.poll_for_response(config[:api_host], auth_token, question_id)
38
+
39
+ if global_options[:json]
40
+ puts "\n\n#{JSON.dump({response: response})}\n\n"
41
+ else
42
+ puts "\n\n#{response}\n\n"
43
+ end
44
+
45
+ break if options[:no_followup]
46
+
47
+ prompt = TTY::Prompt.new
48
+ is_follow_up = prompt.yes?("Would you like to ask a follow-up question?", default: false)
49
+
50
+ break unless is_follow_up
51
+
52
+ follow_up_question = prompt.ask("Enter your follow-up question:").strip
53
+ content = follow_up_question
54
+ rescue => e
55
+ abort "Error: #{e}"
56
+ end
57
+ end
58
+ end
59
+ c
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,80 @@
1
+ module MyAsk
2
+ class PromptHelper
3
+ def initialize(global_options, options, args)
4
+ @global_options = global_options
5
+ @options = options
6
+ @args = args
7
+ end
8
+
9
+ def submit_question(api_host, auth_token, project_id, content, context_ids)
10
+ uri = URI("#{api_host}/api/questions")
11
+ http = Net::HTTP.new(uri.host, uri.port)
12
+ http.use_ssl = (uri.scheme == "https")
13
+
14
+ request = Net::HTTP::Post.new(uri.path)
15
+ request["Authorization"] = "Bearer #{auth_token}"
16
+ request["Content-Type"] = "application/json"
17
+
18
+ request.body = {
19
+ question: {
20
+ project_id: project_id,
21
+ content: content,
22
+ context_ids: context_ids
23
+ }
24
+ }.to_json
25
+
26
+ response = http.request(request)
27
+ parsed_response = JSON.parse(response.body)
28
+
29
+ parsed_response['id'] || nil
30
+ end
31
+
32
+ def poll_for_response(api_host, auth_token, question_id)
33
+ unless @global_options[:silent]
34
+ spinner = TTY::Spinner.new('🔄 Waiting for response from MyAsk API... [:spinner]', format: :dots)
35
+ spinner.auto_spin
36
+ end
37
+
38
+ max_retries = 50
39
+ attempt = 0
40
+
41
+ while attempt < max_retries
42
+ sleep 3
43
+ uri = URI("#{api_host}/api/responses/#{question_id}")
44
+ response = Net::HTTP.get(uri, { 'Authorization' => "Bearer #{auth_token}" })
45
+ parsed_response = JSON.parse(response)
46
+
47
+ if parsed_response.key?('content')
48
+ spinner.success('✅ Response received!') unless @global_options[:silent]
49
+ return parsed_response['content']
50
+ end
51
+
52
+ attempt += 1
53
+ end
54
+
55
+ spinner.error('❌ Timed out waiting for MyAsk API response.') unless @global_options[:silent]
56
+ raise 'No response received from MyAsk API after multiple attempts.'
57
+ end
58
+
59
+ def get_initial_question
60
+ file_contents = []
61
+
62
+ if @options[:input_file]&.any?
63
+ @options[:input_file].each do |file_path|
64
+ begin
65
+ content = File.read(file_path).strip
66
+ file_contents << "**File**: #{file_path}**\n#{content}"
67
+ rescue => e
68
+ raise "❌ Failed to read input file: #{file_path}"
69
+ end
70
+ end
71
+ end
72
+
73
+ combined_question = "#{@options[:prompt]}\n\n---\n#{file_contents.join("\n\n---\n")}" unless file_contents.empty?
74
+ combined_question ||= @options[:prompt] || TTY::Prompt.new.ask('Please enter a prompt:').strip
75
+
76
+ combined_question.empty? ? nil : combined_question
77
+ end
78
+
79
+ end
80
+ end
@@ -0,0 +1,3 @@
1
+ module Myask
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1,28 @@
1
+ require 'myask/version.rb'
2
+
3
+ require 'myask/config.rb'
4
+ require 'myask/config_helper.rb'
5
+
6
+ require 'myask/api/api_helper.rb'
7
+
8
+ require 'myask/api/question.rb'
9
+ require 'myask/api/invitation.rb'
10
+
11
+ require 'myask/api/project.rb'
12
+ require 'myask/api/project_helper.rb'
13
+
14
+ require 'myask/prompt.rb'
15
+ require 'myask/prompt_helper.rb'
16
+
17
+ # Add requires for other files you add to your project here, so
18
+ # you just need to require this one file in your bin file
19
+
20
+ require 'net/http'
21
+ require 'json'
22
+
23
+ require 'io/console'
24
+ require 'tty-spinner'
25
+ require 'tty-prompt'
26
+ require 'yaml'
27
+
28
+ require 'pry-byebug'
@@ -0,0 +1,22 @@
1
+ # Ensure we require the local version and not one we might have installed already
2
+ require File.join([File.dirname(__FILE__),'lib','myask','version.rb'])
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = 'myask'
5
+ s.version = Myask::VERSION
6
+ s.author = 'Andrew Chaney (netuoso)'
7
+ s.email = 'netuoso@myask.io'
8
+ s.homepage = 'https://myask.io'
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = 'MyAsk Command Line Tool Integrates with MyAsk AI API (https://myask.io).'
11
+ s.files = `git ls-files`.split("
12
+ ")
13
+ s.require_paths << 'lib'
14
+ s.extra_rdoc_files = ['README.rdoc','myask.rdoc']
15
+ s.rdoc_options << '--title' << 'myask' << '--main' << 'README.rdoc' << '-ri'
16
+ s.bindir = 'bin'
17
+ s.executables << 'myask'
18
+ s.add_development_dependency('rake')
19
+ s.add_development_dependency('rdoc')
20
+ s.add_development_dependency('minitest')
21
+ s.add_runtime_dependency('gli','~> 2.22.2')
22
+ end
@@ -0,0 +1,138 @@
1
+ == myask - Describe your application here
2
+
3
+ v0.0.1
4
+
5
+ === Global Options
6
+ === --api_host arg
7
+
8
+ Host for MyAsk API
9
+
10
+ [Default Value] http://localhost:3000
11
+
12
+
13
+ === --api_key arg
14
+
15
+ API Key for MyAsk API
16
+
17
+ [Default Value] A9qVFSgXFH8Ubclq4jVYn0PBsEGMSfQf
18
+
19
+
20
+ === --project arg
21
+
22
+ Current MyAsk Project
23
+
24
+ [Default Value] 156891416
25
+
26
+
27
+ === --help
28
+ Show this message
29
+
30
+
31
+
32
+ === --[no-]json
33
+ Format Output as JSON
34
+
35
+
36
+
37
+ === --[no-]silent
38
+ Silent Progress Spinner
39
+
40
+
41
+
42
+ === --version
43
+ Display the program version
44
+
45
+
46
+
47
+ === Commands
48
+ ==== Command: <tt>config </tt>
49
+ View current or set new MyAsk configuration values
50
+
51
+
52
+ ===== Commands
53
+ ====== Command: <tt>save </tt>
54
+
55
+
56
+
57
+ ====== Command: <tt>show </tt>
58
+
59
+
60
+
61
+ [Default Command] show
62
+ ==== Command: <tt>help command</tt>
63
+ Shows a list of commands or help for one command
64
+
65
+ Gets help for the application or its commands. Can also list the commands in a way helpful to creating a bash-style completion function
66
+ ===== Options
67
+ ===== -c
68
+ List commands one per line, to assist with shell completion
69
+
70
+
71
+
72
+ ==== Command: <tt>initconfig </tt>
73
+ Initialize the config file using current global options
74
+
75
+ Initializes a configuration file where you can set default options for command line flags, both globally and on a per-command basis. These defaults override the built-in defaults and allow you to omit commonly-used command line flags when invoking this program
76
+ ===== Options
77
+ ===== --[no-]force
78
+ force overwrite of existing config file
79
+
80
+
81
+
82
+ ==== Command: <tt>invitation </tt>
83
+ Create/list MyAsk Invitations
84
+
85
+
86
+ ===== Commands
87
+ ====== Command: <tt>list </tt>
88
+ List MyAsk invitations.
89
+
90
+
91
+ ====== Command: <tt>send </tt>
92
+ Send MyAsk invitation to a new user
93
+
94
+
95
+ [Default Command] list
96
+ ==== Command: <tt>project </tt>
97
+ Create/show/list/delete MyAsk Project
98
+
99
+
100
+ ===== Commands
101
+ ====== Command: <tt>create </tt>
102
+ Create MyAsk Project
103
+
104
+
105
+ ====== Command: <tt>delete </tt>
106
+ Delete MyAsk Project
107
+
108
+
109
+ ====== Command: <tt>edit project</tt>
110
+ Edit MyAsk Project
111
+
112
+
113
+ ====== Command: <tt>set project</tt>
114
+ Set MyAsk Project
115
+
116
+
117
+ ====== Command: <tt>show project</tt>
118
+ Show MyAsk Project Details
119
+
120
+
121
+ ==== Command: <tt>prompt </tt>
122
+ Send a prompt to MyAsk API
123
+
124
+
125
+ ==== Command: <tt>question </tt>
126
+ Show/delete MyAsk Question
127
+
128
+
129
+ ===== Commands
130
+ ====== Command: <tt>delete question_id</tt>
131
+ Delete MyAsk question
132
+
133
+
134
+ ====== Command: <tt>show question_id</tt>
135
+ Show details for MyAsk question
136
+
137
+
138
+ [Default Command] show
@@ -0,0 +1,14 @@
1
+ require_relative "test_helper"
2
+
3
+ class DefaultTest < Minitest::Test
4
+
5
+ def setup
6
+ end
7
+
8
+ def teardown
9
+ end
10
+
11
+ def test_the_truth
12
+ assert true
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ require "minitest/autorun"
2
+
3
+ # Add test libraries you want to use here, e.g. mocha
4
+ # Add helper classes or methods here, too
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myask
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Chaney (netuoso)
@@ -80,6 +80,63 @@ files:
80
80
  - README.rdoc
81
81
  - Rakefile
82
82
  - bin/myask
83
+ - html/App.html
84
+ - html/MyAsk.html
85
+ - html/MyAsk/Api.html
86
+ - html/MyAsk/Api/Helper.html
87
+ - html/MyAsk/Api/Invitation.html
88
+ - html/MyAsk/Api/Project.html
89
+ - html/MyAsk/Api/ProjectHelper.html
90
+ - html/MyAsk/Api/Question.html
91
+ - html/MyAsk/Config.html
92
+ - html/MyAsk/ConfigHelper.html
93
+ - html/MyAsk/Prompt.html
94
+ - html/MyAsk/PromptHelper.html
95
+ - html/README_rdoc.html
96
+ - html/created.rid
97
+ - html/css/fonts.css
98
+ - html/css/rdoc.css
99
+ - html/fonts/Lato-Light.ttf
100
+ - html/fonts/Lato-LightItalic.ttf
101
+ - html/fonts/Lato-Regular.ttf
102
+ - html/fonts/Lato-RegularItalic.ttf
103
+ - html/fonts/SourceCodePro-Bold.ttf
104
+ - html/fonts/SourceCodePro-Regular.ttf
105
+ - html/images/add.png
106
+ - html/images/arrow_up.png
107
+ - html/images/brick.png
108
+ - html/images/brick_link.png
109
+ - html/images/bug.png
110
+ - html/images/bullet_black.png
111
+ - html/images/bullet_toggle_minus.png
112
+ - html/images/bullet_toggle_plus.png
113
+ - html/images/date.png
114
+ - html/images/delete.png
115
+ - html/images/find.png
116
+ - html/images/loadingAnimation.gif
117
+ - html/images/macFFBgHack.png
118
+ - html/images/package.png
119
+ - html/images/page_green.png
120
+ - html/images/page_white_text.png
121
+ - html/images/page_white_width.png
122
+ - html/images/plugin.png
123
+ - html/images/ruby.png
124
+ - html/images/tag_blue.png
125
+ - html/images/tag_green.png
126
+ - html/images/transparent.png
127
+ - html/images/wrench.png
128
+ - html/images/wrench_orange.png
129
+ - html/images/zoom.png
130
+ - html/index.html
131
+ - html/js/darkfish.js
132
+ - html/js/navigation.js
133
+ - html/js/navigation.js.gz
134
+ - html/js/search.js
135
+ - html/js/search_index.js
136
+ - html/js/search_index.js.gz
137
+ - html/js/searcher.js
138
+ - html/js/searcher.js.gz
139
+ - html/table_of_contents.html
83
140
  - lib/myask.rb
84
141
  - lib/myask/api/api_helper.rb
85
142
  - lib/myask/api/invitation.rb
@@ -93,6 +150,27 @@ files:
93
150
  - lib/myask/version.rb
94
151
  - myask.gemspec
95
152
  - myask.rdoc
153
+ - pkg/myask-0.0.1.gem
154
+ - pkg/myask-0.0.1/Gemfile
155
+ - pkg/myask-0.0.1/Gemfile.lock
156
+ - pkg/myask-0.0.1/README.rdoc
157
+ - pkg/myask-0.0.1/Rakefile
158
+ - pkg/myask-0.0.1/bin/myask
159
+ - pkg/myask-0.0.1/lib/myask.rb
160
+ - pkg/myask-0.0.1/lib/myask/api/api_helper.rb
161
+ - pkg/myask-0.0.1/lib/myask/api/invitation.rb
162
+ - pkg/myask-0.0.1/lib/myask/api/project.rb
163
+ - pkg/myask-0.0.1/lib/myask/api/project_helper.rb
164
+ - pkg/myask-0.0.1/lib/myask/api/question.rb
165
+ - pkg/myask-0.0.1/lib/myask/config.rb
166
+ - pkg/myask-0.0.1/lib/myask/config_helper.rb
167
+ - pkg/myask-0.0.1/lib/myask/prompt.rb
168
+ - pkg/myask-0.0.1/lib/myask/prompt_helper.rb
169
+ - pkg/myask-0.0.1/lib/myask/version.rb
170
+ - pkg/myask-0.0.1/myask.gemspec
171
+ - pkg/myask-0.0.1/myask.rdoc
172
+ - pkg/myask-0.0.1/test/default_test.rb
173
+ - pkg/myask-0.0.1/test/test_helper.rb
96
174
  - test/default_test.rb
97
175
  - test/test_helper.rb
98
176
  homepage: https://myask.io