logicstamp-context 0.2.1 → 0.2.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/LLM_CONTEXT.md CHANGED
@@ -88,7 +88,7 @@ The `context_main.json` file serves as a directory index:
88
88
  }
89
89
  ],
90
90
  "meta": {
91
- "source": "logicstamp-context@0.1.0"
91
+ "source": "logicstamp-context@0.2.3"
92
92
  }
93
93
  }
94
94
  ```
@@ -111,7 +111,7 @@ Each folder's `context.json` contains an array of LogicStamp bundles. Each bundl
111
111
  - `graph.edges` lists dependency relationships between nodes (empty when analysis depth is 1).
112
112
  - `meta` section contains two critical fields:
113
113
  - `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.
114
- - `source`: Generator version string (e.g., `"logicstamp-context@0.1.0"`) for compatibility tracking.
114
+ - `source`: Generator version string (e.g., `"logicstamp-context@0.2.3"`) for compatibility tracking.
115
115
  - Example bundle skeleton:
116
116
 
117
117
  ```
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  <img src="assets/logicstamp-fox.svg" alt="LogicStamp Fox Mascot" width="120" height="120">
5
5
  </div>
6
6
 
7
- ![Version](https://img.shields.io/badge/version-0.2.1-blue.svg)
7
+ ![Version](https://img.shields.io/badge/version-0.2.3-blue.svg)
8
8
  ![Beta](https://img.shields.io/badge/status-beta-orange.svg)
9
9
  ![License](https://img.shields.io/badge/license-MIT-green.svg)
10
10
  ![Node](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)
@@ -25,7 +25,7 @@ That's it! LogicStamp Context will scan your project and generate `context.json`
25
25
  ![LogicStamp Context in action](assets/demo-screenshot.png)
26
26
  *Terminal output showing `stamp context` execution and generated context.json structure*
27
27
 
28
- > **Note:** This is a beta release (v0.2.1). We're actively improving the tool based on user feedback. If you encounter any issues or have suggestions, please [open an issue on GitHub](https://github.com/LogicStamp/logicstamp-context/issues).
28
+ > **Note:** This is a beta release (v0.2.3). We're actively improving the tool based on user feedback. If you encounter any issues or have suggestions, please [open an issue on GitHub](https://github.com/LogicStamp/logicstamp-context/issues).
29
29
 
30
30
  ## What is this?
31
31
 
@@ -45,160 +45,25 @@ After installation, the `stamp` command will be available globally.
45
45
  - **Local install**: `npm install logicstamp-context` → only available in that project
46
46
  - **Global install**: `npm install -g logicstamp-context` → available everywhere via `stamp` command
47
47
 
48
- ## What's New in v0.2.0
48
+ ## Recent Updates
49
49
 
50
- 🎨 **Style Metadata Extraction**
51
- - **New `stamp context style` command** - Generate design-aware context bundles with visual and layout information
52
- - **`--include-style` flag** - Alternative syntax for enabling style metadata extraction
53
- - **Comprehensive style detection** - Identifies Tailwind CSS, SCSS/CSS modules, inline styles, styled-components, and framer-motion
54
- - **Layout pattern recognition** - Extracts flex/grid patterns, hero sections, feature cards, and responsive breakpoints
55
- - **Visual design metadata** - Captures color palettes, spacing patterns, border radius, and typography classes
56
- - **Animation detection** - Identifies framer-motion animations, CSS transitions, and viewport triggers
57
- - **SCSS/CSS module parsing** - Analyzes imported style files to extract selectors, properties, and SCSS features
50
+ **v0.2.3** - README streamlined, improved token estimation accuracy, UIF Contracts documentation
51
+ **v0.2.2** - Documentation fixes for optional tokenizer dependencies
52
+ **v0.2.1** - Dynamic version loading from package.json
53
+ **v0.2.0** - Style metadata extraction, enhanced token comparison, modular architecture
54
+ **v0.1.1** - CI-friendly defaults, improved initialization workflow
55
+ **v0.1.0** - Initial release with token optimization, drift detection, and Next.js support
58
56
 
59
- 📊 **Enhanced Token Comparison**
60
- - **Four-mode comparison** - `--compare-modes` now shows `none`, `header`, `header+style`, and `full` modes
61
- - **Dual comparison tables** - Shows savings vs raw source and vs full context for better decision-making
62
- - **Accurate style impact** - Automatically regenerates contracts with/without style metadata for precise token counts
63
- - **Optional tokenizer support** - Automatically uses `@dqbd/tiktoken` (GPT-4) and `@anthropic-ai/tokenizer` (Claude) if installed for accurate token counts, with graceful fallback to character-based estimation
57
+ 📋 **See [CHANGELOG.md](CHANGELOG.md) for complete version history**
64
58
 
65
- 🏗️ **Architectural Improvements**
66
- - **Modular CLI structure** - Refactored into dedicated handlers for better maintainability and testability
67
- - **Extracted AST parsing** - Modularized AST extraction into focused detector and extractor modules
68
- - **Modularized style extraction** - Organized style extraction into dedicated modules (tailwind, scss, motion, layout, etc.)
69
- - **Improved code organization** - Better separation of concerns and easier contribution
59
+ ### Optional Tokenizers
70
60
 
71
- **Installation for Accurate Token Counts:**
61
+ LogicStamp Context includes `@dqbd/tiktoken` (GPT-4) and `@anthropic-ai/tokenizer` (Claude) as **optional dependencies**. npm automatically attempts to install them when you install `logicstamp-context`.
72
62
 
73
- By default, LogicStamp Context uses a fast character-based heuristic (usually within 10–15% of real token counts). For model-accurate counts, you can optionally install tokenizer libraries in the same environment where you use `stamp`.
63
+ - **If installed**: Token counts are model-accurate for GPT-4 and Claude
64
+ - **If not installed**: Falls back to character-based estimation (typically within 10–15% accuracy)
74
65
 
75
- **If you use LogicStamp Context in a project (recommended):**
76
-
77
- ```bash
78
- # Install LogicStamp Context as a dev dependency
79
- npm install -D logicstamp-context
80
-
81
- # Install tokenizers in your project root
82
- npm install @dqbd/tiktoken @anthropic-ai/tokenizer
83
-
84
- # Run with npx
85
- npx stamp context
86
- ```
87
-
88
- **If you installed LogicStamp Context globally:**
89
-
90
- ```bash
91
- # Install LogicStamp Context globally
92
- npm install -g logicstamp-context
93
-
94
- # Install tokenizers globally (same environment)
95
- npm install -g @dqbd/tiktoken @anthropic-ai/tokenizer
96
-
97
- # Run from anywhere
98
- stamp context
99
- ```
100
-
101
- **Important:**
102
- - Install tokenizers in your **project root** (for local installs) or **globally** (for global installs), alongside where you installed `logicstamp-context`
103
- - You do **not** need to (and should **not**) install anything manually inside the `logicstamp-context` package folder under `node_modules`
104
- - LogicStamp Context will automatically detect and use the tokenizers if available, or gracefully fall back to character-based estimation if not
105
-
106
- ## What's New in v0.1.1
107
-
108
- 🔧 **CI-Friendly Defaults**
109
- - **`stamp context` no longer prompts** - Interactive prompts moved to `stamp init` for better CI/CD compatibility
110
- - **Safe defaults** - `stamp context` now defaults to skipping both `.gitignore` and `LLM_CONTEXT.md` setup unless explicitly opted in via `stamp init`
111
- - **Auto-config creation** - On first run, creates `.logicstamp/config.json` with safe defaults (`'skipped'` for both preferences)
112
- - **New `--skip-gitignore` flag** - Allows skipping `.gitignore` setup on a per-run basis, useful for CI environments
113
-
114
- 🎯 **Improved Initialization**
115
- - **`stamp init` now prompts interactively** - Prompts for both `.gitignore` patterns and `LLM_CONTEXT.md` generation (only in interactive/TTY mode)
116
- - **Non-interactive defaults** - In CI/non-TTY environments, defaults to "yes" for both prompts
117
- - **Better user control** - Users can explicitly set preferences via `stamp init` before running `stamp context`
118
- - **Config-based behavior** - `stamp context` respects preferences saved in `.logicstamp/config.json` without prompting
119
-
120
- **Migration Note:** If you were using `stamp context` interactively before, run `stamp init` once to set your preferences. Subsequent `stamp context` runs will respect your saved choices automatically.
121
-
122
- ## What's New in v0.1.0
123
-
124
- 🎉 **Token Cost Optimization**
125
- - Automatic token estimates for GPT-4o-mini and Claude
126
- - Mode comparison showing savings (none/header/full)
127
- - `--compare-modes` flag for detailed token analysis
128
-
129
- 🔍 **Multi-File Context Drift Detection**
130
- - New `compare` command with multi-file support
131
- - Compares **all context files** using `context_main.json` as index
132
- - Detects ADDED folders, ORPHANED folders, per-folder DRIFT, and PASS status
133
- - Three-tier output: folder summary → component summary → detailed changes
134
- - `--clean-orphaned` flag to automatically remove stale context files
135
- - CI-friendly exit codes and per-folder token delta stats
136
-
137
- ⚛️ **Next.js App Router Support**
138
- - Detects `'use client'` and `'use server'` directives
139
- - Identifies files in Next.js App Router (`/app` directory)
140
- - Adds metadata to contracts for framework-aware analysis
141
-
142
- ✅ **Enhanced Component Detection**
143
- - Fixed React component detection for HTML-only JSX
144
- - Improved dependency resolution (relative paths prioritized)
145
- - Better handling of cross-directory component references
146
-
147
- 🛡️ **CI/CD Improvements**
148
- - `--strict-missing` flag for dependency validation
149
- - Enhanced `--stats` output with mode estimates
150
- - JSON output optimized for CI parsing
151
-
152
- ## Quick Start
153
-
154
- ```bash
155
- # Install globally
156
- npm i -g logicstamp-context
157
-
158
- # Optional: Initialize project (set up .gitignore and LLM_CONTEXT.md)
159
- stamp init
160
-
161
- # Generate context.json (llm-chat profile)
162
- stamp context
163
-
164
- # Generate context with style metadata (Tailwind, SCSS, animations, layout)
165
- stamp context style
166
-
167
- # Or use the flag (equivalent)
168
- stamp context --include-style
169
-
170
- # Preview stats without writing files
171
- stamp context --dry-run --stats
172
-
173
- # Compare token costs across modes
174
- stamp context --compare-modes
175
-
176
- # Generate minimal API documentation
177
- stamp context --include-code none --format pretty --out docs/api.json
178
-
179
- # Compare all context files for drift (multi-file mode)
180
- stamp context compare
181
-
182
- # Auto-approve and update all drifted files (like jest -u)
183
- stamp context compare --approve
184
-
185
- # Compare with per-folder token stats
186
- stamp context compare --stats
187
-
188
- # Compare two specific context files
189
- stamp context compare old.json new.json --stats
190
-
191
- # Validate generated context
192
- stamp context validate context.json
193
-
194
- # Clean all context artifacts (dry run)
195
- stamp context clean
196
-
197
- # Actually delete all context files
198
- stamp context clean --all --yes
199
- ```
200
-
201
- **Why?** Generate AI-ready context from your React/TS codebase in seconds with built-in token cost optimization.
66
+ You do **not** need to manually install tokenizers unless automatic installation failed and you specifically need accurate counts.
202
67
 
203
68
  ## What does it generate?
204
69
 
@@ -257,89 +122,44 @@ LogicStamp Context automatically detects and annotates Next.js App Router compon
257
122
  ```bash
258
123
  stamp --version # Show version number
259
124
  stamp --help # Show help
260
- stamp init [path] [options]
261
- stamp context [path] [options]
262
- stamp context style [path] [options] # Generate context with style metadata
263
- stamp context compare <old.json> <new.json> [options]
264
- stamp context validate [file] [options]
265
- stamp context clean [path] [options]
266
- ```
267
-
268
- ### Commands
269
-
270
- - **`stamp init [path]`** - Initialize LogicStamp in a project by creating or updating `.gitignore` with patterns for context files (`context.json`, `context_*.json`, `.logicstamp/`, etc.), generating `LLM_CONTEXT.md` in the project root, and saving preferences to `.logicstamp/config.json`. Prompts interactively (in TTY mode) for both `.gitignore` setup and `LLM_CONTEXT.md` generation. In CI/non-TTY environments, defaults to "yes" for both. Use this command to set your preferences before running `stamp context` - subsequent `stamp context` runs will respect your saved choices automatically.
271
-
272
- See [docs/cli/INIT.md](docs/cli/INIT.md) for detailed documentation.
273
-
274
- - **`stamp context [path]`** - Scans a directory and writes AI-ready context files organized by folder. Generates multiple `context.json` files (one per folder containing components) plus a `context_main.json` index file at the output root. Shows token estimates and mode comparison in output. Automatically validates the generated context before writing. **CI-friendly**: No interactive prompts - respects preferences saved in `.logicstamp/config.json` (created by `stamp init`). On first run without config, creates `.logicstamp/config.json` with safe defaults (skips both `.gitignore` and `LLM_CONTEXT.md` setup).
275
-
276
- See [docs/cli/CONTEXT.md](docs/cli/CONTEXT.md) for detailed documentation.
277
-
278
- - **`stamp context style [path]`** - Generates context with style metadata included. Equivalent to `stamp context --include-style`. Extracts visual and layout information from components including Tailwind classes, SCSS/CSS modules, styled-components, framer-motion animations, layout patterns (flex/grid), color palettes, spacing, typography, and animation configurations. This makes context bundles design-aware, enabling AI assistants to understand both the logic and visual presentation of your components.
279
-
280
- See [docs/cli/STYLE.md](docs/cli/STYLE.md) for detailed documentation.
281
-
282
- - **`stamp context compare [options]`** - Compares all context files (multi-file mode) or two specific files to detect drift. In multi-file mode, uses `context_main.json` as index to compare all folder context files and detect ADDED/ORPHANED folders, per-folder DRIFT, and unchanged files (PASS). Shows three-tier output: folder summary, component summary, and detailed changes. Supports `--approve` for auto-updates (Jest-style), `--clean-orphaned` to remove stale files, and `--stats` for per-folder token deltas. Exits with code 1 if drift is detected (CI-friendly).
283
-
284
- See [docs/cli/COMPARE.md](docs/cli/COMPARE.md) for detailed documentation.
285
-
286
- - **`stamp context validate [file]`** - Checks an existing context file for schema and structural issues before sharing it with an AI or committing it to a repo. When no file is specified it looks for `context.json` in the current directory.
287
-
288
- See [docs/cli/VALIDATE.md](docs/cli/VALIDATE.md) for detailed documentation.
289
-
290
- - **`stamp context clean [path]`** - Removes all generated context artifacts (`context_main.json`, all folder `context.json` files, and `.logicstamp/` directory if present). Safe by default (dry run), requires `--all --yes` to actually delete. Useful for resetting context files or cleaning before switching branches.
291
-
292
- See [docs/cli/CLEAN.md](docs/cli/CLEAN.md) for detailed documentation.
293
-
294
- ### Arguments & Options (`init` command)
295
-
296
- - `[path]` - Target directory to initialize (default: current directory)
297
- - `--skip-gitignore` - Skip `.gitignore` setup
298
- - `--help`, `-h` - Show help message
299
-
300
- See [docs/cli/INIT.md](docs/cli/INIT.md) for detailed documentation.
301
-
302
- ### Arguments (`context` command)
303
-
304
- - `[path]` - Directory to scan (default: current directory)
305
-
306
- ### Options (`context` command)
307
-
308
- | Option | Alias | Description | Default |
309
- |--------|-------|-------------|---------|
310
- | `--depth <n>` | `-d` | Dependency traversal depth | `1` |
311
- | `--include-code <mode>` | `-c` | Code inclusion: `none\|header\|full` | `header` |
312
- | `--format <format>` | `-f` | Output format: `json\|pretty\|ndjson` | `json` |
313
- | `--out <file>` | `-o` | Output directory or file path. If a `.json` file is specified, its directory is used as the output directory. Otherwise, the path is used as the output directory. | `context.json` (creates output directory) |
314
- | `--max-nodes <n>` | `-m` | Maximum nodes per bundle | `100` |
315
- | `--profile <profile>` | | Profile preset (see below) | `llm-chat` |
316
- | `--strict` | `-s` | Fail on missing dependencies | `false` |
317
- | `--strict-missing` | | Exit with error code 1 if any missing dependencies found (CI-friendly) | `false` |
318
- | `--predict-behavior` | | Include experimental behavior predictions in contracts | `false` |
319
- | `--dry-run` | | Skip writing output; show on-screen summary only | `false` |
320
- | `--stats` | | Emit single-line JSON stats with token estimates (intended for CI) | `false` |
321
- | `--compare-modes` | | Show detailed token comparison table across modes (none/header/full) | `false` |
322
- | `--include-style` | | Extract style metadata (Tailwind, SCSS, animations, layout) | `false` |
323
- | `--skip-gitignore` | | Skip `.gitignore` setup (never prompt or modify) | `false` |
324
- | `--quiet` | `-q` | Suppress verbose output (show only errors) | `false` |
325
- | `--help` | `-h` | Show help message | |
326
-
327
- ### Options (`compare` command)
328
-
329
- | Option | Description | Default |
330
- |--------|-------------|---------|
331
- | `--stats` | Show token count statistics and delta | `false` |
332
- | `--approve` | Auto-approve updates (non-interactive, CI-safe) | `false` |
333
- | `--clean-orphaned` | Auto-delete orphaned files with `--approve` | `false` |
334
- | `--quiet` | `-q` | Suppress verbose output (show only diffs) | `false` |
335
- | `--help`, `-h` | Show help message | |
336
-
337
- ### Options (`validate` command)
338
-
339
- - `[file]` – Optional path to a generated `context.json` file to validate. Defaults to `./context.json`. You can validate individual folder context files or the main index file.
340
- - `--quiet` | `-q` – Suppress verbose output (show only errors)
341
- - Exits with code `0` on success, `1` on invalid structure or read/parse errors.
342
- - Prints bundle counts, node totals, and highlights schema mismatches.
125
+ stamp init [path] [options] # Initialize project preferences
126
+ stamp context [path] [options] # Generate context bundles
127
+ stamp context style [path] [options] # Generate with style metadata
128
+ stamp context compare [options] # Detect context drift
129
+ stamp context validate [file] # Validate context files
130
+ stamp context clean [path] [options] # Remove generated files
131
+ ```
132
+
133
+ ### Quick Command Reference
134
+
135
+ | Command | Description | Docs |
136
+ |---------|-------------|------|
137
+ | `stamp init` | Initialize project (`.gitignore`, `LLM_CONTEXT.md`, config) | [INIT.md](docs/cli/INIT.md) |
138
+ | `stamp context` | Generate AI-ready context bundles organized by folder | [CONTEXT.md](docs/cli/CONTEXT.md) |
139
+ | `stamp context style` | Generate context with style metadata (Tailwind, SCSS, etc.) | [STYLE.md](docs/cli/STYLE.md) |
140
+ | `stamp context compare` | Compare context files to detect changes (CI-friendly) | [COMPARE.md](docs/cli/COMPARE.md) |
141
+ | `stamp context validate` | Validate context file schema and structure | [VALIDATE.md](docs/cli/VALIDATE.md) |
142
+ | `stamp context clean` | Remove all generated context artifacts | [CLEAN.md](docs/cli/CLEAN.md) |
143
+
144
+ ### Common Options
145
+
146
+ **`stamp context` options:**
147
+ - `--depth <n>` / `-d` - Dependency traversal depth (default: `1`)
148
+ - `--include-code <mode>` / `-c` - Code inclusion: `none|header|full` (default: `header`)
149
+ - `--include-style` - Extract style metadata (Tailwind, SCSS, animations, layout)
150
+ - `--profile <profile>` - Preset: `llm-chat` (default), `llm-safe`, `ci-strict`
151
+ - `--compare-modes` - Show detailed token comparison across all modes
152
+ - `--stats` - Emit JSON stats with token estimates (CI-friendly)
153
+ - `--strict-missing` - Exit with error if missing dependencies found
154
+ - `--out <path>` / `-o` - Output directory or file path
155
+ - `--quiet` / `-q` - Suppress verbose output
156
+
157
+ **Other commands:**
158
+ - `stamp context compare` - `--stats`, `--approve`, `--clean-orphaned`
159
+ - `stamp context validate` - Validates schema and structure (exits 0/1)
160
+ - `stamp init` - `--skip-gitignore`
161
+
162
+ 📋 **See [docs/cli/COMMANDS.md](docs/cli/COMMANDS.md) for complete option reference**
343
163
 
344
164
  ### Profiles
345
165
 
@@ -451,17 +271,7 @@ Output:
451
271
 
452
272
  **Note:** The `--compare-modes` flag automatically regenerates contracts with and without style metadata to provide accurate token counts for all modes. This ensures you see the true impact of including style information.
453
273
 
454
- **Optional tokenizers for accurate counts:** Token estimation uses character-based approximations by default. For more accurate token counts, you can optionally install these libraries:
455
-
456
- - `@dqbd/tiktoken` for GPT-4 token counts
457
- - `@anthropic-ai/tokenizer` for Claude token counts
458
-
459
- **Installation location:**
460
- - **Local install** (recommended): Install tokenizers in your project root when using `npm install -D logicstamp-context`
461
- - **Global install**: Install tokenizers globally when using `npm install -g logicstamp-context`
462
- - **Do not** install tokenizers inside the `logicstamp-context` package folder
463
-
464
- LogicStamp Context will automatically detect and use tokenizers if available, or fall back to character-based estimation (typically within 10-15% accuracy) if not installed.
274
+ **Optional tokenizers for accurate counts:** LogicStamp Context includes `@dqbd/tiktoken` (GPT-4) and `@anthropic-ai/tokenizer` (Claude) as optional dependencies. npm will automatically attempt to install them when you install `logicstamp-context`. If installation succeeds, you get model-accurate token counts. If installation fails or is skipped (normal for optional dependencies), LogicStamp Context gracefully falls back to character-based estimation (typically within 10-15% accuracy). No manual installation is required unless you specifically want accurate counts and the automatic installation failed.
465
275
 
466
276
  ### Stats for CI/CD
467
277
 
@@ -666,198 +476,45 @@ stamp context validate context.json
666
476
 
667
477
  LogicStamp Context generates a **folder-organized, multi-file output structure** that maintains your project's directory hierarchy:
668
478
 
669
- ### File Structure
670
-
671
- The tool writes multiple `context.json` files, one per folder containing components, plus a `context_main.json` index file at the output root:
672
-
673
479
  ```
674
480
  output/
675
481
  ├── context_main.json # Main index with folder metadata
676
482
  ├── context.json # Root folder bundles (if any)
677
483
  ├── src/
678
484
  │ └── context.json # Bundles from src/ folder
679
- ├── src/components/
680
- └── context.json # Bundles from src/components/
681
- └── src/utils/
682
- └── context.json # Bundles from src/utils/
683
- ```
684
-
685
- ### Folder-Based Organization
686
-
687
- Each folder's `context.json` contains bundles for components in that folder. This organization:
688
- - **Matches your project structure** - Easy to locate context for specific directories
689
- - **Enables incremental updates** - Only regenerate context for changed folders
690
- - **Improves AI context loading** - Load only relevant folder contexts
691
- - **Maintains relative paths** - Folder structure mirrors your project layout
692
-
693
- ### Main Index File (`context_main.json`)
694
-
695
- The `context_main.json` file serves as a directory index with:
696
-
697
- ```json
698
- {
699
- "type": "LogicStampIndex",
700
- "schemaVersion": "0.1",
701
- "projectRoot": ".",
702
- "projectRootResolved": "/absolute/path/to/project",
703
- "createdAt": "2025-01-15T10:30:00.000Z",
704
- "summary": {
705
- "totalComponents": 42,
706
- "totalBundles": 15,
707
- "totalFolders": 5,
708
- "totalTokenEstimate": 13895
709
- },
710
- "folders": [
711
- {
712
- "path": "src/components",
713
- "contextFile": "src/components/context.json",
714
- "bundles": 3,
715
- "components": ["Button.tsx", "Card.tsx", "Modal.tsx"],
716
- "isRoot": false,
717
- "tokenEstimate": 5234
718
- },
719
- {
720
- "path": ".",
721
- "contextFile": "context.json",
722
- "bundles": 2,
723
- "components": ["App.tsx"],
724
- "isRoot": true,
725
- "rootLabel": "Project Root",
726
- "tokenEstimate": 2134
727
- }
728
- ],
729
- "meta": {
730
- "source": "logicstamp-context@0.1.0"
731
- }
732
- }
733
- ```
734
-
735
- **Key fields in folder entries:**
736
- - `path` - Relative path from project root
737
- - `contextFile` - Path to the folder's context.json file
738
- - `bundles` - Number of bundles in this folder
739
- - `components` - List of component files in this folder
740
- - `isRoot` - Whether this folder is an application entry point
741
- - `rootLabel` - Human-readable label for root folders (e.g., "Next.js App", "Project Root")
742
- - `tokenEstimate` - Estimated token count for this folder's context
743
-
744
- ### Bundle Structure
745
-
746
- Each folder's `context.json` contains an array of bundles (one bundle per entry point). Each bundle represents a root component plus its complete dependency graph, with all related components and their contracts included within that bundle. This per-root bundle design is optimized for how developers and LLMs work—when you need help with a specific page or feature, the root bundle contains everything related to that feature in one self-contained unit.
747
-
748
- **📋 Full Schema Reference:** See [`schema/logicstamp.context.schema.json`](schema/logicstamp.context.schema.json) for the complete JSON Schema definition.
749
-
750
- **Example: `src/components/context.json`**
751
-
752
- ```json
753
- [
754
- {
755
- "$schema": "https://logicstamp.dev/schemas/context/v0.1.json",
756
- "position": "1/3",
757
- "type": "LogicStampBundle",
758
- "schemaVersion": "0.1",
759
- "entryId": "src/components/Button.tsx",
760
- "depth": 1,
761
- "createdAt": "2025-01-15T10:30:00.000Z",
762
- "bundleHash": "uifb:abc123...",
763
- "graph": {
764
- "nodes": [
765
- {
766
- "entryId": "src/components/Button.tsx",
767
- "contract": {
768
- "type": "UIFContract",
769
- "schemaVersion": "0.3",
770
- "kind": "react:component",
771
- "description": "Button - Interactive component",
772
- "version": {
773
- "variables": ["variant", "size"],
774
- "hooks": ["useState"],
775
- "components": [],
776
- "functions": ["handleClick"]
777
- },
778
- "logicSignature": {
779
- "props": {
780
- "onClick": { "type": "function", "signature": "() => void" },
781
- "variant": { "type": "literal-union", "literals": ["primary", "secondary"] }
782
- },
783
- "events": {},
784
- "state": {}
785
- },
786
- "nextjs": {
787
- "directive": "client",
788
- "isInAppDir": true
789
- }
790
- }
791
- }
792
- ],
793
- "edges": []
794
- },
795
- "meta": {
796
- "missing": [],
797
- "source": "logicstamp-context@0.1.0"
798
- }
799
- }
800
- ]
485
+ └── src/components/
486
+ └── context.json # Bundles from src/components/
801
487
  ```
802
488
 
803
- **📋 Full Schema Reference:** See [`schema/logicstamp.context.schema.json`](schema/logicstamp.context.schema.json) for the complete JSON Schema definition.
489
+ ### Structure Overview
804
490
 
805
- ### Understanding the Meta Field
491
+ - **Folder-based organization** - Each folder containing components gets its own `context.json`
492
+ - **Main index** - `context_main.json` indexes all folders with metadata (components, bundles, token estimates)
493
+ - **Per-root bundles** - Each bundle contains a root component plus its complete dependency graph
494
+ - **Self-contained units** - Each bundle includes all related components and contracts for that feature/page
806
495
 
807
- The `meta` section provides metadata about bundle generation and dependency resolution:
496
+ ### Key Fields
808
497
 
809
- #### `missing` Array
498
+ **`context_main.json` index:**
499
+ - `folders[]` - Array of folder metadata (path, bundles, components, token estimates)
500
+ - `summary` - Total components, bundles, folders, token estimates
810
501
 
811
- Tracks dependencies that couldn't be resolved during analysis. An empty array `[]` means all dependencies were successfully found.
502
+ **Bundle structure (`context.json`):**
503
+ - `entryId` - Root component file path
504
+ - `graph.nodes[]` - Component contracts with structure, props, hooks, state
505
+ - `graph.edges[]` - Dependency relationships
506
+ - `meta.missing[]` - Unresolved dependencies (if any)
507
+ - `meta.source` - Generator version
812
508
 
813
- When dependencies are missing, each entry contains:
814
- - `name` - The import specifier that couldn't be resolved (e.g., `"./MissingComponent"`)
815
- - `reason` - Why it couldn't be found (e.g., `"file not found"`, `"external package"`)
816
- - `referencedBy` - The component that tried to import it
817
-
818
- **Example with missing dependencies:**
819
- ```json
820
- {
821
- "meta": {
822
- "missing": [
823
- {
824
- "name": "./components/DeletedComponent",
825
- "reason": "file not found",
826
- "referencedBy": "src/App.tsx"
827
- },
828
- {
829
- "name": "@external/ui-lib",
830
- "reason": "external package",
831
- "referencedBy": "src/components/Button.tsx"
832
- }
833
- ],
834
- "source": "logicstamp-context@0.1.0"
835
- }
836
- }
837
- ```
838
-
839
- **Common reasons for missing dependencies:**
840
- - `file not found` - Referenced file doesn't exist (deleted or moved)
509
+ **Missing dependencies:**
510
+ - `file not found` - Deleted or moved file
841
511
  - `external package` - Third-party npm package (intentionally excluded)
842
- - `outside scan path` - File exists but outside the specified scan directory
843
- - `circular dependency` - Circular import detected and skipped
844
- - `max depth exceeded` - Dependency beyond `--depth` limit
512
+ - `outside scan path` - File exists but outside scan directory
513
+ - `circular dependency` - Circular import detected
514
+ - `max depth exceeded` - Beyond `--depth` limit
845
515
 
846
- **Using `--strict-missing` for CI/CD:**
847
- ```bash
848
- # Exit with error code 1 if ANY missing dependencies found
849
- stamp context --strict-missing
850
-
851
- # Perfect for CI validation
852
- stamp context --strict-missing || exit 1
853
- ```
854
-
855
- #### `source` Field
856
-
857
- Identifies the generator and version (e.g., `"logicstamp-context@0.1.0"`). Useful for:
858
- - Debugging context generation issues
859
- - Ensuring compatibility with consuming tools
860
- - Tracking which version generated historical contexts
516
+ 📋 **See [`schema/logicstamp.context.schema.json`](schema/logicstamp.context.schema.json) for complete JSON Schema**
517
+ 📋 **See [`docs/SCHEMA.md`](docs/SCHEMA.md) for detailed field documentation**
861
518
 
862
519
  ## Use Cases
863
520
 
@@ -999,47 +656,24 @@ All in one command, no pre-compilation needed!
999
656
 
1000
657
  ## Future Roadmap
1001
658
 
1002
- ### Next.js Enhancements (Planned)
1003
-
1004
- The current Next.js support (v0.1) provides foundational directive and App Router detection. Future versions may include:
1005
-
1006
- **App Router Advanced Features**
1007
- - `role` detection - Identify `page`, `layout`, `route`, `loading`, `error` files
1008
- - `segmentPath` extraction - Capture dynamic route segments (e.g., `[id]`, `[...slug]`)
1009
- - Route dependency graph - Map App Router file relationships
1010
- - Metadata exports - Detect `generateMetadata`, `generateStaticParams`
659
+ ### Planned Features
1011
660
 
1012
- **Server Actions & RPC**
1013
- - Server Action signature extraction from `'use server'` blocks
1014
- - Form action detection and validation
1015
- - RPC call graph (client server action relationships)
1016
-
1017
- **Streaming & Suspense**
1018
- - Suspense boundary detection
1019
- - Streaming component identification
1020
- - Loading states and error boundaries
1021
-
1022
- **Example Future Contract**
1023
- ```json
1024
- {
1025
- "nextjs": {
1026
- "directive": "client",
1027
- "isInAppDir": true,
1028
- "role": "page",
1029
- "segmentPath": "dashboard/[userId]",
1030
- "hasMetadata": true
1031
- }
1032
- }
1033
- ```
661
+ **Next.js Enhancements:**
662
+ - App Router role detection (`page`, `layout`, `route`, `loading`, `error`)
663
+ - Dynamic route segment extraction (`[id]`, `[...slug]`)
664
+ - Server Action signature extraction and RPC call graphs
665
+ - Suspense boundary and streaming component detection
1034
666
 
1035
- **Note:** These features will be added incrementally based on community feedback and real-world usage patterns. The current implementation prioritizes the 80/20 rule - maximum value with minimal complexity.
667
+ **Framework Support:**
668
+ - Vue.js 3 Composition API components
669
+ - Svelte component analysis
1036
670
 
1037
- ### Other Planned Features
671
+ **Other:**
672
+ - Custom contract fields via config
673
+ - Performance metrics (bundle size, render estimates)
674
+ - Incremental bundle caching
1038
675
 
1039
- - **Vue.js Support** - Extend to Vue 3 Composition API components
1040
- - **Svelte Support** - Component analysis for Svelte files
1041
- - **Custom Contract Fields** - User-defined metadata via config
1042
- - **Performance Metrics** - Bundle size and render performance estimates
676
+ **Note:** Features are added incrementally based on community feedback. Current implementation prioritizes maximum value with minimal complexity.
1043
677
 
1044
678
  ## Requirements
1045
679
 
@@ -1064,5 +698,3 @@ Issues and PRs welcome! This is an open-source project.
1064
698
 
1065
699
  - [LogicStamp Main Project](https://github.com/LogicStamp/logicstamp)
1066
700
  - [Report Issues](https://github.com/LogicStamp/logicstamp-context/issues)
1067
-
1068
- #TEST: CI Workflow
@@ -1 +1 @@
1
- {"version":3,"file":"statsCalculator.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/context/statsCalculator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,WAAW,CAUvE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,WAAW,EAAE,EACxB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,gBAAgB,EAAE,EAC3B,KAAK,EAAE,WAAW,EAClB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,MAAM,GACd,MAAM,CAoBR;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,WAAW,EAAE,EACxB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,gBAAgB,EAAE,EAC3B,KAAK,EAAE,WAAW,EAClB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE;IACP,WAAW,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;IACxC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;QACrC,QAAQ,EAAE,OAAO,CAAC;QAClB,MAAM,EAAE,OAAO,CAAC;QAChB,YAAY,EAAE,OAAO,CAAC;QACtB,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;IACF,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GACA,OAAO,CAAC,IAAI,CAAC,CA4Gf"}
1
+ {"version":3,"file":"statsCalculator.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/context/statsCalculator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,WAAW,CAUvE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,WAAW,EAAE,EACxB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,gBAAgB,EAAE,EAC3B,KAAK,EAAE,WAAW,EAClB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,MAAM,GACd,MAAM,CAoBR;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,WAAW,EAAE,EACxB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,gBAAgB,EAAE,EAC3B,KAAK,EAAE,WAAW,EAClB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE;IACP,WAAW,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;IACxC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;QACrC,QAAQ,EAAE,OAAO,CAAC;QAClB,MAAM,EAAE,OAAO,CAAC;QAChB,YAAY,EAAE,OAAO,CAAC;QACtB,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;IACF,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GACA,OAAO,CAAC,IAAI,CAAC,CAgIf"}