Learning Context System is an experimental CLI for coding with teaching, memory, and context control at the same time.
Spanish summary available in README.es.md.
It does three things together:
- selects useful context
- teaches from that context
- remembers durable decisions through Engram
This repository is experimental but serious.
It is already usable as:
- a local research CLI
- a context-selection prototype
- a teaching-oriented coding assistant scaffold
- a durable-memory playground backed by Engram
- an optional PR-to-Notion learnings sync flow after merges
It is not yet a mature framework.
- Generate code and explanations in the same loop.
- Adapt the teaching style to the active language through skills.
- Preserve useful probability mass inside the context window by filtering noise, duplicates, and stale material.
- Keep memory and prompt context separate but cooperative.
Este proyecto es una CLI experimental para:
- filtrar contexto antes de usar un LLM
- ensenar sobre el codigo mientras se trabaja
- recordar decisiones duraderas del proyecto
La idea no es mandar todo al modelo, sino elegir mejor:
- que codigo entra
- que test importa
- que memoria historica vale recuperar
- que ruido debe quedar afuera
The primary repo to use as the architectural base is engram.
Why:
- it is the strongest fit for persistent memory and context retrieval
- it already thinks in terms of durable knowledge for agents
- it is a better foundation for context hygiene than a UI-first or transport-first repo
Use these other repositories as complementary references:
gentleman-architecture-agentsfor agent contracts and scope controlGentle-Learningfor the learning experience and pedagogical flowGentleman-MCPlater, if we need external tool orchestration
Full analysis lives in docs/repo-analysis.md.
This project uses Engram from Gentleman-Programming only for the durable memory layer.
In concrete terms, Engram is used to:
- save durable project memories
- recall past decisions and summaries
- keep historical memory separate from the current prompt context
Engram is not used here as:
- the code-generation engine
- the context selector
- the pedagogical layer
- the general orchestration layer
En este repo usamos Engram de Gentleman-Programming unicamente para la memoria durable.
Se usa solo para:
- guardar memorias importantes
- recuperar decisiones previas
- traer resumenes utiles de sesiones anteriores
No se usa aqui para:
- generar codigo
- rankear chunks
- ensenar el contenido
- reemplazar la logica principal de la CLI
This repository is not JavaScript-only.
It currently uses:
- JavaScript (ESM) for the core CLI, selector, recall flow, and teaching packet logic
- TypeScript in the real backend vertical under
examples/typescript-backend/ - Markdown for documentation, agent contracts, and skills
- JSON for fixtures, benchmarks, package manifests, and structured inputs
- YAML for GitHub Actions CI
- Node.js is the required runtime for the main CLI
- Engram binary is the external memory runtime used for durable memory features such as
recall,remember, andclose
The root package intentionally has no external npm runtime dependencies.
That is deliberate:
- easier local iteration
- lower installation friction
- smaller dependency surface
The TypeScript backend vertical under examples/typescript-backend/ uses:
zod
typescriptvitest@types/node
- GitHub Actions for CI
- Git for version control
- Engram for durable memory only
This repository was built as an original implementation, but it openly credits external references that shaped specific parts of the architecture.
- Engram from Gentleman-Programming: reference and local runtime only for durable memory persistence and recall
- gentleman-architecture-agents: reference for agent contracts, scope discipline, and
AGENTS.mdstructure - Gentle-Learning: reference for the teaching-oriented framing and learning flow
These projects are credited as architectural inspiration. They are not listed as direct contributors to this repository unless they contribute commits here.
AGENTS.md: operating contract for future agentsbenchmark/recall-benchmark.json: fixed benchmark cases for durable-memory recall qualitybenchmark/selector-benchmark.json: fixed benchmark cases for context selection qualityCHANGELOG.md: release history and user-visible changesCONTRIBUTING.md: contributor rules and local validation checklistdocs/context-noise-cancellation.md: design of the context filtering systemdocs/benchmark.md: benchmark method and metricsdocs/security-model.md: scan safety model, secret redaction policy, and limitsdocs/skills-governance.md: policy to approve/block skills with risk tiers and rollback rulesdocs/ops-runbook.md: operational checklist for validation, degraded mode, and release hygienedocs/status-actual.md: current operational status and closed milestonesdocs/typescript-backend-vertical.md: end-to-end TypeScript backend demo flowdocs/usage.md: CLI usage and input contractexamples/typescript-backend/: realistic TypeScript middleware workspacelearning-context.config.json: tracked project defaults for selection, memory, and Engram pathsROADMAP.md: next prioritiesVERSIONING.md: package/tag/release alignment policysrc/analysis/readme-generator.js: generated learning README buildersrc/ci/pr-learnings.js: merged-PR metadata to durable learning-note payload mappersrc/context/noise-canceler.js: prototype signal-over-noise selectorsrc/learning/mentor-loop.js: learning packet buildersrc/memory/engram-client.js/src/memory/engram-client.ts: local Engram adapter for recall and durable memory writes (JS runtime + TS build track)src/observability/metrics-store.js: local command metrics store and aggregated observability reportsrc/security/prowler-ingest.js: converter from Prowler findings JSON to LCS-compatible chunk JSONscripts/sync-pr-learnings.js: CI helper that syncs merged PR learnings to Notion throughsync-knowledgesrc/cli.js: local CLI entrypointskills/: language-specific and workflow-specific teaching skills
To use the project locally in a serious way, you need:
- Node.js for the CLI and benchmarks
- Git for normal development workflow
- Engram binary if you want durable-memory commands such as
recall,remember,close, or memory-backedteach
You can still use parts of the system without Engram:
selectreadmeteach --no-recall
npm run doctor
npm run init:config
npm test
npm run typecheck
npm run build
npm run release:check
npm run benchmark
npm run benchmark:recall
npm run benchmark:vertical
npm run security:pipeline:examplesecurity:pipeline:example includes a default quality gate (min-included-findings=1, min-selected-teach-chunks=1, min-priority=0.84).
The CLI now auto-loads learning-context.config.json when present.
That file is the official place for:
- default project name
- default workspace
- selection budgets
- recall defaults
- memory automation defaults (
memory.autoRecall,memory.autoRemember) - Engram binary and data directory paths
- scan safety defaults and per-project overrides
CLI flags still win over config values when both are present.
Security note: when auto-remember is enabled for teach, saved memory content is sanitized (sensitive paths masked, secret-like values redacted) before writing to Engram.
To inspect the local setup:
npm run doctorTo generate the base config file:
npm run init:configKey config.security fields:
ignoreSensitiveFilesredactSensitiveContentignoreGeneratedFilesallowSensitivePathsextraSensitivePathFragments
Current typecheck scope is intentionally incremental: it hardens the config/bootstrap and workspace-scan layer first, instead of pretending the whole repo is already fully migrated to strict TypeScript.
The repo now has two different TypeScript-related flows on purpose:
npm run typecheck- strict incremental safety gate for the hardened core chain
npm run build- emits a runnable
dist/CLI from the current runtime without pretending every file is fully migrated
- emits a runnable
Useful commands:
npm run build
npm run build:smoke
npm run pack:check
npm run release:checkConceptually:
- typecheck = where we already enforce stronger contracts
- build = publishable runtime output for packaging and CI smoke tests
- pack:check = validates
npm packincludes required package assets before publication work
The local developer entrypoint stays src/cli.js for now. The dist/ build is the bridge toward a later full .ts migration, not a fake claim that migration is already done.
In this repo, migration is considered real only when all three happen:
- module source moves to
.ts - runtime behavior is validated through
dist/ - package distribution uses
distas the executable surface
The project now enforces step (2) and step (3) through CI build + smoke and bin pointing to dist/cli.js.
Current real .ts migrations in src/:
src/security/secret-redaction.tssrc/io/text-file.tssrc/contracts/config-contracts.tssrc/io/config-file.tssrc/io/workspace-chunks.tssrc/system/project-ops.tssrc/cli/arg-parser.tssrc/contracts/cli-contracts.tssrc/cli/teach-command.tssrc/memory/recall-queries.tssrc/memory/teach-recall.tssrc/memory/engram-auto-orchestrator.tssrc/memory/engram-client.ts
Compatibility note:
- Node 20/22 local runtime still uses
.jsentry modules insrc/ dist/build emits from the.tsmigration track for packaging and CI smoke validation
The workspace scanner is not a blind dump.
It currently:
- ignores high-risk credential containers such as:
.env*.npmrc,.pypirc,.netrc.aws/credentials,.docker/config.json,.kube/configid_rsa,id_dsa,id_ed25519.pem,.key,.pfx,.crt,.cer,.tfvars
- redacts secret-like fragments inside otherwise useful files:
- private key blocks
- API keys and access tokens
- bearer tokens
- JWT-like tokens
- connection strings and DSNs
- common password/secret assignments
- counts redacted files, ignored sensitive files, and redaction categories in scan statistics
- allows project-level security overrides through
learning-context.config.json
That means the CLI now exposes not only selected context, but also how much data was ignored, truncated, or redacted.
Security overrides are deliberately explicit:
- use
allowSensitivePathsonly for known-safe fixtures such as examples - use
extraSensitivePathFragmentswhen a repo has custom sensitive areas that should never enter context - use
safety.requirePlanForWrite+--plan-approved trueto force Plan/Execute discipline in write mode - use
safety.allowedScopePathsto block out-of-scope changed/output paths - use
safety.maxTokenBudgetto block over-budget token windows before execution
Security model details live in docs/security-model.md.
To make the repository usable by others, GitHub surfaces are now explicitly wired:
- Issue templates:
- bug report
- feature request
- usage question
- Pull request template with mandatory validation checklist
- CI workflow with typecheck/build/tests/benchmarks plus secret scan gate
- PR Learnings Sync workflow that can export merged PR learnings to Notion (
sync:pr-learnings) when secrets are configured - CodeQL workflow for JavaScript/TypeScript static analysis
- Dependabot configuration for npm and GitHub Actions updates
- Security policy in
SECURITY.md
The strongest current demo is the TypeScript backend middleware vertical:
npm run vertical:ts:teach
npm run vertical:ts:seed-memory
npm run vertical:ts:teach:memoryThat flow shows:
- changed code and related tests
- controlled noise suppression
- pedagogical teaching sections
- durable memory entering the final packet
node src/cli.js select --input examples/auth-context.json --focus "jwt middleware expired session validation" --min-score 0.25 --format text
node src/cli.js teach --input examples/auth-context.json --task "Improve auth middleware" --objective "Teach why validation runs before route handlers" --changed-files "src/auth/middleware.ts,test/auth/middleware.test.ts" --project learning-context-system --min-score 0.25 --format text
node src/cli.js ingest-security --input examples/prowler-findings.sample.json --status-filter non-pass --output ./security-chunks.json --format text
node src/cli.js readme --workspace . --focus "learning context cli noise cancellation" --output README.LEARN.md --format text
node src/cli.js recall --project learning-context-system --query "auth middleware" --type decision --scope project --limit 5 --format text
node src/cli.js remember --title "JWT order" --content "Validation runs before route handlers." --project learning-context-system --type decision --topic architecture/auth-order --format text
node src/cli.js close --summary "Integrated recall and remember commands." --learned "Context retrieval and durable memory are different layers." --next "Connect recall to the teaching flow." --project learning-context-system --format text
node src/cli.js sync-knowledge --title "PR #39 learnings" --content "Migrated Engram adapter to TS build track." --project learning-context-system --source "pr-39" --tags "typescript,memory,engram" --notion-page-id "<page-id>" --notion-token "<token>" --format text
npm run sync:pr-learnings -- --event "$GITHUB_EVENT_PATH" --dry-run trueWhen you use --format json, the CLI now returns a versioned JSON contract with:
schemaVersioncommandstatusdegradedwarningsconfigmeta
and then the command payload itself.
That makes the CLI safer to consume from scripts and future tooling.
This repo now has three benchmark layers:
- selector benchmark
- recall benchmark
- vertical benchmark
The goal is not only to say "it feels better", but to show when behavior improves or regresses.
The prototype is intentionally dependency-light and runs on plain Node so we can iterate even in a minimal local environment. The only external runtime it now leans on is a locally installed Engram binary for durable memory, and teach now uses that memory automatically before building the teaching packet with a smarter multi-query recall strategy.
Use ROADMAP.md as the index and the section roadmaps under docs/roadmaps/ when you want the next steps split by concern instead of mixed in one list.