@opencommerceprotocol/cli 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.
package/LICENSE ADDED
@@ -0,0 +1,144 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other transformations
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal, or
51
+ written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and included
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by the combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any
81
+ Contribution embodied within the Work constitutes direct or contributory
82
+ patent infringement, then any patent licenses granted to You under this
83
+ License for that Work shall terminate as of the date such litigation
84
+ is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative Works
92
+ a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file, You must include a
104
+ readable copy of the attribution notices contained within such
105
+ NOTICE file.
106
+
107
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
108
+ any Contribution intentionally submitted for inclusion in the Work
109
+ by You to the Licensor shall be under the terms and conditions of
110
+ this License, without any additional terms or conditions.
111
+
112
+ 6. Trademarks. This License does not grant permission to use the trade
113
+ names, trademarks, service marks, or product names of the Licensor.
114
+
115
+ 7. Disclaimer of Warranty. Unless required by applicable law or
116
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
117
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
118
+
119
+ 8. Limitation of Liability. In no event and under no legal theory shall
120
+ any Contributor be liable to You for damages, including any direct,
121
+ indirect, special, incidental, or exemplary damages.
122
+
123
+ 9. Accepting Warranty or Additional Liability. While redistributing the
124
+ Work or Derivative Works thereof, You may offer, and charge a fee for,
125
+ acceptance of support, warranty, indemnity, or other liability
126
+ obligations consistent with this License. However, in accepting such
127
+ obligations, You may act only on Your own behalf and on Your sole
128
+ responsibility.
129
+
130
+ END OF TERMS AND CONDITIONS
131
+
132
+ Copyright 2026 Open Commerce Protocol Contributors
133
+
134
+ Licensed under the Apache License, Version 2.0 (the "License");
135
+ you may not use this file except in compliance with the License.
136
+ You may obtain a copy of the License at
137
+
138
+ http://www.apache.org/licenses/LICENSE-2.0
139
+
140
+ Unless required by applicable law or agreed to in writing, software
141
+ distributed under the License is distributed on an "AS IS" BASIS,
142
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
143
+ See the License for the specific language governing permissions and
144
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,263 @@
1
+ # @opencommerceprotocol/cli
2
+
3
+ Command-line tool for the [Open Commerce Protocol](https://opencommerceprotocol.org). Set up, validate, and manage OCP for any website.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @opencommerceprotocol/cli
9
+ # or use without installing:
10
+ npx @opencommerceprotocol/cli <command>
11
+ ```
12
+
13
+ ## Commands
14
+
15
+ ### `ocp init`
16
+
17
+ Interactive wizard to generate OCP files for your store.
18
+
19
+ ```bash
20
+ ocp init
21
+ ocp init --output ./public
22
+ ```
23
+
24
+ Generates:
25
+ - `.well-known/ocp.json` — manifest
26
+ - `ocp/products.jsonl` — product feed
27
+ - `ocp.md` — natural language store description
28
+
29
+ ---
30
+
31
+ ### `ocp crawl <url>`
32
+
33
+ Crawl a website and extract Schema.org Product JSON-LD to generate OCP files automatically.
34
+
35
+ ```bash
36
+ ocp crawl https://mystore.com
37
+ ocp crawl https://mystore.com --output ./ocp-output
38
+ ocp crawl https://mystore.com --max-products 500
39
+ ocp crawl https://mystore.com --product-pattern "/products/"
40
+ ocp crawl https://mystore.com --dry-run # list URLs without fetching
41
+ ocp crawl https://mystore.com --verbose # detailed per-URL output
42
+ ```
43
+
44
+ | Flag | Default | Description |
45
+ |------|---------|-------------|
46
+ | `--output <dir>` | `./ocp-output` | Output directory |
47
+ | `--concurrency <n>` | `5` | Max concurrent requests |
48
+ | `--delay <ms>` | `200` | Delay between requests |
49
+ | `--product-pattern <regex>` | — | URL pattern for product pages |
50
+ | `--max-products <n>` | — | Maximum products to extract |
51
+ | `--user-agent <string>` | `OCPBot/1.0` | Custom User-Agent |
52
+ | `--include-variants` | `true` | Extract product variants |
53
+ | `--generate-agent-notes` | `true` | Auto-generate `agent_notes` |
54
+ | `--dry-run` | `false` | List URLs without fetching |
55
+ | `--resume` | `false` | Resume interrupted crawl |
56
+
57
+ ---
58
+
59
+ ### `ocp validate <target>`
60
+
61
+ Validate a live site or local directory. Shows a 0–100 quality score.
62
+
63
+ ```bash
64
+ ocp validate https://mystore.com
65
+ ocp validate ./public # local directory
66
+ ```
67
+
68
+ Checks:
69
+ - Manifest structure and required fields
70
+ - Product feed validity
71
+ - `robots.txt` has `OCP-Manifest` directive
72
+ - `llms.txt` has Commerce section
73
+ - `agent_notes` quality scores
74
+
75
+ ---
76
+
77
+ ### `ocp generate`
78
+
79
+ Generate OCP files from a product CSV, JSON, or JSONL file.
80
+
81
+ ```bash
82
+ ocp generate --products catalog.csv
83
+ ocp generate --products catalog.json
84
+ ocp generate --products catalog.jsonl
85
+ ocp generate --products catalog.csv --config ocp.config.json --output ./public
86
+ ```
87
+
88
+ CSV example:
89
+ ```csv
90
+ id,name,price,currency,url,description
91
+ prod-001,Headphones,149.99,USD,https://mystore.com/headphones,Premium wireless headphones
92
+ ```
93
+
94
+ | Flag | Default | Description |
95
+ |------|---------|-------------|
96
+ | `--products <file>` | — | Input file (.csv, .json, or .jsonl) |
97
+ | `--config <file>` | — | OCP config file |
98
+ | `--output <dir>` | `.` | Output directory |
99
+
100
+ ---
101
+
102
+ ### `ocp bridge`
103
+
104
+ Generate bridge configuration for other agent protocols.
105
+
106
+ ```bash
107
+ ocp bridge --protocol mcp
108
+ ocp bridge --protocol ucp
109
+ ocp bridge --protocol a2a
110
+ ocp bridge --manifest .well-known/ocp.json --output ./bridge
111
+ ```
112
+
113
+ | Flag | Default | Description |
114
+ |------|---------|-------------|
115
+ | `--protocol <protocol>` | `mcp` | Target: `mcp`, `ucp`, or `a2a` |
116
+ | `--manifest <file>` | `.well-known/ocp.json` | OCP manifest file |
117
+ | `--output <dir>` | `./bridge` | Output directory |
118
+
119
+ ---
120
+
121
+ ### `ocp robots [path]`
122
+
123
+ Add the `OCP-Manifest` directive to your `robots.txt`.
124
+
125
+ ```bash
126
+ ocp robots # updates ./robots.txt in place
127
+ ocp robots /etc/nginx/robots.txt
128
+ ocp robots --stdout # print to stdout
129
+ ocp robots --url https://mystore.com/.well-known/ocp.json
130
+ ```
131
+
132
+ Result in `robots.txt`:
133
+ ```
134
+ OCP-Manifest: https://mystore.com/.well-known/ocp.json
135
+ ```
136
+
137
+ ---
138
+
139
+ ### `ocp llms [path]`
140
+
141
+ Generate or patch `llms.txt` with an OCP Commerce section.
142
+
143
+ ```bash
144
+ ocp llms # updates ./llms.txt in place
145
+ ocp llms --stdout # print to stdout
146
+ ocp llms --full # also generate llms-full.txt with product descriptions
147
+ ```
148
+
149
+ ---
150
+
151
+ ### `ocp stats [url]`
152
+
153
+ Analyze server access logs to understand AI agent traffic.
154
+
155
+ ```bash
156
+ ocp stats --log /var/log/nginx/access.log
157
+ ocp stats https://mystore.com --log access.log --format nginx --days 30
158
+ ocp stats --log access.log --format apache
159
+ ocp stats --log access.log --format cloudflare
160
+ ```
161
+
162
+ Reports:
163
+ - Total agent visits by bot (ChatGPT, Claude, Gemini, etc.)
164
+ - Products most viewed by agents
165
+ - Search queries agents used
166
+ - Agent traffic trends over time
167
+
168
+ | Flag | Default | Description |
169
+ |------|---------|-------------|
170
+ | `--log <file>` | — | Path to log file |
171
+ | `--format <format>` | `nginx` | Log format: `nginx`, `apache`, `cloudflare` |
172
+ | `--days <n>` | `30` | Number of days to analyze |
173
+
174
+ ---
175
+
176
+ ### `ocp test-agent <url>`
177
+
178
+ Simulate an AI agent visiting your store and produce a pass/fail conformance report.
179
+
180
+ ```bash
181
+ ocp test-agent https://mystore.com
182
+ ocp test-agent https://mystore.com --query "blue running shoes"
183
+ ocp test-agent https://mystore.com --verbose
184
+ ```
185
+
186
+ | Flag | Default | Description |
187
+ |------|---------|-------------|
188
+ | `--query <query>` | `product` | Test search query |
189
+ | `--verbose` | `false` | Show detailed output and sample `agent_notes` |
190
+
191
+ ---
192
+
193
+ ### `ocp preview <url>`
194
+
195
+ Render what an AI agent sees when visiting your store.
196
+
197
+ ```bash
198
+ ocp preview https://mystore.com
199
+ ocp preview https://mystore.com --products 10
200
+ ocp preview https://mystore.com --verbose
201
+ ```
202
+
203
+ | Flag | Default | Description |
204
+ |------|---------|-------------|
205
+ | `--products <n>` | `5` | Number of sample products to show |
206
+ | `--verbose` | `false` | Show full `ocp.md` and best/worst `agent_notes` |
207
+
208
+ ---
209
+
210
+ ### `ocp agent-discover <url>`
211
+
212
+ Discover agent tools at any URL via `/.well-known/agent.json` or OCP fallback.
213
+
214
+ ```bash
215
+ ocp agent-discover https://mystore.com
216
+ ocp agent-discover https://mystore.com --verbose
217
+ ocp agent-discover https://mystore.com --format json
218
+ ocp agent-discover https://mystore.com --format mcp
219
+ ocp agent-discover https://mystore.com --format openai
220
+ ```
221
+
222
+ | Flag | Default | Description |
223
+ |------|---------|-------------|
224
+ | `--verbose` | `false` | Show full tool list with descriptions |
225
+ | `--format <format>` | `text` | Output: `text`, `json`, `mcp`, `openai` |
226
+
227
+ ---
228
+
229
+ ## CI/CD Integration
230
+
231
+ ### Validate on deploy (GitHub Actions)
232
+
233
+ ```yaml
234
+ - name: Validate OCP
235
+ run: npx @opencommerceprotocol/cli validate https://mystore.com
236
+ ```
237
+
238
+ ### Cron sync with `generate`
239
+
240
+ ```bash
241
+ # crontab: regenerate feed daily at midnight
242
+ 0 0 * * * ocp generate --products /data/products.csv --output /var/www/html
243
+ ```
244
+
245
+ ## Configuration File
246
+
247
+ Create `ocp.config.json` for `generate`:
248
+
249
+ ```json
250
+ {
251
+ "merchant": {
252
+ "name": "My Store",
253
+ "url": "https://mystore.com",
254
+ "currency": "USD"
255
+ },
256
+ "capabilities": {
257
+ "catalog": true,
258
+ "search": true,
259
+ "cart": true,
260
+ "checkout": "redirect"
261
+ }
262
+ }
263
+ ```
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }