Skip to content

Commit 8f57970

Browse files
authored
docs: sync CLI and MCP docs with latest GitHub updates (#232)
1 parent b4926e5 commit 8f57970

33 files changed

Lines changed: 1103 additions & 2099 deletions

docs/context/README.md

Lines changed: 65 additions & 112 deletions
Large diffs are not rendered by default.

docs/context/ROADMAP.md

Lines changed: 99 additions & 622 deletions
Large diffs are not rendered by default.

docs/context/SCHEMA_VALIDATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ The schema completeness test runs as part of the test suite. To ensure schema st
133133

134134
- **Deprecated fields**: Fields marked `@deprecated` in TypeScript (e.g., `entryPathAbs`, `entryPathRel`, `os`) may not be in the schema if they're no longer generated. This is intentional for backward compatibility - old files with these fields may still exist.
135135

136-
- **Conditional validation**: The schema doesn't currently validate language-specific field combinations (e.g., `style` shouldn't exist on `node:api` contracts). This is planned for v0.8.x (see ROADMAP.md).
136+
- **Conditional validation**: The schema doesn't currently validate language-specific field combinations (e.g., `style` shouldn't exist on `node:api` contracts). This is planned for a future release (see [ROADMAP.md](../ROADMAP.md)).
137137

138138
- **Style mode variants**: The schema supports both `lean` and `full` style modes. Lean mode uses count fields (e.g., `selectorCount`, `componentCount`), while full mode uses arrays (e.g., `selectors`, `components`). Both formats are valid and should be tested separately.
139139

docs/context/cli/compare-modes.md

Lines changed: 39 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
# Mode Comparison Guide
22

3-
Compare token costs across all context compilation modes to choose the right one for your workflow.
3+
Compare token costs across context modes.
44

55
```bash
66
stamp context --compare-modes
77
```
88

99
## Overview
1010

11-
Four modes balance information vs token cost:
11+
Four modes balance detail vs tokens:
1212

13-
- **none** - Contracts only (props, state, hooks, dependencies), no source code
14-
- **header** - Contracts plus JSDoc headers and function signatures
15-
- **header+style** - Header mode plus style metadata (Tailwind, SCSS, Material UI, animations, layout)
16-
- **full** - Everything including complete source code
17-
18-
The comparison shows token costs for all modes so you can see the tradeoffs.
13+
- **none** - Contracts only (props, state, hooks, dependencies), no source
14+
- **header** - Contracts plus JSDoc headers and signatures
15+
- **header+style** - Header plus style metadata (Tailwind, SCSS, MUI, layout, motion)
16+
- **full** - Contracts plus complete embedded source
1917

2018
## Output Format
2119

22-
The output shows three things:
20+
**1. Token estimation** — Which tokenizers ran, or character fallback.
21+
22+
**2. Comparison vs raw source** — See [baselines](#what-the-two-baselines-mean). Negative % means summed header bundles exceed one copy of all source files, but a **single** root’s bundle is often still far smaller than raw because the row totals **every** root, not the one bundle you attach in chat.
2323

24-
**1. Token estimation method** - Shows which tokenizers are being used, or if it's falling back to approximations
24+
**3. Mode breakdown** — Each mode vs **full** (same bundle set): how much smaller than maximum.
2525

26-
**2. Comparison vs raw source** - Savings compared to including all source files directly:
26+
Example tables:
2727

2828
```
2929
Comparison:
@@ -34,10 +34,6 @@ The output shows three things:
3434
Header+style | 170,466 | 184,864 | 38%
3535
```
3636

37-
Header mode saves ~70% by extracting contracts and signatures without implementation code. Header+style saves ~38% but adds visual context. Full mode actually costs more than raw source (~30% overhead) due to contract structure.
38-
39-
**3. Mode breakdown** - All modes compared to the maximum (full):
40-
4137
```
4238
Mode breakdown:
4339
Mode | Tokens GPT-4o | Tokens Claude | Savings vs Full Context
@@ -50,130 +46,73 @@ Header mode saves ~70% by extracting contracts and signatures without implementa
5046

5147
## Token Estimation
5248

53-
By default, the tool uses character-based approximations (~4 chars/token for GPT-4o, ~4.5 for Claude). These are usually within 10-15% of actual counts, which is fine for most cases.
54-
55-
For accurate counts, LogicStamp includes `@dqbd/tiktoken` (GPT-4) and `@anthropic-ai/tokenizer` (Claude) as optional dependencies. npm installs them automatically when you install `logicstamp-context`. If that works, you get exact token counts. If it fails (normal for optional deps), it falls back to approximation.
56-
57-
You only need to install tokenizers manually if:
58-
- You need exact counts (not approximations)
59-
- AND automatic installation failed
49+
Defaults use ~4 chars/token (GPT-4o) and ~4.5 (Claude). Optional deps `@dqbd/tiktoken` and `@anthropic-ai/tokenizer` give exact counts when install succeeds.
6050

6151
```bash
6252
npm install @dqbd/tiktoken @anthropic-ai/tokenizer
6353
```
6454

65-
Accurate counts matter for production deployments, tight budgets, or comparing tools. For development, approximations are usually fine.
55+
## What the two baselines mean
6656

67-
## Mode Selection Guide
57+
**Raw source** — Every project `.ts` / `.tsx` (tests excluded), each file **once**, joined. No JSON bundles.
58+
59+
**Header / header+style (first table)** — Tokens for **all root bundles**, formatted and concatenated. Anything imported by many roots is repeated; bundle JSON adds overhead. So the table can show header **above** raw on large multi-root graphs, even when **one** feature bundle is still cheap. In chat you usually send one bundle—that is **not** the same as this summed row.
6860

69-
**none** - Maximum compression (~18% of raw source)
70-
- Contracts only, no code or style
71-
- Good for: CI/CD validation, dependency analysis, architecture reviews
72-
- Skip if: You need implementation details or visual context
61+
**Tailwind + header+style** — Style extraction expands utilities into structured text, so that row often grows vs raw more than on SCSS-heavy repos (in addition to duplication above).
7362

74-
**header** - Balanced compression (~30% of raw source) *recommended default*
75-
- Contracts + JSDoc headers + function signatures
76-
- Good for: Most AI chat workflows, code review, understanding interfaces
77-
- This is what most people need 90% of the time
63+
## Mode Selection Guide
7864

79-
**header+style** - Visual context (~62% of raw source)
80-
- Everything from header + style metadata (Tailwind, SCSS, animations, layout patterns)
81-
- Good for: UI/UX discussions, design system work, frontend generation
82-
- Adds ~13% token overhead vs header mode
65+
**~N% vs raw** below = rough when summed header output beats one pass over all files ([above](#what-the-two-baselines-mean)).
8366

84-
**full** - Complete context (~130% of raw source)
85-
- Everything including full source code
86-
- Good for: Deep reviews, complex refactoring, bug investigation
87-
- Note: Costs more than raw source due to contract structure overhead
67+
**none** ~18% of raw in typical cases. CI, graphs, no UI detail.
68+
**header**~30% when totals beat raw. Default for most chat/review.
69+
**header+style**~62% when totals beat raw; Tailwind pushes it up. UI and design-system work.
70+
**full**~130% vs one file pass; contracts + full source. Deep refactors, bugs.
8871

8972
## Example Workflows
9073

91-
**Budget planning:**
9274
```bash
9375
stamp context --compare-modes
9476
stamp context --include-code header --max-nodes 50
9577
```
9678

97-
**Style cost analysis:**
9879
```bash
9980
stamp context --compare-modes
100-
stamp context style # only if budget allows
101-
```
102-
103-
**Production optimization:**
104-
```bash
105-
stamp context --compare-modes | tee token-analysis.txt
106-
stamp context --include-code none --profile ci-strict
81+
stamp context style # if budget allows
10782
```
10883

109-
**Multi-repo comparison:**
11084
```bash
111-
for repo in api web mobile; do
112-
echo "=== $repo ==="
113-
cd $repo && stamp context --compare-modes --quiet && cd ..
114-
done
85+
stamp context --compare-modes --stats # writes context_compare_modes.json
11586
```
11687

117-
**MCP integration:**
118-
```bash
119-
stamp context --compare-modes --stats
120-
# Creates context_compare_modes.json with structured data for MCP servers
121-
```
122-
123-
## Understanding the Numbers
124-
125-
**Savings vs Raw Source:** Shows how much you save compared to just concatenating all source files. Higher is better. Header mode typically saves ~70%, header+style saves ~38%. Full mode actually costs more (~30% overhead) due to contract structure.
126-
127-
**Savings vs Full Context:** Shows efficiency compared to the maximum mode. Header saves ~77%, header+style saves ~52%.
128-
129-
**GPT-4o vs Claude:** Token counts differ slightly (usually 5-10%) because each model tokenizes differently. Both estimates are shown so you can plan for either.
130-
131-
**Accuracy:** Approximations are usually within 10-15% and fine for planning. Tokenizers give exact counts but require installation.
132-
13388
## Common Questions
13489

135-
**Why are my numbers different from raw file sizes?**
136-
Token counts ≠ character counts. Tokenizers split text into semantic units—common words are 1 token, rare words are multiple, code symbols vary, whitespace compresses.
90+
**Why don’t tokens match file size?** Tokens ≠ bytes; tokenizers split code and prose unevenly.
13791

138-
**Should I always use accurate tokenizers?**
139-
Use approximations for development/prototyping. Use tokenizers for production, tight budgets, or comparing tools.
92+
**When are tokenizers worth it?** Tight budgets, production gates, comparing tools. Approximations are fine for day-to-day.
14093

141-
**How much overhead do contracts add?**
142-
In `full` mode, contracts add ~30% overhead vs raw source due to JSON structure and metadata. The overhead is worth it for structured dependency graphs and better AI comprehension, but `header` mode avoids most of it while still giving you what you need.
94+
**`full` overhead?** JSON + metadata on top of embedded source; `header` avoids most of that.
14395

144-
**Why do the savings percentages seem generous?**
145-
"Savings vs raw source" compares against simple file concatenation. Header mode saves 70% because it extracts contracts and signatures without implementation code. Full mode actually costs more than raw source (~30% overhead) due to contract structure. The real win: header mode gives you 90% of what you need at 30% of the cost.
96+
### Why can Header show more tokens than Raw source?
14697

147-
**Can I compare specific folders?**
148-
Yes:
149-
```bash
150-
stamp context ./src/components --compare-modes
151-
```
98+
[What the two baselines mean](#what-the-two-baselines-mean) — raw is one copy of each file; the header row is **every root bundle** summed.
15299

153-
**Does --compare-modes write files?**
154-
No, it's analysis-only by default. It generates contracts in memory, computes estimates, and displays tables. Use `stamp context` (without the flag) to actually generate context files.
100+
**Folder scope?** `stamp context ./src/components --compare-modes`
155101

156-
With `--stats`, it writes `context_compare_modes.json` for MCP integration:
157-
```bash
158-
stamp context --compare-modes --stats
159-
```
102+
**Writes files?** No, unless `--stats` (JSON). Normal `stamp context` writes bundles.
160103

161104
## Performance
162105

163-
Takes 2-3x longer than normal generation because it regenerates contracts with and without style for accurate comparison. Uses in-memory processing (no disk writes). Typical execution: 5-15 seconds for medium projects (50-150 files).
106+
~2–3× normal run; in-memory, no bundle files unless `--stats`.
164107

165108
## Related Commands
166109

167-
- [`stamp context`](context.md) - Generate context files
168-
- [`stamp context style`](style.md) - Generate context with style metadata
169-
- [`stamp context compare`](compare.md) - Compare context changes over time
170-
- [`stamp context validate`](validate.md) - Validate schema compliance
110+
- [`stamp context`](context.md)
111+
- [`stamp context style`](style.md)
112+
- [`stamp context compare`](compare.md)
113+
- [`stamp context validate`](validate.md)
171114

172115
## Tips
173116

174-
- Run `--compare-modes` before committing to a mode
175-
- Use approximations in dev, tokenizers in production
176-
- Default to `header` mode—it covers most use cases
177-
- Add `header+style` only when you need visual context
178-
- Reserve `full` mode for deep implementation work
179-
- Check costs regularly as your codebase grows
117+
- Default **header**; add **header+style** only for UI-heavy prompts.
118+
- Re-run as the repo grows.

docs/context/cli/context.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ stamp context [path] [options]
1313

1414
**Setup:** `stamp context` respects preferences saved in `.logicstamp/config.json` and never prompts. On first run (no config), it defaults to skipping both `.gitignore` and `LLM_CONTEXT.md` setup for CI-friendly behavior. Use [`stamp init`](init.md) to configure these options (non-interactive by default; use `--no-secure` for interactive mode).
1515

16-
**File Exclusion:** `stamp context` respects `.stampignore` and excludes those files from context compilation. You'll see how many files were excluded (unless using `--quiet`). Use `stamp ignore <file>` to add files to `.stampignore`. `.stampignore` is completely optional and independent of security scanning. See [stampignore.md](../stampignore.md) for details.
16+
**File Exclusion:** `stamp context` respects `.stampignore` and excludes those files from context compilation. You'll see how many files were excluded (unless using `--quiet`). Use `stamp ignore <file>` to add files to `.stampignore`. `.stampignore` is completely optional and independent of security scanning. See [stampignore.md](../reference/stampignore.md) for details.
1717

1818
**Secret Sanitization:** If a security report (`stamp_security_report.json`) exists, `stamp context` automatically replaces detected secrets with `"PRIVATE_DATA"` in the generated JSON files. **Your source code files are never modified** - only the generated context files contain sanitized values. See [security-scan.md](security-scan.md) for details.
1919

@@ -187,9 +187,9 @@ Example `.stampignore`:
187187
}
188188
```
189189
190-
`.stampignore` is completely optional and can be created manually. It's independent of security scanning. See [stampignore.md](../stampignore.md) for complete documentation.
190+
`.stampignore` is completely optional and can be created manually. It's independent of security scanning. See [stampignore.md](../reference/stampignore.md) for complete documentation.
191191
192-
For complete documentation on `.stampignore` file format, see [stampignore.md](../stampignore.md).
192+
For complete documentation on `.stampignore` file format, see [stampignore.md](../reference/stampignore.md).
193193
194194
## Secret Sanitization
195195
@@ -205,8 +205,8 @@ When generating context files, LogicStamp automatically sanitizes secrets if a s
205205
206206
Source code:
207207
```typescript
208-
const apiKey = 'sk_live_1234567890abcdef';
209-
const password = 'mySecretPassword123';
208+
const apiKey = 'PLACEHOLDER_KEY_1234567890abcdef';
209+
const password = 'FAKE_PASSWORD_FOR_DOCS_12345678';
210210
```
211211
212212
Generated `context.json`:

docs/context/cli/ignore.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ This ensures consistent formatting regardless of how you specify paths.
181181
- `src/**/*.test.ts` - Matches all `.test.ts` files under `src/`
182182
- `config/*.json` - Matches all `.json` files directly in `config/`
183183

184-
See [stampignore.md](../stampignore.md) for more details on glob pattern syntax.
184+
See [stampignore.md](../reference/stampignore.md) for more details on glob pattern syntax.
185185

186186
## Best Practices
187187

@@ -193,7 +193,7 @@ See [stampignore.md](../stampignore.md) for more details on glob pattern syntax.
193193

194194
## See Also
195195

196-
- [stampignore.md](../stampignore.md) - Complete `.stampignore` file format and usage guide
196+
- [stampignore.md](../reference/stampignore.md) - Complete `.stampignore` file format and usage guide
197197
- [context.md](context.md) - How `.stampignore` affects context compilation
198198
- [security-scan.md](security-scan.md) - Security scanning to detect secrets in your codebase
199199

0 commit comments

Comments
 (0)