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 +2 -2
- package/README.md +91 -405
- package/dist/cli/commands/context/statsCalculator.d.ts.map +1 -1
- package/dist/cli/commands/context/statsCalculator.js +29 -10
- package/dist/cli/commands/context/statsCalculator.js.map +1 -1
- package/dist/cli/commands/context/tokenEstimator.d.ts +1 -1
- package/dist/cli/commands/context/tokenEstimator.d.ts.map +1 -1
- package/dist/cli/commands/context/tokenEstimator.js +38 -5
- package/dist/cli/commands/context/tokenEstimator.js.map +1 -1
- package/dist/cli/commands/context.js +1 -1
- package/dist/cli/commands/context.js.map +1 -1
- package/dist/cli/parser/helpText.js +348 -348
- package/package.json +1 -1
- package/schema/logicstamp.context.schema.json +1 -1
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.
|
|
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.
|
|
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
|
-

|
|
8
8
|

|
|
9
9
|

|
|
10
10
|

|
|
@@ -25,7 +25,7 @@ That's it! LogicStamp Context will scan your project and generate `context.json`
|
|
|
25
25
|

|
|
26
26
|
*Terminal output showing `stamp context` execution and generated context.json structure*
|
|
27
27
|
|
|
28
|
-
> **Note:** This is a beta release (v0.2.
|
|
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
|
-
##
|
|
48
|
+
## Recent Updates
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
57
|
+
📋 **See [CHANGELOG.md](CHANGELOG.md) for complete version history**
|
|
55
58
|
|
|
56
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
221
|
-
stamp context compare
|
|
222
|
-
stamp context validate [file]
|
|
223
|
-
stamp context clean [path] [options]
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
###
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
-
|
|
628
|
-
|
|
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
|
-
|
|
752
|
-
|
|
753
|
-
### Understanding the Meta Field
|
|
489
|
+
### Structure Overview
|
|
754
490
|
|
|
755
|
-
|
|
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
|
-
|
|
496
|
+
### Key Fields
|
|
758
497
|
|
|
759
|
-
|
|
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
|
-
|
|
762
|
-
- `
|
|
763
|
-
- `
|
|
764
|
-
- `
|
|
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
|
-
**
|
|
767
|
-
|
|
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
|
|
791
|
-
- `circular dependency` - Circular import detected
|
|
792
|
-
- `max depth exceeded` -
|
|
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
|
-
|
|
806
|
-
|
|
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
|
-
###
|
|
659
|
+
### Planned Features
|
|
951
660
|
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
-
|
|
956
|
-
-
|
|
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
|
-
**
|
|
667
|
+
**Framework Support:**
|
|
668
|
+
- Vue.js 3 Composition API components
|
|
669
|
+
- Svelte component analysis
|
|
984
670
|
|
|
985
|
-
|
|
671
|
+
**Other:**
|
|
672
|
+
- Custom contract fields via config
|
|
673
|
+
- Performance metrics (bundle size, render estimates)
|
|
674
|
+
- Incremental bundle caching
|
|
986
675
|
|
|
987
|
-
|
|
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,
|
|
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"}
|