logicstamp-context 0.2.2 → 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.2-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.2). 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,118 +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.2
48
+ ## Recent Updates
49
49
 
50
- 🔧 **Documentation Fixes**
51
- - **Fixed optional dependencies documentation** - Corrected all documentation to accurately reflect that `@dqbd/tiktoken` and `@anthropic-ai/tokenizer` are included as optional dependencies in package.json and are automatically installed by npm when installing `logicstamp-context`
52
- - **Updated user-facing messages** - Console output and source code comments now correctly explain optional dependency installation behavior
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
53
56
 
54
- ## What's New in v0.2.1
57
+ 📋 **See [CHANGELOG.md](CHANGELOG.md) for complete version history**
55
58
 
56
- 🔧 **Bug Fixes**
57
- - **Dynamic version loading** - Fixed hardcoded version string in generated context files to dynamically load from `package.json`, ensuring version consistency across all generated context files
59
+ ### Optional Tokenizers
58
60
 
59
- ### Changed
60
- - Updated all version references in documentation to reflect 0.2.1 release
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`.
61
62
 
62
- ## What's New in v0.2.0
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)
63
65
 
64
- 🎨 **Style Metadata Extraction**
65
- - **New `stamp context style` command** - Generate design-aware context bundles with visual and layout information
66
- - **`--include-style` flag** - Alternative syntax for enabling style metadata extraction
67
- - **Comprehensive style detection** - Identifies Tailwind CSS, SCSS/CSS modules, inline styles, styled-components, and framer-motion
68
- - **Layout pattern recognition** - Extracts flex/grid patterns, hero sections, feature cards, and responsive breakpoints
69
- - **Visual design metadata** - Captures color palettes, spacing patterns, border radius, and typography classes
70
- - **Animation detection** - Identifies framer-motion animations, CSS transitions, and viewport triggers
71
- - **SCSS/CSS module parsing** - Analyzes imported style files to extract selectors, properties, and SCSS features
72
-
73
- 📊 **Enhanced Token Comparison**
74
- - **Four-mode comparison** - `--compare-modes` now shows `none`, `header`, `header+style`, and `full` modes
75
- - **Dual comparison tables** - Shows savings vs raw source and vs full context for better decision-making
76
- - **Accurate style impact** - Automatically regenerates contracts with/without style metadata for precise token counts
77
- - **Optional tokenizer support** - Includes `@dqbd/tiktoken` (GPT-4) and `@anthropic-ai/tokenizer` (Claude) as optional dependencies. npm automatically attempts to install them when installing `logicstamp-context`. If installation succeeds, the tool uses them for accurate token counts. If installation fails or is skipped, gracefully falls back to character-based estimation
78
-
79
- 🏗️ **Architectural Improvements**
80
- - **Modular CLI structure** - Refactored into dedicated handlers for better maintainability and testability
81
- - **Extracted AST parsing** - Modularized AST extraction into focused detector and extractor modules
82
- - **Modularized style extraction** - Organized style extraction into dedicated modules (tailwind, scss, motion, layout, etc.)
83
- - **Improved code organization** - Better separation of concerns and easier contribution
84
-
85
- **Optional Tokenizers for Accurate Token Counts:**
86
-
87
- LogicStamp Context includes `@dqbd/tiktoken` and `@anthropic-ai/tokenizer` as optional dependencies. npm will automatically attempt to install them when you install `logicstamp-context`, but installation may be skipped if there are build issues (this is normal for optional dependencies).
88
-
89
- **If tokenizers are installed (automatic):**
90
- - Token counts will be model-accurate for GPT-4 and Claude
91
- - No additional setup required
92
-
93
- **If tokenizers are not installed (installation failed or skipped):**
94
- - LogicStamp Context automatically falls back to character-based estimation
95
- - Estimates are typically within 10–15% of real token counts
96
- - This is fine for most use cases
97
-
98
- **To manually install tokenizers (optional):**
99
-
100
- If the automatic installation failed and you want accurate token counts, you can install them manually:
101
-
102
- ```bash
103
- # For local installs
104
- npm install -D @dqbd/tiktoken @anthropic-ai/tokenizer
105
-
106
- # For global installs
107
- npm install -g @dqbd/tiktoken @anthropic-ai/tokenizer
108
- ```
109
-
110
- **Important:**
111
- - Tokenizers are installed as **optional dependencies** of `logicstamp-context` and will be installed automatically in most cases
112
- - If automatic installation fails, LogicStamp Context gracefully falls back to character-based estimation
113
- - You do **not** need to manually install tokenizers unless you specifically want accurate token counts and the automatic installation failed
114
-
115
- ## What's New in v0.1.1
116
-
117
- 🔧 **CI-Friendly Defaults**
118
- - **`stamp context` no longer prompts** - Interactive prompts moved to `stamp init` for better CI/CD compatibility
119
- - **Safe defaults** - `stamp context` now defaults to skipping both `.gitignore` and `LLM_CONTEXT.md` setup unless explicitly opted in via `stamp init`
120
- - **Auto-config creation** - On first run, creates `.logicstamp/config.json` with safe defaults (`'skipped'` for both preferences)
121
- - **New `--skip-gitignore` flag** - Allows skipping `.gitignore` setup on a per-run basis, useful for CI environments
122
-
123
- 🎯 **Improved Initialization**
124
- - **`stamp init` now prompts interactively** - Prompts for both `.gitignore` patterns and `LLM_CONTEXT.md` generation (only in interactive/TTY mode)
125
- - **Non-interactive defaults** - In CI/non-TTY environments, defaults to "yes" for both prompts
126
- - **Better user control** - Users can explicitly set preferences via `stamp init` before running `stamp context`
127
- - **Config-based behavior** - `stamp context` respects preferences saved in `.logicstamp/config.json` without prompting
128
-
129
- **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.
130
-
131
- ## What's New in v0.1.0
132
-
133
- 🎉 **Token Cost Optimization**
134
- - Automatic token estimates for GPT-4o-mini and Claude
135
- - Mode comparison showing savings (none/header/full)
136
- - `--compare-modes` flag for detailed token analysis
137
-
138
- 🔍 **Multi-File Context Drift Detection**
139
- - New `compare` command with multi-file support
140
- - Compares **all context files** using `context_main.json` as index
141
- - Detects ADDED folders, ORPHANED folders, per-folder DRIFT, and PASS status
142
- - Three-tier output: folder summary → component summary → detailed changes
143
- - `--clean-orphaned` flag to automatically remove stale context files
144
- - CI-friendly exit codes and per-folder token delta stats
145
-
146
- ⚛️ **Next.js App Router Support**
147
- - Detects `'use client'` and `'use server'` directives
148
- - Identifies files in Next.js App Router (`/app` directory)
149
- - Adds metadata to contracts for framework-aware analysis
150
-
151
- ✅ **Enhanced Component Detection**
152
- - Fixed React component detection for HTML-only JSX
153
- - Improved dependency resolution (relative paths prioritized)
154
- - Better handling of cross-directory component references
155
-
156
- 🛡️ **CI/CD Improvements**
157
- - `--strict-missing` flag for dependency validation
158
- - Enhanced `--stats` output with mode estimates
159
- - JSON output optimized for CI parsing
66
+ You do **not** need to manually install tokenizers unless automatic installation failed and you specifically need accurate counts.
160
67
 
161
68
  ## What does it generate?
162
69
 
@@ -215,89 +122,44 @@ LogicStamp Context automatically detects and annotates Next.js App Router compon
215
122
  ```bash
216
123
  stamp --version # Show version number
217
124
  stamp --help # Show help
218
- stamp init [path] [options]
219
- stamp context [path] [options]
220
- stamp context style [path] [options] # Generate context with style metadata
221
- stamp context compare <old.json> <new.json> [options]
222
- stamp context validate [file] [options]
223
- stamp context clean [path] [options]
224
- ```
225
-
226
- ### Commands
227
-
228
- - **`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.
229
-
230
- See [docs/cli/INIT.md](docs/cli/INIT.md) for detailed documentation.
231
-
232
- - **`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).
233
-
234
- See [docs/cli/CONTEXT.md](docs/cli/CONTEXT.md) for detailed documentation.
235
-
236
- - **`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.
237
-
238
- See [docs/cli/STYLE.md](docs/cli/STYLE.md) for detailed documentation.
239
-
240
- - **`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).
241
-
242
- See [docs/cli/COMPARE.md](docs/cli/COMPARE.md) for detailed documentation.
243
-
244
- - **`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.
245
-
246
- See [docs/cli/VALIDATE.md](docs/cli/VALIDATE.md) for detailed documentation.
247
-
248
- - **`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.
249
-
250
- See [docs/cli/CLEAN.md](docs/cli/CLEAN.md) for detailed documentation.
251
-
252
- ### Arguments & Options (`init` command)
253
-
254
- - `[path]` - Target directory to initialize (default: current directory)
255
- - `--skip-gitignore` - Skip `.gitignore` setup
256
- - `--help`, `-h` - Show help message
257
-
258
- See [docs/cli/INIT.md](docs/cli/INIT.md) for detailed documentation.
259
-
260
- ### Arguments (`context` command)
261
-
262
- - `[path]` - Directory to scan (default: current directory)
263
-
264
- ### Options (`context` command)
265
-
266
- | Option | Alias | Description | Default |
267
- |--------|-------|-------------|---------|
268
- | `--depth <n>` | `-d` | Dependency traversal depth | `1` |
269
- | `--include-code <mode>` | `-c` | Code inclusion: `none\|header\|full` | `header` |
270
- | `--format <format>` | `-f` | Output format: `json\|pretty\|ndjson` | `json` |
271
- | `--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) |
272
- | `--max-nodes <n>` | `-m` | Maximum nodes per bundle | `100` |
273
- | `--profile <profile>` | | Profile preset (see below) | `llm-chat` |
274
- | `--strict` | `-s` | Fail on missing dependencies | `false` |
275
- | `--strict-missing` | | Exit with error code 1 if any missing dependencies found (CI-friendly) | `false` |
276
- | `--predict-behavior` | | Include experimental behavior predictions in contracts | `false` |
277
- | `--dry-run` | | Skip writing output; show on-screen summary only | `false` |
278
- | `--stats` | | Emit single-line JSON stats with token estimates (intended for CI) | `false` |
279
- | `--compare-modes` | | Show detailed token comparison table across modes (none/header/full) | `false` |
280
- | `--include-style` | | Extract style metadata (Tailwind, SCSS, animations, layout) | `false` |
281
- | `--skip-gitignore` | | Skip `.gitignore` setup (never prompt or modify) | `false` |
282
- | `--quiet` | `-q` | Suppress verbose output (show only errors) | `false` |
283
- | `--help` | `-h` | Show help message | |
284
-
285
- ### Options (`compare` command)
286
-
287
- | Option | Description | Default |
288
- |--------|-------------|---------|
289
- | `--stats` | Show token count statistics and delta | `false` |
290
- | `--approve` | Auto-approve updates (non-interactive, CI-safe) | `false` |
291
- | `--clean-orphaned` | Auto-delete orphaned files with `--approve` | `false` |
292
- | `--quiet` | `-q` | Suppress verbose output (show only diffs) | `false` |
293
- | `--help`, `-h` | Show help message | |
294
-
295
- ### Options (`validate` command)
296
-
297
- - `[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.
298
- - `--quiet` | `-q` – Suppress verbose output (show only errors)
299
- - Exits with code `0` on success, `1` on invalid structure or read/parse errors.
300
- - 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**
301
163
 
302
164
  ### Profiles
303
165
 
@@ -614,198 +476,45 @@ stamp context validate context.json
614
476
 
615
477
  LogicStamp Context generates a **folder-organized, multi-file output structure** that maintains your project's directory hierarchy:
616
478
 
617
- ### File Structure
618
-
619
- The tool writes multiple `context.json` files, one per folder containing components, plus a `context_main.json` index file at the output root:
620
-
621
479
  ```
622
480
  output/
623
481
  ├── context_main.json # Main index with folder metadata
624
482
  ├── context.json # Root folder bundles (if any)
625
483
  ├── src/
626
484
  │ └── context.json # Bundles from src/ folder
627
- ├── src/components/
628
- └── context.json # Bundles from src/components/
629
- └── src/utils/
630
- └── context.json # Bundles from src/utils/
631
- ```
632
-
633
- ### Folder-Based Organization
634
-
635
- Each folder's `context.json` contains bundles for components in that folder. This organization:
636
- - **Matches your project structure** - Easy to locate context for specific directories
637
- - **Enables incremental updates** - Only regenerate context for changed folders
638
- - **Improves AI context loading** - Load only relevant folder contexts
639
- - **Maintains relative paths** - Folder structure mirrors your project layout
640
-
641
- ### Main Index File (`context_main.json`)
642
-
643
- The `context_main.json` file serves as a directory index with:
644
-
645
- ```json
646
- {
647
- "type": "LogicStampIndex",
648
- "schemaVersion": "0.1",
649
- "projectRoot": ".",
650
- "projectRootResolved": "/absolute/path/to/project",
651
- "createdAt": "2025-01-15T10:30:00.000Z",
652
- "summary": {
653
- "totalComponents": 42,
654
- "totalBundles": 15,
655
- "totalFolders": 5,
656
- "totalTokenEstimate": 13895
657
- },
658
- "folders": [
659
- {
660
- "path": "src/components",
661
- "contextFile": "src/components/context.json",
662
- "bundles": 3,
663
- "components": ["Button.tsx", "Card.tsx", "Modal.tsx"],
664
- "isRoot": false,
665
- "tokenEstimate": 5234
666
- },
667
- {
668
- "path": ".",
669
- "contextFile": "context.json",
670
- "bundles": 2,
671
- "components": ["App.tsx"],
672
- "isRoot": true,
673
- "rootLabel": "Project Root",
674
- "tokenEstimate": 2134
675
- }
676
- ],
677
- "meta": {
678
- "source": "logicstamp-context@0.1.0"
679
- }
680
- }
681
- ```
682
-
683
- **Key fields in folder entries:**
684
- - `path` - Relative path from project root
685
- - `contextFile` - Path to the folder's context.json file
686
- - `bundles` - Number of bundles in this folder
687
- - `components` - List of component files in this folder
688
- - `isRoot` - Whether this folder is an application entry point
689
- - `rootLabel` - Human-readable label for root folders (e.g., "Next.js App", "Project Root")
690
- - `tokenEstimate` - Estimated token count for this folder's context
691
-
692
- ### Bundle Structure
693
-
694
- 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.
695
-
696
- **📋 Full Schema Reference:** See [`schema/logicstamp.context.schema.json`](schema/logicstamp.context.schema.json) for the complete JSON Schema definition.
697
-
698
- **Example: `src/components/context.json`**
699
-
700
- ```json
701
- [
702
- {
703
- "$schema": "https://logicstamp.dev/schemas/context/v0.1.json",
704
- "position": "1/3",
705
- "type": "LogicStampBundle",
706
- "schemaVersion": "0.1",
707
- "entryId": "src/components/Button.tsx",
708
- "depth": 1,
709
- "createdAt": "2025-01-15T10:30:00.000Z",
710
- "bundleHash": "uifb:abc123...",
711
- "graph": {
712
- "nodes": [
713
- {
714
- "entryId": "src/components/Button.tsx",
715
- "contract": {
716
- "type": "UIFContract",
717
- "schemaVersion": "0.3",
718
- "kind": "react:component",
719
- "description": "Button - Interactive component",
720
- "version": {
721
- "variables": ["variant", "size"],
722
- "hooks": ["useState"],
723
- "components": [],
724
- "functions": ["handleClick"]
725
- },
726
- "logicSignature": {
727
- "props": {
728
- "onClick": { "type": "function", "signature": "() => void" },
729
- "variant": { "type": "literal-union", "literals": ["primary", "secondary"] }
730
- },
731
- "events": {},
732
- "state": {}
733
- },
734
- "nextjs": {
735
- "directive": "client",
736
- "isInAppDir": true
737
- }
738
- }
739
- }
740
- ],
741
- "edges": []
742
- },
743
- "meta": {
744
- "missing": [],
745
- "source": "logicstamp-context@0.1.0"
746
- }
747
- }
748
- ]
485
+ └── src/components/
486
+ └── context.json # Bundles from src/components/
749
487
  ```
750
488
 
751
- **📋 Full Schema Reference:** See [`schema/logicstamp.context.schema.json`](schema/logicstamp.context.schema.json) for the complete JSON Schema definition.
752
-
753
- ### Understanding the Meta Field
489
+ ### Structure Overview
754
490
 
755
- The `meta` section provides metadata about bundle generation and dependency resolution:
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
756
495
 
757
- #### `missing` Array
496
+ ### Key Fields
758
497
 
759
- Tracks dependencies that couldn't be resolved during analysis. An empty array `[]` means all dependencies were successfully found.
498
+ **`context_main.json` index:**
499
+ - `folders[]` - Array of folder metadata (path, bundles, components, token estimates)
500
+ - `summary` - Total components, bundles, folders, token estimates
760
501
 
761
- When dependencies are missing, each entry contains:
762
- - `name` - The import specifier that couldn't be resolved (e.g., `"./MissingComponent"`)
763
- - `reason` - Why it couldn't be found (e.g., `"file not found"`, `"external package"`)
764
- - `referencedBy` - The component that tried to import it
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
765
508
 
766
- **Example with missing dependencies:**
767
- ```json
768
- {
769
- "meta": {
770
- "missing": [
771
- {
772
- "name": "./components/DeletedComponent",
773
- "reason": "file not found",
774
- "referencedBy": "src/App.tsx"
775
- },
776
- {
777
- "name": "@external/ui-lib",
778
- "reason": "external package",
779
- "referencedBy": "src/components/Button.tsx"
780
- }
781
- ],
782
- "source": "logicstamp-context@0.1.0"
783
- }
784
- }
785
- ```
786
-
787
- **Common reasons for missing dependencies:**
788
- - `file not found` - Referenced file doesn't exist (deleted or moved)
509
+ **Missing dependencies:**
510
+ - `file not found` - Deleted or moved file
789
511
  - `external package` - Third-party npm package (intentionally excluded)
790
- - `outside scan path` - File exists but outside the specified scan directory
791
- - `circular dependency` - Circular import detected and skipped
792
- - `max depth exceeded` - Dependency beyond `--depth` limit
793
-
794
- **Using `--strict-missing` for CI/CD:**
795
- ```bash
796
- # Exit with error code 1 if ANY missing dependencies found
797
- stamp context --strict-missing
798
-
799
- # Perfect for CI validation
800
- stamp context --strict-missing || exit 1
801
- ```
802
-
803
- #### `source` Field
512
+ - `outside scan path` - File exists but outside scan directory
513
+ - `circular dependency` - Circular import detected
514
+ - `max depth exceeded` - Beyond `--depth` limit
804
515
 
805
- Identifies the generator and version (e.g., `"logicstamp-context@0.1.0"`). Useful for:
806
- - Debugging context generation issues
807
- - Ensuring compatibility with consuming tools
808
- - 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**
809
518
 
810
519
  ## Use Cases
811
520
 
@@ -947,47 +656,24 @@ All in one command, no pre-compilation needed!
947
656
 
948
657
  ## Future Roadmap
949
658
 
950
- ### Next.js Enhancements (Planned)
659
+ ### Planned Features
951
660
 
952
- The current Next.js support (v0.1) provides foundational directive and App Router detection. Future versions may include:
953
-
954
- **App Router Advanced Features**
955
- - `role` detection - Identify `page`, `layout`, `route`, `loading`, `error` files
956
- - `segmentPath` extraction - Capture dynamic route segments (e.g., `[id]`, `[...slug]`)
957
- - Route dependency graph - Map App Router file relationships
958
- - Metadata exports - Detect `generateMetadata`, `generateStaticParams`
959
-
960
- **Server Actions & RPC**
961
- - Server Action signature extraction from `'use server'` blocks
962
- - Form action detection and validation
963
- - RPC call graph (client → server action relationships)
964
-
965
- **Streaming & Suspense**
966
- - Suspense boundary detection
967
- - Streaming component identification
968
- - Loading states and error boundaries
969
-
970
- **Example Future Contract**
971
- ```json
972
- {
973
- "nextjs": {
974
- "directive": "client",
975
- "isInAppDir": true,
976
- "role": "page",
977
- "segmentPath": "dashboard/[userId]",
978
- "hasMetadata": true
979
- }
980
- }
981
- ```
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
982
666
 
983
- **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
984
670
 
985
- ### Other Planned Features
671
+ **Other:**
672
+ - Custom contract fields via config
673
+ - Performance metrics (bundle size, render estimates)
674
+ - Incremental bundle caching
986
675
 
987
- - **Vue.js Support** - Extend to Vue 3 Composition API components
988
- - **Svelte Support** - Component analysis for Svelte files
989
- - **Custom Contract Fields** - User-defined metadata via config
990
- - **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.
991
677
 
992
678
  ## Requirements
993
679
 
@@ -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"}