@velaro/cli 1.4.134 → 1.4.136

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.
@@ -1,15 +1,15 @@
1
- // velaro part-finder - the per-site Part Finder: one ordered lookup (cross-reference matrix, business system, own catalog, spec search, hand-off).
1
+ // velaro part-finder (alias: velaro smart-match) - Smart Match, the per-site ordered lookup that matches anything a customer names or shows in a photo to the company's own item (cross-reference matrix, business system, own catalog, spec search, hand-off).
2
2
  //
3
3
  // velaro part-finder find "<part, model or description>" Run the same lookup the bot uses (shows the trace)
4
4
  // velaro part-finder config get Show the order, time limits, confidence and no-result action
5
5
  // velaro part-finder config set [--enabled true|false] [--order matrix,erp,catalog_exact,spec_search] [--disable erp,...]
6
- // [--min-confidence 0.8] [--no-result handoff|categories|handoff_and_categories|capture_lead]
6
+ // [--item-noun part|product|service|plan|policy|course] [--min-confidence 0.8] [--on-no-result handoff|categories|handoff_and_categories|capture_lead]
7
7
  // velaro part-finder sources list|sync|preview|remove [id] Matrix sources (SharePoint, OneDrive); preview shows the diff, nothing applied
8
8
  // velaro part-finder sources add --url <share link> [--type sharepoint|onedrive] [--load-mode preload|live] [--sync-hours N] [--auto-approve]
9
9
  // velaro part-finder misses [--dismiss <id>] What customers asked that found nothing
10
10
  // velaro part-finder suggestions list|generate|approve <id>|reject <id>
11
11
  //
12
- // Calls messaging /PartFinder endpoints. Site scope comes from the signed-in identity. Needs the Part Finder package (EnablePartFinder);
12
+ // Calls messaging /PartFinder endpoints (live contract, name kept). Site scope comes from the signed-in identity. Needs the Smart Match package (EnablePartFinder);
13
13
  // without it the server answers 403 / not enabled.
14
14
  import { messagingGet, messagingPost, messagingPut, messagingDel } from '../api.js';
15
15
  import { runCommand } from '../run.js';
@@ -50,9 +50,15 @@ export function buildConfigPatch(current, flags) {
50
50
  if (!Number.isFinite(v) || v < 0 || v > 1) throw new Error('--min-confidence must be between 0 and 1.');
51
51
  patch.minConfidence = v;
52
52
  }
53
- if (flags['no-result'] !== undefined) {
54
- if (!NO_RESULT_ACTIONS.includes(flags['no-result'])) throw new Error(`--no-result must be one of ${NO_RESULT_ACTIONS.join(', ')}.`);
55
- patch.noResultAction = flags['no-result'];
53
+ if (flags['item-noun'] !== undefined) {
54
+ const t = String(flags['item-noun']).trim();
55
+ if (t.length > 40) throw new Error('--item-noun must be 40 characters or fewer.');
56
+ if (t !== '' && !/^[\p{L}\p{N} -]+$/u.test(t)) throw new Error('--item-noun can use letters, digits, spaces and hyphens only.');
57
+ patch.itemNoun = t === '' ? 'item' : t;
58
+ }
59
+ if (flags['on-no-result'] !== undefined) {
60
+ if (!NO_RESULT_ACTIONS.includes(flags['on-no-result'])) throw new Error(`--on-no-result must be one of ${NO_RESULT_ACTIONS.join(', ')}.`);
61
+ patch.noResultAction = flags['on-no-result'];
56
62
  }
57
63
  if (flags.enabled !== undefined) patch.enabled = String(flags.enabled) === 'true';
58
64
  if (Object.keys(patch).length === 0) throw new Error('Nothing to change. Pass at least one flag.');
@@ -94,9 +100,10 @@ const J = { type: 'boolean', describe: 'print raw JSON' };
94
100
 
95
101
  export const partFinderCommand = {
96
102
  command: 'part-finder',
97
- describe: 'Part Finder: find the right part from a photo, a part number or a competitor model, in the order you choose',
103
+ aliases: ['smart-match'],
104
+ describe: 'Smart Match: match a photo, a number, a name or a competitor name to the right item of yours, in the order you choose',
98
105
  builder: (yargs) => yargs
99
- .command('find <query>', 'Run the lookup the bot uses', (y) => y.positional('query', { type: 'string' }).option('json', J),
106
+ .command('find <query>', 'Run the lookup the bot uses for a name, number, model or description', (y) => y.positional('query', { type: 'string' }).option('json', J),
100
107
  runCommand(async (a) => {
101
108
  const r = await messagingPost('/PartFinder/Find', { query: a.query });
102
109
  if (a.json) { console.log(JSON.stringify(r, null, 2)); return; }
@@ -109,13 +116,14 @@ export const partFinderCommand = {
109
116
  .option('disable', { type: 'string' })
110
117
  .option('enable', { type: 'string' })
111
118
  .option('min-confidence', { type: 'string' })
112
- .option('no-result', { type: 'string' })
119
+ .option('on-no-result', { type: 'string' })
120
+ .option('item-noun', { type: 'string', describe: 'what you call the things customers look for: part, product, service, plan, policy, course (default item)' })
113
121
  .option('json', J),
114
122
  runCommand(async (a) => {
115
123
  let r = await messagingGet('/PartFinder/Config');
116
124
  if (a.action === 'set') r = await messagingPut('/PartFinder/Config', buildConfigPatch(r, a));
117
125
  if (a.json) { console.log(JSON.stringify(r, null, 2)); return; }
118
- console.log(`Part Finder: ${r.enabled ? 'on' : 'off'} min confidence ${r.minConfidence} no result: ${r.noResultAction}`);
126
+ console.log(`Smart Match: ${r.enabled ? 'on' : 'off'} min confidence ${r.minConfidence} no result: ${r.noResultAction} item noun: ${r.itemNoun ?? 'item'}`);
119
127
  (r.steps ?? []).forEach((s, i) => console.log(` ${i + 1}. ${s.id} ${s.enabled ? 'on' : 'off'} ${s.timeoutMs} ms`));
120
128
  }))
121
129
  .command('sources <action> [id]', 'list, add, sync, preview or remove matrix sources', (y) => y
@@ -1,6 +1,6 @@
1
1
  import { test } from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
- import { buildConfigPatch, buildSourceBody, describeFind, listOf, parseList } from './commands/part-finder.js';
3
+ import { partFinderCommand, buildConfigPatch, buildSourceBody, describeFind, listOf, parseList } from './commands/part-finder.js';
4
4
  import { tools, handlers } from '../../mcp/parity/part-finder.customer.js';
5
5
 
6
6
  const current = () => ({
@@ -37,8 +37,8 @@ test('rejects unknown steps, duplicates, and switching off both matrix and catal
37
37
  test('validates confidence and the no-result action, and refuses an empty change', () => {
38
38
  assert.equal(buildConfigPatch(current(), { 'min-confidence': '0.9' }).minConfidence, 0.9);
39
39
  assert.throws(() => buildConfigPatch(current(), { 'min-confidence': '2' }), /between 0 and 1/);
40
- assert.equal(buildConfigPatch(current(), { 'no-result': 'capture_lead' }).noResultAction, 'capture_lead');
41
- assert.throws(() => buildConfigPatch(current(), { 'no-result': 'shrug' }), /must be one of/);
40
+ assert.equal(buildConfigPatch(current(), { 'on-no-result': 'capture_lead' }).noResultAction, 'capture_lead');
41
+ assert.throws(() => buildConfigPatch(current(), { 'on-no-result': 'shrug' }), /must be one of/);
42
42
  assert.equal(buildConfigPatch(current(), { enabled: 'false' }).enabled, false);
43
43
  assert.throws(() => buildConfigPatch(current(), {}), /Nothing to change/);
44
44
  });
@@ -124,3 +124,28 @@ test('sources add (MCP): body carries shareUrl, upload is refused, input schema
124
124
  await assert.rejects(() => handlers.part_finder_source_add({ shareUrl: 'Cross.xlsx' }, ctx), /https/);
125
125
  await assert.rejects(() => handlers.part_finder_source_add({ shareUrl: LINK, type: 'upload' }, ctx), /sharepoint or onedrive/);
126
126
  });
127
+
128
+ test('item noun: trimmed, validated like the server, empty resets to item, and goes in the config patch', () => {
129
+ assert.equal(buildConfigPatch(current(), { 'item-noun': ' plan ' }).itemNoun, 'plan');
130
+ assert.equal(buildConfigPatch(current(), { 'item-noun': 'service plan' }).itemNoun, 'service plan');
131
+ assert.equal(buildConfigPatch(current(), { 'item-noun': ' ' }).itemNoun, 'item');
132
+ assert.throws(() => buildConfigPatch(current(), { 'item-noun': 'plan!' }), /letters, digits, spaces and hyphens/);
133
+ assert.throws(() => buildConfigPatch(current(), { 'item-noun': 'x'.repeat(41) }), /40 characters/);
134
+ });
135
+
136
+ test('MCP part_finder_config accepts itemNoun, sends it, and refuses a bad one', async () => {
137
+ const cfgTool = tools.find((t) => t.name === 'part_finder_config');
138
+ assert.ok(cfgTool.inputSchema.properties.itemNoun);
139
+ const calls = [];
140
+ const ctx = { messagingGet: async () => ({}), messagingPut: async (p, b) => { calls.push([p, b]); return {}; } };
141
+ await handlers.part_finder_config({ itemNoun: ' policy ' }, ctx);
142
+ assert.deepEqual(calls[0], ['/PartFinder/Config', { itemNoun: 'policy' }]);
143
+ await assert.rejects(() => handlers.part_finder_config({ itemNoun: 'a/b' }, ctx), /itemNoun/);
144
+ });
145
+
146
+ test('customer-facing text says Smart Match, the CLI keeps part-finder and adds the smart-match alias', () => {
147
+ assert.equal(partFinderCommand.command, 'part-finder');
148
+ assert.ok(partFinderCommand.aliases.includes('smart-match'));
149
+ assert.match(partFinderCommand.describe, /Smart Match/);
150
+ for (const t of tools) assert.doesNotMatch(t.description, /Part Finder/, t.name);
151
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velaro/cli",
3
- "version": "1.4.134",
3
+ "version": "1.4.136",
4
4
  "description": "Velaro Workspace v20 — command-line interface for managing bots, knowledge base ingestion, MCP API keys, search indexes, and ops health.",
5
5
  "type": "module",
6
6
  "bin": {