@s2life/mcp 0.1.1 → 0.2.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/match.mjs CHANGED
@@ -4,7 +4,8 @@ export function matchComponents(description, components, limit = 5) {
4
4
  const query = normalize(description);
5
5
  if (!query) return [];
6
6
  const words = description.normalize('NFKC').toLowerCase().split(/[^\p{L}\p{N}]+/u).filter((word) => word.length >= 2);
7
- return components.filter((c) => c.kind !== 'constant').map((component) => {
7
+ // 선택 질문에는 조립 루트만 답한다. 개별 부품은 부모의 parts와 get_component로 찾는다.
8
+ return components.filter((c) => c.kind !== 'constant' && !c.partOf).map((component) => {
8
9
  let score = 0;
9
10
  const reasons = [];
10
11
  if (query.includes(normalize(component.name))) { const weight = query === normalize(component.name) ? 2000 : 1000;
@@ -20,5 +21,7 @@ export function matchComponents(description, components, limit = 5) {
20
21
  if (matches.length) { score += matches.length * weight; reasons.push(`${field}: ${matches.join(', ')} (+${matches.length * weight})`); }
21
22
  }
22
23
  return { name: component.name, score, reasons, purpose: component.purpose, useWhen: component.useWhen, dont: component.dont };
23
- }).filter((c) => c.score > 0).sort((a, b) => b.score - a.score || a.name.localeCompare(b.name, 'en')).slice(0, limit);
24
+ // purpose 한 토큰(2점)만 맞은 것은 매칭 근거가 못 된다. 조사·일반어가 우연히 겹친다 —
25
+ // "zzzz 아무 관련 없는 말" 이 AlertDialog 의 "되돌릴 수 없는" 과 '없는' 으로 붙었다.
26
+ }).filter((c) => c.score > 2).sort((a, b) => b.score - a.score || a.name.localeCompare(b.name, 'en')).slice(0, limit);
24
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s2life/mcp",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "S2Life 디자인 시스템 MCP 서버 — AI 가 토큰·컴포넌트·규칙을 질의한다",
6
6
  "bin": {
package/server.mjs CHANGED
@@ -11,8 +11,8 @@ const string = { type: 'string', minLength: 1 };
11
11
  const definitions = [
12
12
  ['get_token','토큰 조회','토큰 이름으로 값·참조·용도·Tailwind 클래스와 라이트/다크 값을 조회한다.',objectSchema({ name: string }, ['name'])],
13
13
  ['search_tokens','토큰 검색','category 또는 부분 문자열 query로 토큰을 찾는다. 분류: primitive, semantic, typography, spacing, shape, sizing, motion, loading.',objectSchema({ category: string, query: string })],
14
- ['list_components','컴포넌트 목록','공개 컴포넌트와 상수의 이름·용도·import 구문을 조회한다.',objectSchema({})],
15
- ['get_component','컴포넌트 조회','props·slots·규칙·금지사항·관련 컴포넌트를 조회한다. inherited props는 표준 DOM 속성이다.',objectSchema({ name: string }, ['name'])],
14
+ ['list_components','컴포넌트 목록','공개 컴포넌트와 상수의 이름·용도·import 구문·부품의 partOf를 조회한다.',objectSchema({})],
15
+ ['get_component','컴포넌트 조회','props·slots·규칙·금지사항·부품 목록을 조회한다. 부품의 공통 의도는 부모에서 합치고 inheritedFrom으로 표시한다. extends는 상속 속성이다.',objectSchema({ name: string }, ['name'])],
16
16
  ['which_component','컴포넌트 선택','작업 설명을 단순 점수로 매칭해 후보·판단 근거·useWhen·dont를 함께 준다. 최종 선택은 호출자가 판단한다.',objectSchema({ description: string, limit: { type: 'integer', minimum: 1, maximum: 10 } }, ['description'])],
17
17
  ['get_rules','규칙 조회','주제별 하드 규칙과 DESIGN.md 출처를 조회한다. topic 생략 시 전체 규칙.',objectSchema({ topic: { type: 'string', enum: ['색','타이포','간격','로딩','폼','안내','차트','표'] } })],
18
18
  ].map(([name,title,description,inputSchema]) => ({ name,title,description,inputSchema }));
@@ -55,10 +55,15 @@ function callTool(manifest, params) {
55
55
  const tokens = manifest.tokens.filter((t) => (!args.category || t.category === args.category.trim().toLowerCase()) && `${t.name} ${t.purpose} ${t.tailwind.join(' ')}`.toLowerCase().includes(query));
56
56
  return tokens.length ? structured({ tokens }) : missing('일치하는 토큰이 없습니다. category를 생략하거나 search_tokens의 query를 짧게 해보세요.');
57
57
  }
58
- case 'list_components': return structured({ components: manifest.components.map(({ name, kind, purpose, import: statement }) => ({ name, kind, purpose, import: statement })) });
58
+ case 'list_components': return structured({ components: manifest.components.map(({ name, kind, purpose, import: statement, partOf }) => ({ name, kind, purpose, import: statement, ...(partOf ? { partOf } : {}) })) });
59
59
  case 'get_component': {
60
60
  const component = manifest.components.find((c) => c.name.toLowerCase() === args.name.trim().toLowerCase());
61
- return component ? structured(component) : missing('그런 컴포넌트가 없습니다. list_components로 이름을 확인하세요.');
61
+ if (!component) return missing('그런 컴포넌트가 없습니다. list_components로 이름을 확인하세요.');
62
+ if (!component.partOf) return structured(component);
63
+ const parent = manifest.components.find((c) => c.name === component.partOf);
64
+ // 보관 형태는 바꾸지 않는다. 한 항목을 읽을 때만 부모의 공통 의도를 완성한다.
65
+ const { useWhen, dont, rules, category } = parent;
66
+ return structured({ ...component, useWhen, dont, rules, category, inheritedFrom: parent.name });
62
67
  }
63
68
  case 'which_component': {
64
69
  const candidates = matchComponents(args.description, manifest.components, args.limit);