logicstamp-context 0.5.0 → 0.5.2

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/LLM_CONTEXT.md CHANGED
@@ -94,7 +94,7 @@ The `context_main.json` file serves as a directory index:
94
94
  }
95
95
  ],
96
96
  "meta": {
97
- "source": "logicstamp-context@0.5.0"
97
+ "source": "logicstamp-context@0.5.1"
98
98
  }
99
99
  }
100
100
  ```
@@ -117,7 +117,7 @@ Each folder's `context.json` contains an array of LogicStamp bundles. Each bundl
117
117
  - `graph.edges` lists dependency relationships between nodes (empty when analysis depth is 1).
118
118
  - `meta` section contains two critical fields:
119
119
  - `missing`: Array of unresolved dependencies. Each entry includes `name` (import path), `reason` (why it failed), and `referencedBy` (source component). Empty array indicates complete dependency resolution.
120
- - `source`: Generator version string (e.g., `"logicstamp-context@0.5.0"`) for compatibility tracking.
120
+ - `source`: Generator version string (e.g., `"logicstamp-context@0.5.1"`) for compatibility tracking.
121
121
  - Example bundle skeleton:
122
122
 
123
123
  ```
@@ -322,6 +322,43 @@ Even when token counts are similar, structured data is **significantly faster to
322
322
  3. **Filter by `entryId`**: Within a folder's context file, filter bundles by `entryId` to focus on relevant modules.
323
323
  4. **Combine multiple folders**: When a task spans multiple folders, load the relevant folder context files and combine their bundles.
324
324
 
325
+ ### Finding Components: Root vs Dependencies
326
+
327
+ LogicStamp organizes components into two categories:
328
+
329
+ - **Root components** - Components that have their own bundles (listed in `context_main.json` under each folder's `components` array). These are entry points that are **not imported by any other components** in the project. Each root component gets its own bundle.
330
+ - **Dependencies** - Components that are imported by root components. They appear in the importing component's bundle as nodes in `graph.nodes[]`, not as separate root bundles. A dependency can appear in multiple bundles if it's imported by multiple root components.
331
+
332
+ **Workflow for finding a component:**
333
+
334
+ 1. **Check `context_main.json` first** - Look in the `folders[]` array for the component's file name in the `components` list. If found, it's a root component with its own bundle in that folder's `context.json`.
335
+ 2. **If not found as a root** - The component is likely a dependency. Find which root component(s) import it:
336
+ - Search for import statements in source code to identify importing components
337
+ - Check bundles in the same folder (dependencies are often in the same folder as their importing component)
338
+ - Search through bundle `graph.nodes[]` arrays to find which bundles include the dependency
339
+ 3. **Read the importing root's bundle** - The dependency's contract will be in `graph.nodes[]` of that bundle. Each bundle in a folder's `context.json` is an array - find the bundle whose `entryId` matches the importing root component.
340
+
341
+ **Example:**
342
+
343
+ ```
344
+ FAQ.tsx is imported by src/app/page.tsx
345
+ → FAQ is NOT listed in context_main.json folders[].components (not a root)
346
+ → FAQ IS in src/app/page.tsx bundle (as a dependency node in graph.nodes[])
347
+ → To access FAQ:
348
+ 1. Read src/app/context.json (array of bundles)
349
+ 2. Find bundle with entryId: "src/app/page.tsx"
350
+ 3. Look in that bundle's graph.nodes[] for FAQ.tsx contract
351
+ ```
352
+
353
+ **Why this matters:**
354
+
355
+ - Root components = own bundles (e.g., `Features.tsx`, `Stats.tsx` in `src/components/sections/context.json`)
356
+ - Dependencies = included in importing root component's bundle graph (e.g., `FAQ.tsx` in `src/app/page.tsx` bundle)
357
+ - This structure matches how developers think: pages/features are entry points, their dependencies are included automatically
358
+ - A component can be a dependency in multiple bundles if imported by multiple root components
359
+
360
+ **Common mistake:** Looking for a component as a root when it's actually a dependency. Always check `context_main.json` first to see if it's listed as a root component.
361
+
325
362
  ### Working with the Index
326
363
 
327
364
  - Use `context_main.json` to:
package/README.md CHANGED
@@ -7,43 +7,43 @@
7
7
  </picture>
8
8
  </a>
9
9
 
10
- ### Deterministic codebase context for AI assistants.
10
+ ### Deterministic architectural context for TypeScript codebases.
11
+
12
+ Understand your codebase through explicit component contracts and relationships.
11
13
 
12
14
  <small><em>TypeScript · React · Next.js · Vue (TS/TSX) · Express · NestJS</em></small>
13
- <br/>
14
- <br/>
15
15
 
16
- **Structured component contracts for AI - props, hooks, dependencies extracted and organized.**
16
+ **Designed to work alongside Claude, Cursor, Copilot Chat, and MCP-based agents.**
17
17
 
18
18
  <br/>
19
19
  <a href="https://github.com/LogicStamp">
20
20
  <img src="./assets/logicstamp-fox.svg" alt="LogicStamp Fox Mascot" width="100" style="min-width: 80px;">
21
21
  </a>
22
22
 
23
- [![Version](https://img.shields.io/badge/version-0.5.0-8b5cf6.svg)](https://www.npmjs.com/package/logicstamp-context)
23
+ [![Version](https://img.shields.io/badge/version-0.5.2-8b5cf6.svg)](https://www.npmjs.com/package/logicstamp-context)
24
24
  ![Beta](https://img.shields.io/badge/status-beta-orange.svg)
25
25
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
26
26
  ![Node](https://img.shields.io/badge/node-%3E%3D18.18.0-brightgreen.svg)
27
27
  [![CI](https://github.com/LogicStamp/logicstamp-context/workflows/CI/badge.svg)](https://github.com/LogicStamp/logicstamp-context/actions)
28
28
 
29
29
  </div>
30
+ <br/>
30
31
 
31
- ## The Problem
32
+ <details>
33
+ <summary><strong>📌 TL;DR</strong></summary>
32
34
 
33
- AI coding assistants read your source code but don't understand your architecture. They hallucinate prop names, invent dependencies, and miss breaking changes - because raw source code isn't structured context.
35
+ **What it does:** Uses AST parsing to extract deterministic component contracts from your TypeScript codebase.
34
36
 
35
- **LogicStamp generates deterministic component contracts that:**
36
- - Stay in sync with your code (watch mode auto-regenerates)
37
- - Expose what matters (props, hooks, dependencies) without implementation noise
38
- - Work with any MCP-compatible AI assistant (Claude, Cursor, etc.)
37
+ **What you get:** Structured JSON bundles (props, hooks, dependencies, APIs) optimized for AI consumption.
39
38
 
40
- ![LogicStamp MCP Workflow](./assets/logicstamp-workflow.gif)
41
- *Context bundles generated and consumed across MCP-powered AI workflows.*
39
+ **Why it matters:** Gives AI assistants explicit architectural context without reading implementations - prevents inferred prop names and missed dependencies by making contracts explicit.
40
+
41
+ </details>
42
42
 
43
- <br/>
44
43
  <details>
45
44
  <summary><strong>📑 Table of Contents</strong></summary>
46
45
 
46
+ - [The Problem](#the-problem)
47
47
  - [Quick Start](#quick-start)
48
48
  - [Drift Detection](#drift-detection)
49
49
  - [Why Structured Context?](#why-structured-context)
@@ -60,8 +60,32 @@ AI coding assistants read your source code but don't understand your architectur
60
60
  - [Known Limitations](#known-limitations)
61
61
  - [Requirements](#requirements)
62
62
  - [Need Help?](#need-help)
63
+ - [License](#license)
63
64
  </details>
64
65
 
66
+ ## The Problem
67
+
68
+ AI coding assistants can read your source code, but they lack explicit structural context. They often infer prop names, invent dependencies, and miss breaking changes - because raw source code isn't machine-structured context.
69
+
70
+ **LogicStamp Context** is a compiler-like static analyzer that emits deterministic architectural contracts from your TypeScript source code.
71
+
72
+ **LogicStamp Context generates deterministic component contracts that:**
73
+ - Stay in sync with your code (watch mode auto-regenerates)
74
+ - Expose what matters (props, hooks, dependencies) without implementation noise
75
+ - Work with any MCP-compatible AI assistant (Claude, Cursor, etc.)
76
+
77
+ ![LogicStamp MCP Workflow](./assets/logicstamp-workflow.gif)
78
+ *Context bundles generated and consumed across MCP-powered AI workflows.*
79
+
80
+ **Same code ⇒ same context output.** Diff outputs to detect architectural drift.
81
+
82
+ ```
83
+ TypeScript Code → AST Parsing → Deterministic Contracts → AI Assistant
84
+ (.ts/.tsx) (ts-morph) (context.json bundles) (Claude, Cursor)
85
+ ```
86
+
87
+ ---
88
+
65
89
  ## Quick Start
66
90
 
67
91
  **Try it in 30 seconds (no install required):**
@@ -84,29 +108,34 @@ stamp context
84
108
 
85
109
  > **ℹ️ Note:** With `npx`, run `npx logicstamp-context context`. After global install, use `stamp context`.
86
110
 
111
+ 📋 **For detailed setup instructions, see the [Getting Started Guide](https://logicstamp.dev/docs/getting-started).**
112
+
87
113
  ## Drift Detection
88
114
 
89
- Compare regenerated context against existing context files:
115
+ Compare regenerated context against existing context files (useful for one-time checks and CI workflows):
90
116
 
91
117
  ```bash
92
118
  stamp context compare # detect changes
93
119
  stamp context compare --approve # update (like jest -u)
94
120
  ```
95
121
 
96
- Useful during development to see what changed. Shows added/removed components, changed props, hooks, dependencies.
122
+ Shows added/removed components, changed props, hooks, dependencies.
123
+
124
+ > **💡 Tip:** If you're using [watch mode](#watch-mode), context files are automatically regenerated and changes are shown in real-time. Use `compare` for one-time checks or CI workflows.
97
125
 
98
- > **Note:** Context files are gitignored by default. For CI-based drift detection (comparing against git refs like `main` or `HEAD~1`), see the [roadmap](https://logicstamp.dev/roadmap) - this feature is planned for a future release.
126
+ > ⚠️ **Note:** Context files are gitignored by default. For CI-based drift detection, the `--baseline git:<ref>` option (e.g., `--baseline git:main`) is **not yet implemented**. Until automation is available, use the manual workflow: generate context from current code, checkout baseline branch, generate context from baseline, then compare. See the [roadmap](https://logicstamp.dev/roadmap) for planned automation.
99
127
 
100
128
  ## Why Structured Context?
101
129
 
102
- | Without LogicStamp | With LogicStamp |
130
+ | Without LogicStamp Context | With LogicStamp Context |
103
131
  |-------------------|-----------------|
104
- | AI reads 200 lines to understand a component | AI reads a 20-line contract |
132
+ | AI parses 200 lines of implementation to infer a component's interface | AI reads a 20-line interface contract |
105
133
  | Props/hooks inferred (often wrong) | Props/hooks explicit and verified |
106
134
  | No way to know if context is stale | Watch mode catches changes in real-time |
107
135
  | Different prompts = different understanding | Deterministic: same code = same contract |
136
+ | Manual context gathering: "Here's my Button component..." | Structured contracts: AI understands architecture automatically |
108
137
 
109
- **The key insight:** AI assistants don't need your implementation - they need your *interfaces*. LogicStamp extracts what matters and discards the noise.
138
+ **The key insight:** AI assistants don't need your implementation - they need your *interfaces*. LogicStamp Context extracts what matters and discards the noise.
110
139
 
111
140
  ### What "Structured" Means
112
141
 
@@ -120,7 +149,7 @@ export const Button = ({ variant = 'primary', disabled, onClick, children }) =>
120
149
  }
121
150
  ```
122
151
 
123
- LogicStamp generates:
152
+ LogicStamp Context generates:
124
153
 
125
154
  ```json
126
155
  {
@@ -136,7 +165,7 @@ LogicStamp generates:
136
165
  }
137
166
  ```
138
167
 
139
- Pre-parsed. Categorized. Deterministic. The AI reads contracts, not implementations.
168
+ Pre-parsed. Categorized. Stable. The AI reads contracts, not implementations.
140
169
 
141
170
  ## ⚡ Features
142
171
 
@@ -149,7 +178,7 @@ Pre-parsed. Categorized. Deterministic. The AI reads contracts, not implementati
149
178
  **Analysis:**
150
179
  - React/Next.js/Vue component extraction (props, hooks, state, deps)
151
180
  - Backend API extraction (Express.js, NestJS routes and controllers)
152
- - Dependency graphs with cycle detection
181
+ - Dependency graphs (handles circular dependencies)
153
182
  - Style metadata extraction (Tailwind, SCSS, MUI, shadcn)
154
183
  - Next.js App Router detection (client/server, layouts, pages)
155
184
 
@@ -175,9 +204,9 @@ Strict watch catches breaking changes that affect consumers:
175
204
 
176
205
  | Violation | Example |
177
206
  |-----------|---------|
178
- | `prop_removed` | Removed `disabled` prop from Button |
179
- | `event_removed` | Removed `onSubmit` callback |
180
- | `function_removed` | Deleted exported `formatDate()` |
207
+ | `breaking_change_prop_removed` | Removed `disabled` prop from Button |
208
+ | `breaking_change_event_removed` | Removed `onSubmit` callback |
209
+ | `breaking_change_function_removed` | Deleted exported `formatDate()` |
181
210
  | `contract_removed` | Deleted entire component |
182
211
 
183
212
  **Recommended workflow:**
@@ -192,16 +221,49 @@ Context always fresh as you code
192
221
  ## How it Works
193
222
 
194
223
  1. **Scan** - Finds all `.ts` and `.tsx` files in your project
195
- 2. **Analyze** - Parses components and APIs using TypeScript AST
224
+ 2. **Analyze** - Parses components and APIs using TypeScript AST (Abstract Syntax Tree) via `ts-morph`
196
225
  3. **Extract** - Builds contracts with props, hooks, state, signatures
197
226
  4. **Graph** - Creates dependency graph showing relationships
198
227
  5. **Bundle** - Packages context optimized for AI consumption
199
228
  6. **Organize** - Groups by folder, writes `context.json` files
200
229
  7. **Index** - Creates `context_main.json` with metadata and statistics
201
230
 
231
+ **Why AST parsing matters:** Unlike text-based parsing (regex, string matching), AST parsing understands TypeScript's syntax structure, type information, and code semantics. This enables LogicStamp Context to accurately extract prop types, detect hooks, understand component composition, and handle complex patterns reliably - making contracts deterministic and trustworthy.
232
+
202
233
  No pre-compilation needed. One command.
203
234
 
204
- > **Tip:** Use `stamp context` for basic contracts. Use `stamp context style` when you need style metadata (Tailwind classes, SCSS selectors, layout patterns).
235
+ > **💡Tip:** Use `stamp context` for basic contracts. Use `stamp context style` when you need style metadata (Tailwind classes, SCSS selectors, layout patterns).
236
+
237
+ <details>
238
+ <summary><strong>📋 What LogicStamp Context Is (and Isn't)</strong></summary>
239
+
240
+ **LogicStamp Context IS:**
241
+
242
+ ✅ **An AST-based static analysis tool** - Uses the TypeScript compiler API (via ts-morph) to extract component contracts, props, hooks, and dependencies in a deterministic, type-aware way.
243
+
244
+ ✅ **A deterministic context generator** - Produces structured architectural contract bundles for tooling and AI workflows.
245
+
246
+ ✅ **Local and offline-first** - Runs entirely on your machine (no cloud services, no network calls).
247
+
248
+ ✅ **Framework-aware** - Understands React, Next.js, Vue, Express, and NestJS patterns and extracts relevant metadata.
249
+
250
+ ✅ **Non-opinionated** - Describes what exists without enforcing patterns or architectural decisions.
251
+
252
+ **LogicStamp Context IS NOT:**
253
+
254
+ ❌ **A code generator** - It never writes or modifies your source code.
255
+
256
+ ❌ **A documentation generator** - It produces structured contracts, not documentation.
257
+
258
+ ❌ **A build or runtime tool** - It analyzes static source code only; it does not execute or bundle your application.
259
+
260
+ ❌ **A linter, formatter, or testing framework** - It does not check code quality or run tests.
261
+
262
+ ❌ **An AI behavior controller** - It provides structured context; it does not alter AI responses.
263
+
264
+ ❌ **A replacement for reading code** - It accelerates understanding without replacing engineering judgment.
265
+
266
+ </details>
205
267
 
206
268
  ## MCP Server
207
269
 
@@ -217,7 +279,7 @@ Then configure your AI assistant to use the LogicStamp MCP Server.
217
279
 
218
280
  ## Example Output
219
281
 
220
- LogicStamp generates structured JSON bundles organized by folder:
282
+ LogicStamp Context generates structured JSON bundles organized by folder:
221
283
 
222
284
  ```json
223
285
  {
@@ -261,12 +323,12 @@ After installation, the `stamp` command is available globally.
261
323
 
262
324
  **Automatic Secret Protection**
263
325
 
264
- LogicStamp protects sensitive data in generated context:
326
+ LogicStamp Context protects sensitive data in generated context:
265
327
 
266
328
  - **Security scanning by default** - `stamp init` scans for secrets (API keys, passwords, tokens)
267
329
  - **Automatic sanitization** - Detected secrets replaced with `"PRIVATE_DATA"` in output
268
330
  - **Manual exclusions** - Use `stamp ignore <file>` to exclude files via `.stampignore`
269
- - **Safe by default** - Only metadata included; credentials only appear in `--include-code full` mode
331
+ - **Safe by default** - Only metadata included. Credentials only appear in `--include-code full` mode
270
332
 
271
333
  > **⚠️ Seeing `"PRIVATE_DATA"` in output?** Review `stamp_security_report.json`, remove hardcoded secrets from source, use environment variables instead.
272
334
 
@@ -302,6 +364,7 @@ stamp context clean [path] # Remove generated files
302
364
  | `--stats` | Emit JSON stats with token estimates |
303
365
  | `--out <path>` | Output directory |
304
366
  | `--quiet` | Suppress verbose output |
367
+ | `--strict-missing` | Exit with error if any missing dependencies found (CI-friendly) |
305
368
  | `--debug` | Show detailed hash info (watch mode) |
306
369
  | `--log-file` | Write change logs to `.logicstamp/` (watch mode) |
307
370
 
@@ -316,13 +379,13 @@ stamp context clean [path] # Remove generated files
316
379
  | **Vue 3** | Partial | Composition API (TS/TSX only, not .vue SFC) |
317
380
  | **Express.js** | Full | Routes, middleware, API signatures |
318
381
  | **NestJS** | Full | Controllers, decorators, API signatures |
319
- | **UI Libraries** | Full | Material UI, ShadCN, Radix, Tailwind, Styled Components, SCSS |
382
+ | **UI Libraries** | Full | Material UI, ShadCN, Radix, Tailwind, Styled Components, SCSS, Chakra UI, Ant Design (component usage, props, composition; not raw CSS) |
320
383
 
321
- > **ℹ️ Note:** LogicStamp analyzes `.ts` and `.tsx` files only. JavaScript files are not analyzed.
384
+ > **ℹ️ Note:** LogicStamp Context analyzes `.ts` and `.tsx` files only. JavaScript files are not analyzed.
322
385
 
323
386
  ## Documentation
324
387
 
325
- **[Full documentation at logicstamp.dev/docs](https://logicstamp.dev/docs)**
388
+ **Full documentation at [logicstamp.dev/docs](https://logicstamp.dev/docs)**
326
389
 
327
390
  - [Getting Started Guide](https://logicstamp.dev/docs/getting-started)
328
391
  - [Usage Guide](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/usage.md)
@@ -334,7 +397,7 @@ stamp context clean [path] # Remove generated files
334
397
 
335
398
  ## Known Limitations
336
399
 
337
- LogicStamp is in beta. Some edge cases are not fully supported.
400
+ LogicStamp Context is in beta. Some edge cases are not fully supported.
338
401
 
339
402
  📋 **See [docs/limitations.md](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/limitations.md)** for the full list.
340
403
 
@@ -350,7 +413,7 @@ LogicStamp is in beta. Some edge cases are not fully supported.
350
413
 
351
414
  ## License
352
415
 
353
- MIT
416
+ [MIT](LICENSE)
354
417
 
355
418
  ---
356
419
 
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Ant Design extractor - Extracts Ant Design component library usage
3
+ */
4
+ import { SourceFile } from 'ts-morph';
5
+ /**
6
+ * Extract Ant Design usage from a source file
7
+ */
8
+ export declare function extractAntDesign(source: SourceFile): {
9
+ components: string[];
10
+ packages: string[];
11
+ features: {
12
+ usesTheme?: boolean;
13
+ usesConfigProvider?: boolean;
14
+ usesForm?: boolean;
15
+ usesLocale?: boolean;
16
+ usesIcons?: boolean;
17
+ };
18
+ };
19
+ //# sourceMappingURL=antd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"antd.d.ts","sourceRoot":"","sources":["../../../src/extractors/styling/antd.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAA+D,MAAM,UAAU,CAAC;AAyBnG;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG;IACpD,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE;QACR,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,CAAC;CACH,CA4TA"}