# shapelex - Doramagic AI Context Pack

> Positioning: a pre-install experience and judgment asset. It helps the host AI get off to a good start, but it does not mean the project has already been installed, run, or validated.

## Sufficiency Principle

- **Sufficiency over compression**: The AI Context Pack should be sufficient for the host AI to understand the project's value, capability boundaries, entrypoints, risks, and evidence sources before starting work; it may be layered, but it does not aim for the shortest possible summary.
- **Compression policy**: Compress only noise and duplication, never context that affects judgment or the quality of the work.

## How the Host AI Should Use This

You are reading the AI Context Pack that Doramagic compiled for shapelex. Treat it as pre-work context: help the user understand who it fits, what it can do, how to start, what must be verified after install, and where the risks are. Do not claim that you have already installed, run, or executed the target project.

## Claim Consumption Rules

- **Fact source**: Repo Evidence + Claim/Evidence Graph; the Human Wiki only supplies salience, terminology, and narrative structure.
- **Minimum status for a fact**: `supported`
- `supported`: May be used as a project fact, but the answer must cite the claim_id and evidence path.
- `weak`: Usable only as a low-confidence lead; the user must be asked to keep verifying.
- `inferred`: Usable only for risk notes or open questions; must not be packaged as a project fact.
- `unverified`: Must not be used as fact; state clearly that evidence is insufficient.
- `contradicted`: Must show the conflicting sources and must not force a single version on the user's behalf.

## Who It Fits Best

- **Developers already using host AIs such as Claude/Codex/Cursor/Gemini**: The README or plugin config mentions multiple host AIs. Evidence: `README.md` Claim: `clm_0003` supported 0.86
- **Users who want to bring professional workflows into a host AI**: The repo contains Skill documents. Evidence: `skills/shapelex-memory/SKILL.md` Claim: `clm_0004` supported 0.86

## What It Can Do

- **AI Skill / Agent Instruction Asset Library** (Previewable before install): The project contains Skill or Agent instruction files that a host AI can read, useful for bringing professional workflows into hosts like Claude, Codex, or Cursor. Evidence: `skills/shapelex-memory/SKILL.md` Claim: `clm_0001` supported 0.86
- **Command-Line Startup or Install Flow** (Verify after install): The project documentation contains runnable commands; real use requires running them in a local or host environment. Evidence: `README.md`, `docs/QUICKSTART.es.md` Claim: `clm_0002` supported 0.86

## How to Start

- `npx -y shapelex-mcp --doctor` Evidence: `README.md` Claim: `clm_0005` supported 0.86
- `npx -y shapelex-mcp` Evidence: `README.md` Claim: `clm_0005` supported 0.86, `clm_0006` supported 0.86, `clm_0007` supported 0.86, `clm_0008` supported 0.86 et al.
- `claude mcp add --transport stdio --env SHAPELEX_STORE_DIR=.shapelex-claude --env SHAPELEX_MAX_STORE_MB=100 shapelex -- npx -y shapelex-mcp` Evidence: `README.md` Claim: `clm_0007` supported 0.86
- `claude mcp add --transport stdio --env SHAPELEX_STORE_DIR=.shapelex-claude --env SHAPELEX_MAX_STORE_MB=100 shapelex -- cmd /c npx -y shapelex-mcp` Evidence: `README.md` Claim: `clm_0008` supported 0.86
- `git clone https://github.com/AldoDior/shapelex.git` Evidence: `README.md` Claim: `clm_0009` supported 0.86
- `npx -y shapelex-mcp@latest --doctor` Evidence: `docs/QUICKSTART.es.md` Claim: `clm_0010` supported 0.86
- `claude mcp add --scope local \` Evidence: `docs/QUICKSTART.es.md` Claim: `clm_0011` supported 0.86

## Continue-or-Stop Decision Card

- **Current recommendation**: Needs admin / security approval
- **Why**: Continuing may involve secrets, accounts, external services, or sensitive context; get admin or security approval first.

### 30-Second Read

- **What to do now**: Needs admin / security approval
- **Minimum safe next step**: Run Prompt Preview first; if credentials or an enterprise environment are involved, get approval before trialing
- **Do not trust yet**: Tool permission boundaries cannot be trusted before install.
- **Continuing will touch**: Command execution, Host AI configuration, Local environment or project files

### What You Can Trust Now

- **Target-audience signal: Developers already using host AIs such as Claude/Codex/Cursor/Gemini** (supported): Backed by a supported claim or project evidence, but that still is not the same as real install results. Evidence: `README.md` Claim: `clm_0003` supported 0.86
- **Target-audience signal: Users who want to bring professional workflows into a host AI** (supported): Backed by a supported claim or project evidence, but that still is not the same as real install results. Evidence: `skills/shapelex-memory/SKILL.md` Claim: `clm_0004` supported 0.86
- **Capability exists: AI Skill / Agent Instruction Asset Library** (supported): You can trust that the project contains signals of this capability; whether it fits your specific task still needs trial or after-install verification. Evidence: `skills/shapelex-memory/SKILL.md` Claim: `clm_0001` supported 0.86
- **Capability exists: Command-Line Startup or Install Flow** (supported): You can trust that the project contains signals of this capability; whether it fits your specific task still needs trial or after-install verification. Evidence: `README.md`, `docs/QUICKSTART.es.md` Claim: `clm_0002` supported 0.86
- **There are Quick Start / install-command signals** (supported): You can trust that the docs mention a startup or install entrypoint; do not run it directly in your primary environment because of that. Evidence: `README.md` Claim: `clm_0005` supported 0.86

### What You Cannot Trust Yet

- **Tool permission boundaries cannot be trusted before install.** (unverified): MCP/tool projects usually touch files, the network, the browser, or external APIs, so permissions and logs must be checked for real.
- **Real output quality cannot be trusted before install.** (unverified): Prompt Preview can only show how it guides you; it cannot prove result quality in the real project.
- **Host AI version compatibility cannot be trusted before install.** (unverified): Host loading rules and version differences across Claude, Cursor, Codex, Gemini, and others must be verified in a real environment.
- **That it will not pollute your existing host AI's behavior cannot be trusted directly.** (inferred): Skill, plugin, and AGENTS/CLAUDE/GEMINI instructions may change the host AI's default behavior. Evidence: `AGENTS.md`, `skills/shapelex-memory/SKILL.md`
- **Safe rollback cannot be assumed by default.** (unverified): Unless the project clearly provides uninstall and recovery instructions, verify in an isolated environment first.
- **After a real install, is it compatible with the user's current host AI version?** (unverified): Compatibility can only be verified in the actual host environment.
- **Does the project's output quality meet the user's specific task?** (unverified): The pre-install preview can only show flow and boundaries; it cannot replace real evaluation.
- **Do the install commands require network access, permissions, or global writes?** (unverified): This affects install risk in both enterprise and personal environments. Evidence: `README.md`

### What Continuing Will Touch

- **Command execution**: Package managers, network downloads, the local plugin directory, project config, or the user's home directory. Why: Running the very first command can already change your environment; decide whether it is worth running first. Evidence: `README.md`, `docs/QUICKSTART.es.md`
- **Host AI configuration**: The plugin, Skill, or rule-loading config of hosts like Claude/Codex/Cursor/Gemini/OpenCode. Why: Host configuration changes how the AI works afterward and may conflict with the user's existing rules. Evidence: `AGENTS.md`, `skills/shapelex-memory/SKILL.md`
- **Local environment or project files**: Install results, plugin caches, project config, or local dependency directories. Why: The write scope and rollback path cannot be proven before install and need isolated verification. Evidence: `README.md`, `docs/QUICKSTART.es.md`
- **Environment variables / API keys**: Project entry docs explicitly showing API key, token, secret, or account credential configuration. Why: If a real install needs credentials, use test credentials first and go through a permission/compliance review. Evidence: `README.md`
- **Host AI context**: The AI Context Pack, Prompt Preview, Skill routing, risk rules, and project facts. Why: Importing context affects the host AI's later judgment, so avoid packaging unverified items as facts.

### Minimum Safe Next Steps

- **Run Prompt Preview first**: Use a pre-install interactive trial to judge whether the way of working fits; it needs no authorization or environment change. (applies when: Applies to any project, especially when output quality is unknown.)
- **Trial-install only in an isolated directory or a test account**: Avoid letting install commands pollute your primary host AI, real projects, or home directory. (applies when: When there are signals of command execution, plugin config, or local writes.)
- **Back up your host AI configuration first**: Skill, plugin, and rule files may change the default behavior of Claude/Cursor/Codex. (applies when: When there is a plugin manifest, a Skill, or a host rule entrypoint.)
- **Do not use real production credentials**: Once an environment variable / API key enters the host or toolchain, it can create account and compliance risk. (applies when: When environment signals like API, TOKEN, KEY, or SECRET appear.)
- **After install, verify just one minimal task**: Verify loading, compatibility, output quality, and rollback first, then decide whether to use it deeply. (applies when: When moving from a trial into a real workflow.)

### Exit Plan

- **Preserve the pre-install state**: Record the original host config and project state so you can later judge whether it is recoverable.
- **Be ready to remove the host plugin / Skill / rule entrypoint**: If behavior is off after the trial install, you can restore the host AI to its pre-trial state.
- **Record the install commands and written paths**: Without clear uninstall instructions, you at least need to know which directories or configs to clean up manually.
- **Be ready to revoke test API keys or tokens**: If test credentials leak or are misused, you can cut losses quickly.
- **If there is no rollback path, do not enter your primary environment**: No rollback is a blocker before continuing; do not proceed on trust or luck.

## What Can Only Be Previewed

- Explain who the project fits and what it can do
- Demonstrate a typical conversation flow based on project docs
- Help the user decide whether it is worth installing or researching further

## What Must Be Verified After Install

- Actually installing the Skill, plugin, or CLI
- Running scripts, modifying local files, or accessing external services
- Verifying real output quality, performance, and compatibility

## Boundary & Risk Decision Card

- **Mistaking the pre-install preview for a real run**: The user may overestimate how much configuration, permission, and compatibility verification the project has already done. Mitigation: Clearly separate prompt_preview_can_do from runtime_required. Claim: `clm_0012` inferred 0.45
- **Command execution will modify the local environment**: Install commands may write to the user's home directory, the host plugin directory, or project configuration. Mitigation: Run in an isolated environment or a test account first. Evidence: `README.md`, `docs/QUICKSTART.es.md` Claim: `clm_0013` supported 0.86
- **To confirm**: After a real install, is it compatible with the user's current host AI version?. Why: Compatibility can only be verified in the actual host environment.
- **To confirm**: Does the project's output quality meet the user's specific task?. Why: The pre-install preview can only show flow and boundaries; it cannot replace real evaluation.
- **To confirm**: Do the install commands require network access, permissions, or global writes?. Why: This affects install risk in both enterprise and personal environments.

## Pre-Work Working Context

### Loading Order

- First read how_to_use.host_ai_instruction to establish the boundaries of this pre-install judgment asset.
- Read claim_graph_summary to confirm facts come from the Claim/Evidence Graph, not the Human Wiki narrative.
- Then read intended_users, capabilities, and quick_start_candidates to judge whether the user is a match.
- When you need to carry out a concrete task, check role_skill_index first, then evidence_index.
- For real install, file modification, network access, performance, or compatibility questions, turn to risk_card and boundaries.runtime_required.

### Task Routes

- **AI Skill / Agent Instruction Asset Library**: Use role_skill_index / evidence_index to help the user pick a usable role, Skill, or workflow first. Boundary: Can be experienced via a pre-install Prompt. Evidence: `skills/shapelex-memory/SKILL.md` Claim: `clm_0001` supported 0.86
- **Command-Line Startup or Install Flow**: State that this is an after-install capability first, then give a pre-install checklist. Boundary: Must be verified after a real install or run. Evidence: `README.md`, `docs/QUICKSTART.es.md` Claim: `clm_0002` supported 0.86

### Context Scale

- Total files: 84
- Important-file coverage: 40/84
- Evidence index entries: 56
- Role / Skill entries: 1

### Handling Insufficient Evidence

- **missing_evidence**: State that evidence is insufficient and ask the user for the target file, a README section, or after-install verification records; do not fill in facts.
- **out_of_scope_request**: State that the task is beyond the current AI Context Pack's evidence scope and suggest the user check the Human Manual or verify after a real install.
- **runtime_request**: Provide a pre-install checklist and command sources, but do not run commands for the user or claim they have been run.
- **source_conflict**: Show the conflicting sources side by side, mark them as unverified, and do not force a single version.

## Prompt Recipes

### Fit assessment

- Goal: Judge whether this project fits the user's current task.
- Expected output: A fit conclusion, key reasons, evidence citations, what can be previewed before install, what must be verified after install, and a next-step recommendation.

```text
Based on the AI Context Pack for shapelex, ask me 3 necessary questions first, then judge whether it fits my task. The answer must cover: who it fits, what it can do, what it cannot do, whether it is worth installing, and where the evidence comes from. Every project fact must cite evidence_refs, source_paths, or a claim_id.
```

### Pre-install experience

- Goal: Let the user feel the core workflow before installing, while avoiding packaging the preview as real capability or a marketing promise.
- Expected output: An experience script with boundary labels, an after-install verification checklist, and a cautious recommendation; with no real-run promises or strong marketing language.

```text
Treat shapelex as a pre-install experience asset, not an already-installed tool or a real runtime environment.

Output exactly four parts:
1. Ask me 3 necessary questions first.
2. Give an "experience script": use the three labels [Previewable before install], [Must verify after install], and [Insufficient evidence] to show how it might guide the workflow.
3. Give an after-install verification checklist: list which capabilities can only be confirmed after a real install, real host loading, and a real project run.
4. Give a cautious recommendation: only "worth researching/trialing further", "add information before deciding", or "not recommended to continue"; do not endorse the project.

Hard boundaries:
- Do not claim you have installed, run, executed tests, modified files, or produced real results.
- Do not write promise-like phrasing such as "auto-adapts", "guarantees passing", "perfect fit", or "strongly recommend installing".
- If you describe how it works after install, you must use a conditional such as "if installed successfully and the host loads the Skill correctly, it might...".
- The experience script may only be written as "example lines / hypothetical flow": use "might ask / might suggest / might show", not "has written, has generated, has passed, is running, is generating".
- Prompt Preview does not hand out install commands; if the user is ready to trial, only prompt them to read Quick Start and the Risk Card first and to verify in an isolated environment.
- Every project fact must come from a supported claim, evidence_refs, or source_paths; inferred/unverified items can only be risks or open questions.

```

### Role / Skill selection

- Goal: Pick the best-matching asset from the project's roles or Skills.
- Expected output: A list of candidate roles or Skills, each with an applicable scenario, evidence paths, risk boundary, and whether after-install verification is needed.

```text
Read role_skill_index and recommend 3-5 of the most relevant roles or Skills for my target task. For each recommendation, state the applicable scenario, likely output, risk boundary, and evidence_refs.
```

### Risk pre-check

- Goal: Identify environment, permission, rule-conflict, and quality risks before installing or adopting.
- Expected output: A checklist of environment, permission, dependency, license, host-conflict, quality risk, and unknown items.

```text
Based on risk_card, boundaries, and quick_start_candidates, give me a pre-install risk pre-check list. Do not run commands for me; only explain what I should check, why, and what impact a failure would have.
```

### Host AI kickoff instruction

- Goal: Turn the project context into a host AI instruction for the start of a conversation.
- Expected output: A pre-work instruction with clear boundaries and clear evidence citations, suitable to copy to a host AI.

```text
Based on the AI Context Pack for shapelex, generate a pre-work instruction I can paste to my host AI. This instruction must obey not_runtime=true and must not claim the project has been installed, run, or produced real results.
```

## Role / Skill Index

- Indexed 1 role / Skill / project-doc entries.

- **shapelex-memory** (skill): Use ShapeLex MCP memory to reduce token usage while preserving model quality. Use when working with long pasted context, repeated project notes, old conversation history, large documents, policies, logs, or code snippets where an agent should compress context into sx:// handles, search/retrieve compressed memory, and expand exact text before relying on numbers, negations, instructions, code, or user intent. Activation hint: When the user's task is highly relevant to the workflow described by “shapelex-memory”, use it for a pre-install experience first, then decide whether to install. Evidence: `skills/shapelex-memory/SKILL.md`

## Evidence Index

- Indexed 56 evidence entries.

- **ShapeLex** (documentation): New to ShapeLex? Start with the English quick start docs/QUICKSTART.md for Codex, Cursor, and Claude Code. ¿Primera vez con ShapeLex? Empieza con la guía rápida en español docs/QUICKSTART.es.md para Codex, Cursor y Claude Code. Evidence: `README.md`
- **Package** (package_manifest): { "name": "shapelex-mcp", "version": "0.6.0", "description": "Local MCP navigable memory for reducing LLM read-token usage.", "type": "module", "main": "./dist/src/shapelex.js", "types": "./dist/src/shapelex.d.ts", "homepage": "https://github.com/AldoDior/shapelex readme", "repository": { "type": "git", "url": "git+https://github.com/AldoDior/shapelex.git" }, "bugs": { "url": "https://github.com/AldoDior/shapelex/issues" }, "files": "bin/", "docs/", "dist/src/fingerprint/ .d.ts", "dist/src/fingerprint/ .js", "dist/src/mcp-server.d.ts", "dist/src/mcp-server.js", "dist/src/shapelex-doctor.d.ts", "dist/src/shapelex-doctor.js", "dist/src/shapelex.d.ts", "dist/src/shapelex.js", "dist/src/storage… Evidence: `package.json`
- **ShapeLex Memory** (skill_instruction): Use ShapeLex proactively as a navigable memory layer, not as lossy reconstruction. ShapeLex is agent-driven by default: decide when it helps, and do not wait for the user to say "use ShapeLex" during long or repeated-context work. Prefer exact source text when the context is short or when compressed output fails to save tokens. Evidence: `skills/shapelex-memory/SKILL.md`
- **Agent Instructions** (documentation): These instructions apply to the entire repository. Evidence: `AGENTS.md`
- **ShapeLex Agent Instructions** (documentation): Use this as a persistent project instruction in Codex, Claude Code, Cursor, or any agent that can use the ShapeLex MCP server. Evidence: `docs/AGENT_INSTRUCTIONS.md`
- **Agent Setup Prompt** (documentation): Copy one of these prompts into Codex, Claude Code, or Cursor if you want the AI agent to help you set up ShapeLex. Evidence: `docs/AGENT_SETUP_PROMPT.md`
- **Guía Rápida De ShapeLex** (documentation): Esta guía está dirigida a personas que quieren usar ShapeLex con Codex, Cursor o Claude Code sin tener que comprender los detalles internos de MCP. Evidence: `docs/QUICKSTART.es.md`
- **ShapeLex Quick Start** (documentation): This guide is for people who want to use ShapeLex with Codex, Cursor, or Claude Code without needing to understand MCP internals. Evidence: `docs/QUICKSTART.md`
- **Contributing** (documentation): Thanks for helping improve ShapeLex. Evidence: `CONTRIBUTING.md`
- **License** (source_file): Copyright c 2026 ShapeLex contributors Evidence: `LICENSE`
- **Guía De Uso De ShapeLex** (documentation): Esta guía está escrita para personas que no necesariamente tienen experiencia técnica. Si ya sabes usar Node, npm y MCP, puedes ir directo a la sección de tu app: Codex, Claude Code o Cursor. Evidence: `docs/USAGE.es.md`
- **ShapeLex Usage** (documentation): ShapeLex is a local MCP server that stores exact source text in a private local JSON store and returns compact sx:// handles. It should be agent-driven after setup: the agent decides when it helps, uses compact context first, and expands exact handles when details matter. Evidence: `docs/USAGE.md`
- **ShapeLex Cursor Rule** (documentation): Use ShapeLex proactively for long-session memory. ShapeLex is agent-driven by default: decide when it helps and do not wait for the user to say "use ShapeLex". Evidence: `docs/cursor-rule.md`
- **Mcp Server** (source_file): import process from "node:process"; import { DEFAULT MAX STORE BYTES, ShapeLexEngine } from "./shapelex.js"; import { PACKAGE VERSION } from "./version.js"; ⋮---- export function createEngineFromEnvironment environment: any = process.env, cwd = process.cwd ⋮---- export function startMcpServer { input = process.stdin, output = process.stdout, maxLineCharacters = DEFAULT MAX JSON RPC LINE CHARACTERS, targetEngine = engine, toolset = defaultToolset }: any = ⋮---- const enqueueLine = line: string undefined = ⋮---- export function createJsonRpcHandler targetEngine: ShapeLexEngine, ⋮---- async function dispatch targetEngine: ShapeLexEngine, activeTools: any , method: any, params: any : Promise ⋮-… Evidence: `src/mcp-server.ts`
- **Protocol Ledger** (source_file): import { createJsonRpcHandler } from "./mcp-server.js"; import { ShapeLexEngine, estimateTokens } from "./shapelex.js"; ⋮---- export interface TokenLedgerEntry { id: string; rawPromptTokens: number; toolSchemaTokens: number; requestTokens: number; responseTokens: number; expansionTokens: number; requiredFacts: readonly string ; recoveredFacts: readonly string ; } ⋮---- export interface TokenLedgerSummary { cases: number; aggregateReduction: number; medianReduction: number; requiredFactFidelity: number; regressions: string ; rawTokens: number; shapeLexTokens: number; } ⋮---- export interface OfflineProtocolReport { methodology: { followUpTurns: number; schemaTokensPerTurn: number; tokenEstim… Evidence: `src/protocol-ledger.ts`
- **Shapelex Doctor** (source_file): import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import process from "node:process"; import { fileURLToPath } from "node:url"; import { createJsonRpcHandler } from "./mcp-server.js"; import { ShapeLexEngine } from "./shapelex.js"; import { PACKAGE VERSION } from "./version.js"; ⋮---- type Check = { name: string; ok: boolean; message: string; }; ⋮---- export async function runDoctor ⋮---- export function renderDoctorReport report: Awaited ⋮---- function checkNodeVersion : Check ⋮---- function checkPackageVersion packageRoot: string : Check ⋮---- function checkFile cwd: string, relativePath: string, message: string : Check ⋮---- function checkGitignore cwd: st… Evidence: `src/shapelex-doctor.ts`
- **Shapelex E2E Eval** (source_file): import { createJsonRpcHandler } from "./mcp-server.js"; import { estimateTokens, ShapeLexEngine } from "./shapelex.js"; ⋮---- type Scenario = { name: string; sessionId: string; task: string; context: string; query: string; requiredFacts: Array ; generateCode: prompt: string = string; qualityChecks: Array boolean } ; }; ⋮---- export async function runE2EEval ⋮---- async function toolSchemaTokens toolset: "lean" "full" ⋮---- function renderRawPrompt scenario: Scenario ⋮---- function renderShapeLexPrompt scenario: Scenario, compressed: any, context: any ⋮---- async function callTool handleJsonRpc: request: any = Promise , name: string, args: any ⋮---- function factCoverage prompt: string, scen… Evidence: `src/shapelex-e2e-eval.ts`
- **Shapelex Smoke Eval** (source_file): import { createJsonRpcHandler } from "./mcp-server.js"; import { estimateTokens, ShapeLexEngine } from "./shapelex.js"; ⋮---- export async function runSmokeEval ⋮---- async function callTool handleJsonRpc: request: any = Promise , name: string, args: any ⋮---- function factCoverage prompt: string ⋮---- function decideImplementation prompt: string ⋮---- function tokenSavings rawTokens: number, compressedTokens: number Evidence: `src/shapelex-smoke-eval.ts`
- **Shapelex** (source_file): import crypto from "node:crypto"; import fs from "node:fs"; import path from "node:path"; import { LEXICAL PROFILE, LazyFingerprintIndex, type FingerprintMatchAlignment, type FingerprintMatchWindow, type MatchResult } from "./fingerprint/index.js"; import { StoreBusyError, StoreRevisionConflictError, TransactionalStoreV2, sourceRecordFromMaterial, type StoreSourceRecord } from "./storage/index.js"; ⋮---- export interface CompactMatch { uri: string; matchKind: "exact" "normalized equal" "strong related" "related reordered" "related" "keyword" "unrelated"; score: number; exact: boolean; mustExpand: boolean; criticalDiff: boolean; } ⋮---- function staleSourceError message: string, cause?: unkn… Evidence: `src/shapelex.ts`
- **Version** (source_file): import fs from "node:fs"; ⋮---- interface PackageMetadata { name?: unknown; version?: unknown; } ⋮---- function readPackageVersion : string Evidence: `src/version.ts`
- **Lazy Index** (source_file): import { sha256Hex } from "./exact.js"; import { classifyFingerprintDocuments, isKeywordFallback, scoreFingerprintMatch } from "./matcher.js"; import { buildBoundedFingerprintDocument, buildFingerprintDocument } from "./profile.js"; import { LEXICAL PROFILE, type Fingerprint, type FingerprintDocument, type MatchResult } from "./types.js"; ⋮---- export type FingerprintText = string Uint8Array; export type FingerprintTextProvider = = FingerprintText; ⋮---- export interface FingerprintIndexLimits { maxPostingsPerHash: number; maxFingerprintsPerDocument: number; maxQueryFingerprints: number; maxColdDocumentsPerQuery: number; maxCandidateDocuments: number; maxVerificationsPerQuery: number; maxEs… Evidence: `src/fingerprint/lazy-index.ts`
- **Matcher** (source_file): import { detectCriticalDifference } from "./critical-diff.js"; import { verifyExactBytes } from "./exact.js"; import { buildFingerprintDocument } from "./profile.js"; import type { Fingerprint, FingerprintDocument, MatchKind, MatchMetrics, MatchResult, MatchThresholds } from "./types.js"; ⋮---- export function scoreFingerprintMatch query: FingerprintDocument, candidate: FingerprintDocument : MatchMetrics ⋮---- export function classifyFingerprintMatch queryText: string Uint8Array, candidateText: string Uint8Array, thresholds: Readonly = DEFAULT MATCH THRESHOLDS : MatchResult ⋮---- export function classifyFingerprintDocuments query: FingerprintDocument, candidate: FingerprintDocument, queryBy… Evidence: `src/fingerprint/matcher.ts`
- **Normalize** (source_file): import type { NormalizedText, NormalizedUnit } from "./types.js"; ⋮---- export function normalizeStrict input: string : NormalizedText ⋮---- export function normalizeRecall input: string NormalizedText : NormalizedText ⋮---- export function normalizeCanonicalAsciiRecallText strict: NormalizedText : string undefined ⋮---- function normalizeStrictAscii input: string : NormalizedText ⋮---- function normalizeRecallAscii strict: NormalizedText : NormalizedText ⋮---- function isAsciiWhitespace code: number : boolean ⋮---- function appendMappedValue units: NormalizedUnit , value: string, rawByteStart: number, rawByteEnd: number, initialNormalizedOffset: number : void ⋮---- / c8 ignore next -- defe… Evidence: `src/fingerprint/normalize.ts`
- **Profile** (source_file): import { sha256Hex } from "./exact.js"; import { hashToHex, type HashableUnit } from "./hash.js"; import { normalizeCanonicalAsciiRecallText, normalizeRecall, normalizeStrict } from "./normalize.js"; import { tokenizeStrict } from "./tokenize.js"; import { LEXICAL PROFILE, type Fingerprint, type FingerprintChannel, type FingerprintDocument, type HashedNgram } from "./types.js"; import { winnowRollingNgrams, winnowRollingNgramsBounded, winnowIdentityAsciiTextBounded, winnowMappedAsciiTextBounded, type BoundedWinnowResult } from "./winnow.js"; ⋮---- export interface BoundedFingerprintDocument { document: FingerprintDocument; complete: boolean; } ⋮---- export function buildFingerprintDocument… Evidence: `src/fingerprint/profile.ts`
- **Tokenize** (source_file): import { normalizeStrict } from "./normalize.js"; import type { NormalizedText, NormalizedUnit, StrictToken, StrictTokenKind } from "./types.js"; ⋮---- export function tokenizeStrict input: string NormalizedText : StrictToken ⋮---- function tokenizeAscii normalized: NormalizedText : StrictToken ⋮---- function tokenizeAsciiText text: string, create: text: string, start: number, end: number, kind: StrictTokenKind = StrictToken : StrictToken ⋮---- function createIdentityToken text: string, start: number, end: number, kind: StrictTokenKind : StrictToken ⋮---- function isAsciiWhitespace code: number : boolean ⋮---- function isAsciiNumber code: number : boolean ⋮---- function isAsciiWordScalar co… Evidence: `src/fingerprint/tokenize.ts`
- **Types** (source_file): export type FingerprintChannel = "token" "character"; ⋮---- export type StrictTokenKind = "word" "number" "operator" "punctuation"; ⋮---- export interface SourceRange { normalizedStart: number; normalizedEnd: number; rawByteStart: number; rawByteEnd: number; } ⋮---- export interface NormalizedUnit extends SourceRange { value: string; } ⋮---- export interface NormalizedText { text: string; units: NormalizedUnit ; rawByteLength: number; } ⋮---- export interface StrictToken extends SourceRange { value: string; kind: StrictTokenKind; } ⋮---- export interface HashedNgram { hash: bigint; position: number; endPosition: number; rawByteStart: number; rawByteEnd: number; } ⋮---- export interface Fing… Evidence: `src/fingerprint/types.ts`
- **Store V2** (source_file): import crypto from "node:crypto"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; ⋮---- export type SourceOrigin = { kind: "text"; sessionId: string; documentId: string; } { kind: "file"; sessionId: string; documentId: string; relativePath: string; }; ⋮---- export interface SourceMaterial { bytes: Uint8Array; origin: SourceOrigin; legacyChecksum?: string; } ⋮---- export interface StoreSourceRecord { sourceId: string; checksumAlgorithm: typeof STORE V2 CHECKSUM ALGORITHM; sha256: string; byteLength: number; mediaType: "text/utf8"; text?: string; origins: SourceOrigin ; legacyChecksums: string ; } ⋮---- export interface LazyIndexManifest { strategy: "lazy-mem… Evidence: `src/storage/store-v2.ts`
- **Property Profile** (source_file): import process from "node:process"; ⋮---- export interface PropertyProfile { numRuns: number; seed: number; nightly: boolean; } ⋮---- function readBoundedInteger environment: NodeJS.ProcessEnv, name: string, fallback: number, maximum: number : number ⋮---- export function getPropertyProfile environment: NodeJS.ProcessEnv = process.env : PropertyProfile ⋮---- export function propertyFailureContext profile: PropertyProfile : string Evidence: `test/v06/property-profile.ts`
- **Changelog** (documentation): - Added bilingual quick-start guides for Codex, Cursor, and Claude Code, with prominent README links and safe upgrade instructions. Evidence: `CHANGELOG.md`
- **Security Policy** (documentation): ShapeLex is early software. Security fixes are applied to the latest published version. Evidence: `SECURITY.md`
- **.C8Rc** (structured_config): { "all": true, "include": "dist/src/fingerprint/ / .js", "dist/src/storage/ / .js" , "exclude": "dist/ / .d.ts", "dist/test/ " , "reporter": "text", "html", "json-summary" , "reports-dir": "coverage/v06", "check-coverage": true, "lines": 95, "branches": 90, "functions": 100, "statements": 95 } Evidence: `.c8rc.json`
- **Mcp** (structured_config): { "mcpServers": { "shapelex": { "command": "node", "args": "./bin/shapelex-mcp.js" , "env": { "SHAPELEX STORE DIR": ".shapelex-cursor", "SHAPELEX MAX STORE MB": "100", "SHAPELEX TOOLSET": "lean" } } } } Evidence: `.cursor/mcp.json`
- **.Mcp** (structured_config): { "mcpServers": { "shapelex": { "command": "node", "args": "./bin/shapelex-mcp.js" , "env": { "SHAPELEX STORE DIR": ".shapelex-claude", "SHAPELEX MAX STORE MB": "100", "SHAPELEX TOOLSET": "lean" } } } } Evidence: `.mcp.json`
- **Tsconfig** (structured_config): { "compilerOptions": { "target": "ES2022", "module": "NodeNext", "moduleResolution": "NodeNext", "lib": "ES2022" , "types": "node" , "outDir": "dist", "declaration": true, "sourceMap": true, "strict": false, "noEmitOnError": true, "forceConsistentCasingInFileNames": true, "skipLibCheck": true }, "include": "src/ / .ts", "test/ / .ts" } Evidence: `tsconfig.json`
- **Tsconfig.Strict** (structured_config): { "extends": "./tsconfig.json", "compilerOptions": { "noEmit": true, "strict": true, "noUncheckedIndexedAccess": true, "noImplicitOverride": true, "useUnknownInCatchVariables": true }, "include": "src/fingerprint/ / .ts", "src/storage/ / .ts", "test/v06/ / .ts" , "exclude": "test/v06/offline-token-ledger.ts", "test/v06/offline-token-ledger.test.ts", "test/v06/torture.nightly.test.ts", "test/v06/store-concurrency-worker.ts" } Evidence: `tsconfig.strict.json`
- **Config** (source_file): mcp servers.shapelex command = "node" args = "./bin/shapelex-mcp.js" cwd = ".." startup timeout sec = 10 tool timeout sec = 60 default tools approval mode = "approve" Evidence: `.codex/config.toml`
- **Dependencies** (source_file): Logs logs/ .log codex-live- .txt codex-shapelex-smoke-output.txt npm-debug.log yarn-debug.log yarn-error.log pnpm-debug.log Evidence: `.gitignore`
- **Provider Ab** (source_file): export type ProviderVariant = "raw" "shapelex" "native compaction"; ⋮---- export interface ProviderABCase { id: string; requiredFacts: readonly string ; prompts: Record ; } ⋮---- export interface ProviderInvocation { caseId: string; variant: ProviderVariant; prompt: string; } ⋮---- export interface ProviderInvocationResult { output: string; inputTokens: number; outputTokens: number; } ⋮---- export type ProviderInvoker = invocation: ProviderInvocation = Promise ; ⋮---- export interface ProviderABResult { caseId: string; variant: ProviderVariant; inputTokens: number; outputTokens: number; factFidelity: number; } ⋮---- export async function runProviderAB cases: readonly ProviderABCase , { invo… Evidence: `src/provider-ab.ts`
- **Release Lint** (source_file): import { execFileSync } from "node:child process"; import fs from "node:fs"; import path from "node:path"; import process from "node:process"; ⋮---- function checkTrackedFiles ⋮---- function checkPackageMetadata ⋮---- function checkTextFiles Evidence: `src/release-lint.ts`
- **Run Tests** (source_file): import fs from "node:fs"; import path from "node:path"; import process from "node:process"; import { spawnSync } from "node:child process"; ⋮---- function collectTestFiles directory: string : string Evidence: `src/run-tests.ts`
- **Shapelex Agent Adoption Eval** (source_file): import process from "node:process"; import { createJsonRpcHandler } from "./mcp-server.js"; import { estimateTokens, ShapeLexEngine } from "./shapelex.js"; ⋮---- type AgentScenario = { name: string; userPrompt: string; context: string; expectedUsesShapeLex: boolean; expectedTool?: "shapelex compress text" "shapelex compress messages" "shapelex context"; expectedSuggestions?: string ; }; ⋮---- type AgentDecision = { usesShapeLex: boolean; plannedTools: string ; suggestions: string ; userNotice: string null; reason: string; rawPromptTokens: number; estimatedAfterShapeLexTokens: number; estimatedSavingsRatio: number; }; ⋮---- export async function runAgentAdoptionEval ⋮---- function simulateAg… Evidence: `src/shapelex-agent-adoption-eval.ts`
- **Shapelex Benchmark** (source_file): import process from "node:process"; import { runOfflineProtocolEvaluation } from "./protocol-ledger.js"; ⋮---- export async function runBenchmark Evidence: `src/shapelex-benchmark.ts`
- **Shapelex Provider Ab Eval** (source_file): import fs from "node:fs"; import path from "node:path"; import process from "node:process"; import { createEnvironmentHttpInvoker, runProviderAB, type ProviderABCase } from "./provider-ab.js"; ⋮---- function readCases filePath: string : ProviderABCase ⋮---- function positiveInteger value: string, name: string : number Evidence: `src/shapelex-provider-ab-eval.ts`
- **Agent Adoption Eval.Test** (source_file): import assert from "node:assert/strict"; import test from "node:test"; import { runAgentAdoptionEval } from "../src/shapelex-agent-adoption-eval.js"; Evidence: `test/agent-adoption-eval.test.ts`
- **Benchmark.Test** (source_file): import assert from "node:assert/strict"; import test from "node:test"; import { runBenchmark } from "../src/shapelex-benchmark.js"; Evidence: `test/benchmark.test.ts`
- **Doctor.Test** (source_file): import assert from "node:assert/strict"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import test from "node:test"; import { renderDoctorReport, runDoctor } from "../src/shapelex-doctor.js"; Evidence: `test/doctor.test.ts`
- **E2E Eval.Test** (source_file): import assert from "node:assert/strict"; import test from "node:test"; import { runE2EEval } from "../src/shapelex-e2e-eval.js"; Evidence: `test/e2e-eval.test.ts`
- **Fingerprint Core.Test** (source_file): import assert from "node:assert/strict"; import test from "node:test"; import { LEXICAL PROFILE, buildBoundedFingerprintDocument, buildFingerprintDocument, classifyFingerprintDocuments, classifyFingerprintMatch, detectCriticalDifference, extractCriticalElements, hashString64, hashToHex, normalizeRecall, normalizeStrict, referenceNgramHash, rollingNgrams, sha256Hex, scoreFingerprintMatch, tokenizeStrict, verifyExactBytes, winnow, winnowRollingNgrams, type FingerprintDocument, type HashableUnit, type HashedNgram, type MatchThresholds } from "../src/fingerprint/index.js"; ⋮---- function makeHashableUnits values: readonly string : HashableUnit ⋮---- function makeNgrams hashes: readonly bigint :… Evidence: `test/fingerprint-core.test.ts`
- **Fingerprint Index.Test** (source_file): import assert from "node:assert/strict"; import test from "node:test"; import { DEFAULT INDEX LIMITS, LazyFingerprintIndex } from "../src/fingerprint/index.js"; ⋮---- const create = ids: readonly string = Evidence: `test/fingerprint-index.test.ts`
- **Mcp Config.Test** (source_file): import assert from "node:assert/strict"; import fs from "node:fs"; import test from "node:test"; Evidence: `test/mcp-config.test.ts`
- **Mcp V06 Contract.Test** (source_file): import assert from "node:assert/strict"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { PassThrough } from "node:stream"; import test from "node:test"; import { createJsonRpcHandler, startMcpServer } from "../src/mcp-server.js"; import { ShapeLexEngine } from "../src/shapelex.js"; import { PACKAGE VERSION } from "../src/version.js"; Evidence: `test/mcp-v06-contract.test.ts`
- **Shapelex V06 Integration.Test** (source_file): import assert from "node:assert/strict"; import crypto from "node:crypto"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import test from "node:test"; import { createJsonRpcHandler } from "../src/mcp-server.js"; import { ShapeLexEngine } from "../src/shapelex.js"; Evidence: `test/shapelex-v06-integration.test.ts`
- **Shapelex.Test** (source_file): import assert from "node:assert/strict"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import test from "node:test"; import { ShapeLexEngine, charShape, estimateTokens, fingerprintTokens } from "../src/shapelex.js"; import { createEngineFromEnvironment, createJsonRpcHandler, handleJsonRpc } from "../src/mcp-server.js"; Evidence: `test/shapelex.test.ts`
- **Smoke Eval.Test** (source_file): import assert from "node:assert/strict"; import test from "node:test"; import { runSmokeEval } from "../src/shapelex-smoke-eval.js"; Evidence: `test/smoke-eval.test.ts`
- **Store V2 Validation.Test** (source_file): import assert from "node:assert/strict"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import test from "node:test"; import { StoreBusyError, StoreFormatError, StoreRevisionConflictError, TransactionalStoreV2, migrateV1Store, parseStoreEnvelope, sourceRecordFromMaterial } from "../src/storage/index.js"; ⋮---- enumerateSources ⋮---- onBeforeRename ⋮---- function withTemporaryDirectory run: directory: string = void : void Evidence: `test/store-v2-validation.test.ts`
- **Store V2.Test** (source_file): import assert from "node:assert/strict"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import test from "node:test"; import { StoreBusyError, StoreFormatError, StoreRevisionConflictError, StoreSizeLimitError, TransactionalStoreV2, UnsupportedStoreVersionError, migrateV1Store, parseStoreEnvelope, sha256Hex } from "../src/storage/index.js"; ⋮---- interface TestSession { id: string; nextDocument?: number; documents?: Array ; handles?: string ; } ⋮---- resolveFileSource context ⋮---- onBeforeRename ⋮---- function withTemporaryDirectory run: directory: string = void : void ⋮---- function errnoError code: string : NodeJS.ErrnoException Evidence: `test/store-v2.test.ts`

## Rules the Host AI Must Follow

- **Treat this asset as pre-work context, not a runtime environment.**: The AI Context Pack contains only an evidence-backed understanding of the project, not the project's executable state. Evidence: `README.md`, `package.json`, `skills/shapelex-memory/SKILL.md`
- **When answering the user, distinguish what can be previewed from what can only be verified after install.**: The consumer value of the pre-install experience comes from reducing bad installs and misjudgments, not from pretending to be a real run. Evidence: `README.md`, `package.json`, `skills/shapelex-memory/SKILL.md`

## Questions the User Should Answer First

- Which host AI or local environment do you plan to use it in?
- Do you just want to experience the workflow first, or are you ready to actually install?
- What matters most to you: install cost, output quality, or conflicts with your existing rules?

## Acceptance Checks

- Every capability claim can be traced back to a file path in evidence_refs.
- AI_CONTEXT_PACK.md does not package previews as a real run.
- The user can understand who it fits, what it can do, how to start, and the risk boundaries within 3 minutes.

---

## Doramagic Context Augmentation

The following sections strengthen the repository context for a host AI. Human Manual data is a reading route, and pitfall notes become operating constraints.

## Human Manual Outline

Usage rule: this is only a reading route and salience signal, not factual authority. Concrete claims must still return to repo evidence or Claim Graph.

Host AI hard rules:
- Do not treat page titles, section order, summaries, or importance values as factual project evidence.
- When explaining the Human Manual outline, state that it is only a reading route or salience signal.
- Capability, installation, compatibility, runtime state, and risk claims must cite repo evidence, source paths, or Claim Graph.

- **Introduction and Quick Start**: importance `high`
  - source_paths: README.md, docs/QUICKSTART.md, docs/QUICKSTART.es.md, docs/AGENT_SETUP_PROMPT.md, docs/AGENT_INSTRUCTIONS.md
- **MCP Server Architecture and Toolset**: importance `high`
  - source_paths: src/mcp-server.ts, src/shapelex.ts, src/version.ts, bin/shapelex-mcp.js, package.json
- **Fingerprint Retrieval, Hierarchy, and Token Accounting**: importance `high`
  - source_paths: src/fingerprint/index.ts, src/fingerprint/types.ts, src/fingerprint/profile.ts, src/fingerprint/tokenize.ts, src/fingerprint/normalize.ts
- **Storage, Persistence, Privacy, and Evaluation**: importance `high`
  - source_paths: src/storage/index.ts, src/storage/store-v2.ts, src/protocol-ledger.ts, src/shapelex-doctor.ts, src/shapelex-smoke-eval.ts

## Repo Inspection Evidence

- repo_clone_verified: true
- repo_inspection_verified: true
- repo_commit: `edc252d6b1805fe790b9134d333bef46a9fb5a47`
- inspected_files: `README.md`, `package.json`, `docs/AGENT_INSTRUCTIONS.md`, `docs/AGENT_SETUP_PROMPT.md`, `docs/QUICKSTART.es.md`, `docs/QUICKSTART.md`, `docs/USAGE.es.md`, `docs/USAGE.md`, `docs/cursor-rule.md`, `src/fingerprint/critical-diff.ts`, `src/fingerprint/exact.ts`, `src/fingerprint/hash.ts`, `src/fingerprint/index.ts`, `src/fingerprint/lazy-index.ts`, `src/fingerprint/matcher.ts`, `src/fingerprint/normalize.ts`, `src/fingerprint/profile.ts`, `src/fingerprint/tokenize.ts`, `src/fingerprint/types.ts`, `src/fingerprint/winnow.ts`

Host AI hard rules:
- Without repo_clone_verified=true, do not claim that the source code has been read.
- Without repo_inspection_verified=true, do not write README, docs, or package-file conclusions as facts.
- Without quick_start_verified=true, do not claim that the Quick Start path has run successfully.

## Doramagic Pitfall Constraints

These rules come from Doramagic discovery, validation, or compilation findings. The host AI must treat them as operating constraints, not background notes.

### Constraint 1: Capability evidence risk requires verification

- Trigger: README/documentation is current enough for a first validation pass.
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: capability.assumptions | https://github.com/AldoDior/shapelex
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 2: Security or permission risk requires verification

- Trigger: no_demo
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: downstream_validation.risk_items | https://github.com/AldoDior/shapelex
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 3: Security or permission risk requires verification

- Trigger: no_demo
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: risks.scoring_risks | https://github.com/AldoDior/shapelex
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 4: Maintenance risk requires verification

- Trigger: issue_or_pr_quality=unknown。
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: evidence.maintainer_signals | https://github.com/AldoDior/shapelex
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 5: Maintenance risk requires verification

- Trigger: release_recency=unknown。
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: evidence.maintainer_signals | https://github.com/AldoDior/shapelex
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.
