logicstamp-context 0.2.2 → 0.2.4
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 +116 -923
- 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/dist/core/styleExtractor/index.d.ts +1 -0
- package/dist/core/styleExtractor/index.d.ts.map +1 -1
- package/dist/core/styleExtractor/index.js +1 -0
- package/dist/core/styleExtractor/index.js.map +1 -1
- package/dist/core/styleExtractor/material.d.ts +19 -0
- package/dist/core/styleExtractor/material.d.ts.map +1 -0
- package/dist/core/styleExtractor/material.js +103 -0
- package/dist/core/styleExtractor/material.js.map +1 -0
- package/dist/core/styleExtractor/styleExtractor.d.ts.map +1 -1
- package/dist/core/styleExtractor/styleExtractor.js +14 -0
- package/dist/core/styleExtractor/styleExtractor.js.map +1 -1
- package/dist/types/UIFContract.d.ts +11 -0
- package/dist/types/UIFContract.d.ts.map +1 -1
- package/dist/types/UIFContract.js.map +1 -1
- package/package.json +1 -1
- package/schema/logicstamp.context.schema.json +48 -1
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# LogicStamp Context
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
|
-
<img src="assets/logicstamp-fox.svg" alt="LogicStamp Fox Mascot" width="120" height="120">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/LogicStamp/logicstamp-context/main/assets/logicstamp-fox.svg" alt="LogicStamp Fox Mascot" width="120" height="120">
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
|
-

|
|
8
8
|

|
|
9
9
|

|
|
10
10
|

|
|
@@ -14,908 +14,160 @@
|
|
|
14
14
|
|
|
15
15
|
## Quick Start
|
|
16
16
|
|
|
17
|
+
**Global CLI (recommended):**
|
|
17
18
|
```bash
|
|
18
19
|
npm install -g logicstamp-context
|
|
19
20
|
cd your-project
|
|
20
21
|
stamp context
|
|
21
22
|
```
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-

|
|
26
|
-
*Terminal output showing `stamp context` execution and generated context.json structure*
|
|
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).
|
|
29
|
-
|
|
30
|
-
## What is this?
|
|
31
|
-
|
|
32
|
-
**LogicStamp Context** is a lightweight tool that scans your React/TypeScript codebase and generates structured context bundles optimized for AI tools like Claude, ChatGPT, and other LLMs.
|
|
33
|
-
|
|
34
|
-
No setup, no configuration, no pre-compilation required. Just point it at your code and get instant, AI-ready documentation.
|
|
35
|
-
|
|
36
|
-
## Installation
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npm install -g logicstamp-context
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
After installation, the `stamp` command will be available globally.
|
|
43
|
-
|
|
44
|
-
**Note**: "Global CLI" means the tool is installed globally on your system (via `npm install -g`), making the `stamp` command available from any directory in your terminal, not just within a specific project folder.
|
|
45
|
-
- **Local install**: `npm install logicstamp-context` → only available in that project
|
|
46
|
-
- **Global install**: `npm install -g logicstamp-context` → available everywhere via `stamp` command
|
|
47
|
-
|
|
48
|
-
## What's New in v0.2.2
|
|
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
|
|
53
|
-
|
|
54
|
-
## What's New in v0.2.1
|
|
55
|
-
|
|
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
|
|
58
|
-
|
|
59
|
-
### Changed
|
|
60
|
-
- Updated all version references in documentation to reflect 0.2.1 release
|
|
61
|
-
|
|
62
|
-
## What's New in v0.2.0
|
|
63
|
-
|
|
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
|
-
|
|
24
|
+
**OR local:**
|
|
102
25
|
```bash
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
# For global installs
|
|
107
|
-
npm install -g @dqbd/tiktoken @anthropic-ai/tokenizer
|
|
26
|
+
npm install -D logicstamp-context
|
|
27
|
+
npx stamp context
|
|
108
28
|
```
|
|
109
29
|
|
|
110
|
-
|
|
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
|
|
30
|
+
That's it! LogicStamp Context will scan your project and generate `context.json` files organized by folder, plus a `context_main.json` index file. Share these files with AI assistants for instant codebase understanding.
|
|
155
31
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
- Enhanced `--stats` output with mode estimates
|
|
159
|
-
- JSON output optimized for CI parsing
|
|
32
|
+

|
|
33
|
+
*Sample stamp context output with generated bundles*
|
|
160
34
|
|
|
161
|
-
|
|
35
|
+
> **Note:** This is a beta release (v0.2.4). 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).
|
|
162
36
|
|
|
163
|
-
|
|
37
|
+
## Why LogicStamp?
|
|
164
38
|
|
|
165
|
-
-
|
|
166
|
-
- **Logic signatures**: props, events, state types
|
|
167
|
-
- **Dependency graph**: how components relate to each other
|
|
168
|
-
- **Code snippets**: headers or full source (configurable)
|
|
169
|
-
- **Semantic hashes**: for tracking changes
|
|
170
|
-
- **Next.js metadata**: App Router directives and file location (when applicable)
|
|
39
|
+
LLMs understand your project instantly - without scanning 10,000+ lines of code
|
|
171
40
|
|
|
172
|
-
|
|
41
|
+
- **~65–72% token savings** vs raw source
|
|
42
|
+
- **Deterministic, structured contracts** that help AI avoid hallucinations by only referencing the true architecture
|
|
43
|
+
- **Perfect for Cursor/Claude/GitHub Copilot Chat** — share context files for instant codebase understanding
|
|
44
|
+
- **CI-friendly** — detect drift, validate bundles, track changes
|
|
173
45
|
|
|
174
|
-
|
|
46
|
+
This gives newcomers the "aha moment" in seconds.
|
|
175
47
|
|
|
176
|
-
|
|
48
|
+
## Features
|
|
177
49
|
|
|
178
|
-
|
|
50
|
+
- 🧠 **AI-ready bundles** - predictable, structured, deterministic
|
|
51
|
+
- ⚛️ **React/TypeScript awareness** - props, hooks, state, deps
|
|
52
|
+
- 🎨 **Style metadata** - (Tailwind, SCSS, MUI, shadcn)
|
|
53
|
+
- 🛣️ **Next.js App Router detection** - (client/server, layout/page/etc)
|
|
54
|
+
- 🔎 **Dependency graph** - (imports, cycles, missing deps)
|
|
55
|
+
- 📦 **Per-folder bundles** - organized by your project structure
|
|
56
|
+
- ⚙️ **CI validation** - (drift detection, schema validation)
|
|
57
|
+
- 🔢 **Accurate token estimates** - (GPT/Claude)
|
|
58
|
+
- 💨 **Fast, zero-config** - works out of the box
|
|
59
|
+
- 🤖 **MCP-ready (coming soon)** - AI agents can consume context bundles via a standardized MCP interface
|
|
179
60
|
|
|
180
|
-
|
|
181
|
-
- **`'use server'` directive** - Marks Server Actions
|
|
182
|
-
- **App Router location** - Identifies files in `/app` directory
|
|
61
|
+
## Example Output
|
|
183
62
|
|
|
184
|
-
|
|
63
|
+
LogicStamp Context generates structured JSON contracts for each component:
|
|
185
64
|
|
|
186
65
|
```json
|
|
187
66
|
{
|
|
188
|
-
"
|
|
67
|
+
"entryId": "src/components/Button.tsx",
|
|
189
68
|
"kind": "react:component",
|
|
190
|
-
"
|
|
191
|
-
|
|
192
|
-
"
|
|
193
|
-
"isInAppDir": true
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### Benefits for AI Analysis
|
|
199
|
-
|
|
200
|
-
- **Framework-aware suggestions** - AI knows which APIs are available (client vs server)
|
|
201
|
-
- **Better refactoring** - AI understands boundaries between client/server code
|
|
202
|
-
- **Accurate recommendations** - AI won't suggest client-only hooks in Server Components
|
|
203
|
-
|
|
204
|
-
### Supported Scenarios
|
|
205
|
-
|
|
206
|
-
✅ Client Components with `'use client'`
|
|
207
|
-
✅ Server Actions with `'use server'`
|
|
208
|
-
✅ Server Components in `/app` directory (no directive)
|
|
209
|
-
✅ Regular components outside `/app` (no metadata)
|
|
210
|
-
|
|
211
|
-
**Note:** The `nextjs` field is only added when relevant, keeping contracts clean for non-Next.js projects.
|
|
212
|
-
|
|
213
|
-
## Usage
|
|
214
|
-
|
|
215
|
-
```bash
|
|
216
|
-
stamp --version # Show version number
|
|
217
|
-
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.
|
|
301
|
-
|
|
302
|
-
### Profiles
|
|
303
|
-
|
|
304
|
-
Profiles are preset configurations optimized for different use cases:
|
|
305
|
-
|
|
306
|
-
#### `llm-chat` (default)
|
|
307
|
-
Balanced mode for AI chat interfaces
|
|
308
|
-
- Depth: 1
|
|
309
|
-
- Code: headers only
|
|
310
|
-
- Max nodes: 100
|
|
311
|
-
- Behavioral predictions: disabled by default (enable with `--predict-behavior`)
|
|
312
|
-
|
|
313
|
-
#### `llm-safe`
|
|
314
|
-
Conservative mode for token-limited contexts
|
|
315
|
-
- Depth: 1
|
|
316
|
-
- Code: headers only
|
|
317
|
-
- Max nodes: 30
|
|
318
|
-
- Behavioral predictions: disabled by default (enable with `--predict-behavior`)
|
|
319
|
-
|
|
320
|
-
#### `ci-strict`
|
|
321
|
-
Strict validation mode for CI/CD
|
|
322
|
-
- Code: none
|
|
323
|
-
- Strict dependencies enabled
|
|
324
|
-
- Behavioral predictions: not applicable (metadata-only mode)
|
|
325
|
-
|
|
326
|
-
### Behavioral Predictions
|
|
327
|
-
|
|
328
|
-
The `--predict-behavior` flag enables experimental behavioral analysis that adds predicted component behaviors to the contract output. These predictions include:
|
|
329
|
-
|
|
330
|
-
- Form validation patterns
|
|
331
|
-
- Side effect management (useEffect)
|
|
332
|
-
- Data fetching/mutation patterns
|
|
333
|
-
- Memoization usage
|
|
334
|
-
- Context consumption
|
|
335
|
-
- Ref usage for DOM access
|
|
336
|
-
- Loading/error state handling
|
|
337
|
-
|
|
338
|
-
**Note:** Behavioral predictions are **disabled by default** in all profiles to minimize token usage. Enable them explicitly when you need richer semantic information about component behavior.
|
|
339
|
-
|
|
340
|
-
**Example:**
|
|
341
|
-
```bash
|
|
342
|
-
# Enable predictions with the default profile
|
|
343
|
-
stamp context --predict-behavior
|
|
344
|
-
|
|
345
|
-
# Enable predictions with a specific profile
|
|
346
|
-
stamp context --profile llm-safe --predict-behavior
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
## Token Optimization
|
|
350
|
-
|
|
351
|
-
LogicStamp Context includes built-in token cost analysis and optimization features:
|
|
352
|
-
|
|
353
|
-
### Automatic Token Estimates
|
|
354
|
-
|
|
355
|
-
Every context generation shows token costs for both GPT-4o-mini and Claude:
|
|
356
|
-
|
|
357
|
-
```
|
|
358
|
-
📏 Token Estimates (header+style mode):
|
|
359
|
-
GPT-4o-mini: 13,895 tokens
|
|
360
|
-
Claude: 12,351 tokens
|
|
361
|
-
|
|
362
|
-
Comparison:
|
|
363
|
-
Raw source | Header | Header+style
|
|
364
|
-
22,000 | 12,228 | 13,895
|
|
365
|
-
|
|
366
|
-
Full context (code+style): ~39,141 GPT-4o-mini / ~34,792 Claude
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
This helps you:
|
|
370
|
-
- **Understand costs** at a glance
|
|
371
|
-
- **Choose the right mode** for your budget
|
|
372
|
-
- **See savings** compared to full context (code+style) mode
|
|
373
|
-
|
|
374
|
-
**Enhanced with `--compare-modes`:** The `--compare-modes` flag provides detailed comparisons across all modes (none/header/header+style/full) with accurate token counts. It automatically regenerates contracts with and without style metadata to show the true impact of including style information.
|
|
375
|
-
|
|
376
|
-
### Mode Comparison Table
|
|
377
|
-
|
|
378
|
-
Use `--compare-modes` for a detailed comparison across all modes:
|
|
379
|
-
|
|
380
|
-
```bash
|
|
381
|
-
stamp context --compare-modes
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
Output:
|
|
385
|
-
```
|
|
386
|
-
📊 Mode Comparison
|
|
387
|
-
|
|
388
|
-
Comparison:
|
|
389
|
-
Mode | Tokens GPT-4o | Tokens Claude | Savings vs Raw Source
|
|
390
|
-
-------------|---------------|---------------|------------------------
|
|
391
|
-
Raw source | 22,000 | 19,556 | 0%
|
|
392
|
-
Header | 12,228 | 10,867 | 44%
|
|
393
|
-
Header+style | 13,895 | 12,351 | 37%
|
|
394
|
-
|
|
395
|
-
Mode breakdown:
|
|
396
|
-
Mode | Tokens GPT-4o | Tokens Claude | Savings vs Full Context
|
|
397
|
-
-------------|---------------|---------------|--------------------------
|
|
398
|
-
none | 8,337 | 7,411 | 79%
|
|
399
|
-
header | 12,228 | 10,867 | 69%
|
|
400
|
-
header+style | 13,895 | 12,351 | 65%
|
|
401
|
-
full | 39,141 | 34,792 | 0%
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
**When to use each mode:**
|
|
405
|
-
- **`none`** - API documentation, CI validation (no code snippets, no style)
|
|
406
|
-
- **`header`** - AI chat, code review (JSDoc headers + contracts, no style)
|
|
407
|
-
- **`header+style`** - Design-aware AI chat (headers + contracts + style metadata)
|
|
408
|
-
- **`full`** - Deep analysis, debugging (complete source code + contracts + style info)
|
|
409
|
-
|
|
410
|
-
**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.
|
|
411
|
-
|
|
412
|
-
**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.
|
|
413
|
-
|
|
414
|
-
### Stats for CI/CD
|
|
415
|
-
|
|
416
|
-
Use `--stats` to get machine-readable token data:
|
|
417
|
-
|
|
418
|
-
```bash
|
|
419
|
-
stamp context --stats
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
Output JSON includes:
|
|
423
|
-
```json
|
|
424
|
-
{
|
|
425
|
-
"tokensGPT4": 13895,
|
|
426
|
-
"tokensClaude": 12351,
|
|
427
|
-
"modeEstimates": {
|
|
428
|
-
"none": {"gpt4": 8337, "claude": 7411},
|
|
429
|
-
"header": {"gpt4": 13895, "claude": 12351},
|
|
430
|
-
"full": {"gpt4": 39141, "claude": 34792}
|
|
69
|
+
"props": {
|
|
70
|
+
"variant": { "type": "literal-union", "literals": ["primary", "secondary"] },
|
|
71
|
+
"onClick": { "type": "function", "signature": "() => void" }
|
|
431
72
|
},
|
|
432
|
-
"
|
|
433
|
-
"
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
## Context Drift Detection
|
|
438
|
-
|
|
439
|
-
The `compare` command helps you track changes between context versions:
|
|
440
|
-
|
|
441
|
-
### Basic Comparison
|
|
442
|
-
|
|
443
|
-
```bash
|
|
444
|
-
stamp context compare old.json new.json
|
|
445
|
-
```
|
|
446
|
-
|
|
447
|
-
Output:
|
|
448
|
-
```
|
|
449
|
-
✅ PASS
|
|
450
|
-
|
|
451
|
-
# or if changes detected:
|
|
452
|
-
|
|
453
|
-
⚠️ DRIFT
|
|
454
|
-
|
|
455
|
-
Added components: 2
|
|
456
|
-
+ src/components/NewButton.tsx
|
|
457
|
-
+ src/utils/helpers.ts
|
|
458
|
-
|
|
459
|
-
Removed components: 1
|
|
460
|
-
- src/components/OldButton.tsx
|
|
461
|
-
|
|
462
|
-
Changed components: 3
|
|
463
|
-
~ src/components/Card.tsx
|
|
464
|
-
Δ imports, hooks
|
|
465
|
-
~ src/App.tsx
|
|
466
|
-
Δ hash
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
### With Token Stats
|
|
470
|
-
|
|
471
|
-
```bash
|
|
472
|
-
stamp context compare old.json new.json --stats
|
|
473
|
-
```
|
|
474
|
-
|
|
475
|
-
Shows token cost changes:
|
|
476
|
-
```
|
|
477
|
-
Token Stats:
|
|
478
|
-
Old: 8,484 (GPT-4o-mini) | 7,542 (Claude)
|
|
479
|
-
New: 9,125 (GPT-4o-mini) | 8,111 (Claude)
|
|
480
|
-
Δ +641 (+7.56%)
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
### Exit Codes
|
|
484
|
-
|
|
485
|
-
- `0` - No drift (PASS)
|
|
486
|
-
- `1` - Drift detected or error
|
|
487
|
-
|
|
488
|
-
Perfect for CI/CD validation:
|
|
489
|
-
```bash
|
|
490
|
-
# In your CI pipeline
|
|
491
|
-
stamp context compare base.json pr.json || echo "Context drift detected!"
|
|
492
|
-
```
|
|
493
|
-
|
|
494
|
-
## Examples
|
|
495
|
-
|
|
496
|
-
### Basic usage
|
|
497
|
-
|
|
498
|
-
```bash
|
|
499
|
-
# Generate context for entire project
|
|
500
|
-
stamp context
|
|
501
|
-
|
|
502
|
-
# CLI output:
|
|
503
|
-
# 🔍 Scanning /path/to/project...
|
|
504
|
-
# ⚙️ Analyzing components...
|
|
505
|
-
# 🔗 Building dependency graph...
|
|
506
|
-
# 📦 Generating context...
|
|
507
|
-
# 🔍 Validating generated context...
|
|
508
|
-
# ✅ Validation passed
|
|
509
|
-
# 📝 Writing context files for 5 folders...
|
|
510
|
-
# ✓ context.json (2 bundles)
|
|
511
|
-
# ✓ src/context.json (3 bundles)
|
|
512
|
-
# ✓ src/components/context.json (5 bundles)
|
|
513
|
-
# ✓ src/utils/context.json (2 bundles)
|
|
514
|
-
# ✓ app/context.json (3 bundles)
|
|
515
|
-
# 📝 Writing main context index...
|
|
516
|
-
# ✓ context_main.json (index of 5 folders)
|
|
517
|
-
# ✅ 6 context files written successfully
|
|
518
|
-
#
|
|
519
|
-
# 📊 Summary:
|
|
520
|
-
# Total components: 15
|
|
521
|
-
# Root components: 3
|
|
522
|
-
# ...
|
|
523
|
-
```
|
|
524
|
-
|
|
525
|
-
### Focused analysis
|
|
526
|
-
|
|
527
|
-
```bash
|
|
528
|
-
# Analyze only the src directory
|
|
529
|
-
stamp context ./src
|
|
530
|
-
|
|
531
|
-
# Analyze with custom output directory
|
|
532
|
-
stamp context --out ./output
|
|
533
|
-
|
|
534
|
-
# Or specify a .json file to use its directory
|
|
535
|
-
stamp context --out ./output/context.json # Uses ./output as directory
|
|
536
|
-
```
|
|
537
|
-
|
|
538
|
-
### Deep traversal
|
|
539
|
-
|
|
540
|
-
```bash
|
|
541
|
-
# Include 2 levels of dependencies
|
|
542
|
-
stamp context --depth 2
|
|
543
|
-
|
|
544
|
-
# Include full source code
|
|
545
|
-
stamp context --include-code full
|
|
546
|
-
```
|
|
547
|
-
|
|
548
|
-
### Token cost analysis
|
|
549
|
-
|
|
550
|
-
```bash
|
|
551
|
-
# Show detailed mode comparison
|
|
552
|
-
stamp context --compare-modes
|
|
553
|
-
|
|
554
|
-
# Get JSON stats for CI
|
|
555
|
-
stamp context --stats
|
|
556
|
-
|
|
557
|
-
# See token costs for specific mode
|
|
558
|
-
stamp context --include-code none
|
|
559
|
-
stamp context --include-code full
|
|
560
|
-
```
|
|
561
|
-
|
|
562
|
-
### Context comparison
|
|
563
|
-
|
|
564
|
-
```bash
|
|
565
|
-
# Basic drift detection
|
|
566
|
-
stamp context compare old.json new.json
|
|
567
|
-
|
|
568
|
-
# With token delta stats
|
|
569
|
-
stamp context compare base.json pr.json --stats
|
|
570
|
-
|
|
571
|
-
# In CI pipeline
|
|
572
|
-
stamp context compare base.json pr.json || exit 1
|
|
573
|
-
```
|
|
574
|
-
|
|
575
|
-
### Clean context files
|
|
576
|
-
|
|
577
|
-
```bash
|
|
578
|
-
# Show what would be removed (dry run)
|
|
579
|
-
stamp context clean
|
|
580
|
-
|
|
581
|
-
# Actually delete all context artifacts
|
|
582
|
-
stamp context clean --all --yes
|
|
583
|
-
|
|
584
|
-
# Clean specific directory
|
|
585
|
-
stamp context clean ./output --all --yes
|
|
586
|
-
|
|
587
|
-
# Suppress verbose output (quiet mode)
|
|
588
|
-
stamp context --quiet
|
|
589
|
-
stamp context validate --quiet
|
|
590
|
-
stamp context compare --quiet
|
|
591
|
-
stamp context clean --all --yes --quiet
|
|
592
|
-
|
|
593
|
-
# Show version number
|
|
594
|
-
stamp --version
|
|
595
|
-
```
|
|
596
|
-
|
|
597
|
-
### CI/CD validation
|
|
598
|
-
|
|
599
|
-
```bash
|
|
600
|
-
# Use llm-safe profile for smaller output
|
|
601
|
-
stamp context --profile llm-safe --out safe-context.json
|
|
602
|
-
|
|
603
|
-
# Strict mode: fail if any dependencies missing
|
|
604
|
-
stamp context --strict-missing
|
|
605
|
-
|
|
606
|
-
# Generate stats for CI monitoring
|
|
607
|
-
stamp context --stats > stats.json
|
|
608
|
-
|
|
609
|
-
# Validate generated context
|
|
610
|
-
stamp context validate context.json
|
|
611
|
-
```
|
|
612
|
-
|
|
613
|
-
## Output Format
|
|
614
|
-
|
|
615
|
-
LogicStamp Context generates a **folder-organized, multi-file output structure** that maintains your project's directory hierarchy:
|
|
616
|
-
|
|
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
|
-
```
|
|
622
|
-
output/
|
|
623
|
-
├── context_main.json # Main index with folder metadata
|
|
624
|
-
├── context.json # Root folder bundles (if any)
|
|
625
|
-
├── src/
|
|
626
|
-
│ └── 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
|
|
73
|
+
"hooks": ["useState"],
|
|
74
|
+
"nextjs": { "directive": "client" },
|
|
75
|
+
"style": {
|
|
76
|
+
"styleSources": {
|
|
77
|
+
"tailwind": { "categories": { "layout": ["flex"], "colors": ["bg-blue-500"] } }
|
|
675
78
|
}
|
|
676
|
-
|
|
677
|
-
"
|
|
678
|
-
"source": "logicstamp-context@0.1.0"
|
|
679
|
-
}
|
|
79
|
+
},
|
|
80
|
+
"edges": ["./Icon"]
|
|
680
81
|
}
|
|
681
82
|
```
|
|
682
83
|
|
|
683
|
-
**
|
|
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
|
-
]
|
|
749
|
-
```
|
|
750
|
-
|
|
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
|
|
754
|
-
|
|
755
|
-
The `meta` section provides metadata about bundle generation and dependency resolution:
|
|
756
|
-
|
|
757
|
-
#### `missing` Array
|
|
758
|
-
|
|
759
|
-
Tracks dependencies that couldn't be resolved during analysis. An empty array `[]` means all dependencies were successfully found.
|
|
84
|
+
📋 **See [docs/SCHEMA.md](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/SCHEMA.md) for complete output format documentation**
|
|
760
85
|
|
|
761
|
-
|
|
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
|
|
765
|
-
|
|
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)
|
|
789
|
-
- `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
|
|
86
|
+
## Installation
|
|
793
87
|
|
|
794
|
-
**Using `--strict-missing` for CI/CD:**
|
|
795
88
|
```bash
|
|
796
|
-
|
|
797
|
-
stamp context --strict-missing
|
|
798
|
-
|
|
799
|
-
# Perfect for CI validation
|
|
800
|
-
stamp context --strict-missing || exit 1
|
|
89
|
+
npm install -g logicstamp-context
|
|
801
90
|
```
|
|
802
91
|
|
|
803
|
-
|
|
804
|
-
|
|
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
|
|
809
|
-
|
|
810
|
-
## Use Cases
|
|
811
|
-
|
|
812
|
-
### AI-Assisted Development
|
|
813
|
-
|
|
814
|
-
Share context with Claude or ChatGPT to get:
|
|
815
|
-
- Architecture suggestions
|
|
816
|
-
- Refactoring recommendations
|
|
817
|
-
- Bug fixes based on full component understanding
|
|
818
|
-
|
|
819
|
-
### Documentation
|
|
820
|
-
|
|
821
|
-
Generate up-to-date component documentation automatically:
|
|
822
|
-
- API contracts
|
|
823
|
-
- Dependency trees
|
|
824
|
-
- Component relationships
|
|
825
|
-
|
|
826
|
-
### Code Review
|
|
92
|
+
After installation, the `stamp` command will be available globally.
|
|
827
93
|
|
|
828
|
-
|
|
829
|
-
-
|
|
830
|
-
-
|
|
831
|
-
- Track component complexity
|
|
94
|
+
**Note**: "Global CLI" means the tool is installed globally on your system (via `npm install -g`), making the `stamp` command available from any directory in your terminal, not just within a specific project folder.
|
|
95
|
+
- **Local install**: `npm install logicstamp-context` → only available in that project
|
|
96
|
+
- **Global install**: `npm install -g logicstamp-context` → available everywhere via `stamp` command
|
|
832
97
|
|
|
833
|
-
##
|
|
98
|
+
## Recent Updates
|
|
834
99
|
|
|
835
|
-
|
|
100
|
+
**v0.2.4**
|
|
101
|
+
- Material UI style extraction
|
|
102
|
+
- Improved global CLI installation docs
|
|
103
|
+
- Refined README and docs structure
|
|
836
104
|
|
|
837
|
-
|
|
105
|
+
**v0.2.3**
|
|
106
|
+
- Streamlined README
|
|
107
|
+
- Improved token estimation
|
|
108
|
+
- UIF Contracts documentation
|
|
838
109
|
|
|
839
|
-
|
|
840
|
-
```json
|
|
841
|
-
{
|
|
842
|
-
"name": "@mui/material",
|
|
843
|
-
"reason": "external package"
|
|
844
|
-
}
|
|
845
|
-
```
|
|
846
|
-
**Solution:** This is normal. LogicStamp only analyzes your source code, not node_modules. External packages are intentionally excluded.
|
|
110
|
+
📋 **Full history → [CHANGELOG.md](https://github.com/LogicStamp/logicstamp-context/blob/main/CHANGELOG.md)**
|
|
847
111
|
|
|
848
|
-
|
|
849
|
-
```json
|
|
850
|
-
{
|
|
851
|
-
"name": "./components/OldButton",
|
|
852
|
-
"reason": "file not found",
|
|
853
|
-
"referencedBy": "src/App.tsx"
|
|
854
|
-
}
|
|
855
|
-
```
|
|
856
|
-
**Solutions:**
|
|
857
|
-
- Check if the file was deleted or moved
|
|
858
|
-
- Update the import path in the referencing component
|
|
859
|
-
- Use `--strict-missing` in CI to catch these issues early
|
|
860
|
-
|
|
861
|
-
#### 3. Outside Scan Path
|
|
862
|
-
```json
|
|
863
|
-
{
|
|
864
|
-
"name": "../../shared/utils",
|
|
865
|
-
"reason": "outside scan path"
|
|
866
|
-
}
|
|
867
|
-
```
|
|
868
|
-
**Solutions:**
|
|
869
|
-
- Expand your scan path: `stamp context ../` (parent directory)
|
|
870
|
-
- Or scan from project root: `stamp context .` (from root)
|
|
871
|
-
|
|
872
|
-
#### 4. Max Depth Exceeded
|
|
873
|
-
```json
|
|
874
|
-
{
|
|
875
|
-
"name": "./deeply/nested/component",
|
|
876
|
-
"reason": "max depth exceeded"
|
|
877
|
-
}
|
|
878
|
-
```
|
|
879
|
-
**Solutions:**
|
|
880
|
-
- Increase depth: `stamp context --depth 2` or `--depth 3`
|
|
881
|
-
- Note: Higher depth = more tokens consumed
|
|
882
|
-
|
|
883
|
-
#### 5. Circular Dependencies
|
|
884
|
-
```json
|
|
885
|
-
{
|
|
886
|
-
"name": "./ComponentA",
|
|
887
|
-
"reason": "circular dependency"
|
|
888
|
-
}
|
|
889
|
-
```
|
|
890
|
-
**Solutions:**
|
|
891
|
-
- Refactor to break the circular import
|
|
892
|
-
- Extract shared logic to a separate module
|
|
893
|
-
- This is a code smell that should be addressed
|
|
112
|
+
## Usage
|
|
894
113
|
|
|
895
|
-
|
|
114
|
+
```bash
|
|
115
|
+
stamp --version # Show version number
|
|
116
|
+
stamp --help # Show help
|
|
117
|
+
stamp init [path] [options] # Initialize project preferences
|
|
118
|
+
stamp context [path] [options] # Generate context bundles
|
|
119
|
+
stamp context style [path] [options] # Generate with style metadata
|
|
120
|
+
stamp context compare [options] # Detect context drift
|
|
121
|
+
stamp context validate [file] # Validate context files
|
|
122
|
+
stamp context clean [path] [options] # Remove generated files
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Quick Command Reference
|
|
126
|
+
|
|
127
|
+
| Command | Description | Docs |
|
|
128
|
+
|---------|-------------|------|
|
|
129
|
+
| `stamp init` | Initialize project (`.gitignore`, `LLM_CONTEXT.md`, config) | [INIT.md](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/cli/INIT.md) |
|
|
130
|
+
| `stamp context` | Generate AI-ready context bundles organized by folder | [CONTEXT.md](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/cli/CONTEXT.md) |
|
|
131
|
+
| `stamp context style` | Generate context with style metadata (Tailwind, SCSS, etc.) | [STYLE.md](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/cli/STYLE.md) |
|
|
132
|
+
| `stamp context compare` | Compare context files to detect changes (CI-friendly) | [COMPARE.md](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/cli/COMPARE.md) |
|
|
133
|
+
| `stamp context validate` | Validate context file schema and structure | [VALIDATE.md](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/cli/VALIDATE.md) |
|
|
134
|
+
| `stamp context clean` | Remove all generated context artifacts | [CLEAN.md](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/cli/CLEAN.md) |
|
|
135
|
+
|
|
136
|
+
### Common Options
|
|
137
|
+
|
|
138
|
+
**`stamp context` options:**
|
|
139
|
+
- `--depth <n>` / `-d` - Dependency traversal depth (default: `1`)
|
|
140
|
+
- `--include-code <mode>` / `-c` - Code inclusion: `none|header|full` (default: `header`)
|
|
141
|
+
- `--include-style` - Extract style metadata (Tailwind, SCSS, animations, layout)
|
|
142
|
+
- `--format <fmt>` / `-f` - Output format: `json|pretty|ndjson` (default: `json`)
|
|
143
|
+
- `--max-nodes <n>` / `-m` - Maximum nodes per bundle (default: `100`)
|
|
144
|
+
- `--profile <profile>` - Preset: `llm-chat` (default), `llm-safe`, `ci-strict`
|
|
145
|
+
- `--stats` - Emit JSON stats with token estimates (CI-friendly)
|
|
146
|
+
- `--out <path>` / `-o` - Output directory or file path
|
|
147
|
+
- `--quiet` / `-q` - Suppress verbose output
|
|
148
|
+
|
|
149
|
+
📋 **See [docs/cli/COMMANDS.md](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/cli/COMMANDS.md) for complete option reference**
|
|
150
|
+
|
|
151
|
+
## Documentation
|
|
152
|
+
|
|
153
|
+
- **[Usage Guide](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/USAGE.md)** — Complete usage documentation with examples
|
|
154
|
+
- **[Token Optimization](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/USAGE.md#token-cost-comparison)** — Understand token costs and savings
|
|
155
|
+
- **[Mode Comparison](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/cli/COMPARE-MODES.md)** — Detailed comparison across all modes
|
|
156
|
+
- **[Output Format](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/SCHEMA.md)** — Complete schema documentation
|
|
157
|
+
- **[CI Integration](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/USAGE.md#cicd-integration)** — CI/CD workflows and validation
|
|
158
|
+
- **[Troubleshooting](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/USAGE.md#troubleshooting)** — Common issues and solutions
|
|
159
|
+
- **[UIF Contracts](https://github.com/LogicStamp/logicstamp-context/blob/main/docs/UIF_CONTRACTS.md)** — Understanding component contracts
|
|
160
|
+
|
|
161
|
+
## Need Help?
|
|
162
|
+
|
|
163
|
+
- **Open an issue** → https://github.com/LogicStamp/logicstamp-context/issues
|
|
164
|
+
- **Join our roadmap** → https://logicstamp.dev
|
|
896
165
|
|
|
897
|
-
|
|
898
|
-
- Use `--include-code none` to exclude all source code (smallest)
|
|
899
|
-
- Use `--include-code header` (default) for balanced output
|
|
900
|
-
- Use `--profile llm-safe` for token-constrained scenarios
|
|
901
|
-
- Check `--compare-modes` to see token savings
|
|
166
|
+
## What is this?
|
|
902
167
|
|
|
903
|
-
**
|
|
904
|
-
```bash
|
|
905
|
-
stamp context validate context.json
|
|
906
|
-
# Or validate the main index
|
|
907
|
-
stamp context validate context_main.json
|
|
908
|
-
```
|
|
909
|
-
- Check for schema mismatches (outdated schema version)
|
|
910
|
-
- Verify JSON is well-formed (no trailing commas, proper escaping)
|
|
911
|
-
- Ensure all required fields are present
|
|
912
|
-
- Each folder's context.json should be a valid bundle array
|
|
913
|
-
- The context_main.json should have the LogicStampIndex structure
|
|
168
|
+
**LogicStamp Context** is a lightweight tool that scans your React/TypeScript codebase and generates structured context bundles optimized for AI tools like Claude, ChatGPT, and other LLMs.
|
|
914
169
|
|
|
915
|
-
|
|
916
|
-
- LogicStamp respects `.gitignore` automatically
|
|
917
|
-
- `node_modules/` and common build directories are excluded by default
|
|
918
|
-
- Scan specific directories: `stamp context ./src`
|
|
170
|
+
No setup, no configuration, no pre-compilation required. Just point it at your code and get instant, AI-ready documentation.
|
|
919
171
|
|
|
920
172
|
## How it Works
|
|
921
173
|
|
|
@@ -929,66 +181,6 @@ stamp context validate context_main.json
|
|
|
929
181
|
|
|
930
182
|
All in one command, no pre-compilation needed!
|
|
931
183
|
|
|
932
|
-
## Planned Orchestrator (@logicstamp/cli)
|
|
933
|
-
|
|
934
|
-
`logicstamp-context` is the primary CLI available today. A higher-level orchestrator package `@logicstamp/cli` is planned as an optional wrapper.
|
|
935
|
-
|
|
936
|
-
| Feature | logicstamp-context | LogicStamp Orchestrator (planned) |
|
|
937
|
-
|---------|-------------------|----------------------------------|
|
|
938
|
-
| Standalone | ✅ Yes | ❌ No (wraps underlying tools) |
|
|
939
|
-
| Pre-compilation required | ❌ No | ✅ Yes (for verification) |
|
|
940
|
-
| Context generation | ✅ Yes | ✅ Yes |
|
|
941
|
-
| UIF contracts per file | ✅ Yes (embedded in bundles) | ✅ Yes (as `.uif.json` sidecar files) |
|
|
942
|
-
| Contract compilation | ✅ Built-in | ✅ Separate command |
|
|
943
|
-
| Contract verification | ❌ No | ✅ Yes (planned) |
|
|
944
|
-
| Size | Focused | Orchestrator |
|
|
945
|
-
|
|
946
|
-
**TL;DR**: Use `stamp context` (logicstamp-context) for AI context generation today. The future `@logicstamp/cli` orchestrator will provide optional higher-level workflows once it's released.
|
|
947
|
-
|
|
948
|
-
## Future Roadmap
|
|
949
|
-
|
|
950
|
-
### Next.js Enhancements (Planned)
|
|
951
|
-
|
|
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
|
-
```
|
|
982
|
-
|
|
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.
|
|
984
|
-
|
|
985
|
-
### Other Planned Features
|
|
986
|
-
|
|
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
|
|
991
|
-
|
|
992
184
|
## Requirements
|
|
993
185
|
|
|
994
186
|
- Node.js >= 18.0.0
|
|
@@ -1002,7 +194,7 @@ MIT
|
|
|
1002
194
|
|
|
1003
195
|
Issues and PRs welcome! This is an open-source project.
|
|
1004
196
|
|
|
1005
|
-
**See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines**, including:
|
|
197
|
+
**See [CONTRIBUTING.md](https://github.com/LogicStamp/logicstamp-context/blob/main/CONTRIBUTING.md) for detailed guidelines**, including:
|
|
1006
198
|
- Branching strategy (feature → `main`, no `develop` branch)
|
|
1007
199
|
- Branch naming conventions (`feature/*`, `fix/*`, `docs/*`)
|
|
1008
200
|
- Commit message format (Conventional Commits)
|
|
@@ -1010,5 +202,6 @@ Issues and PRs welcome! This is an open-source project.
|
|
|
1010
202
|
|
|
1011
203
|
## Links
|
|
1012
204
|
|
|
1013
|
-
- [LogicStamp Main Project](https://
|
|
205
|
+
- [LogicStamp Main Project](https://logicstamp.dev)
|
|
206
|
+
- [GitHub Repository](https://github.com/LogicStamp/logicstamp-context)
|
|
1014
207
|
- [Report Issues](https://github.com/LogicStamp/logicstamp-context/issues)
|