@pymodel/niblet 0.2.1 → 0.3.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/README.md CHANGED
@@ -92,10 +92,13 @@ API check: OK
92
92
  | --- | --- | --- |
93
93
  | `find_ui_references` | One concrete unresolved question about a layout, state, or interaction. Returns one to three real screens as inline images. | yes |
94
94
  | `find_ui_materials` | A font, icon, or animated icon role your design system does not already cover. Returns the recorded license with each result. | yes |
95
+ | `get_design_reference` | The colours, typography, and components recorded for a web screen you already picked. Pass the `screenId` from a reference, or a pack slug. | yes |
95
96
  | `niblet_help` | "What can Niblet do?", or choosing between commands. Lists the four surface modes and every command; pass `command` for one entry. | no |
96
97
  | `niblet_status` | Diagnosing the connection before concluding the catalogue is empty. Never prints the token. | no |
97
98
 
98
- The two catalogue tools match the hosted service exactly. `niblet_help` and `niblet_status` are local-only.
99
+ The three catalogue tools match the hosted service exactly. `niblet_help` and `niblet_status` are local-only.
100
+
101
+ Only web screens carry a design reference, and a web result says so in its own text, so an agent that finds a screen worth borrowing from can read the system behind it in one follow-up call.
99
102
 
100
103
  ## Resources
101
104
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pymodel/niblet",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Niblet MCP server and design skill: real UI screen references for coding agents",
5
5
  "keywords": [
6
6
  "mcp",
package/src/server.mjs CHANGED
@@ -157,7 +157,7 @@ export function createServer({
157
157
 
158
158
  const server = new McpServer(
159
159
  { name: 'niblet', version: pkg.version, websiteUrl: 'https://niblet.com' },
160
- { instructions: `Read niblet://skill for the Niblet design workflow; its reference documents are served alongside it (niblet://skill/commands, /connection, /evidence, /native). Call niblet_help to list the surface modes and every design command, or when asked what Niblet can do; call niblet_status to diagnose the connection before concluding the catalogue is empty. ${UNTRUSTED_DATA} The two catalogue tools require NIBLET_TOKEN; the bundled skill, niblet_help, and niblet_status do not. This server only reads ${API_ORIGIN}/v1 and does not provide a remote UI review service.` },
160
+ { instructions: `Read niblet://skill for the Niblet design workflow; its reference documents are served alongside it (niblet://skill/commands, /connection, /evidence, /native). Call niblet_help to list the surface modes and every design command, or when asked what Niblet can do; call niblet_status to diagnose the connection before concluding the catalogue is empty. ${UNTRUSTED_DATA} After picking a web reference, call get_design_reference with its screenId for the recorded colors, typography, and components. The catalogue tools require NIBLET_TOKEN; the bundled skill, niblet_help, and niblet_status do not. This server only reads ${API_ORIGIN}/v1 and does not provide a remote UI review service.` },
161
161
  );
162
162
 
163
163
  function credentialError() {
@@ -296,7 +296,11 @@ export function createServer({
296
296
  // The API treats `limit` as advisory, so bound the fan-out here: one image fetch per ref.
297
297
  const refs = all.slice(0, input.limit);
298
298
 
299
- const content = [{ type: 'text', text: [REFERENCE_PREAMBLE, '', ...refs.map(refText)].join('\n') }];
299
+ // Only web screens belong to a design pack, so only they get the follow-up pointer.
300
+ const pointer = refs.some((ref) => ref.platform === 'web')
301
+ ? ['', 'A full style reference is recorded for the web screens above. Call get_design_reference with the screenId to read its colors, typography, and components.']
302
+ : [];
303
+ const content = [{ type: 'text', text: [REFERENCE_PREAMBLE, '', ...refs.map(refText), ...pointer].join('\n') }];
300
304
  for (const [index, ref] of refs.entries()) {
301
305
  const image = await fetchImage(ref.thumbUrl, extra.signal);
302
306
  // Keep one block per reference so position still identifies which screen an image belongs to.
@@ -349,6 +353,37 @@ export function createServer({
349
353
 
350
354
  const localAnnotations = { ...annotations, openWorldHint: false };
351
355
 
356
+ server.registerTool('get_design_reference', {
357
+ title: 'Get design reference',
358
+ description: 'Read the recorded style reference for a web screen returned by find_ui_references, or for a design pack by slug: colors with their roles, typography, and component inventory, as markdown. Only web screens have one.',
359
+ inputSchema: z.object({
360
+ screenId: screenId.optional().describe('A screen ID from find_ui_references.'),
361
+ packSlug: z.string().min(1).max(160).optional().describe('A design pack slug, when the pack is already known.'),
362
+ clientSkillVersion: clientSkillVersion.optional(),
363
+ }).strict().refine((value) => value.screenId !== undefined || value.packSlug !== undefined, 'Pass screenId or packSlug.'),
364
+ annotations,
365
+ }, async (input, extra) => {
366
+ const credential = credentialError();
367
+ if (credential) return errorResult(credential);
368
+
369
+ const result = await requestJson(['design-reference'], { screenId: input.screenId, slug: input.packSlug }, extra.signal);
370
+ if (!result.ok) {
371
+ if (result.status === 404) {
372
+ return textResult(
373
+ input.screenId
374
+ ? 'No style reference is recorded for that screen. Only web screens have one; continue with the local design system.'
375
+ : 'No design pack with that slug. Continue with the local design system.',
376
+ );
377
+ }
378
+ return errorResult(result.message);
379
+ }
380
+ const markdown = result.data?.markdown;
381
+ if (typeof markdown !== 'string' || markdown.trim() === '') return errorResult('Niblet API returned an invalid response.');
382
+ const slug = field(result.data.slug ?? '', 160);
383
+ const source = slug ? `\n\nSource: https://niblet.com/packs/${slug}` : '';
384
+ return { content: [{ type: 'text', text: `${REFERENCE_PREAMBLE}${source}` }, { type: 'text', text: field(markdown, 40_000) }] };
385
+ });
386
+
352
387
  server.registerTool('niblet_help', {
353
388
  title: 'Niblet help',
354
389
  description: 'List everything Niblet offers: the surface modes, every design command with its purpose, and the reference documents available as resources. Use when asked what Niblet can do, which command fits, or to present the choice menu before making changes.',