@commercelayer/agent-cli 0.1.4 → 0.1.7
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/README.md +1 -1
- package/dist/api/client.js +2 -2
- package/dist/bin.js +1 -1
- package/dist/commands.js +1 -1
- package/dist/storefront.js +6 -3
- package/dist/ucp/client.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ npx -y @commercelayer/agent-cli@latest init --name "The Blue Brand" # runs c11
|
|
|
16
16
|
| `init [--name <business name>]` | Create a sandbox store, with no login. The name (the folder name when absent) names the organization; the org slug and store hostname derive from it, numbered when taken. Writes `store.yml` (a commented template) and `credentials`. Reuses the store if they exist. |
|
|
17
17
|
| `plan` | Validate `store.yml` and the product files, and list what `apply` would create, update or delete: markets, products, and the store's name and policies. |
|
|
18
18
|
| `apply [--allow-delete]` | Make the store match the files. Refuses deletes without the flag. |
|
|
19
|
-
| `storefront init [--force]` | Write `storefront/index.html`: a static page on [drop-in.js](https://commercelayer.github.io/drop-in.js/) listing the products in `store.yml`, with the hosted cart and checkout, wired to the sandbox's sales channel. Refuses to overwrite without the flag. |
|
|
19
|
+
| `storefront init [--force]` | Write `storefront/index.html`: a static page on [drop-in.js](https://commercelayer.github.io/drop-in.js/) listing the products in `store.yml`, with a minicart that slides in on add to cart, and the hosted cart and checkout, wired to the sandbox's sales channel. Refuses to overwrite without the flag. |
|
|
20
20
|
| `storefront publish` | Upload the folder at `storefront.path` (default `storefront`) to the store host. |
|
|
21
21
|
| `orders test [--sku <id>] [--quantity <n>] [--country <CC>] [--code <discount>] [--via-cart] [--decline]` | Buy from the store over UCP as a shopping agent would: discover, search, (cart,) checkout, address, pay with the sandbox handler, read the order back. Prints the order and every step. |
|
|
22
22
|
| `orders list` | The orders placed in the store, newest first, as UCP order entities. |
|
package/dist/api/client.js
CHANGED
|
@@ -18,14 +18,14 @@ export function createApi(auth) {
|
|
|
18
18
|
data = res.body ? JSON.parse(res.body) : null;
|
|
19
19
|
}
|
|
20
20
|
catch {
|
|
21
|
-
fail('api_error', `${base} answered ${res.status} with something that is not JSON.`, 'Try again. If it keeps happening,
|
|
21
|
+
fail('api_error', `${base} answered ${res.status} with something that is not JSON.`, 'Try again. If it keeps happening, tell the human, with the output of `c11r status`.');
|
|
22
22
|
}
|
|
23
23
|
if (res.status < 400)
|
|
24
24
|
return data;
|
|
25
25
|
const err = data?.error;
|
|
26
26
|
if (err)
|
|
27
27
|
fail(err.code, err.message, err.hint);
|
|
28
|
-
fail('api_error', `The API answered ${res.status}.`, 'Try again. If it keeps happening,
|
|
28
|
+
fail('api_error', `The API answered ${res.status}.`, 'Try again. If it keeps happening, tell the human, with the output of `c11r status`.');
|
|
29
29
|
};
|
|
30
30
|
return {
|
|
31
31
|
createSandbox: (name) => request('POST', '/sandboxes', { name }),
|
package/dist/bin.js
CHANGED
|
@@ -77,7 +77,7 @@ run()
|
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
79
79
|
const message = e instanceof Error ? e.message : String(e);
|
|
80
|
-
print({ error: { code: 'internal', message, hint: 'This is a bug in the CLI.
|
|
80
|
+
print({ error: { code: 'internal', message, hint: 'This is a bug in the CLI. Tell the human, with this output, and try again with npx -y @commercelayer/agent-cli@latest in case it is already fixed.' } });
|
|
81
81
|
}
|
|
82
82
|
process.exit(1);
|
|
83
83
|
});
|
package/dist/commands.js
CHANGED
|
@@ -18,7 +18,7 @@ export const HELP = {
|
|
|
18
18
|
init: 'Create a sandbox store for this repo, with no login: c11r init --name "<business name>" (the folder name when --name is absent). The name becomes the organization\'s name, and the org slug and store hostname derive from it. Writes .commercelayer/store.yml and .commercelayer/credentials. Reuses the store if store.yml already exists.',
|
|
19
19
|
plan: 'Show what apply would create, update or delete: markets, products and the store\'s name and policies, from .commercelayer/store.yml and the product files under .commercelayer/products/ (*.yml lists, *.csv rows, merged by sku).',
|
|
20
20
|
apply: 'Make the store match .commercelayer/store.yml and .commercelayer/products/. Refuses deletes unless --allow-delete is given.',
|
|
21
|
-
'storefront init': 'Write storefront/index.html: a static page on drop-in.js listing the products in store.yml, with the hosted cart and checkout. Refuses to overwrite unless --force is given.',
|
|
21
|
+
'storefront init': 'Write storefront/index.html: a static page on drop-in.js listing the products in store.yml, with a minicart that opens on add to cart, and the hosted cart and checkout. Refuses to overwrite unless --force is given.',
|
|
22
22
|
'storefront publish': 'Upload the storefront folder (store.yml storefront.path, default storefront) to the sandbox preview URL.',
|
|
23
23
|
'orders test': 'Buy from the store over UCP as a shopping agent would, paying with the sandbox handler: discover, search, checkout, address, pay, read the order. Options: --sku <id> --quantity <n> --country <CC> --code <discount> --via-cart --decline.',
|
|
24
24
|
'orders list': 'List the orders placed in the store, newest first, as UCP order entities.',
|
package/dist/storefront.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// The storefront scaffold: one static page on drop-in.js listing the products in
|
|
2
|
-
// store.yml, with the hosted cart and checkout. The agent then makes it the human's.
|
|
2
|
+
// store.yml, with the minicart, the hosted cart and checkout. The agent then makes it the human's.
|
|
3
3
|
const esc = (t) => String(t ?? '').replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[c]);
|
|
4
4
|
export function storefrontHtml(store, clientId) {
|
|
5
5
|
const name = esc(store.name);
|
|
@@ -18,8 +18,9 @@ ${p.description ? ` <p>${esc(p.description)}</p>\n` : ''} <cl-pric
|
|
|
18
18
|
<meta charset="utf-8">
|
|
19
19
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
20
20
|
<title>${name}</title>
|
|
21
|
-
<!-- Commerce Layer drop-in.js: prices, availability, add to cart, and links to the hosted cart and checkout. -->
|
|
21
|
+
<!-- Commerce Layer drop-in.js: prices, availability, add to cart, the minicart (a slide-in panel, styled by minicart.css) and links to the hosted cart and checkout. -->
|
|
22
22
|
<link href="https://cdn.jsdelivr.net/npm/@commercelayer/drop-in.js@2/dist/drop-in/drop-in.css" rel="stylesheet">
|
|
23
|
+
<link href="https://cdn.jsdelivr.net/npm/@commercelayer/drop-in.js@2/dist/drop-in/minicart.css" rel="stylesheet">
|
|
23
24
|
<script>
|
|
24
25
|
// The market comes from ?market=<code>; the first market in store.yml is the default. Keep clientId as it is.
|
|
25
26
|
var market = new URLSearchParams(location.search).get('market') || '${esc(store.markets[0].code)}';
|
|
@@ -45,6 +46,8 @@ ${p.description ? ` <p>${esc(p.description)}</p>\n` : ''} <cl-pric
|
|
|
45
46
|
cl-price-amount[type="compare-at"] { color: var(--muted); font-weight: 400; text-decoration: line-through; }
|
|
46
47
|
cl-availability { font-size: 13px; color: var(--muted); }
|
|
47
48
|
cl-add-to-cart { margin-top: auto; }
|
|
49
|
+
/* drop-in.css styles the count as a badge beside a cart icon (absolute, pushed right). The link is text here, so render it inline: "Cart (3)". */
|
|
50
|
+
cl-cart-link cl-cart-count { position: static; transform: none; display: inline; min-width: 0; height: auto; padding: 0; border-radius: 0; background: none; color: inherit; font-size: inherit; }
|
|
48
51
|
cl-add-to-cart::part(button), cl-checkout-link::part(a) { display: inline-block; padding: 10px 16px; border-radius: 6px; background: var(--accent); color: #fff; font: inherit; border: 0; cursor: pointer; text-decoration: none; }
|
|
49
52
|
footer { padding: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
|
|
50
53
|
</style>
|
|
@@ -58,7 +61,7 @@ ${p.description ? ` <p>${esc(p.description)}</p>\n` : ''} <cl-pric
|
|
|
58
61
|
${options}
|
|
59
62
|
</select>
|
|
60
63
|
</label>
|
|
61
|
-
<cl-cart-link>Cart (<cl-cart-count></cl-cart-count>)
|
|
64
|
+
<cl-cart-link aria-label="Cart">Cart (<cl-cart-count></cl-cart-count>)<cl-cart type="mini" open-on-add></cl-cart></cl-cart-link>
|
|
62
65
|
<cl-checkout-link>Checkout</cl-checkout-link>
|
|
63
66
|
</nav>
|
|
64
67
|
</header>
|
package/dist/ucp/client.js
CHANGED
|
@@ -65,7 +65,7 @@ export async function discover(origin) {
|
|
|
65
65
|
profile = JSON.parse(res.body);
|
|
66
66
|
}
|
|
67
67
|
catch {
|
|
68
|
-
fail('ucp_profile_malformed', `${origin}/.well-known/ucp is not JSON.`, '
|
|
68
|
+
fail('ucp_profile_malformed', `${origin}/.well-known/ucp is not JSON.`, 'The store host answered badly. Try again; if it keeps happening, tell the human, with the output of `c11r status`.');
|
|
69
69
|
}
|
|
70
70
|
const ucp = profile.ucp ?? {};
|
|
71
71
|
if (ucp.version !== UCP_VERSION) {
|
|
@@ -74,7 +74,7 @@ export async function discover(origin) {
|
|
|
74
74
|
const rest = (name) => (ucp.services?.[name] ?? []).find((s) => s.transport === 'rest')?.endpoint ?? null;
|
|
75
75
|
const endpoint = rest('dev.ucp.shopping');
|
|
76
76
|
if (!endpoint)
|
|
77
|
-
fail('ucp_no_rest_service', 'The store profile has no REST dev.ucp.shopping service.', '
|
|
77
|
+
fail('ucp_no_rest_service', 'The store profile has no REST dev.ucp.shopping service.', 'The store host serves a profile this CLI cannot use. Tell the human, with the output of `c11r ucp profile`.');
|
|
78
78
|
const capabilities = new Set();
|
|
79
79
|
for (const [name, entries] of Object.entries(ucp.capabilities ?? {})) {
|
|
80
80
|
if (entries.some((e) => e.version === UCP_VERSION))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercelayer/agent-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "c11r: the Commerce Layer CLI for coding agents. Builds a sandbox store that people and shopping agents can buy from.",
|
|
5
5
|
"homepage": "https://commercelayer.ai",
|
|
6
6
|
"keywords": [
|