@tokenoftrust/cli 7.6.4 → 7.6.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/cli",
3
- "version": "7.6.4",
3
+ "version": "7.6.6",
4
4
  "description": "Token of Trust developer CLI — clone a tenant store, run it locally with save→reload, and submit it for preview. Installs the `tot` command.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Token of Trust",
@@ -48,12 +48,24 @@ const USAGE = `tot feedback — send a note to Token of Trust (with your recent
48
48
  --severity <critical|high|medium|low> default: medium
49
49
  --category <doc-gap|api-ambiguity|setup-confusion|platform-bug|
50
50
  ai-agent-confusion|product-ux|scenario-instruction-gap> default: product-ux
51
+ --tenant <appDomain> tag the store this note is about
51
52
  --no-activity don't attach the activity log
52
53
  --yes, -y send without the confirmation prompt (required non-interactively)
53
54
  --mcp <url> MCP base URL (default: env MCP_BASE_URL / TOT_MCP_URL)
54
55
 
55
56
  Requires a signed-in session — run \`tot login\` first if needed.`;
56
57
 
58
+ /** `feedback_submit` caps `sensitive` at 4000 chars. */
59
+ export const MAX_SENSITIVE_CHARS = 4000;
60
+
61
+ function tailWithinBudget(header, body, budget) {
62
+ const full = `${header}\n${body}`;
63
+ if (full.length <= budget) return full;
64
+ const marker = "…(earlier entries truncated)\n";
65
+ const keep = Math.max(0, budget - header.length - 1 - marker.length);
66
+ return `${header}\n${marker}${body.slice(body.length - keep)}`;
67
+ }
68
+
57
69
  /**
58
70
  * Assemble the `feedback_submit` payload. Pure + exported so the wire shape
59
71
  * (including the additive `sensitive` activity attachment and the invite→problem
@@ -61,23 +73,41 @@ Requires a signed-in session — run \`tot login\` first if needed.`;
61
73
  * are OMITTED when their source is absent — never sent as null/empty.
62
74
  * @param {{ type: string, category: string, severity: string, title: string,
63
75
  * description: string, activityText?: string|null, diagnosticsText?: string|null,
64
- * traceId?: string|null }} f
76
+ * traceId?: string|null, tenant?: string|null }} f
65
77
  */
66
- export function buildFeedbackPayload({ type, category, severity, title, description, activityText, diagnosticsText, traceId }) {
67
- const attachments = [
68
- activityText ? `tot CLI activity (most recent last):\n${activityText}` : null,
69
- diagnosticsText ? `tot CLI diagnostics (redacted, most recent last):\n${diagnosticsText}` : null,
70
- ].filter(Boolean);
78
+ export function buildFeedbackPayload({ type, category, severity, title, description, activityText, diagnosticsText, traceId, tenant }) {
79
+ const activityHeader = "tot CLI activity (most recent last):";
80
+ const diagHeader = "tot CLI diagnostics (redacted, most recent last):";
81
+ /** @type {Array<{ header: string, body: string }>} */
82
+ const rawParts = [];
83
+ if (activityText) rawParts.push({ header: activityHeader, body: activityText });
84
+ if (diagnosticsText) rawParts.push({ header: diagHeader, body: diagnosticsText });
85
+ let sensitive = rawParts.map((p) => `${p.header}\n${p.body}`).join("\n\n");
86
+ if (sensitive.length > MAX_SENSITIVE_CHARS) {
87
+ if (rawParts.length === 1) {
88
+ sensitive = tailWithinBudget(rawParts[0].header, rawParts[0].body, MAX_SENSITIVE_CHARS);
89
+ } else if (rawParts.length >= 2) {
90
+ const half = Math.floor((MAX_SENSITIVE_CHARS - 2) / 2);
91
+ sensitive = [
92
+ tailWithinBudget(rawParts[0].header, rawParts[0].body, half),
93
+ tailWithinBudget(rawParts[1].header, rawParts[1].body, MAX_SENSITIVE_CHARS - 2 - half),
94
+ ].join("\n\n");
95
+ }
96
+ }
97
+ const cleanTenant = typeof tenant === "string" ? tenant.trim() : "";
98
+ const fullDescription = cleanTenant && !description.includes(cleanTenant)
99
+ ? `[tenant: ${cleanTenant}] ${description}`
100
+ : description;
71
101
  return {
72
102
  type,
73
103
  category,
74
104
  severity,
75
105
  title,
76
- description,
106
+ description: fullDescription,
77
107
  scenario: "tot-cli",
78
108
  // CLI context → `sensitive` (ToT-admins-only, never clustered/shared). It is
79
109
  // redacted before attachment; `sensitive` is the belt-and-suspenders home for it.
80
- ...(attachments.length ? { sensitive: attachments.join("\n\n") } : {}),
110
+ ...(rawParts.length ? { sensitive } : {}),
81
111
  // Invite→terminal→problem trace link (omitted when this wasn't an invite login).
82
112
  ...(traceId ? { traceId } : {}),
83
113
  };
@@ -94,23 +124,32 @@ export function feedbackReportId(result) {
94
124
  return typeof value === "string" && FEEDBACK_ID.test(value) ? value : null;
95
125
  }
96
126
 
97
- function parseArgs(argv) {
127
+ export function parseArgs(argv) {
128
+ /** @type {{ mcp: string|null, type: string, category: string, severity: string, tenant: string|null, activity: boolean, yes: boolean, help: boolean, unknown: string[], message?: string|null }} */
98
129
  const a = {
99
130
  mcp: null, type: "improvement", category: "product-ux", severity: "medium",
100
- activity: true, yes: false, help: false,
131
+ tenant: null, activity: true, yes: false, help: false, unknown: [],
101
132
  };
102
133
  const words = [];
134
+ const takeValue = (i, t) => {
135
+ const eq = t.indexOf("=");
136
+ if (eq >= 0) return { value: t.slice(eq + 1), next: i };
137
+ return { value: argv[i + 1], next: i + 1 };
138
+ };
103
139
  for (let i = 0; i < argv.length; i++) {
104
140
  const t = argv[i];
105
- if (t === "--mcp") a.mcp = argv[++i];
106
- else if (t === "--type") a.type = argv[++i];
141
+ const flag = t.startsWith("--") && t.includes("=") ? t.slice(0, t.indexOf("=")) : t;
142
+ if (flag === "--mcp") { const { value, next } = takeValue(i, t); a.mcp = value; i = next; }
143
+ else if (flag === "--type") { const { value, next } = takeValue(i, t); a.type = value; i = next; }
107
144
  else if (t === "--bug") a.type = "bug";
108
145
  else if (t === "--feature") a.type = "feature";
109
- else if (t === "--category") a.category = argv[++i];
110
- else if (t === "--severity") a.severity = argv[++i];
146
+ else if (flag === "--category") { const { value, next } = takeValue(i, t); a.category = value; i = next; }
147
+ else if (flag === "--severity") { const { value, next } = takeValue(i, t); a.severity = value; i = next; }
148
+ else if (flag === "--tenant") { const { value, next } = takeValue(i, t); a.tenant = value; i = next; }
111
149
  else if (t === "--no-activity") a.activity = false;
112
150
  else if (t === "--yes" || t === "-y") a.yes = true;
113
151
  else if (t === "--help" || t === "-h") a.help = true;
152
+ else if (t.startsWith("--")) a.unknown.push(t);
114
153
  else words.push(t);
115
154
  }
116
155
  a.message = words.join(" ").trim() || null;
@@ -129,6 +168,10 @@ export async function run(argv, deps = {}) {
129
168
  console.log(USAGE);
130
169
  return 0;
131
170
  }
171
+ if (args.unknown.length) {
172
+ console.error(fail(`unknown option ${args.unknown[0]}.`, "run `tot feedback --help`."));
173
+ return 2;
174
+ }
132
175
  if (!TYPES.has(args.type)) {
133
176
  console.error(fail(`--type must be one of: ${[...TYPES].join(", ")}.`, "e.g. --bug"));
134
177
  return 2;
@@ -221,6 +264,7 @@ export async function run(argv, deps = {}) {
221
264
  activityText,
222
265
  diagnosticsText,
223
266
  traceId,
267
+ tenant: args.tenant,
224
268
  });
225
269
  const res = await client.callTool("feedback_submit", payload);
226
270
  const id = feedbackReportId(res);
@@ -238,6 +238,7 @@ export const MANIFEST_SCOPES = [
238
238
  "inventory:write",
239
239
  "purchasing:read",
240
240
  "purchasing:write",
241
+ "proposal-events:read",
241
242
  "reports:read",
242
243
  "attribution:write",
243
244
  "widgets:launch",
@@ -265,6 +266,10 @@ export const MANIFEST_WEBHOOK_TOPICS = [
265
266
  "fulfillment.assignment.created",
266
267
  "fulfillment.assignment.updated",
267
268
  "fulfillment.label.voided",
269
+ "proposal.filed",
270
+ "proposal.applied",
271
+ "proposal.rejected",
272
+ "proposal.expired",
268
273
  ];
269
274
 
270
275
  export const MANIFEST_WIDGET_PLACEMENTS = ["product.aside", "home.section", "global.footer"];
@@ -10,6 +10,7 @@ import { extname, join, relative } from "node:path";
10
10
  import { workspacePathForTenantRelative } from "./tot-repo-mappings.mjs";
11
11
 
12
12
  const ERROR = "error";
13
+ const BULK_QUOTE_UNITS = ["each", "case", "gallon", "pail", "drum", "tote", "pound", "kilogram", "liter", "custom"];
13
14
  // Public routes implemented by the renderer. Authentication and cart URLs are
14
15
  // deliberately absent: they are flow-specific, not portable parity targets.
15
16
  const PLATFORM_ROUTES = ["/collections", "/collections/", "/products/", "/search", "/saved", "/account", "/account/", "/blog", "/blog/"];
@@ -256,8 +257,9 @@ function pageShape(value, file) {
256
257
  case "callout": if (!rich(section.body) || !["info", "warning", "legal", "success"].includes(section.tone) || section.title !== undefined && !string(section.title)) findings.push(finding("parity-section-shape", at, "callout requires supported tone, RichText body, and optional string title", "supply a valid callout")); break;
257
258
  case "contact": if (section.heading !== undefined && !string(section.heading) || section.email !== undefined && !string(section.email) || section.phone !== undefined && !string(section.phone) || section.address !== undefined && (!Array.isArray(section.address) || section.address.some((line) => !string(line))) || !string(section.email) && !string(section.phone) && !(Array.isArray(section.address) && section.address.length)) findings.push(finding("parity-section-shape", at, "contact requires string members and email, phone, or address", "supply valid contact details")); break;
258
259
  case "contact_form": if (["heading", "messageLabel", "submitLabel", "successMessage"].some((key) => section[key] !== undefined && !string(section[key])) || section.fields !== undefined && (!Array.isArray(section.fields) || section.fields.some((field) => field !== "name" && field !== "phone"))) findings.push(finding("parity-section-shape", at, "contact_form requires optional string copy and fields limited to name or phone", "supply a valid contact_form section")); break;
260
+ case "bulk_quote_form": if (["heading", "intro", "submitLabel", "successMessage"].some((key) => section[key] !== undefined && !string(section[key])) || section.units !== undefined && (!Array.isArray(section.units) || section.units.some((unit) => !BULK_QUOTE_UNITS.includes(unit)))) findings.push(finding("parity-section-shape", at, "bulk_quote_form requires optional string copy and units limited to the supported quote units", "supply a valid bulk_quote_form section")); break;
259
261
  case "needs_review": if (!string(section.reason) || section.severity !== undefined && !["blocker", "note"].includes(section.severity) || section.owner !== undefined && !string(section.owner) || section.href !== undefined && !string(section.href)) findings.push(finding("parity-section-shape", at, "needs_review requires reason and valid optional severity/owner/href", "supply a valid needs_review section")); break;
260
- default: findings.push(finding("parity-section-kind", `${at}/kind`, "section kind is not supported by the renderer", "use heading, paragraph, list, definitions, callout, contact, contact_form, or needs_review"));
262
+ default: findings.push(finding("parity-section-kind", `${at}/kind`, "section kind is not supported by the renderer", "use heading, paragraph, list, definitions, callout, contact, contact_form, bulk_quote_form, or needs_review"));
261
263
  }
262
264
  });
263
265
  const bodyHtml = typeof value.body_html === "string" && value.body_html.trim() !== "";