stools-cli 0.1.0__py3-none-any.whl

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.
stools_cli/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """stools — CLI to extract structured data from Steam."""
stools_cli/cli.py ADDED
@@ -0,0 +1,244 @@
1
+ """stools — CLI to extract structured data from Steam.
2
+
3
+ Usage:
4
+ stools search <query> [--limit <n>]
5
+ stools reviews <app_id_or_url> [--language <code>] [--limit <n>] [--output <file>]
6
+
7
+ All output is JSON on stdout. Errors go to stderr.
8
+ Exit codes: 0 = success, 1 = usage error, 2 = network/API error.
9
+ """
10
+
11
+ import argparse
12
+ import json
13
+ import re
14
+ import sys
15
+ import time
16
+ import urllib.error
17
+ import urllib.parse
18
+ import urllib.request
19
+
20
+ VERSION = "0.1.0"
21
+
22
+
23
+ def pick_fields(items: list[dict], fields: list[str]) -> list[dict]:
24
+ """Keep only the specified keys from each dict in a list."""
25
+ picked = []
26
+ for item in items:
27
+ picked.append({k: item[k] for k in fields if k in item})
28
+ return picked
29
+
30
+
31
+ def parse_app_id(value: str) -> int:
32
+ """Extract a Steam app ID from a store URL or plain integer string."""
33
+ match = re.search(r"store\.steampowered\.com/app/(\d+)", value)
34
+ if match:
35
+ return int(match.group(1))
36
+ if value.isdigit():
37
+ return int(value)
38
+ print(
39
+ json.dumps({"error": f"Cannot parse app ID from '{value}'. Provide a Steam store URL or numeric app ID."}),
40
+ file=sys.stderr,
41
+ )
42
+ sys.exit(1)
43
+
44
+
45
+ def fetch_reviews(app_id: int, language: str = "all", limit: int = 0) -> dict:
46
+ """Fetch reviews for a Steam app, paginating automatically."""
47
+ all_reviews: list[dict] = []
48
+ cursor = "*"
49
+ query_summary = None
50
+ per_page = 100
51
+
52
+ while True:
53
+ if limit and len(all_reviews) >= limit:
54
+ break
55
+
56
+ batch_size = min(per_page, limit - len(all_reviews)) if limit else per_page
57
+
58
+ params = urllib.parse.urlencode({
59
+ "json": 1,
60
+ "num_per_page": batch_size,
61
+ "cursor": cursor,
62
+ "filter": "recent",
63
+ "language": language,
64
+ "review_type": "all",
65
+ "purchase_type": "all",
66
+ })
67
+ url = f"https://store.steampowered.com/appreviews/{app_id}?{params}"
68
+
69
+ try:
70
+ req = urllib.request.Request(url, headers={"User-Agent": "stools/0.1.0"})
71
+ with urllib.request.urlopen(req, timeout=30) as resp:
72
+ data = json.loads(resp.read().decode())
73
+ except urllib.error.URLError as e:
74
+ print(json.dumps({"error": f"Network error: {e}"}), file=sys.stderr)
75
+ sys.exit(2)
76
+
77
+ if data.get("success") != 1:
78
+ print(json.dumps({"error": "Steam API error. Verify the app ID exists."}), file=sys.stderr)
79
+ sys.exit(2)
80
+
81
+ if query_summary is None:
82
+ query_summary = data.get("query_summary", {})
83
+
84
+ reviews = data.get("reviews", [])
85
+ if not reviews:
86
+ break
87
+
88
+ all_reviews.extend(reviews)
89
+
90
+ cursor = data.get("cursor")
91
+ if not cursor:
92
+ break
93
+
94
+ time.sleep(0.5)
95
+
96
+ if limit:
97
+ all_reviews = all_reviews[:limit]
98
+
99
+ return {
100
+ "app_id": app_id,
101
+ "query_summary": query_summary,
102
+ "total_fetched": len(all_reviews),
103
+ "reviews": all_reviews,
104
+ }
105
+
106
+
107
+ def fetch_search(query: str, limit: int = 10) -> dict:
108
+ """Search Steam for games matching a query."""
109
+ params = urllib.parse.urlencode({
110
+ "term": query,
111
+ "l": "english",
112
+ "cc": "US",
113
+ })
114
+ url = f"https://store.steampowered.com/api/storesearch/?{params}"
115
+
116
+ try:
117
+ req = urllib.request.Request(url, headers={"User-Agent": "stools/0.1.0"})
118
+ with urllib.request.urlopen(req, timeout=30) as resp:
119
+ data = json.loads(resp.read().decode())
120
+ except urllib.error.URLError as e:
121
+ print(json.dumps({"error": f"Network error: {e}"}), file=sys.stderr)
122
+ sys.exit(2)
123
+
124
+ items = data.get("items", [])[:limit]
125
+
126
+ results = []
127
+ for item in items:
128
+ results.append({
129
+ "app_id": item["id"],
130
+ "name": item["name"],
131
+ "price": item.get("price"),
132
+ "platforms": item.get("platforms"),
133
+ "metascore": item.get("metascore") or None,
134
+ })
135
+
136
+ return {
137
+ "query": query,
138
+ "total_results": data.get("total", 0),
139
+ "results": results,
140
+ }
141
+
142
+
143
+ def cmd_search(args: argparse.Namespace) -> None:
144
+ result = fetch_search(args.query, limit=args.limit)
145
+ if args.fields:
146
+ result["results"] = pick_fields(result["results"], args.fields)
147
+ print(json.dumps(result, indent=2, ensure_ascii=False))
148
+
149
+
150
+ def cmd_reviews(args: argparse.Namespace) -> None:
151
+ app_id = parse_app_id(args.app)
152
+ result = fetch_reviews(app_id, language=args.language, limit=args.limit)
153
+ if args.fields:
154
+ result["reviews"] = pick_fields(result["reviews"], args.fields)
155
+
156
+ output = json.dumps(result, indent=2, ensure_ascii=False)
157
+ if args.output:
158
+ with open(args.output, "w", encoding="utf-8") as f:
159
+ f.write(output + "\n")
160
+ else:
161
+ print(output)
162
+
163
+
164
+ def main() -> None:
165
+ parser = argparse.ArgumentParser(
166
+ prog="stools",
167
+ description="CLI to extract structured data from Steam. All output is JSON.",
168
+ )
169
+ parser.add_argument("--version", action="version", version=f"stools {VERSION}")
170
+ subparsers = parser.add_subparsers(dest="command", required=True)
171
+
172
+ # --- search subcommand ---
173
+ search_parser = subparsers.add_parser(
174
+ "search",
175
+ help="Search Steam for games matching a query.",
176
+ description=(
177
+ "Search for games on Steam by name. Returns a JSON object with fields: "
178
+ "query, total_results, results. Each result has: app_id, name, price, platforms, metascore."
179
+ ),
180
+ )
181
+ search_parser.add_argument(
182
+ "query",
183
+ help="Search term (e.g. 'megaman', 'dark souls', 'snake')",
184
+ )
185
+ search_parser.add_argument(
186
+ "--limit",
187
+ type=int,
188
+ default=10,
189
+ metavar="N",
190
+ help="Max results to return (default: 10)",
191
+ )
192
+ search_parser.add_argument(
193
+ "--fields",
194
+ type=lambda s: s.split(","),
195
+ metavar="f1,f2,...",
196
+ help="Comma-separated list of fields to keep per result. Available: app_id, name, price, platforms, metascore",
197
+ )
198
+ search_parser.set_defaults(func=cmd_search)
199
+
200
+ # --- reviews subcommand ---
201
+ reviews_parser = subparsers.add_parser(
202
+ "reviews",
203
+ help="Fetch all reviews for a Steam game as JSON.",
204
+ description=(
205
+ "Fetch reviews for a Steam game. Accepts a numeric app ID or a full Steam store URL. "
206
+ "Output is a JSON object with fields: app_id, query_summary, total_fetched, reviews."
207
+ ),
208
+ )
209
+ reviews_parser.add_argument(
210
+ "app",
211
+ help="Steam app ID (e.g. 1005310) or store URL (e.g. https://store.steampowered.com/app/1005310/Snake_vs_Snake/)",
212
+ )
213
+ reviews_parser.add_argument(
214
+ "--language",
215
+ default="all",
216
+ metavar="CODE",
217
+ help="Filter by language: english, spanish, french, german, etc. (default: all)",
218
+ )
219
+ reviews_parser.add_argument(
220
+ "--limit",
221
+ type=int,
222
+ default=0,
223
+ metavar="N",
224
+ help="Max number of reviews to fetch. 0 = all (default: 0)",
225
+ )
226
+ reviews_parser.add_argument(
227
+ "--output",
228
+ metavar="FILE",
229
+ help="Write JSON to FILE instead of stdout.",
230
+ )
231
+ reviews_parser.add_argument(
232
+ "--fields",
233
+ type=lambda s: s.split(","),
234
+ metavar="f1,f2,...",
235
+ help="Comma-separated list of fields to keep per review. Available: recommendationid, author, language, review, timestamp_created, timestamp_updated, voted_up, votes_up, votes_funny, steam_purchase, received_for_free, written_during_early_access",
236
+ )
237
+ reviews_parser.set_defaults(func=cmd_reviews)
238
+
239
+ args = parser.parse_args()
240
+ args.func(args)
241
+
242
+
243
+ if __name__ == "__main__":
244
+ main()
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.4
2
+ Name: stools-cli
3
+ Version: 0.1.0
4
+ Summary: CLI to extract structured data from Steam (reviews, game search) — designed for LLM agents
5
+ Project-URL: Repository, https://github.com/aotarola/stools
6
+ Author: aotarola
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Keywords: agent,cli,llm,reviews,steam
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Games/Entertainment
16
+ Classifier: Topic :: Utilities
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+
20
+ # stools
21
+
22
+ CLI tool to extract structured data from Steam. Outputs JSON to stdout, making it easy to pipe into other tools or consume from LLM agents.
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pipx install stools-cli
28
+ ```
29
+
30
+ Or with pip:
31
+
32
+ ```bash
33
+ pip install stools-cli
34
+ ```
35
+
36
+ Requires Python 3.9+. No external dependencies.
37
+
38
+ ## Commands
39
+
40
+ ### `stools search`
41
+
42
+ Search Steam for games by name.
43
+
44
+ ```
45
+ stools search <query> [--limit N] [--fields f1,f2,...]
46
+ ```
47
+
48
+ | Argument | Description |
49
+ |---------------|----------------------------------------------------------|
50
+ | `query` | Search term (e.g. `megaman`, `dark souls`) |
51
+ | `--limit N` | Max results to return. Default: `10` |
52
+ | `--fields` | Comma-separated fields to keep per result (e.g. `app_id,name`) |
53
+
54
+ #### Output schema
55
+
56
+ ```json
57
+ {
58
+ "query": "megaman",
59
+ "total_results": 10,
60
+ "results": [
61
+ {
62
+ "app_id": 742300,
63
+ "name": "Mega Man 11",
64
+ "price": { "currency": "USD", "initial": 2999, "final": 2999 },
65
+ "platforms": { "windows": true, "mac": false, "linux": false },
66
+ "metascore": "80"
67
+ }
68
+ ]
69
+ }
70
+ ```
71
+
72
+ #### Examples
73
+
74
+ ```bash
75
+ # Search for a game
76
+ stools search "megaman"
77
+
78
+ # Get top 3 results, only app_id and name
79
+ stools search "dark souls" --limit 3 --fields app_id,name
80
+
81
+ # Search then fetch reviews for the first result
82
+ APP_ID=$(stools search "snake vs snake" 2>/dev/null | jq '.results[0].app_id')
83
+ stools reviews "$APP_ID"
84
+ ```
85
+
86
+ ### `stools reviews`
87
+
88
+ Fetch all reviews for a Steam game.
89
+
90
+ ```
91
+ stools reviews <app_id_or_url> [--language CODE] [--limit N] [--fields f1,f2,...] [--output FILE]
92
+ ```
93
+
94
+ | Argument | Description |
95
+ |----------------|-----------------------------------------------------------------------------|
96
+ | `app` | Steam app ID (`1005310`) or store URL (`https://store.steampowered.com/app/1005310/Snake_vs_Snake/`) |
97
+ | `--language` | Filter by language code: `english`, `spanish`, `french`, `german`, etc. Default: `all` |
98
+ | `--limit N` | Max reviews to return. `0` = all. Default: `0` |
99
+ | `--fields` | Comma-separated fields to keep per review (e.g. `review,voted_up`) |
100
+ | `--output FILE`| Write JSON to a file instead of stdout |
101
+
102
+ #### Output schema
103
+
104
+ ```json
105
+ {
106
+ "app_id": 1005310,
107
+ "query_summary": {
108
+ "num_reviews": 33,
109
+ "review_score": 7,
110
+ "review_score_desc": "Positive",
111
+ "total_positive": 33,
112
+ "total_negative": 0,
113
+ "total_reviews": 33
114
+ },
115
+ "total_fetched": 33,
116
+ "reviews": [
117
+ {
118
+ "recommendationid": "210668843",
119
+ "author": {
120
+ "steamid": "76561198079866033",
121
+ "personaname": "username",
122
+ "num_reviews": 32,
123
+ "playtime_forever": 1554,
124
+ "playtime_at_review": 1554
125
+ },
126
+ "language": "english",
127
+ "review": "Review text here.",
128
+ "timestamp_created": 1764106395,
129
+ "timestamp_updated": 1764106395,
130
+ "voted_up": true,
131
+ "votes_up": 0,
132
+ "votes_funny": 0,
133
+ "steam_purchase": true,
134
+ "received_for_free": false,
135
+ "written_during_early_access": false
136
+ }
137
+ ]
138
+ }
139
+ ```
140
+
141
+ #### Examples
142
+
143
+ ```bash
144
+ # Fetch all reviews for a game
145
+ stools reviews 1005310
146
+
147
+ # Fetch only English reviews, save to file
148
+ stools reviews 1005310 --language english --output reviews.json
149
+
150
+ # Fetch first 10 reviews, no progress output
151
+ stools reviews 1005310 --limit 10
152
+ # Use a full Steam URL
153
+ stools reviews "https://store.steampowered.com/app/1005310/Snake_vs_Snake/"
154
+
155
+ # Get only review text and sentiment
156
+ stools reviews 1005310 --fields review,voted_up
157
+ ```
158
+
159
+ ## Exit codes
160
+
161
+ | Code | Meaning |
162
+ |------|--------------------|
163
+ | `0` | Success |
164
+ | `1` | Usage / input error|
165
+ | `2` | Network / API error|
166
+
167
+ ## Agent integration
168
+
169
+ stools ships as a [Claude Code plugin](https://docs.anthropic.com/en/docs/claude-code). To use it in your agent:
170
+
171
+ ```bash
172
+ claude install-plugin aotarola/stools
173
+ ```
174
+
175
+ This registers the `stools` CLI as a skill that Claude Code can discover and invoke automatically. See [`skills/stools/SKILL.md`](skills/stools/SKILL.md) for the agent-facing documentation.
176
+
177
+ ## Design notes
178
+
179
+ - **JSON only**: all output goes to stdout as JSON; errors go to stderr.
180
+ - **No dependencies**: uses only Python standard library.
181
+ - **Subcommand structure**: `stools <command>` — designed to grow with more Steam data commands.
182
+ - **Agent-ready**: includes `.claude-plugin/` manifest and `skills/` for automatic discovery by LLM agents.
@@ -0,0 +1,7 @@
1
+ stools_cli/__init__.py,sha256=LT52Axj4CBTcBuxxW_qLiRjM5hcgEjaj_7zNWnXrM30,60
2
+ stools_cli/cli.py,sha256=WRiOxNpjc8_GUx_wLSDLvWN8SymHSD-yGYsDn3WJIwQ,7727
3
+ stools_cli-0.1.0.dist-info/METADATA,sha256=qD3I_b6k5wYFDvLSAUH36vaDCgB6LiLSuac6gSGYNMo,5247
4
+ stools_cli-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
5
+ stools_cli-0.1.0.dist-info/entry_points.txt,sha256=aPwBZ98s-GreQKZ5KPrzsBUaTBGYUJQjcQEh1k2v2h0,47
6
+ stools_cli-0.1.0.dist-info/licenses/LICENSE,sha256=ZSxT2w1FY7KtCoW08V3MUAaB4H8qKLp3rxBpAvt0SE4,1065
7
+ stools_cli-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ stools = stools_cli.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 aotarola
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.