agentic-commerce-readiness 0.0.0-stage → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (unreleased)
4
+
5
+ First release.
6
+
7
+ - `store <url>`: reads the public Shopify (`/products.json`, `/cart.js`) or WooCommerce Store API catalog, or your own feed with `--feed`.
8
+ - `feed <file>`: CSV, TSV, JSON, JSONL, Google RSS/Atom XML and Shopify product export CSV. Accepts column names from both the OpenAI and Google specs.
9
+ - Validation against the OpenAI product feed spec (stable) and the Google Merchant Center product data specification, with errors, warnings and tips per channel.
10
+ - Money parsing that diagnoses symbols, thousands separators, decimal commas, regional formats, code position and case, unknown ISO 4217 codes and minor units. Suggested fixes never round a price.
11
+ - GTIN checks: length, GS1 check digit, ISBN-10, Google restricted and coupon prefixes.
12
+ - UCP profile validation (`/.well-known/ucp`, spec 2026-08-25): HTTPS, no redirects, caching headers, required registries, transport bindings, capability and payment handler entries, key placement. Older single-object capability entries are accepted.
13
+ - ACP discovery document check (`/.well-known/acp.json`).
14
+ - robots.txt access for six shopping crawlers, with a copy-ready fix.
15
+ - Feed vs product page comparison of price, currency and availability using Product JSON-LD. Offers are matched by SKU, GTIN or `?variant=` URL and never compared with another variant's offer.
16
+ - Explainable readiness scores for ChatGPT, Google (AI Mode, Gemini, Shopping) and other agents.
17
+ - Text, Markdown and JSON reports. `--fail-on` for CI.
18
+ - Exports: ChatGPT JSONL and Google Merchant Center RSS with safe fixes only.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ahmad Zia (https://www.ahmadzia.com)
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.
package/README.md CHANGED
@@ -1,3 +1,201 @@
1
- # Temporary Holding Version
1
+ # agentic-commerce-readiness
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <!-- badges -->
4
+ [![npm](https://img.shields.io/npm/v/agentic-commerce-readiness?color=3a7a4e&label=npm)](https://www.npmjs.com/package/agentic-commerce-readiness) [![CI](https://github.com/MuhammadAhmadZia/agentic-commerce-readiness/actions/workflows/ci.yml/badge.svg)](https://github.com/MuhammadAhmadZia/agentic-commerce-readiness/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/license-MIT-0d2018)](LICENSE) [![Agent skill](https://img.shields.io/badge/agent%20skill-agentic--commerce--readiness-c5dfc9)](skills/agentic-commerce-readiness/SKILL.md) [![Guide](https://img.shields.io/badge/guide-ahmadzia.com-3a7a4e)](https://www.ahmadzia.com/tools/agentic-commerce-readiness)
5
+
6
+ Get your online store ready for AI shopping agents.
7
+
8
+ ChatGPT, Google AI Mode, Gemini and other agents now answer "what should I buy" questions and, more and more, complete the purchase themselves. They work from structured product data, not from your homepage design. This tool shows what they see, what is broken and how to fix it.
9
+
10
+ It checks four things:
11
+
12
+ 1. **Your product data** against the OpenAI product feed spec (ChatGPT shopping, Agentic Commerce Protocol) and the Google Merchant Center product data spec (Google Shopping, AI Mode, Gemini).
13
+ 2. **Discovery files** that agents look for: the UCP profile at `/.well-known/ucp`, the ACP discovery document at `/.well-known/acp.json`, and robots.txt rules for six shopping crawlers.
14
+ 3. **Feed vs page.** It opens a sample of product pages and compares price, currency and stock in your data with the Product JSON-LD on the page. Mismatches get products disapproved on Google and make agents quote wrong prices.
15
+ 4. **Attribute richness.** These are the details agents match shopper questions on: GTIN, category, long descriptions, extra images, color, size, material, returns, shipping and reviews.
16
+
17
+ It can also **export** a clean ChatGPT feed (JSONL) and a Google Merchant Center feed (RSS XML) from a Shopify or WooCommerce store or a Shopify export CSV. Only safe fixes are applied. Nothing is invented.
18
+
19
+ No account, no API key, and nothing is sent anywhere except requests to the store you check.
20
+
21
+ ## Quick start
22
+
23
+ You need Node.js 18.17 or newer. Check with `node --version`.
24
+
25
+ Check a live Shopify or WooCommerce store:
26
+
27
+ ```bash
28
+ npx agentic-commerce-readiness store https://your-store.com --country US
29
+ ```
30
+
31
+ Check a feed file you already have (CSV, TSV, JSON, JSONL, Google XML, or a Shopify product export):
32
+
33
+ ```bash
34
+ npx agentic-commerce-readiness feed products.csv --seller-name "Your Store" --country US
35
+ ```
36
+
37
+ Turn a Shopify product export into feeds for both channels:
38
+
39
+ ```bash
40
+ npx agentic-commerce-readiness feed products_export.csv \
41
+ --site https://your-store.com --currency USD --seller-name "Your Store" --country US \
42
+ --export-openai chatgpt-feed.jsonl --export-google google-feed.xml
43
+ ```
44
+
45
+ ## What the report looks like
46
+
47
+ ```
48
+ Readiness by channel
49
+ ChatGPT shopping ████░░░░░░ 43/100
50
+ Items eligible for the ChatGPT feed 67%
51
+ OAI-SearchBot can crawl product pages 0%
52
+ Feed matches product pages 33%
53
+ Attribute richness for AI matching 8%
54
+ ...
55
+
56
+ Issues (most important first)
57
+ [ERROR] Google · 2 item(s) · apparel-gender-missing
58
+ Apparel item missing gender (Google requires it for apparel in US)
59
+ items: SC-BLU, SC-RED
60
+ fix: Add gender: male, female or unisex.
61
+ [WARNING] ChatGPT + Google · 2 item(s) · title-promo
62
+ Title contains promotional text ("50% OFF")
63
+ ...
64
+
65
+ Discovery
66
+ /.well-known/ucp not published (needed for agentic checkout on Google AI Mode and Gemini)
67
+ Shopping crawlers (robots.txt, product pages):
68
+ BLOCKED OAI-SearchBot ChatGPT search and shopping
69
+ ...
70
+ fix: if you want these assistants to show your products, add to robots.txt:
71
+ User-agent: OAI-SearchBot
72
+ Allow: /
73
+
74
+ Feed vs product page (3 pages sampled, 2 with mismatches)
75
+ [error] SC-BLU: Feed price 20.00 USD but page says 18.00 USD
76
+ [warning] SC-RED: No offer on the page matches this item (page offers: SC-BLU)
77
+ ```
78
+
79
+ Every score is broken into named parts, so you can see exactly why a channel scored low. Errors block items from a channel. Warnings cost visibility. Tips are optional improvements.
80
+
81
+ ## Options
82
+
83
+ | Option | What it does |
84
+ |---|---|
85
+ | `--channel <c>` | `chatgpt`, `google` or `both` (default `both`) |
86
+ | `--seller-name <name>` | Fills `seller_name` on every item (ChatGPT requires it). In store mode it defaults to your site name |
87
+ | `--country <CC>` | Target country for ChatGPT (`target_countries`), for example `US` |
88
+ | `--store-country <CC>` | Your store's country (`store_country`). Defaults to `--country` |
89
+ | `--google-countries <list>` | Countries you target on Google, for example `US,GB`. Changes the apparel rules. Default `US` |
90
+ | `--currency <CODE>` | Currency for data that lacks one, for example `USD` or `PKR` |
91
+ | `--site <url>` | Your store URL, needed to build product links from a Shopify export CSV |
92
+ | `--feed <file>` | Store mode: check your own feed file instead of the public catalog, while still checking discovery and pages |
93
+ | `--sample <n>` | Store mode: product pages to compare with the feed. Default 10, `0` to skip |
94
+ | `--max-products <n>` | Store mode: catalog items to read. Default 250 |
95
+ | `--export-openai <file>` | Write a ChatGPT product feed (JSONL) with safe fixes |
96
+ | `--export-google <file>` | Write a Google Merchant Center feed (RSS 2.0 XML) with safe fixes |
97
+ | `--md <file>` | Also write a Markdown report (good for a GitHub issue or a client) |
98
+ | `--json` | Print JSON instead of the text report |
99
+ | `--fail-on <level>` | `error`, `warning` or `none` (default). Exit code 1 when issues reach that level, for CI |
100
+
101
+ Exit codes: `0` finished, `1` issues reached `--fail-on`, `2` bad arguments or the check could not run.
102
+
103
+ ## Which stores it can read
104
+
105
+ | Source | How it is read | Notes |
106
+ |---|---|---|
107
+ | Shopify store | Public `/products.json`, currency from `/cart.js` | No GTINs in public data. Variant links use `?variant=` |
108
+ | WooCommerce store | Public Store API `/wp-json/wc/store/v1/products` | Variable products are read at parent level |
109
+ | Any other store | Pass your feed with `--feed` | Discovery and page checks still run |
110
+ | Feed files | CSV, TSV, JSON, JSONL, Google RSS/Atom XML, Shopify product export CSV | Column names from both specs are accepted (`id`, `sku`, `item_group_id`, `g:price` ...) |
111
+
112
+ If a store disables its public catalog, the tool says so and asks for a feed file.
113
+
114
+ ## What "safe fixes" means in exports
115
+
116
+ The exporters only change things that have one correct answer:
117
+
118
+ - `$19.99` becomes `19.99 USD`, `1.299,00 EUR` and `1 299,00 EUR` become `1299.00 EUR`, `19.99usd` becomes `19.99 USD`
119
+ - `In Stock`, `instock` or `https://schema.org/InStock` becomes `in_stock` (ChatGPT) or `in_stock` / `preorder` (Google)
120
+ - Spaces are removed from GTINs
121
+ - HTML tags are removed from descriptions
122
+
123
+ They never round a price (`19.999 USD` is reported, not changed) and never make up a GTIN, brand, gender, category or any other fact about your product. Missing facts stay missing and stay in the report.
124
+
125
+ ## Rules it checks (summary)
126
+
127
+ - **Required fields** for each channel: `item_id`, `title`, `description`, `url`, `brand`, `seller_name`, `image_url`, `availability`, `price`, `target_countries`, `store_country` (ChatGPT), plus Google's `condition`, identifier and apparel rules.
128
+ - **Money format**: `amount CURRENCY`, positive, decimal point, no thousands separators, ISO 4217 code, correct decimal places (JPY 0, KWD 3 ...). `sale_price` must be lower than `price` in the same currency.
129
+ - **Availability** enums for each channel, and `availability_date` for Google pre-orders.
130
+ - **GTIN**: length 8, 12, 13 or 14, valid check digit, no ISBN-10, Google's restricted (02, 04, 2) and coupon (98, 99) prefixes. `identifier_exists` for handmade and own-brand goods.
131
+ - **Apparel** (US, GB, DE, FR, JP, BR on Google): `color`, `gender`, `age_group`, plus `size` for clothing and shoes.
132
+ - **Variants**: `group_id` differs from `item_id`, `listing_has_variations`, a valid `variant_dict`, and no shared titles without a group.
133
+ - **ChatGPT extras**: `dimensions` object, weight units, eligibility flags (`is_eligible_search`, `is_eligible_checkout` and their `enable_*` aliases), checkout policy URLs, returns, shipping, reviews, and current country coverage.
134
+ - **Quality**: length limits, ALL CAPS and promo text in titles, thin or duplicate descriptions, placeholder values such as `N/A` or `TBD`, non-https links.
135
+ - **UCP profile** (spec 2026-08-25): HTTPS, no redirects, `Cache-Control: public` with `max-age` of 60 or more, ETag or Last-Modified, required `ucp.version`, `ucp.services` and `ucp.payment_handlers`, and valid transport bindings (`rest`, `mcp`, `a2a`, `embedded`), capability and payment handler entries, and `keys` at the top level.
136
+
137
+ ## Use it from code
138
+
139
+ ```js
140
+ import { checkStore, checkFeed, toOpenAIJsonl, formatText } from 'agentic-commerce-readiness';
141
+
142
+ const result = await checkFeed('products.csv', { defaults: { seller_name: 'My Store', target_countries: ['US'], store_country: 'US' } });
143
+ console.log(result.readiness.chatgpt.score, result.issues.length);
144
+ const { text } = toOpenAIJsonl(result.records, result.defaults);
145
+ ```
146
+
147
+ `validateFeed`, `validateUcpProfile`, `compareRecordToPage` and `parseMoney` are exported as pure functions too.
148
+
149
+ ## Limits, stated honestly
150
+
151
+ - A clean report does not guarantee you will appear. ChatGPT feed onboarding is for approved partners (apply at chatgpt.com/merchants), and Google ranks products using signals this tool cannot see.
152
+ - OpenAI says Shopify product data already reaches ChatGPT through Shopify Catalog. For Shopify stores, a direct feed is optional: fix your data inside Shopify.
153
+ - Public catalogs hide some fields (GTINs on Shopify, variant details on WooCommerce). Check your own export for those.
154
+ - Specs change. The rules here were checked against the OpenAI product feed spec (stable), the Google Merchant Center product data specification and UCP 2026-08-25 in December 2026. Open an issue if something has moved.
155
+
156
+ ## Sustainable Development Goals
157
+
158
+ This tool is built to support **SDG target 8.3**: development-oriented policies that support productive activities, entrepreneurship and the growth of micro, small and medium-sized enterprises. It also touches **target 9.3** (integration of small-scale enterprises into value chains and markets): feeds that pass the checks are how a small store's products enter AI shopping channels next to large retailers.
159
+
160
+ How it contributes:
161
+
162
+ - AI shopping agents are becoming a new market access channel. Large retailers have teams and paid feed tools to get into them. Small sellers usually do not. This tool gives a small store the same specification-level check for free.
163
+ - The exporters let a seller with only a Shopify export, or a WooCommerce store, produce spec-compliant feeds without paid software.
164
+ - The feed vs page check reduces wrong prices and stock shown to shoppers, which protects small sellers from disapprovals and refunds.
165
+
166
+ What it does not do: it cannot measure whether a store's sales or reach actually grew. If you use it in research or a pilot, measure that separately (for example, AI referral traffic before and after fixes).
167
+
168
+ ## Related tools
169
+
170
+ - [ai-ready-audit](https://www.npmjs.com/package/ai-ready-audit): can AI search crawlers reach and read your site
171
+ - [storefront-vitals](https://www.npmjs.com/package/storefront-vitals): speed of your product pages
172
+ - [shopbot-shield](https://www.npmjs.com/package/shopbot-shield): safety tests for your own shopping chatbot
173
+
174
+ ## Need help?
175
+
176
+ Agentic commerce setup, feed cleanup and AI cost reviews: [ahmadzia.com](https://www.ahmadzia.com/tools/agentic-commerce-readiness).
177
+
178
+ ## License
179
+
180
+ MIT © Ahmad Zia
181
+
182
+ <!-- ahmadzia-links -->
183
+ ## Guide, help and author
184
+
185
+ - **Full guide with examples and FAQs:** [www.ahmadzia.com/tools/agentic-commerce-readiness](https://www.ahmadzia.com/tools/agentic-commerce-readiness)
186
+ - **Background reading:** [WebMCP vs MCP for online stores](https://www.ahmadzia.com/blog/webmcp-vs-mcp-online-stores)
187
+ - **All 30 free tools and agent skills:** [ahmadzia.com/tools](https://www.ahmadzia.com/tools) · [ahmadzia.com/skills](https://www.ahmadzia.com/skills)
188
+ - **Want it set up, fixed or tuned for your store?** [Book a free call](https://www.ahmadzia.com/contact)
189
+
190
+ Built by **[Ahmad Zia](https://www.ahmadzia.com)** (Muhammad Ahmad Zia), an AI consultant for ecommerce since 2020 and green AI researcher at the University of Lahore. [Research](https://www.ahmadzia.com/research) · [Google Scholar](https://scholar.google.com/citations?user=sqjdX2EAAAAJ&hl=en) · [ORCID](https://orcid.org/0000-0002-3208-6246) · [LinkedIn](https://www.linkedin.com/in/muhammad-ahmadzia/) · [GitHub](https://github.com/MuhammadAhmadZia)
191
+ <!-- /ahmadzia-links -->
192
+
193
+ ## More AI search and agent readiness tools
194
+
195
+ - [ai-ready-audit](https://github.com/MuhammadAhmadZia/ai-ready-audit): Check whether ChatGPT, Claude, Perplexity and Google AI can find and cite your site
196
+ - [ai-traffic-insights](https://github.com/MuhammadAhmadZia/ai-traffic-insights): See what ChatGPT, Claude and Perplexity actually do on your site, from your own logs
197
+ - [webmcp-store-tools](https://github.com/MuhammadAhmadZia/webmcp-store-tools): WebMCP tools for WooCommerce and headless stores, plus a checker for any WebMCP site
198
+ - [astro-ai-ready](https://github.com/MuhammadAhmadZia/astro-ai-ready): Generate llms.txt and llms-full.txt for any Astro site on every build
199
+ - [astro-seo-check](https://github.com/MuhammadAhmadZia/astro-seo-check): Catch SEO mistakes in Astro and static sites at build time
200
+
201
+ All 30 tools and agent skills: [github.com/MuhammadAhmadZia](https://github.com/MuhammadAhmadZia) · [ahmadzia.com/tools](https://www.ahmadzia.com/tools)
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ import { writeFile } from 'node:fs/promises';
3
+ import { checkFeed, checkStore, toOpenAIJsonl, toGoogleXml, formatText, formatMarkdown } from '../src/index.js';
4
+
5
+ const HELP = `agentic-commerce-readiness - get your store ready for AI shopping agents
6
+
7
+ Usage:
8
+ npx agentic-commerce-readiness store <url> Check a live store (Shopify or WooCommerce catalog,
9
+ UCP/ACP discovery, crawler access, feed vs page)
10
+ npx agentic-commerce-readiness feed <file> Validate a product feed file (CSV, TSV, JSON, JSONL,
11
+ Google XML or a Shopify product export CSV)
12
+
13
+ Options:
14
+ --channel <c> chatgpt, google or both (default both)
15
+ --seller-name <name> Fill seller_name on every item (required by ChatGPT)
16
+ --country <CC> Target country for ChatGPT (target_countries), e.g. US
17
+ --store-country <CC> Your store's country (store_country); defaults to --country
18
+ --google-countries <list> Countries you target on Google, e.g. US,GB (affects apparel rules). Default US
19
+ --currency <CODE> Currency for feeds or catalogs that lack one, e.g. USD or PKR
20
+ --site <url> Store URL, needed to build product links from a Shopify export CSV
21
+ --feed <file> (store mode) check your own feed file instead of the public catalog
22
+ --sample <n> (store mode) product pages to compare with the feed. Default 10, 0 to skip
23
+ --max-products <n> (store mode) catalog items to read. Default 250
24
+ --export-openai <file> Write a ChatGPT product feed (JSONL) with safe fixes applied
25
+ --export-google <file> Write a Google Merchant Center feed (RSS XML) with safe fixes applied
26
+ --md <file> Also write a Markdown report
27
+ --json Print JSON
28
+ --fail-on <level> error, warning or none. Exit 1 when issues reach this level. Default none
29
+ -h, --help Show this help`;
30
+
31
+ const args = process.argv.slice(2);
32
+ if (!args.length || args.includes('-h') || args.includes('--help')) { console.log(HELP); process.exit(args.length ? 0 : 1); }
33
+ const cmd = args[0];
34
+ const target = args[1];
35
+ const fail = (m) => { console.error(m); process.exit(2); };
36
+ const VALUE_FLAGS = ['--channel', '--seller-name', '--country', '--store-country', '--google-countries', '--currency', '--site', '--feed', '--sample', '--max-products', '--export-openai', '--export-google', '--md', '--fail-on'];
37
+ const BOOL_FLAGS = ['--json'];
38
+ for (let i = 2; i < args.length; i++) {
39
+ const a = args[i];
40
+ if (VALUE_FLAGS.includes(a)) {
41
+ if (args[i + 1] === undefined || args[i + 1].startsWith('--')) fail(`${a} needs a value. Run with --help for details.`);
42
+ i++;
43
+ } else if (!BOOL_FLAGS.includes(a)) fail(`Unknown option "${a}". Run with --help for details.`);
44
+ }
45
+ const val = (f) => { const i = args.indexOf(f); return i >= 0 ? args[i + 1] : undefined; };
46
+ if (!['store', 'feed'].includes(cmd) || !target || target.startsWith('--')) fail('Use "store <url>" or "feed <file>". Run with --help for details.');
47
+ if (val('--channel') && !['chatgpt', 'google', 'both'].includes(val('--channel'))) fail('--channel must be chatgpt, google or both.');
48
+ if (val('--fail-on') && !['error', 'warning', 'none'].includes(val('--fail-on'))) fail('--fail-on must be error, warning or none.');
49
+ for (const f of ['--sample', '--max-products']) if (val(f) !== undefined && !(Number.isInteger(Number(val(f))) && Number(val(f)) >= 0)) fail(`${f} must be a whole number.`);
50
+ for (const f of ['--country', '--store-country']) if (val(f) && !/^[A-Za-z]{2}$/.test(val(f))) fail(`${f} must be a two-letter country code such as US or PK.`);
51
+ if (val('--currency') && !/^[A-Za-z]{3}$/.test(val('--currency'))) fail('--currency must be a three-letter code such as USD or PKR.');
52
+
53
+ const channel = val('--channel') || 'both';
54
+ const channels = channel === 'both' ? ['chatgpt', 'google'] : [channel];
55
+ const country = val('--country')?.toUpperCase();
56
+ const defaults = {};
57
+ if (val('--seller-name')) defaults.seller_name = val('--seller-name');
58
+ if (country) defaults.target_countries = [country];
59
+ if (val('--store-country') || country) defaults.store_country = (val('--store-country') || country).toUpperCase();
60
+ const opts = {
61
+ channels,
62
+ defaults,
63
+ googleCountries: (val('--google-countries') || 'US').split(',').map((s) => s.trim()),
64
+ currency: val('--currency')?.toUpperCase(),
65
+ site: val('--site'),
66
+ feedPath: val('--feed'),
67
+ sample: val('--sample') !== undefined ? Number(val('--sample')) : 10,
68
+ maxProducts: val('--max-products') ? Number(val('--max-products')) : 250,
69
+ log: args.includes('--json') ? () => {} : (m) => console.error(`> ${m}`),
70
+ };
71
+
72
+ let result;
73
+ try {
74
+ result = cmd === 'store' ? await checkStore(target, opts) : await checkFeed(target, opts);
75
+ } catch (e) {
76
+ console.error(`Could not complete the check: ${e.message}`);
77
+ process.exit(2);
78
+ }
79
+
80
+ const allDefaults = { ...result.defaults, ...defaults };
81
+ if (val('--export-openai')) {
82
+ const { text, fixes } = toOpenAIJsonl(result.records, allDefaults);
83
+ await writeFile(val('--export-openai'), text);
84
+ console.error(`> Wrote ${result.records.length} items to ${val('--export-openai')} (${fixes.length} safe fixes applied)`);
85
+ }
86
+ if (val('--export-google')) {
87
+ const { text, fixes } = toGoogleXml(result.records, { title: allDefaults.seller_name || 'Product feed', link: result.mode === 'store' ? result.target : '', defaults: allDefaults });
88
+ await writeFile(val('--export-google'), text);
89
+ console.error(`> Wrote ${result.records.length} items to ${val('--export-google')} (${fixes.length} safe fixes applied)`);
90
+ }
91
+
92
+ if (args.includes('--json')) {
93
+ const { records, ...rest } = result;
94
+ console.log(JSON.stringify({ ...rest, itemCount: records.length }, null, 2));
95
+ } else console.log(formatText(result));
96
+ if (val('--md')) await writeFile(val('--md'), formatMarkdown(result));
97
+
98
+ const failOn = val('--fail-on') || 'none';
99
+ const hit = (s) => result.issues.some((i) => i.severity === s) || (result.consistency || []).some((c) => c.findings.some((f) => f.severity === s));
100
+ if ((failOn === 'error' && hit('error')) || (failOn === 'warning' && (hit('error') || hit('warning')))) process.exitCode = 1;
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "agentic-commerce-readiness",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Get your store ready for AI shopping agents. Validates product feeds against the ChatGPT (Agentic Commerce Protocol) and Google Merchant Center specs, checks UCP and ACP discovery files, compares feed data with your live product pages, and exports ready-to-submit feeds from Shopify or WooCommerce.",
5
+ "type": "module",
6
+ "bin": {
7
+ "agentic-commerce-readiness": "bin/agentic-commerce-readiness.js"
8
+ },
9
+ "main": "src/index.js",
10
+ "exports": {
11
+ ".": "./src/index.js"
12
+ },
13
+ "files": [
14
+ "bin",
15
+ "src",
16
+ "README.md",
17
+ "LICENSE",
18
+ "CHANGELOG.md"
19
+ ],
20
+ "scripts": {
21
+ "test": "node --test test/*.test.js"
22
+ },
23
+ "engines": {
24
+ "node": ">=18.17"
25
+ },
26
+ "dependencies": {
27
+ "ai-ready-audit": "^0.1.0"
28
+ },
29
+ "keywords": [
30
+ "agentic-commerce",
31
+ "acp",
32
+ "ucp",
33
+ "chatgpt-shopping",
34
+ "product-feed",
35
+ "google-merchant-center",
36
+ "gemini",
37
+ "ai-mode",
38
+ "shopify",
39
+ "woocommerce",
40
+ "gtin",
41
+ "feed-validator",
42
+ "ai-shopping",
43
+ "geo"
44
+ ],
45
+ "author": {
46
+ "name": "Ahmad Zia (Muhammad Ahmad Zia)",
47
+ "url": "https://www.ahmadzia.com"
48
+ },
49
+ "license": "MIT",
50
+ "homepage": "https://www.ahmadzia.com/tools/agentic-commerce-readiness",
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "git+https://github.com/MuhammadAhmadZia/agentic-commerce-readiness.git"
54
+ },
55
+ "bugs": {
56
+ "url": "https://github.com/MuhammadAhmadZia/agentic-commerce-readiness/issues"
57
+ }
58
+ }
@@ -0,0 +1,109 @@
1
+ // Export normalized records as submit-ready feeds.
2
+ // Only safe, deterministic fixes are applied (money format, availability spelling,
3
+ // separators in GTINs, HTML in descriptions). Nothing is invented: missing data stays
4
+ // missing so the validator keeps reporting it.
5
+
6
+ import { parseMoney, canonicalAvailability, toGoogleAvailability, checkGtin, parseList, parseObject, parseBool } from './values.js';
7
+ import { stripHtml } from './parse.js';
8
+
9
+ const OPENAI_FIELDS = [
10
+ 'item_id', 'title', 'description', 'url', 'brand', 'seller_name', 'image_url', 'availability', 'price',
11
+ 'target_countries', 'store_country', 'is_eligible_search', 'is_eligible_checkout',
12
+ 'group_id', 'listing_has_variations', 'variant_dict', 'gtin', 'mpn', 'condition', 'product_category',
13
+ 'material', 'color', 'size', 'gender', 'age_group', 'weight', 'item_weight_unit', 'dimensions', 'length', 'width', 'height', 'dimensions_unit', 'additional_image_urls',
14
+ 'sale_price', 'seller_url', 'shipping_price', 'shipping', 'accepts_returns', 'return_deadline_in_days',
15
+ 'return_policy', 'review_count', 'star_rating', 'seller_privacy_policy', 'seller_tos',
16
+ ];
17
+
18
+ function fixRecord(rec, defaults, fixes) {
19
+ const r = { ...defaults, ...Object.fromEntries(Object.entries(rec).filter(([k, v]) => !k.startsWith('_') && v !== undefined)) };
20
+ const note = (field, from, to) => { if (String(from) !== String(to)) fixes.push({ item_id: r.item_id, field, from, to }); };
21
+ for (const f of ['price', 'sale_price', 'shipping_price']) {
22
+ if (r[f] === undefined) continue;
23
+ const m = parseMoney(r[f]);
24
+ if (!m.ok && m.suggestion) { note(f, r[f], m.suggestion); r[f] = m.suggestion; }
25
+ }
26
+ if (r.availability !== undefined) {
27
+ const c = canonicalAvailability(r.availability);
28
+ if (c) { note('availability', r.availability, c); r.availability = c; }
29
+ }
30
+ if (r.gtin !== undefined) {
31
+ const g = checkGtin(r.gtin);
32
+ if (g.problems.length === 1 && g.problems[0].includes('spaces')) { note('gtin', r.gtin, g.cleaned); r.gtin = g.cleaned; }
33
+ }
34
+ if (r.description && /<\/?[a-z][^>]*>/i.test(r.description)) { const clean = stripHtml(r.description); note('description', '(html)', '(plain text)'); r.description = clean; }
35
+ if (r.product_category === undefined && r.product_type) r.product_category = r.product_type;
36
+ return r;
37
+ }
38
+
39
+ /** ChatGPT product feed as JSONL (one record per line). */
40
+ export function toOpenAIJsonl(records, defaults = {}) {
41
+ const fixes = [];
42
+ const lines = records.map((rec) => {
43
+ const r = fixRecord(rec, defaults, fixes);
44
+ const out = {};
45
+ for (const f of OPENAI_FIELDS) {
46
+ let v = r[f];
47
+ if (v === undefined || v === '') continue;
48
+ if (f === 'target_countries' || f === 'additional_image_urls') v = parseList(v) || v;
49
+ else if (f === 'dimensions') v = parseObject(v) || v;
50
+ else if (f === 'variant_dict') v = parseObject(v) ?? v;
51
+ else if (['is_eligible_search', 'is_eligible_checkout', 'listing_has_variations', 'accepts_returns'].includes(f)) { const b = parseBool(v); v = b === 'invalid' ? v : b; }
52
+ else if (['review_count', 'return_deadline_in_days'].includes(f) && /^\d+$/.test(String(v))) v = Number(v);
53
+ else v = String(v);
54
+ if (Array.isArray(v) && !v.length) continue;
55
+ out[f] = v;
56
+ }
57
+ return JSON.stringify(out);
58
+ });
59
+ return { text: lines.join('\n') + '\n', fixes };
60
+ }
61
+
62
+ const esc = (s) => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
63
+
64
+ /** Google Merchant Center RSS 2.0 feed. */
65
+ export function toGoogleXml(records, { title = 'Product feed', link = '', description = 'Product feed', defaults = {} } = {}) {
66
+ const fixes = [];
67
+ const items = records.map((rec) => {
68
+ const r = fixRecord(rec, defaults, fixes);
69
+ const tags = [];
70
+ const t = (name, v) => { if (v !== undefined && v !== null && v !== '') tags.push(` <${name}>${esc(v)}</${name}>`); };
71
+ t('g:id', r.item_id);
72
+ t('title', r.title);
73
+ t('description', r.description);
74
+ t('link', r.url);
75
+ t('g:image_link', r.image_url);
76
+ for (const u of (parseList(r.additional_image_urls) || []).slice(0, 10)) t('g:additional_image_link', u);
77
+ const avail = toGoogleAvailability(canonicalAvailability(r.availability));
78
+ t('g:availability', avail || r.availability);
79
+ t('g:availability_date', r.availability_date);
80
+ t('g:price', r.price);
81
+ t('g:sale_price', r.sale_price);
82
+ t('g:brand', r.brand);
83
+ t('g:gtin', r.gtin);
84
+ t('g:mpn', r.mpn);
85
+ t('g:identifier_exists', r.identifier_exists);
86
+ t('g:condition', r.condition);
87
+ t('g:google_product_category', r.product_category && /^\d+$/.test(String(r.product_category)) ? r.product_category : undefined);
88
+ t('g:product_type', r.product_type || (r.product_category && !/^\d+$/.test(String(r.product_category)) ? r.product_category : undefined));
89
+ t('g:item_group_id', r.group_id);
90
+ t('g:color', r.color);
91
+ t('g:size', r.size);
92
+ t('g:material', r.material);
93
+ t('g:gender', r.gender);
94
+ t('g:age_group', r.age_group);
95
+ if (r.weight && r.item_weight_unit) t('g:shipping_weight', `${r.weight} ${r.item_weight_unit}`);
96
+ return ` <item>\n${tags.join('\n')}\n </item>`;
97
+ });
98
+ const xml = `<?xml version="1.0" encoding="UTF-8"?>
99
+ <rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
100
+ <channel>
101
+ <title>${esc(title)}</title>
102
+ <link>${esc(link)}</link>
103
+ <description>${esc(description)}</description>
104
+ ${items.join('\n')}
105
+ </channel>
106
+ </rss>
107
+ `;
108
+ return { text: xml, fixes };
109
+ }