@fragments-sdk/context 0.3.1 → 0.3.3

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/LICENSE CHANGED
@@ -1,21 +1,81 @@
1
- MIT License
1
+ Functional Source License, Version 1.1, MIT Future License
2
2
 
3
- Copyright (c) 2024 Conan McNicholl
3
+ Licensor: Conan McNicholl
4
+ Software: @fragments-sdk/context
4
5
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
6
+ ---
11
7
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
8
+ ## Terms and Conditions
9
+
10
+ ### Licensor ("We")
11
+
12
+ The individual or entity listed above.
13
+
14
+ ### The Software
15
+
16
+ The software identified above, including all source code, object code,
17
+ documentation, and other files provided by the Licensor.
18
+
19
+ ### Grant of Rights
20
+
21
+ Subject to the conditions below, the Licensor grants you a non-exclusive,
22
+ worldwide, royalty-free license to use, copy, modify, create derivative works,
23
+ and redistribute the Software, in each case subject to the limitations below.
24
+
25
+ ### Limitation — Competing Use
26
+
27
+ You may not use the Software in, or to provide, a Commercial Product or Service
28
+ that competes with the Software or with any product or service that the Licensor
29
+ provides using the Software. A "Commercial Product or Service" is any product or
30
+ service offered to third parties for a fee or other consideration.
31
+
32
+ For clarity, the following uses are always permitted regardless of this limitation:
33
+
34
+ - Using the Software for your own internal business purposes
35
+ - Using the Software to build and deploy your own applications
36
+ - Using the Software for personal, educational, or evaluation purposes
37
+ - Providing professional services (consulting, integration) to your clients
38
+ that involve configuring or extending the Software
39
+
40
+ The following are examples of Competing Use that are NOT permitted:
41
+
42
+ - Offering a hosted developer tools service that repackages or exposes
43
+ the functionality of the Software
44
+ - Selling or distributing a product that is a substitute for any product
45
+ or service offered by the Licensor
46
+ - Building and offering an MCP server, CLI tool, or code intelligence
47
+ platform that is substantially derived from the Software
48
+
49
+ ### Change Date and License
50
+
51
+ On the second anniversary of each version's release date, the Licensor grants
52
+ you the rights under the terms of the MIT License for that version.
53
+ The "MIT License" means the license identified by SPDX as "MIT" and published
54
+ at https://opensource.org/licenses/MIT.
55
+
56
+ ### No Warranties
14
57
 
15
58
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
59
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
60
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
61
+
62
+ ### Limitation of Liability
63
+
64
+ IN NO EVENT SHALL THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
65
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
66
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
67
+ THE SOFTWARE.
68
+
69
+ ### General
70
+
71
+ If any provision of this License is held to be unenforceable, that provision
72
+ shall be reformed only to the extent necessary to make it enforceable, and the
73
+ remaining provisions shall continue in full force and effect.
74
+
75
+ This License does not grant permission to use the trade names, trademarks,
76
+ service marks, or product names of the Licensor, except as required for
77
+ reasonable and customary use in describing the origin of the Software.
78
+
79
+ ---
80
+
81
+ For more information about the Functional Source License, see https://fsl.software/
package/README.md CHANGED
@@ -60,3 +60,5 @@ pnpm add @fragments-sdk/context
60
60
  ```
61
61
 
62
62
  Requires Node.js 18+. Tree-sitter WASM grammars are included as dependencies.
63
+
64
+ <img referrerpolicy="no-referrer-when-downgrade" src="https://static.scarf.sh/a.png?x-pxid=a02beb71-df11-498d-8e1f-39de2e64ce5b" />
@@ -38,9 +38,18 @@ var MCP_TOOL_DEFINITIONS = [
38
38
  type: "boolean",
39
39
  description: "If true, includes code examples for each variant"
40
40
  },
41
+ limit: {
42
+ type: "number",
43
+ description: "Maximum number of results to return (default: 10 for useCase mode)"
44
+ },
41
45
  includeRelations: {
42
46
  type: "boolean",
43
47
  description: "If true, includes component relationships"
48
+ },
49
+ verbosity: {
50
+ type: "string",
51
+ enum: ["compact", "standard", "full"],
52
+ description: 'Response detail level: "compact" (names only), "standard" (default), "full" (everything including code)'
44
53
  }
45
54
  }
46
55
  },
@@ -55,7 +64,7 @@ var MCP_TOOL_DEFINITIONS = [
55
64
  fields: {
56
65
  type: "array",
57
66
  items: { type: "string" },
58
- description: 'Specific fields to return (e.g., ["meta", "usage.when", "contract.propsSummary", "props", "examples", "guidelines"]). If omitted, returns everything. Supports dot notation.'
67
+ description: 'Specific fields to return (e.g., ["meta", "guidelines.when", "contract.propsSummary", "props", "examples"]). If omitted, returns everything. Supports dot notation. Aliases: "usage" \u2192 "guidelines".'
59
68
  },
60
69
  variant: {
61
70
  type: "string",
@@ -68,6 +77,11 @@ var MCP_TOOL_DEFINITIONS = [
68
77
  maxLines: {
69
78
  type: "number",
70
79
  description: "Maximum lines per code example (truncates longer examples)"
80
+ },
81
+ verbosity: {
82
+ type: "string",
83
+ enum: ["compact", "standard", "full"],
84
+ description: 'Response detail level: "compact" (meta + prop names), "standard" (default), "full" (everything)'
71
85
  }
72
86
  },
73
87
  required: ["component"]
@@ -91,6 +105,15 @@ var MCP_TOOL_DEFINITIONS = [
91
105
  category: {
92
106
  type: "string",
93
107
  description: 'Filter by category (e.g., "authentication", "marketing", "dashboard", "settings", "ecommerce", "ai")'
108
+ },
109
+ limit: {
110
+ type: "number",
111
+ description: "Maximum number of blocks to return (default: all matching)"
112
+ },
113
+ verbosity: {
114
+ type: "string",
115
+ enum: ["compact", "standard", "full"],
116
+ description: 'Response detail level: "compact" (no code), "standard" (default, code preview for long blocks), "full" (full code)'
94
117
  }
95
118
  }
96
119
  },
@@ -105,6 +128,10 @@ var MCP_TOOL_DEFINITIONS = [
105
128
  search: {
106
129
  type: "string",
107
130
  description: 'Search token names (e.g., "accent", "hover", "padding")'
131
+ },
132
+ limit: {
133
+ type: "number",
134
+ description: "Maximum number of tokens to return per category (default: 25 for search, unlimited for category browsing)"
108
135
  }
109
136
  }
110
137
  },
@@ -115,6 +142,15 @@ var MCP_TOOL_DEFINITIONS = [
115
142
  useCase: {
116
143
  type: "string",
117
144
  description: 'What you want to implement (e.g., "login form", "data table with sorting", "streaming chat messages")'
145
+ },
146
+ limit: {
147
+ type: "number",
148
+ description: "Maximum number of components to return (default: 5)"
149
+ },
150
+ verbosity: {
151
+ type: "string",
152
+ enum: ["compact", "standard", "full"],
153
+ description: 'Response detail level: "compact" (names only), "standard" (default), "full" (all props + examples + full block code)'
118
154
  }
119
155
  },
120
156
  required: ["useCase"]
@@ -151,7 +187,7 @@ var MCP_TOOL_DEFINITIONS = [
151
187
  },
152
188
  variant: {
153
189
  type: "string",
154
- description: "Variant name for compare mode"
190
+ description: "Variant name to render (uses the variant's render function from the fragment definition). Works in both render and compare modes."
155
191
  },
156
192
  threshold: {
157
193
  type: "number",
@@ -182,7 +218,7 @@ var MCP_TOOL_DEFINITIONS = [
182
218
  },
183
219
  {
184
220
  key: "graph",
185
- description: 'Query the component relationship graph. Understand dependencies, impact analysis, composition trees, alternatives, and design system health. Use "health" for an overview, "dependencies"/"dependents" for direct relationships, "impact" for change analysis, "composition" for compound component trees.',
221
+ description: 'Query the component relationship graph. Understand dependencies, impact analysis, composition trees, alternatives, and design system health. Use "health" for an overview, "dependencies"/"dependents" for composition and declared relationships (not code-level imports), "impact" for change analysis, "composition" for compound component trees.',
186
222
  params: {
187
223
  mode: {
188
224
  type: "string",
@@ -1,5 +1,5 @@
1
1
  import { CompiledFragment, CompiledBlock } from '../types/index.js';
2
- import '../types-DOhSojcf.js';
2
+ import '../types-RAbbckR4.js';
3
3
 
4
4
  /**
5
5
  * Context generation for AI agents.
@@ -1,5 +1,5 @@
1
- import { C as ComponentGraph, G as GraphEdgeType, a as GraphEdge, I as ImpactResult, P as PathResult, N as NeighborResult, b as CompositionTree, c as GraphHealth, d as ComponentNode, S as SerializedComponentGraph } from '../types-DOhSojcf.js';
2
- export { E as EDGE_TYPE_WEIGHTS, f as GRAPH_EDGE_TYPES, e as SerializedEdge } from '../types-DOhSojcf.js';
1
+ import { C as ComponentGraph, G as GraphEdgeType, a as GraphEdge, I as ImpactResult, P as PathResult, N as NeighborResult, b as CompositionTree, c as GraphHealth, d as ComponentNode, S as SerializedComponentGraph } from '../types-RAbbckR4.js';
2
+ export { E as EDGE_TYPE_WEIGHTS, f as GRAPH_EDGE_TYPES, e as SerializedEdge } from '../types-RAbbckR4.js';
3
3
 
4
4
  /**
5
5
  * ComponentGraphEngine — query engine for the design-system relationship graph.
@@ -33,7 +33,7 @@ declare class ComponentGraphEngine {
33
33
  neighbors(component: string, maxHops?: number): NeighborResult;
34
34
  /** Get the composition tree for a compound component */
35
35
  composition(component: string): CompositionTree;
36
- /** Get alternative components */
36
+ /** Get alternative components (deduplicated for bidirectional edges) */
37
37
  alternatives(component: string): Array<{
38
38
  component: string;
39
39
  note?: string;
@@ -203,7 +203,7 @@ var ComponentGraphEngine = class {
203
203
  const node = this.nodes.get(component);
204
204
  const subComponents = node?.subComponents ?? [];
205
205
  const parentEdges = (this.outgoing.get(component) ?? []).filter((e) => e.type === "parent-of");
206
- const requiredChildren = parentEdges.map((e) => e.target);
206
+ const children = parentEdges.map((e) => e.target);
207
207
  const childEdges = (this.incoming.get(component) ?? []).filter((e) => e.type === "parent-of");
208
208
  const parent = childEdges.length > 0 ? childEdges[0].source : void 0;
209
209
  const siblings = [];
@@ -227,22 +227,25 @@ var ComponentGraphEngine = class {
227
227
  component,
228
228
  compositionPattern: node?.compositionPattern,
229
229
  subComponents,
230
- requiredChildren,
230
+ children,
231
231
  parent,
232
232
  siblings,
233
233
  blocks: this.blockIndex.get(component) ?? []
234
234
  };
235
235
  }
236
- /** Get alternative components */
236
+ /** Get alternative components (deduplicated for bidirectional edges) */
237
237
  alternatives(component) {
238
+ const seen = /* @__PURE__ */ new Set();
238
239
  const alts = [];
239
240
  for (const edge of this.outgoing.get(component) ?? []) {
240
- if (edge.type === "alternative-to") {
241
+ if (edge.type === "alternative-to" && !seen.has(edge.target)) {
242
+ seen.add(edge.target);
241
243
  alts.push({ component: edge.target, note: edge.note });
242
244
  }
243
245
  }
244
246
  for (const edge of this.incoming.get(component) ?? []) {
245
- if (edge.type === "alternative-to") {
247
+ if (edge.type === "alternative-to" && !seen.has(edge.source)) {
248
+ seen.add(edge.source);
246
249
  alts.push({ component: edge.source, note: edge.note });
247
250
  }
248
251
  }
package/dist/index.d.ts CHANGED
@@ -8,4 +8,4 @@ export { AST_SUPPORTED_LANGUAGES, ChangedFiles, FileEntry, GrammarMapping, INDEX
8
8
  export { ChunkMapping, CitationDocumentBlock, CitationDocumentOptions, DocumentMapping, RawCitation, ResolvedCitation, buildCitationDocuments, resolveCitation, resolveCitations } from './citations/index.js';
9
9
  export { CLI_TOOL_EXTENSIONS, CliToolExtension, MCP_TOOL_DEFINITIONS, McpToolDefinition, McpToolParam, buildMcpTools, buildToolNames } from './mcp-tools/index.js';
10
10
  export { CLI_COMMANDS, CLI_COMMAND_CATEGORIES, CliCategoryInfo, CliCommandCategory, CliCommandDef, CliOptionDef } from './cli-commands/index.js';
11
- import './types-DOhSojcf.js';
11
+ import './types-RAbbckR4.js';
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  MCP_TOOL_DEFINITIONS,
4
4
  buildMcpTools,
5
5
  buildToolNames
6
- } from "./chunk-HAJWPNLU.js";
6
+ } from "./chunk-NECSN43I.js";
7
7
  import {
8
8
  CLI_COMMANDS,
9
9
  CLI_COMMAND_CATEGORIES
@@ -3,7 +3,7 @@ import {
3
3
  MCP_TOOL_DEFINITIONS,
4
4
  buildMcpTools,
5
5
  buildToolNames
6
- } from "../chunk-HAJWPNLU.js";
6
+ } from "../chunk-NECSN43I.js";
7
7
  export {
8
8
  CLI_TOOL_EXTENSIONS,
9
9
  MCP_TOOL_DEFINITIONS,
@@ -1,4 +1,4 @@
1
- import { S as SerializedComponentGraph } from '../types-DOhSojcf.js';
1
+ import { S as SerializedComponentGraph } from '../types-RAbbckR4.js';
2
2
 
3
3
  /**
4
4
  * Compiled fragment types — shared between CLI and MCP packages.
@@ -122,6 +122,7 @@ interface CompiledBlock {
122
122
  */
123
123
  interface CompiledTokenEntry {
124
124
  name: string;
125
+ value?: string;
125
126
  description?: string;
126
127
  }
127
128
  /**
@@ -87,8 +87,8 @@ interface CompositionTree {
87
87
  compositionPattern?: 'compound' | 'simple' | 'controlled';
88
88
  /** Direct sub-components */
89
89
  subComponents: string[];
90
- /** Sub-components that must be present */
91
- requiredChildren: string[];
90
+ /** Components that declare this component as their parent */
91
+ children: string[];
92
92
  /** Parent component (if this is a sub-component) */
93
93
  parent?: string;
94
94
  /** Sibling components at the same level */
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@fragments-sdk/context",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
+ "license": "FSL-1.1-MIT",
4
5
  "description": "Code intelligence and RAG primitives for design system and codebase indexing",
6
+ "author": "Conan McNicholl",
7
+ "homepage": "https://usefragments.com",
5
8
  "repository": {
6
9
  "type": "git",
7
10
  "url": "https://github.com/ConanMcN/fragments"
@@ -56,13 +59,27 @@
56
59
  "import": "./dist/graph/index.js"
57
60
  }
58
61
  },
62
+ "keywords": [
63
+ "rag",
64
+ "embeddings",
65
+ "code-intelligence",
66
+ "chunking",
67
+ "search",
68
+ "indexing",
69
+ "ai",
70
+ "context"
71
+ ],
59
72
  "publishConfig": {
60
73
  "access": "public"
61
74
  },
62
75
  "files": [
63
76
  "dist"
64
77
  ],
78
+ "scarfSettings": {
79
+ "defaultOptIn": true
80
+ },
65
81
  "dependencies": {
82
+ "@scarf/scarf": "^1.4.0",
66
83
  "tree-sitter-go": "^0.25.0",
67
84
  "tree-sitter-java": "^0.23.5",
68
85
  "tree-sitter-javascript": "^0.25.0",