# memgrep - 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 memgrep. 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_0002` supported 0.86

## What It Can Do

- **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` Claim: `clm_0001` supported 0.86

## How to Start

- `npm install -g memgrep` Evidence: `README.md` Claim: `clm_0003` supported 0.86
- `npx memgrep index ./docs` Evidence: `README.md` Claim: `clm_0004` supported 0.86
- `npx memgrep search "how do I configure auth?"` Evidence: `README.md` Claim: `clm_0005` 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**: Real output quality cannot be trusted before install.
- **Continuing will touch**: Command execution, Local environment or project files, Environment variables / API keys

### 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_0002` 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` Claim: `clm_0001` 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_0003` supported 0.86

### What You Cannot Trust Yet

- **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.
- **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`
- **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`
- **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.)
- **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.
- **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_0006` 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` Claim: `clm_0007` 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

- **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` Claim: `clm_0001` supported 0.86

### Context Scale

- Total files: 92
- Important-file coverage: 40/92
- Evidence index entries: 53
- Role / Skill entries: 2

### 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 memgrep, 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 memgrep 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 memgrep, 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 2 role / Skill / project-doc entries.

- **memgrep** (project_doc): Local agent memory - Cursor from your phone - scheduled playbooks. Activation hint: Reference this when the user needs to understand the project's structure, install path, or boundaries. Evidence: `README.md`
- **Changelog** (project_doc): All notable changes to this project are documented in this file. Activation hint: Reference this when the user needs to understand the project's structure, install path, or boundaries. Evidence: `CHANGELOG.md`

## Evidence Index

- Indexed 53 evidence entries.

- **memgrep** (documentation): Local agent memory - Cursor from your phone - scheduled playbooks. Evidence: `README.md`
- **Package** (package_manifest): { "name": "memgrep", "version": "1.3.0", "description": "Telegram → Cursor agent + searchable local memory for playbooks you reuse and schedule with memgrep jobs .", "keywords": "semantic-search", "vector-search", "embeddings", "rag", "hnsw", "transformers", "local-first", "offline", "mcp", "agent-memory", "cursor", "cursor-agent", "claude-code", "telegram", "telegram-bot", "coding-agent", "remote-agent", "cron", "scheduled-jobs" , "license": "MIT", "repository": { "type": "git", "url": "git+https://github.com/darula-hpp/memgrep.git" }, "homepage": "https://github.com/darula-hpp/memgrep readme", "bugs": { "url": "https://github.com/darula-hpp/memgrep/issues" }, "type": "module", "main": "./… Evidence: `package.json`
- **License** (source_file): Copyright c 2026 memgrep contributors Evidence: `LICENSE`
- **Mcp** (structured_config): { "mcpServers": { "memgrep": { "command": "/Users/olebogengmbedzi/.nvm/versions/node/v20.20.2/bin/node", "args": "${workspaceFolder}/dist/cli.js", "serve" } } } Evidence: `.cursor/mcp.json`
- **Copy to .env and fill in real values. Never commit .env.** (source_file): Copy to .env and fill in real values. Never commit .env. TELEGRAM BOT TOKEN= TELEGRAM ALLOWED USER IDS= CURSOR API KEY= MEMGREP MCP TOKEN= MEMGREP MCP URL=http://127.0.0.1:3921/mcp Evidence: `.env.example`
- **Chunker** (source_file): import type { ChunkOptions } from './types.js'; ⋮---- export function chunkText text: string, options: ChunkOptions = ⋮---- function findBreakPoint text: string, start: number, end: number : number Evidence: `src/chunker.ts`
- **Cli** (source_file): import { createProgram } from './cli/program.js'; import { CliError } from './cli/lib/errors.js'; ⋮---- async function main : Promise Evidence: `src/cli.ts`
- **Embedder** (source_file): import { homedir } from 'node:os'; import path from 'node:path'; import { env, pipeline, type FeatureExtractionPipeline } from '@huggingface/transformers'; ⋮---- export class Embedder ⋮---- private constructor ⋮---- static async create model: string = DEFAULT MODEL : Promise ⋮---- async embed texts: string : Promise ⋮---- async embedOne text: string : Promise Evidence: `src/embedder.ts`
- **Types** (source_file): export interface Document { id: string; text: string; metadata?: Record ; } ⋮---- export interface SearchHit { id: string; score: number; chunk: string; chunkIndex: number; metadata?: Record ; } ⋮---- export interface SearchOptions { k?: number; } ⋮---- export interface ChunkOptions { chunkSize?: number; chunkOverlap?: number; } ⋮---- export interface CreateOptions extends ChunkOptions { model?: string; initialCapacity?: number; } Evidence: `src/types.ts`
- **Vector Index** (source_file): import { mkdir, readFile, writeFile } from 'node:fs/promises'; import { createRequire } from 'node:module'; import path from 'node:path'; import type { HierarchicalNSW as HierarchicalNSWType } from 'hnswlib-node'; import { chunkText, DEFAULT CHUNK OVERLAP, DEFAULT CHUNK SIZE } from './chunker.js'; import { DEFAULT MODEL, Embedder } from './embedder.js'; import type { CreateOptions, Document, SearchHit, SearchOptions } from './types.js'; ⋮---- interface ChunkRecord { docId: string; chunkIndex: number; text: string; } ⋮---- interface DocRecord { labels: number ; metadata?: Record ; } ⋮---- interface Meta { version: number; model: string; dimensions: number; chunkSize: number; chunkOverlap: nu… Evidence: `src/vector-index.ts`
- **Index** (source_file): import type { Command } from 'commander'; import { readFile, stat } from 'node:fs/promises'; import path from 'node:path'; import { fail } from '../lib/errors.js'; import { DEFAULT INDEX DIR, MAX FILE BYTES, walkFiles } from '../lib/files.js'; import { VectorIndex } from '../../vector-index.js'; ⋮---- export function registerIndexCommand program: Command : void Evidence: `src/cli/commands/index.ts`
- **Ingest** (source_file): import type { Command } from 'commander'; import { createInterface } from 'node:readline/promises'; import { fail } from '../lib/errors.js'; import { parsePickIndices, parseSourceList } from '../lib/format.js'; import { resolveIngestMode, type IngestMode } from './ingest-mode.js'; ⋮---- async function ingestPickFromScan picks: number : Promise ⋮---- async function ingestInteractivePick sources?: string : Promise ⋮---- async function ingestLast n: number, sources?: string : Promise ⋮---- async function ingestFiles paths: string , opts: { title?: string; project?: string }, : Promise ⋮---- async function ingestAll sources?: string : Promise ⋮---- async function runIngestMode mode: IngestMode… Evidence: `src/cli/commands/ingest.ts`
- **Recall** (source_file): import type { Command } from 'commander'; import { formatRecallFooter, formatRecallHit } from '../lib/format.js'; ⋮---- export function registerRecallCommand program: Command : void Evidence: `src/cli/commands/recall.ts`
- **Remember** (source_file): import type { Command } from 'commander'; import path from 'node:path'; ⋮---- export function registerRememberCommand program: Command : void Evidence: `src/cli/commands/remember.ts`
- **Scan** (source_file): import type { Command } from 'commander'; import { formatScanLine, formatScanMark, formatWhen, parseSourceList, } from '../lib/format.js'; ⋮---- export function registerScanCommand program: Command : void Evidence: `src/cli/commands/scan.ts`
- **Serve** (source_file): import type { Command } from 'commander'; import { DEFAULT HTTP HOST, DEFAULT HTTP PORT } from '../../memory/mcp.js'; ⋮---- export function registerServeCommand program: Command : void Evidence: `src/cli/commands/serve.ts`
- **Telegram** (source_file): import type { Command } from 'commander'; import { fail } from '../lib/errors.js'; ⋮---- async function loadDotenv : Promise ⋮---- async function ensureConfig forceSetup: boolean, profile: string ⋮---- type StartOpts = { noServer?: boolean; mcpUrl?: string; profiles: string ; }; ⋮---- async function startBots opts: StartOpts : Promise ⋮---- const shutdown = async = ⋮---- function printStatus profile: string : Promise ⋮---- export function registerTelegramCommand program: Command : void Evidence: `src/cli/commands/telegram.ts`
- **Program** (source_file): import { Command } from 'commander'; import { registerCopyCommand } from './commands/copy.js'; import { registerDeleteCommand } from './commands/delete.js'; import { registerIndexCommand } from './commands/index.js'; import { registerIngestCommand } from './commands/ingest.js'; import { registerListCommand } from './commands/list.js'; import { registerRecallCommand } from './commands/recall.js'; import { registerRememberCommand } from './commands/remember.js'; import { registerScanCommand } from './commands/scan.js'; import { registerSearchCommand } from './commands/search.js'; import { registerServeCommand } from './commands/serve.js'; import { registerShowCommand } from './commands/show.j… Evidence: `src/cli/program.ts`
- **Atomic Write** (source_file): import { mkdirSync, renameSync, writeFileSync } from 'node:fs'; import path from 'node:path'; ⋮---- export function writeFileAtomic filePath: string, contents: string, options: { mode?: number } = {}, : void Evidence: `src/fs/atomic-write.ts`
- **Cursor Executor** (source_file): import { existsSync } from 'node:fs'; import { createCursorProvider } from '../telegram/agent/providers/cursor.js'; import type { JobExecutor, JobExecuteContext } from './executor.js'; import { buildPlaybookPrompt } from './executor.js'; import type { Job, JobExecuteResult } from './types.js'; ⋮---- export class CursorJobExecutor implements JobExecutor ⋮---- constructor private readonly provider = createCursorProvider ⋮---- async execute job: Job, ctx: JobExecuteContext : Promise Evidence: `src/jobs/cursor-executor.ts`
- **Daemon** (source_file): import { resolveTelegramConfig, DEFAULT TELEGRAM PROFILE } from '../telegram/config.js'; import { DEFAULT CURSOR MODEL } from '../telegram/config.js'; import { startHttpMcpServer, type HttpMcpHandle } from '../memory/mcp.js'; import { CursorJobExecutor } from './cursor-executor.js'; import { ExecutorRegistry } from './executor.js'; import type { JobExecuteContext } from './executor.js'; import { NotifierRegistry, TelegramJobNotifier, NoopNotifier } from './notifier.js'; import { JobsService } from './service.js'; import { JobStore } from './store.js'; import type { Job } from './types.js'; ⋮---- export type JobsDaemonOptions = { home?: string; tickMs?: number; mcpUrl?: string; mcpToken?: st… Evidence: `src/jobs/daemon.ts`
- **Executor** (source_file): import type { Job, JobExecuteResult } from './types.js'; ⋮---- export type JobExecuteContext = { scheduledAt: string; manual?: boolean; mcpUrl: string; mcpToken?: string; cursorApiKey: string; model: string; }; ⋮---- export interface JobExecutor { readonly kind: string; execute job: Job, ctx: JobExecuteContext : Promise ; } ⋮---- execute job: Job, ctx: JobExecuteContext : Promise ; ⋮---- export class ExecutorRegistry ⋮---- register executor: JobExecutor : void ⋮---- get kind: string : JobExecutor ⋮---- has kind: string : boolean ⋮---- export function buildPlaybookPrompt job: Job, scheduledAt: string : string Evidence: `src/jobs/executor.ts`
- **Launchd** (source_file): import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs'; import { homedir } from 'node:os'; import path from 'node:path'; import { spawnSync } from 'node:child process'; import { defaultHome } from '../memory/store.js'; import { buildLaunchdPlist, launchAgentsDir, resolveMemgrepProgramArgs, } from '../telegram/launchd.js'; ⋮---- export type JobsLaunchdInstallOptions = { agentsDir?: string; home?: string; programArgs?: string ; dryRun?: boolean; }; ⋮---- export type JobsLaunchdStatus = { label: string; plistPath: string; installed: boolean; loaded: boolean; logPath: string; programArgs: string null; }; ⋮---- export function jobsLaunchdPlistPath agentsDir = la… Evidence: `src/jobs/launchd.ts`
- **Schedule** (source_file): import { CronExpressionParser } from 'cron-parser'; ⋮---- export interface ScheduleProvider { readonly kind: string; validate expression: string : void; next expression: string, from: Date : Date; } ⋮---- validate expression: string : void; ⋮---- next expression: string, from: Date : Date; ⋮---- export class CronScheduleProvider implements ScheduleProvider ⋮---- validate expression: string : void ⋮---- next expression: string, from: Date : Date ⋮---- export function registerScheduleProvider provider: ScheduleProvider : void ⋮---- export function getScheduleProvider kind = 'cron' : ScheduleProvider Evidence: `src/jobs/schedule.ts`
- **Service** (source_file): import { existsSync } from 'node:fs'; import { expandHomePath } from '../telegram/config.js'; import type { ToolResult } from '../memory/tools.js'; import { getScheduleProvider } from './schedule.js'; import type { JobStore } from './store.js'; import { MISSED GRACE MS } from './store.js'; import type { ExecutorRegistry, JobExecuteContext } from './executor.js'; import type { NotifierRegistry } from './notifier.js'; import type { Job, JobCreateInput, JobExecuteResult, JobRun, JobUpdateInput, } from './types.js'; ⋮---- export type ResolveRunContext = job: Job = Promise JobExecuteContext; ⋮---- export type JobsServiceOptions = { store: JobStore; executors?: ExecutorRegistry; notifiers?: Notif… Evidence: `src/jobs/service.ts`
- **Store** (source_file): import { mkdirSync, readFileSync, existsSync } from 'node:fs'; import { createRequire } from 'node:module'; import { randomUUID } from 'node:crypto'; import path from 'node:path'; import type DatabaseType from 'better-sqlite3'; import { writeFileAtomic } from '../fs/atomic-write.js'; import { defaultHome } from '../memory/store.js'; import { getScheduleProvider } from './schedule.js'; import type { Job, JobCreateInput, JobRun, JobRunStatus, JobUpdateInput, JobsFile, } from './types.js'; ⋮---- export function jobsDir home = defaultHome : string ⋮---- export function jobsFilePath home = defaultHome : string ⋮---- export function runsDbPath home = defaultHome : string ⋮---- function emptyFile… Evidence: `src/jobs/store.ts`
- **Tools** (source_file): import type { ToolResult } from '../memory/tools.js'; import type { JobsService } from './service.js'; import type { JobCreateInput, JobMode, JobUpdateInput } from './types.js'; ⋮---- export class JobsTools ⋮---- constructor private readonly service: JobsService ⋮---- list : ToolResult ⋮---- show idOrName: string : ToolResult ⋮---- add input: { name: string; cron: string; prompt: string; cwd: string; playbookId?: number; playbookQuery?: string; model?: string; telegramProfile?: string; mode?: JobMode; enabled?: boolean; } : ToolResult ⋮---- update idOrName: string, patch: JobUpdateInput : ToolResult ⋮---- remove idOrName: string : ToolResult ⋮---- enable idOrName: string, enabled: boolean :… Evidence: `src/jobs/tools.ts`
- **Types** (source_file): export type JobMode = 'notify' 'auto'; ⋮---- export type JobExecutorKind = 'cursor' string & {} ; ⋮---- export type Job = { id: string; name: string; cron: string; playbookId?: number; playbookQuery?: string; prompt: string; cwd: string; model?: string; telegramProfile?: string; mode: JobMode; executor: JobExecutorKind; enabled: boolean; nextRunAt: string null; lastRunAt: string null; createdAt: string; updatedAt: string; }; ⋮---- export type JobCreateInput = { name: string; cron: string; prompt: string; cwd: string; playbookId?: number; playbookQuery?: string; model?: string; telegramProfile?: string; mode?: JobMode; executor?: JobExecutorKind; enabled?: boolean; }; ⋮---- export type JobUp… Evidence: `src/jobs/types.ts`
- **Ingest** (source_file): import type { ChatInput, MemoryStore } from './store.js'; import { claudeSource, parseClaudeTranscript } from './sources/claude.js'; import { cursorSource, parseCursorTranscript } from './sources/cursor.js'; import { kiroSource, parseKiroSession } from './sources/kiro.js'; import type { TranscriptSource } from './sources/types.js'; ⋮---- export type SourceName = typeof ALL SOURCES number ; ⋮---- export interface IngestResult { scanned: number; added: number; skipped: number; bySource: Record ; } ⋮---- export function buildSources names?: readonly string : TranscriptSource ⋮---- export async function ingestTranscripts store: MemoryStore, sources: TranscriptSource = buildSources , onProgress?… Evidence: `src/memory/ingest.ts`
- **Mcp Server** (source_file): import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { z } from 'zod'; import { MemoryTools, toMcpContent } from './tools.js'; import type { JobsTools } from '../jobs/tools.js'; ⋮---- export function createMemgrepMcpServer tools: MemoryTools, jobs?: JobsTools, : McpServer ⋮---- function registerJobsTools server: McpServer, jobs: JobsTools : void Evidence: `src/memory/mcp-server.ts`
- **Mcp** (source_file): import { createServer } from 'node:http'; import type { AddressInfo } from 'node:net'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'; import { createMcpExpressApp } from '@modelcontextprotocol/sdk/server/express.js'; import { MemoryStore } from './store.js'; import { MemoryTools } from './tools.js'; import { createMemgrepMcpServer } from './mcp-server.js'; import { JobStore } from '../jobs/store.js'; import { JobsService } from '../jobs/service.js'; import { JobsTools } from '../jobs/tools.js'; ⋮---- function openJobsTools storeDir?: string : ⋮---- export ty… Evidence: `src/memory/mcp.ts`
- **Claude** (source_file): import { readdir, readFile, stat } from 'node:fs/promises'; import { homedir } from 'node:os'; import path from 'node:path'; import type { ChatInput } from '../store.js'; import { cleanUserText, extractText, makeTitle, type TranscriptSource } from './types.js'; ⋮---- interface ClaudeLine { type?: string; isSidechain?: boolean; cwd?: string; timestamp?: string; message?: { role?: string; content?: unknown }; } ⋮---- export function claudeSource projectsDir?: string : TranscriptSource ⋮---- async scan : AsyncGenerator ⋮---- export function parseClaudeTranscript raw: string, : Evidence: `src/memory/sources/claude.ts`
- **Cursor** (source_file): import { readdir, readFile, stat } from 'node:fs/promises'; import { homedir } from 'node:os'; import path from 'node:path'; import type { ChatInput } from '../store.js'; import { cleanUserText, extractText, makeTitle, type TranscriptSource } from './types.js'; ⋮---- interface TranscriptLine { role?: 'user' 'assistant'; message?: { content?: unknown }; } ⋮---- export function cursorSource projectsDir?: string : TranscriptSource ⋮---- async scan : AsyncGenerator ⋮---- export function parseCursorTranscript raw: string : ⋮---- function prettifyProject slug: string : string Evidence: `src/memory/sources/cursor.ts`
- **Kiro** (source_file): import { readdir, readFile, stat } from 'node:fs/promises'; import { homedir, platform } from 'node:os'; import path from 'node:path'; import type { ChatInput } from '../store.js'; import { cleanUserText, extractText, makeTitle, type TranscriptSource } from './types.js'; ⋮---- interface KiroSession { title?: string; workspacePath?: string; history?: { message?: { role?: string; content?: unknown } } ; } ⋮---- function defaultKiroDir : string ⋮---- export function kiroSource sessionsDir?: string : TranscriptSource ⋮---- async scan : AsyncGenerator ⋮---- export function parseKiroSession session: KiroSession, : ⋮---- function decodeWorkspace name: string : string Evidence: `src/memory/sources/kiro.ts`
- **Types** (source_file): import type { ChatInput } from '../store.js'; ⋮---- export interface TranscriptSource { name: string; scan : AsyncGenerator ; } ⋮---- scan : AsyncGenerator ; ⋮---- export function extractText content: unknown : string ⋮---- export function cleanUserText text: string : string ⋮---- export function makeTitle text: string : string Evidence: `src/memory/sources/types.ts`
- **Store** (source_file): import { mkdirSync } from 'node:fs'; import { createHash } from 'node:crypto'; import { existsSync } from 'node:fs'; import { createRequire } from 'node:module'; import { homedir } from 'node:os'; import path from 'node:path'; import type DatabaseType from 'better-sqlite3'; import type { HierarchicalNSW as HierarchicalNSWType } from 'hnswlib-node'; import { chunkText } from '../chunker.js'; import { DEFAULT MODEL, Embedder } from '../embedder.js'; import { extractCursorAgentIdFromSource, normalizeCursorAgentId, } from './cursor-agent-id.js'; ⋮---- export function defaultHome : string ⋮---- export interface ChatInput { title: string; project: string; content: string; source?: string; tool?:… Evidence: `src/memory/store.ts`
- **Tools** (source_file): import type { MemoryStore } from './store.js'; import { extractCursorAgentIdFromSource, guessCursorAgentIdFromSource, normalizeCursorAgentId, } from './cursor-agent-id.js'; ⋮---- export type ToolResult = { text: string; isError?: boolean; }; ⋮---- export type RecallInput = { query: string; k?: number; }; ⋮---- export type GetChatInput = { chatId: number; }; ⋮---- export type ListChatsInput = { project?: string; }; ⋮---- export type RememberInput = { text: string; title?: string; project?: string; }; ⋮---- export type OpenTarget = { id: number; title: string; project: string; tool: string; cursorAgentId?: string; resumeCandidate?: string; content: string; chars: number; }; ⋮---- export class… Evidence: `src/memory/tools.ts`
- **Cursor** (source_file): import { Agent, AgentBusyError, Cursor, CursorAgentError, type SDKAgent, type SendOptions, } from '@cursor/sdk'; import type { CodingAgentProvider, ProviderContext, ProviderModel, ProviderRun, ProviderSession, } from '../provider.js'; ⋮---- function mcpHeaders ctx: ProviderContext : Record undefined ⋮---- function sdkOptions ctx: ProviderContext ⋮---- function sendOptions options?: ⋮---- function wrapRun run: Awaited : ProviderRun ⋮---- function summarizeConversationTurn turn: unknown : string undefined ⋮---- function isBusyError error: unknown : boolean ⋮---- function wrapSession agent: SDKAgent : ProviderSession ⋮---- async send text: string, options?: async dispose : Promise ⋮---- export… Evidence: `src/telegram/agent/providers/cursor.ts`
- **Types** (source_file): import type { TelegramWorkspace } from '../config.js'; import type { AgentRunMode } from './mode.js'; ⋮---- export type AgentStatus = { agentId?: string; cwd: string; model: string; mode: AgentRunMode; workspaces: TelegramWorkspace ; }; ⋮---- export interface AgentSession { send text: string : Promise ; reset : Promise ; switchToAgent agentId: string : Promise ; setCwd cwd: string, name?: string : Promise ; setModel model: string : Promise ; listModels : Promise ; setMode mode: string : Promise ; listModes : string; listWorkspaces : string; switchWorkspace ref: string : Promise ; addWorkspace name: string, dir: string : Promise ; removeWorkspace name: string : Promise ; status : AgentStatus… Evidence: `src/telegram/agent/types.ts`
- **Allowlist** (source_file): export function isAllowedUser allowed: ReadonlySet , userId: number undefined : boolean ⋮---- export function parseAllowedUserIds raw: string undefined : Set Evidence: `src/telegram/allowlist.ts`
- **Bot** (source_file): import { buildOpenInjectPrompt, splitForTelegram, type OpenTarget } from '../memory/tools.js'; import { rebuildTelegramTransport, TelegramApi } from './api.js'; import { isAllowedUser } from './allowlist.js'; import { formatFetchError, isAbortError, isNetworkTimeoutError } from './errors.js'; import { clampPollingStallThresholdMs, isPollingStalled, POLLING STALL THRESHOLD MS, POLLING WATCHDOG INTERVAL MS, } from './polling.js'; import { helpText, parseTelegramCommand, TELEGRAM BOT COMMANDS } from './router.js'; import type { AgentSession } from './agent/types.js'; import type { MemoryAccess, TelegramBotConfig, TelegramCommand, TelegramUpdate } from './types.js'; ⋮---- export type TelegramBo… Evidence: `src/telegram/bot.ts`
- **Launchd** (source_file): import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs'; import { homedir } from 'node:os'; import path from 'node:path'; import { spawnSync } from 'node:child process'; import { fileURLToPath } from 'node:url'; import { defaultHome } from '../memory/store.js'; import { sanitizeTelegramProfile } from './config.js'; ⋮---- export type LaunchdRunMode = { kind: 'default' } { kind: 'all' } { kind: 'profile'; profile: string }; ⋮---- export type LaunchdInstallOptions = { mode: LaunchdRunMode; agentsDir?: string; home?: string; programArgs?: string ; dryRun?: boolean; }; ⋮---- export type LaunchdStatus = { label: string; plistPath: string; installed: boolean; loade… Evidence: `src/telegram/launchd.ts`
- **Polling** (source_file): export function clampPollingStallThresholdMs ms: number : number ⋮---- export function isPollingStalled lastCompletedAtMs: number, nowMs: number, thresholdMs = POLLING STALL THRESHOLD MS, : boolean Evidence: `src/telegram/polling.ts`
- **Process Guards** (source_file): import { CursorAgentError } from '@cursor/sdk'; import { formatFetchError, isNetworkTimeoutError } from './errors.js'; ⋮---- export function installTelegramProcessGuards : void ⋮---- export function isTransientSdkOrNetworkError reason: unknown, detail: string : boolean Evidence: `src/telegram/process-guards.ts`
- **Router** (source_file): import type { TelegramCommand } from './types.js'; ⋮---- export type TelegramBotCommand = { command: string; description: string; }; ⋮---- export function helpText : string ⋮---- export function parseTelegramCommand text: string undefined : TelegramCommand ⋮---- function parseWorkspaceCommand args: string undefined : TelegramCommand Evidence: `src/telegram/router.ts`
- **Session Store** (source_file): import { existsSync, mkdirSync, readFileSync } from 'node:fs'; import path from 'node:path'; import { z } from 'zod'; import { writeFileAtomic } from '../fs/atomic-write.js'; import { defaultHome } from '../memory/store.js'; import { DEFAULT TELEGRAM PROFILE, sanitizeTelegramProfile, telegramProfilesDir, } from './config.js'; ⋮---- export type SessionEntry = z.infer ; export type SessionStoreFile = z.infer ; ⋮---- export function telegramSessionsPath home = defaultHome , profile: string = DEFAULT TELEGRAM PROFILE, : string ⋮---- export function readSessionStore home = defaultHome , profile: string = DEFAULT TELEGRAM PROFILE, : SessionStoreFile ⋮---- function writeSessionStore store: Session… Evidence: `src/telegram/session-store.ts`
- **Types** (source_file): import type { OpenTarget, ToolResult } from '../memory/tools.js'; import type { AgentPool, AgentSession } from './agent/types.js'; import type { TelegramWorkspace } from './config.js'; ⋮---- export interface MemoryAccess { recall query: string, k?: number : Promise ; getChat chatId: number : Promise ; listChats project?: string : Promise ; resolveOpen? chatId: number : Promise ; linkCursorAgent? chatId: number, agentId: string : void Promise ; close? : Promise void; } ⋮---- recall query: string, k?: number : Promise ; getChat chatId: number : Promise ; listChats project?: string : Promise ; ⋮---- resolveOpen? chatId: number : Promise ; ⋮---- linkCursorAgent? chatId: number, agentId: string… Evidence: `src/telegram/types.ts`
- **Changelog** (documentation): All notable changes to this project are documented in this file. Evidence: `CHANGELOG.md`
- **Meta** (structured_config): {"version":1,"model":"Xenova/all-MiniLM-L6-v2","dimensions":384,"chunkSize":1000,"chunkOverlap":200,"capacity":1024,"nextLabel":24,"docs":{"src/chunker.ts":{"labels": 0,1 ,"metadata":{"path":"src/chunker.ts"}},"src/cli.ts":{"labels": 2,3,4,5,6,7,8 ,"metadata":{"path":"src/cli.ts"}},"src/embedder.ts":{"labels": 9,10 ,"metadata":{"path":"src/embedder.ts"}},"src/index.ts":{"labels": 11 ,"metadata":{"path":"src/index.ts"}},"src/types.ts":{"labels": 12,13 ,"metadata":{"path":"src/types.ts"}},"src/vector-index.ts":{"labels": 14,15,16,17,18,19,20,21,22,23 ,"metadata":{"path":"src/vector-index.ts"}}},"chunks":{"0":{"docId":"src/chunker.ts","chunkIndex":0,"text":"import type { ChunkOptions } from '.… Evidence: `.vector-grep/meta.json`
- **Tsconfig** (structured_config): { "compilerOptions": { "target": "ES2022", "module": "NodeNext", "moduleResolution": "NodeNext", "lib": "ES2022" , "outDir": "dist", "rootDir": "src", "declaration": true, "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true }, "include": "src" , "exclude": "src/ / tests " } Evidence: `tsconfig.json`
- **.gitignore** (source_file): node modules/ dist/ .memgrep/ .log .DS Store .env .env.local Evidence: `.gitignore`
- **Clipboard** (source_file): import { spawn } from 'node:child process'; import { platform } from 'node:os'; ⋮---- function clipboardCommand : string, string ⋮---- export function copyToClipboard text: string : Promise Evidence: `src/clipboard.ts`
- **Vitest.Config** (source_file): import { defineConfig } from 'vitest/config'; Evidence: `vitest.config.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`, `LICENSE`
- **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`, `LICENSE`

## 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.

- **What is memgrep**: importance `high`
  - source_paths: README.md, package.json
- **Architecture and Data Flow**: importance `high`
  - source_paths: src/index.ts, src/types.ts, src/vector-index.ts, src/embedder.ts, src/chunker.ts
- **Memory, Ingestion, and Vector Search**: importance `high`
  - source_paths: src/memory/ingest.ts, src/memory/store.ts, src/memory/sources/cursor.ts, src/memory/sources/claude.ts, src/memory/sources/kiro.ts
- **CLI Command Reference**: importance `high`
  - source_paths: src/cli.ts, src/cli/program.ts, src/cli/commands/ingest.ts, src/cli/commands/recall.ts, src/cli/commands/remember.ts
- **MCP Server and Agent Tooling**: importance `high`
  - source_paths: src/memory/mcp-server.ts, src/memory/mcp.ts, src/memory/tools.ts, src/cli/commands/serve.ts, .cursor/mcp.json
- **Telegram Bot and Remote Cursor**: importance `high`
  - source_paths: src/telegram/bot.ts, src/telegram/polling.ts, src/telegram/session-store.ts, src/telegram/process-guards.ts, src/telegram/allowlist.ts
- **Scheduled Jobs and Playbooks**: importance `high`
  - source_paths: src/jobs/daemon.ts, src/jobs/executor.ts, src/jobs/cursor-executor.ts, src/jobs/schedule.ts, src/jobs/service.ts
- **Deployment, Operations, and Reliability**: importance `high`
  - source_paths: src/jobs/launchd.ts, src/telegram/launchd.ts, src/fs/atomic-write.ts, src/telegram/process-guards.ts, src/telegram/session-store.ts

## Repo Inspection Evidence

- repo_clone_verified: true
- repo_inspection_verified: true
- repo_commit: `cfb72d988c16c4d0439de69a8e5b99642378af82`
- inspected_files: `README.md`, `package.json`, `src/__tests__/chunker.test.ts`, `src/__tests__/vector-index.test.ts`, `src/chunker.ts`, `src/cli/__tests__/files.test.ts`, `src/cli/__tests__/format.test.ts`, `src/cli/__tests__/ingest-mode.test.ts`, `src/cli/__tests__/program.test.ts`, `src/cli/commands/copy.ts`, `src/cli/commands/cursor.ts`, `src/cli/commands/delete.ts`, `src/cli/commands/index.ts`, `src/cli/commands/ingest-mode.ts`, `src/cli/commands/ingest.ts`, `src/cli/commands/jira.ts`, `src/cli/commands/jobs.ts`, `src/cli/commands/list.ts`, `src/cli/commands/neon.ts`, `src/cli/commands/posthog.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/darula-hpp/memgrep
- 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/darula-hpp/memgrep
- 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/darula-hpp/memgrep
- 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/darula-hpp/memgrep
- 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/darula-hpp/memgrep
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 6: Maintenance risk requires verification

- Trigger: Developers should check this maintenance risk before relying on the project: v1.1.0
- Host AI rule: Before packaging this project, run the relevant install/config/quickstart check for: v1.1.0. Context: Source discussion did not expose a precise runtime context.
- Why it matters: Upgrade or migration may change expected behavior: v1.1.0
- Evidence: failure_mode_cluster:github_release | https://github.com/darula-hpp/memgrep/releases/tag/v1.1.0
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.
