shivanshu-sdk 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.
- checksums.yaml +7 -0
- data/README.md +69 -0
- data/lib/shivanshu/client.rb +132 -0
- data/lib/shivanshu/version.rb +5 -0
- data/lib/shivanshu.rb +9 -0
- metadata +52 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 233f4306a9c4a05d17246f5efcc0b4d50f0645fe66b153bef4f51d436ebe833a
|
|
4
|
+
data.tar.gz: '0518bcf2320490c3b35465e8ae88bd12b4991d55cef9d7d273d983c77ccf5df1'
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 56ab9496eb77d395803311b14a7a5c2daf1cbfb375052707d54438acb917a667a87fd3d0e4294d9d32865289fe3ff9f74201967580b31c04867a3571278450ae
|
|
7
|
+
data.tar.gz: 64ad5ae8e185c3d0b08132d38dffcaeade8ce960ccac3238fdeb825d97d89bfb452573c7e393dc73d6fdd57c7f79ef72efd3b6626d8c910dfb90347f25c98d06
|
data/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Shivanshu Tiwari Ruby SDK — `shivanshu-sdk`
|
|
2
|
+
|
|
3
|
+
Official Ruby client library for integrating with **Shivanshu Tiwari Portfolio APIs**, project catalogs, asynchronous background jobs, sandbox testing, and ephemeral test keys.
|
|
4
|
+
|
|
5
|
+
[](https://rubygems.org/gems/shivanshu-sdk)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
gem install shivanshu-sdk
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
*Note: The SDK relies solely on the Ruby standard library (`net/http`, `json`, `uri`) with zero external dependencies.*
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
require "shivanshu"
|
|
20
|
+
|
|
21
|
+
client = Shivanshu::Client.new
|
|
22
|
+
|
|
23
|
+
# 1. Query engineering projects
|
|
24
|
+
projects = client.list_projects(domain: "ai-agents")
|
|
25
|
+
puts "Found #{projects["data"].length} AI agent projects"
|
|
26
|
+
projects["data"].each { |p| puts "- #{p["title"]} (#{p["slug"]})" }
|
|
27
|
+
|
|
28
|
+
# 2. Inspect project architecture and technical tradeoffs
|
|
29
|
+
honeypot = client.get_project("agentic-honey-pot")
|
|
30
|
+
puts "Architecture: #{honeypot.dig("architecture", "summary")}"
|
|
31
|
+
|
|
32
|
+
# 3. Test sandbox environment
|
|
33
|
+
sandbox = client.ping_sandbox
|
|
34
|
+
puts "Sandbox status: #{sandbox["sandbox"]}"
|
|
35
|
+
|
|
36
|
+
# 4. Generate ephemeral test key
|
|
37
|
+
key_data = client.generate_key
|
|
38
|
+
puts "Test API key: #{key_data["apiKey"]}"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- **Zero Dependencies:** Pure Ruby 3.0+ using standard library primitives.
|
|
44
|
+
- **Project Intelligence:** Query 19 engineering projects, architecture diagrams, and honest limitation disclosures.
|
|
45
|
+
- **Batch Processing:** Run multi-step operations in an atomic batch.
|
|
46
|
+
- **Async Jobs:** Dispatch long-running jobs and poll their status.
|
|
47
|
+
- **Idempotency Built-In:** `Idempotency-Key` header support for safe contact transmissions.
|
|
48
|
+
- **AI Agent Friendly:** Built for ingestion by autonomous agents and agent frameworks.
|
|
49
|
+
|
|
50
|
+
## API Reference
|
|
51
|
+
|
|
52
|
+
- `client.list_projects(limit: nil, cursor: nil, domain: nil)`
|
|
53
|
+
- `client.get_project(slug)`
|
|
54
|
+
- `client.compare_projects(slug_a, slug_b)`
|
|
55
|
+
- `client.generate_key`
|
|
56
|
+
- `client.ping_sandbox`
|
|
57
|
+
- `client.sandbox_contact(name, email, message)`
|
|
58
|
+
- `client.run_batch(operations)`
|
|
59
|
+
- `client.create_job(task, payload: nil)`
|
|
60
|
+
- `client.get_job(job_id)`
|
|
61
|
+
- `client.submit_contact(name, email, message, idempotency_key: nil)`
|
|
62
|
+
- `client.get_docs(path = "llms.txt")`
|
|
63
|
+
|
|
64
|
+
## Links
|
|
65
|
+
|
|
66
|
+
- **Homepage:** [https://shivanshutiwari.in](https://shivanshutiwari.in)
|
|
67
|
+
- **Developer Portal:** [https://shivanshutiwari.in/developers](https://shivanshutiwari.in/developers)
|
|
68
|
+
- **SDK Documentation:** [https://shivanshutiwari.in/developers/sdk](https://shivanshutiwari.in/developers/sdk)
|
|
69
|
+
- **OpenAPI Specification:** [https://shivanshutiwari.in/openapi.json](https://shivanshutiwari.in/openapi.json)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require "net/http"
|
|
5
|
+
require "uri"
|
|
6
|
+
|
|
7
|
+
module Shivanshu
|
|
8
|
+
# Raised when the Portfolio API returns a non-2xx response.
|
|
9
|
+
class APIError < StandardError; end
|
|
10
|
+
|
|
11
|
+
# Official zero-dependency Ruby client for the Shivanshu Tiwari Portfolio API.
|
|
12
|
+
#
|
|
13
|
+
# client = Shivanshu::Client.new
|
|
14
|
+
# projects = client.list_projects(domain: "ai-agents")
|
|
15
|
+
#
|
|
16
|
+
# Homepage: https://shivanshutiwari.in
|
|
17
|
+
class Client
|
|
18
|
+
DEFAULT_BASE_URL = "https://shivanshutiwari.in"
|
|
19
|
+
|
|
20
|
+
attr_reader :base_url, :api_key
|
|
21
|
+
|
|
22
|
+
def initialize(base_url: DEFAULT_BASE_URL, api_key: nil)
|
|
23
|
+
@base_url = base_url
|
|
24
|
+
@api_key = api_key
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# GET /api/v1/projects — list projects with optional pagination and domain filter.
|
|
28
|
+
def list_projects(limit: nil, cursor: nil, domain: nil)
|
|
29
|
+
query = {}
|
|
30
|
+
query["limit"] = limit if limit
|
|
31
|
+
query["cursor"] = cursor if cursor
|
|
32
|
+
query["domain"] = domain if domain
|
|
33
|
+
get("/api/v1/projects", query)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# GET /api/v1/projects/{slug} — project details, architecture, and honest limitations.
|
|
37
|
+
def get_project(slug)
|
|
38
|
+
get("/api/v1/projects/#{URI.encode_www_form_component(slug)}")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# GET /api/v1/projects/{slug_a}/compare?slugB=... — side-by-side project comparison.
|
|
42
|
+
def compare_projects(slug_a, slug_b)
|
|
43
|
+
get("/api/v1/projects/#{URI.encode_www_form_component(slug_a)}/compare", { "slugB" => slug_b })
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# POST /api/v1/keys — generate an ephemeral 24-hour sandbox API key.
|
|
47
|
+
def generate_key
|
|
48
|
+
post("/api/v1/keys", nil)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# GET /api/v1/sandbox/ping — verify connectivity to the isolated sandbox environment.
|
|
52
|
+
def ping_sandbox
|
|
53
|
+
get("/api/v1/sandbox/ping")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# POST /api/v1/sandbox/contact — safe contact-submission test against the sandbox.
|
|
57
|
+
def sandbox_contact(name, email, message)
|
|
58
|
+
post("/api/v1/sandbox/contact", { name: name, email: email, message: message })
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# POST /api/v1/batch — execute multiple operations in a single atomic round-trip.
|
|
62
|
+
def run_batch(operations)
|
|
63
|
+
post("/api/v1/batch", { operations: operations })
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# POST /api/v1/jobs — dispatch an asynchronous job.
|
|
67
|
+
def create_job(task, payload: nil)
|
|
68
|
+
body = { "task" => task }
|
|
69
|
+
body["payload"] = payload if payload
|
|
70
|
+
post("/api/v1/jobs", body)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# GET /api/v1/jobs/{job_id} — fetch the status and result of an async job.
|
|
74
|
+
def get_job(job_id)
|
|
75
|
+
get("/api/v1/jobs/#{URI.encode_www_form_component(job_id)}")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# POST /api/v1/contact — submit a message with optional Idempotency-Key.
|
|
79
|
+
def submit_contact(name, email, message, idempotency_key: nil)
|
|
80
|
+
headers = {}
|
|
81
|
+
headers["Idempotency-Key"] = idempotency_key if idempotency_key
|
|
82
|
+
post("/api/v1/contact", { name: name, email: email, message: message }, headers)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Raw markdown documentation twins (llms.txt, about.md, developers.md, ...).
|
|
86
|
+
def get_docs(path = "llms.txt")
|
|
87
|
+
uri = build_uri("/#{path.sub(%r{\A/}, "")}")
|
|
88
|
+
request(:get, uri, nil, { "Accept" => "text/markdown" }, raw: true)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
private
|
|
92
|
+
|
|
93
|
+
def get(path, query = {})
|
|
94
|
+
request(:get, build_uri(path, query), nil, {})
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def post(path, body, headers = {})
|
|
98
|
+
request(:post, build_uri(path), body, headers)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def build_uri(path, query = {})
|
|
102
|
+
uri = URI.join(base_url, path)
|
|
103
|
+
uri.query = URI.encode_www_form(query) unless query.empty?
|
|
104
|
+
uri
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def request(method, uri, body, headers, raw: false)
|
|
108
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
109
|
+
http.use_ssl = uri.scheme == "https"
|
|
110
|
+
http.open_timeout = 10
|
|
111
|
+
http.read_timeout = 30
|
|
112
|
+
|
|
113
|
+
klass = method == :post ? Net::HTTP::Post : Net::HTTP::Get
|
|
114
|
+
req = klass.new(uri)
|
|
115
|
+
req["User-Agent"] = "shivanshu-ruby-sdk/#{Shivanshu::VERSION}"
|
|
116
|
+
req["Accept"] = "application/json"
|
|
117
|
+
req["Content-Type"] = "application/json" if body
|
|
118
|
+
req["Authorization"] = "Bearer #{@api_key}" if @api_key
|
|
119
|
+
headers.each { |k, v| req[k] = v }
|
|
120
|
+
req.body = JSON.generate(body) if body
|
|
121
|
+
|
|
122
|
+
res = http.request(req)
|
|
123
|
+
unless res.is_a?(Net::HTTPSuccess)
|
|
124
|
+
raise APIError, "api error: #{res.code} #{res.body.to_s[0, 500]}"
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
return res.body if raw
|
|
128
|
+
|
|
129
|
+
JSON.parse(res.body || "{}")
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
data/lib/shivanshu.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: shivanshu-sdk
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Shivanshu Tiwari
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-09-05 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Zero-dependency Ruby client for the Shivanshu Tiwari Portfolio API —
|
|
14
|
+
project intelligence, architecture details, sandbox testing, ephemeral test keys,
|
|
15
|
+
batch operations, and async jobs.
|
|
16
|
+
email:
|
|
17
|
+
- sht4bharat@gmail.com
|
|
18
|
+
executables: []
|
|
19
|
+
extensions: []
|
|
20
|
+
extra_rdoc_files: []
|
|
21
|
+
files:
|
|
22
|
+
- README.md
|
|
23
|
+
- lib/shivanshu.rb
|
|
24
|
+
- lib/shivanshu/client.rb
|
|
25
|
+
- lib/shivanshu/version.rb
|
|
26
|
+
homepage: https://shivanshutiwari.in
|
|
27
|
+
licenses:
|
|
28
|
+
- MIT
|
|
29
|
+
metadata:
|
|
30
|
+
homepage_uri: https://shivanshutiwari.in
|
|
31
|
+
source_code_uri: https://github.com/SHT4BHARAT/NoIntroNeeded/tree/main/sdk/ruby
|
|
32
|
+
documentation_uri: https://shivanshutiwari.in/developers/sdk#ruby
|
|
33
|
+
post_install_message:
|
|
34
|
+
rdoc_options: []
|
|
35
|
+
require_paths:
|
|
36
|
+
- lib
|
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '3.0'
|
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
requirements: []
|
|
48
|
+
rubygems_version: 3.4.19
|
|
49
|
+
signing_key:
|
|
50
|
+
specification_version: 4
|
|
51
|
+
summary: Official Ruby SDK for Shivanshu Tiwari Portfolio APIs
|
|
52
|
+
test_files: []
|