Skip to content

feat: Phase 1 — layered memory loading and /init command#23

Open
GoDiao wants to merge 2 commits intoLiuMengxuan04:mainfrom
GoDiao:main
Open

feat: Phase 1 — layered memory loading and /init command#23
GoDiao wants to merge 2 commits intoLiuMengxuan04:mainfrom
GoDiao:main

Conversation

@GoDiao
Copy link
Copy Markdown
Contributor

@GoDiao GoDiao commented Apr 28, 2026

Summary

Phase 1 of the layered memory system, implementing instruction file loading and project bootstrapping. Closes P1 item #5 (Layered memory loading) on the roadmap.

Changes

Core: src/memory.ts — 3-layer hierarchical instruction file loading:

  1. User global (~/.mini-code/MINI.md or ~/.mini-code/CLAUDE.md)
  2. Project root and ancestor directories (walked upward from cwd)
  3. Nested directories close to cwd take precedence over broader layers
  • 6 filename candidates per directory: MINI.md, MINI.local.md, .mini-code/MINI.md, CLAUDE.md, CLAUDE.local.md, .claude/CLAUDE.md
  • Content deduplication by hash — identical content across scopes is collapsed
  • Capacity limits: 8K chars per file, 20K chars total
  • 19 tests

Core: src/init.ts/init command for project bootstrapping:

  • Creates .mini-code/ directory
  • Appends MiniCode entries to .gitignore (idempotent, no duplication)
  • Generates MINI.md template with auto-detected stack:
    • Languages: TypeScript, Python, Rust, JavaScript/Node.js
    • Frameworks: Next.js, React, Vite, NestJS
    • Verification commands per language
    • Repository shape hints (src/, tests/, rust/ dirs)
  • Idempotent — safe to re-run, won't overwrite existing files
  • 12 tests

Refactor: src/prompt.ts — replaced hardcoded 2-file loading with loadMemory() delegation, dropping ~25 lines of boilerplate.

Test plan

  • All 140 tests pass (0 failures)
  • tsc --noEmit clean
  • Memory: 19 tests covering hierarchy walk, dedup, truncation, global priority, empty files
  • Init: 12 tests covering artifact creation, idempotency, language/framework detection, .gitignore merging

Phase 2 (next PR)

The following follow-ups will be addressed in a separate PR:

  • @path include resolution
  • .mini-code/rules/*.md auto-discovery
  • Auto memory read/write
  • /memory command to inspect loaded files

@GateJustice
Copy link
Copy Markdown
Collaborator

This looks like a solid implementation of Phase 1.

The layering logic, deduplication, and capacity limits all align well with the earlier design. I also like the idempotent /init flow and the auto-detection for languages/frameworks — that should make onboarding much smoother.

The test coverage looks comprehensive as well, especially around hierarchy, dedup, and truncation.

No blocking issues from my side. One small thing to consider later (non-blocking): we might want to expose some minimal debug visibility (e.g. which files were loaded) even before the /memory command lands, just to help with troubleshooting.

Otherwise, LGTM. We might be a bit slower to merge over the May Day holiday, but we'll batch-review and merge PRs during that time.

  - Add src/memory.ts: 3-layer instruction file loading (global, ancestors, cwd), 6 filename candidates, dedup, capacity limits (8K/20K)
  - Add src/init.ts: /init command bootstraps .mini-code/, .gitignore, MINI.md with auto-detected stack
  - Refactor src/prompt.ts to delegate instruction loading to loadMemory()
  - Add tests: 19 memory tests + 12 init tests (all passing)
  - Update docs: ARCHITECTURE, README, ROADMAP (EN + ZH)
@GoDiao
Copy link
Copy Markdown
Contributor Author

GoDiao commented Apr 30, 2026

Thanks for the review. I've addressed the debug visibility suggestion — at startup, MiniCode now shows a one-line memory diagnostics entry listing all loaded instruction files with their paths, line counts, and first-line preview. Ready for merge whenever you're back from the holiday.

@GoDiao
Copy link
Copy Markdown
Contributor Author

GoDiao commented May 1, 2026

$(cat <<'EOF'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants