@punica/form-mcp 0.8.0 → 0.9.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.
@@ -1 +1 @@
1
- {"version":"2.3.1"}
1
+ {"version":"2.3.2"}
@@ -73,6 +73,13 @@ export declare const FileField: (props: FieldProps) => FormPropertyDecorator;
73
73
  * @ArrayField({ label: 'Lines', row: () => new LineForm(), minItems: 1 })
74
74
  * lines: LineForm[] = [];
75
75
  *
76
+ * The rows start from the value of the property: a row for every element,
77
+ * whose values replace those of a new `row()`. `lines: LineForm[] =
78
+ * [new LineForm()]` starts with one row as the class has it; an element may
79
+ * name only what differs (`{ quantity: 1 } as LineForm`), the other fields
80
+ * then come from the class. `[]` starts with none: `minItems` only checks
81
+ * how many there are, it adds no rows.
82
+ *
76
83
  * The row class needs no `@FormKit`; with it, `columns` lays out its fields.
77
84
  */
78
85
  export declare const ArrayField: (props: FieldProps & {
@@ -1 +1 @@
1
- {"version":"0.7.1"}
1
+ {"version":"0.7.2"}
@@ -15,6 +15,10 @@ export type RowOf<E, K extends keyof E> = NonNullable<E[K]> extends ReadonlyArra
15
15
  * await lines.append('lines', { name: 'Paper' });
16
16
  * lines.rows('lines')[0].controller.getService(SetValue).run('price', 5);
17
17
  *
18
+ * The rows start from the value of the item: a row for every element, whose
19
+ * values replace those of a new `row()`, so an element names only what
20
+ * differs (`[{ quantity: 1 }]`); an empty or missing value starts with none.
21
+ *
18
22
  * The value of the item is the array of the values of its rows. The item is
19
23
  * dirty, touched and in error when a row is, and validating the form
20
24
  * validates the rows. A row class without `@Services` gets the services of
@@ -1 +1 @@
1
- {"version":"2.3.1"}
1
+ {"version":"2.3.2"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@punica/form-mcp",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "MCP server for Punica Form: look up the exact API of its packages, read the rules and check code that uses them.",
5
5
  "keywords": [
6
6
  "mcp",
@@ -40,10 +40,10 @@
40
40
  "zod": "^4.6.7"
41
41
  },
42
42
  "devDependencies": {
43
- "@punica/form": "^2.3.1",
44
- "@punica/form-service": "^2.3.1",
43
+ "@punica/form": "^2.3.2",
44
+ "@punica/form-service": "^2.3.2",
45
45
  "@punica/form-react": "^0.2.0",
46
- "@punica/form-kit": "^0.7.1",
46
+ "@punica/form-kit": "^0.7.2",
47
47
  "@punica/form-schema": "^0.1.0"
48
48
  },
49
49
  "scripts": {
package/src/knowledge.mjs CHANGED
@@ -237,13 +237,46 @@ export function createKnowledge(packages) {
237
237
  return `## ${name} (not exported, ${api.get(users[0]).package})\n\nIt cannot be imported; it is part of ${users.join(', ')}, which can.\n\n\`\`\`ts\n${declaration}\n\`\`\``;
238
238
  }
239
239
 
240
+ /** The words of a name, with the ones that mean the same made one. */
241
+ const wordsOf = (name) =>
242
+ name
243
+ .split(/(?=[A-Z][a-z])|_/)
244
+ .map((word) => word.toLowerCase())
245
+ .map((word) => (/^(options|config|params)$/.test(word) ? 'props' : word))
246
+ .filter(Boolean);
247
+
248
+ /** The exports that share most words with a name that is not one. */
249
+ function closest(name) {
250
+ const wanted = new Set(wordsOf(name));
251
+
252
+ return names
253
+ .map((other) => ({
254
+ other,
255
+ shared: wordsOf(other).filter((word) => wanted.has(word)).length
256
+ }))
257
+ .filter(({ shared }) => shared > 0)
258
+ .sort((a, b) => b.shared - a.shared || a.other.length - b.other.length)
259
+ .slice(0, 6)
260
+ .map(({ other }) => other);
261
+ }
262
+
240
263
  function formatMarkdown(name) {
241
264
  const item = get(name);
242
265
 
243
266
  if (!item && /^\w+$/.test(name) && local(name)) return local(name);
244
267
 
245
268
  if (!item) {
246
- return `${name} is not exported by ${packages.map((p) => p.name).join(' or ')}. Exports: ${names.join(', ')}`;
269
+ const missing = `${name} is not exported by ${packages.map((p) => p.name).join(' or ')}.`;
270
+ // TextFieldOptions: what TextField takes is in its own declaration
271
+ const owner = /^(\w+?)(?:Options|Props|Config|Params)$/.exec(name)?.[1];
272
+
273
+ if (owner && get(owner)) {
274
+ return `${missing} What ${owner} takes is in its declaration:\n\n${formatMarkdown(owner)}`;
275
+ }
276
+
277
+ const near = /^\w+$/.test(name) ? closest(name) : [];
278
+
279
+ return `${missing}${near.length ? ` Closest: ${near.join(', ')}.` : ''} Exports: ${names.join(', ')}`;
247
280
  }
248
281
 
249
282
  return `## ${item.name} (${item.kind}, ${item.package})\n\n\`\`\`ts\n${item.declaration}\n\`\`\``;