Skip to content

fix: allow mempalace init to default to the current directory#220

Open
2023Anita wants to merge 7 commits intoMemPalace:developfrom
2023Anita:fix/init-default-current-dir
Open

fix: allow mempalace init to default to the current directory#220
2023Anita wants to merge 7 commits intoMemPalace:developfrom
2023Anita:fix/init-default-current-dir

Conversation

@2023Anita
Copy link
Copy Markdown

Summary

  • make the init directory argument optional and default it to the current directory
  • expose a parser builder so the CLI behavior can be tested directly
  • update docs to show the optional init directory form and add regression coverage

Closes #210.

Validation

  • PYTHONPATH=/Users/anita/mempalace pytest --noconftest tests/test_cli.py -q
  • python3 -m compileall mempalace

@bgauryy
Copy link
Copy Markdown

bgauryy commented Apr 8, 2026

PR Review: fix: allow mempalace init to default to the current directory

Executive Summary

Aspect Value
PR Goal Make mempalace init default to the current directory when no path argument is given
Files Changed 4
Risk Level 🟢 LOW - Small, well-scoped argparse change with backward-compatible refactor
Review Effort 1 - Trivial, clear intent and implementation
Recommendation ✅ APPROVE

Affected Areas: mempalace/cli.py (parser + main entrypoint), tests/test_cli.py (new), README.md, mempalace/onboarding.py

Business Impact: Users no longer need to type mempalace init . when already inside their project directory — removes a common friction point.

Flow Changes: main() split into build_parser() + main(argv=None). When argv=None, argparse reads from sys.argv[1:] — identical to previous behavior. No callers break.

Ratings

Aspect Score
Correctness 5/5
Security 5/5
Performance 5/5
Maintainability 5/5

PR Health

Medium Priority Issues

(Should fix, not blocking)

🎨 #1: Init prints raw "." instead of resolved path

Location: mempalace/cli.py:46 (main branch line) | Confidence: ✅ HIGH

When the user runs mempalace init without arguments, the console prints Scanning for entities in: . which is less informative than the resolved absolute path. The downstream detect_rooms_local() already resolves via Path(project_dir).expanduser().resolve(), but the print in cmd_init uses the raw value.

- print(f"\n  Scanning for entities in: {args.dir}")
+ resolved = str(Path(args.dir).expanduser().resolve())
+ print(f"\n  Scanning for entities in: {resolved}")

Low Priority Issues

(Nice to have)

🎨 #2: Docstring examples still show only the explicit-directory form

Location: mempalace/cli.py:17-27 (Examples block) | Confidence: ⚠️ MED

The top-of-file docstring Examples: section shows mempalace init ~/projects/my_app but doesn't demonstrate the new no-argument form. Adding mempalace init as an example would help discoverability.

 Examples:
+    mempalace init                        # init current directory
     mempalace init ~/projects/my_app

🔗 #3: Test file bypasses project test harness

Location: tests/test_cli.py | Confidence: ⚠️ MED

The PR validation command runs pytest --noconftest tests/test_cli.py, but the file itself doesn't declare anything incompatible with conftest.py. When run via pytest normally (which is the project convention per pyproject.toml), the _reset_mcp_cache autouse fixture from conftest.py will fire unnecessarily. This is harmless but worth noting — the tests work fine either way.

No code change needed — just awareness.


Flow Impact Analysis

BEFORE:  mempalace init <dir>  →  argparse requires positional  →  cmd_init(args)
AFTER:   mempalace init [dir]  →  argparse optional, default="."  →  cmd_init(args)
                                                                       ↓
                                                              scan_for_detection(args.dir)  ← "." is valid
                                                              Path(args.dir).expanduser().resolve()  ← resolves to cwd
                                                              detect_rooms_local(project_dir=args.dir)  ← also resolves internally

All downstream consumers resolve the path via Path().expanduser().resolve(), so the "." default is safe throughout the call chain.


Created by Octocode MCP https://octocode.ai 🔍🐙

@2023Anita
Copy link
Copy Markdown
Author

Updated per the suggestions.

Changes included:

  • resolved the init path before scanning so the CLI prints an absolute path instead of .
  • added the no-argument mempalace init example to the CLI docstring

Re-ran the lightweight CLI checks locally after the update.

Copy link
Copy Markdown

@web3guru888 web3guru888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Review of #220fix: allow mempalace init to default to the current directory

Scope: +43/−10 · 4 file(s)

  • README.md (modified: +1/−1)
  • mempalace/cli.py (modified: +20/−8)
  • mempalace/onboarding.py (modified: +1/−1)
  • tests/test_cli.py (modified: +21/−0)

Strengths

  • ✅ Includes test coverage

🟢 Approved — clean, well-structured PR. Good work @2023Anita!


🏛️ Reviewed by MemPalace-AGI · Autonomous research system with perfect memory · Showcase: Truth Palace of Atlantis

@bensig bensig changed the base branch from main to develop April 11, 2026 22:23
@bensig bensig requested a review from igorls as a code owner April 11, 2026 22:23
@igorls igorls added area/cli CLI commands bug Something isn't working labels Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli CLI commands bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Init in documentation has no dir, but is required

4 participants