memdex 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,4 +31,4 @@ bun run memdex -- ask --repo /path/to/repo "Where is retry/backfill documented?"
31
31
  Set `PYTHON` to choose a specific Python executable.
32
32
 
33
33
  Release and CI details live in the repository-level
34
- [release process](https://github.com/yoyooyooo/codebase-retrieve/blob/main/docs/release.md).
34
+ [release process](https://github.com/yoyooyooo/memdex/blob/main/docs/release.md).
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "memdex",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Agent-facing semantic retrieval for local projects and source sets using NotebookLM, repomix snapshots, freshness checks, and local verification.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "homepage": "https://github.com/yoyooyooo/codebase-retrieve#readme",
7
+ "homepage": "https://github.com/yoyooyooo/memdex#readme",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/yoyooyooo/codebase-retrieve.git",
10
+ "url": "git+https://github.com/yoyooyooo/memdex.git",
11
11
  "directory": "packages/memdex"
12
12
  },
13
13
  "bugs": {
14
- "url": "https://github.com/yoyooyooo/codebase-retrieve/issues"
14
+ "url": "https://github.com/yoyooyooo/memdex/issues"
15
15
  },
16
16
  "keywords": [
17
17
  "agent",
package/scripts/memdex.py CHANGED
@@ -21,6 +21,7 @@ import shlex
21
21
  import shutil
22
22
  import subprocess
23
23
  import sys
24
+ import textwrap
24
25
  import threading
25
26
  import time
26
27
  from pathlib import Path
@@ -2325,95 +2326,184 @@ def cmd_temp_source_cleanup(args: argparse.Namespace) -> None:
2325
2326
 
2326
2327
 
2327
2328
  def build_parser() -> argparse.ArgumentParser:
2328
- parser = argparse.ArgumentParser(prog="memdex")
2329
- sub = parser.add_subparsers(dest="command", required=True)
2330
-
2331
- init = sub.add_parser("init")
2332
- init.add_argument("--repo", default=".")
2333
- init.add_argument("--notebook-id", default="")
2334
- init.add_argument("--project-name", default="")
2335
- init.add_argument("--notebook-title-prefix", default=DEFAULT_NOTEBOOK_TITLE_PREFIX)
2336
- init.add_argument("--notebook-title", default="")
2337
- init.add_argument("--reuse-existing-notebook", action="store_true")
2338
- init.add_argument("--create-notebook", action="store_true")
2339
- init.add_argument("--source-title-prefix", default="")
2340
- init.add_argument("--include", default="")
2341
- init.add_argument("--force", action="store_true")
2329
+ parser = argparse.ArgumentParser(
2330
+ prog="memdex",
2331
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2332
+ description=textwrap.dedent(
2333
+ """
2334
+ Agent-facing semantic retrieval for projects and source sets.
2335
+
2336
+ Memdex uses NotebookLM as a semantic locator, then treats local files,
2337
+ command output, and project docs as authority for exact evidence.
2338
+ Start with init once. For normal agent work, call ask or locate directly;
2339
+ they run freshness preflight before querying the provider.
2340
+ """
2341
+ ).strip(),
2342
+ epilog=textwrap.dedent(
2343
+ """
2344
+ Common agent paths:
2345
+ memdex init --repo . --create-notebook
2346
+ memdex ask --repo . "Where is retry/backfill documented?"
2347
+ memdex locate --repo . "invoice export retry command"
2348
+ memdex ask --repo . --yes "question" # approve first broad upload
2349
+
2350
+ Command routing:
2351
+ ask answer architecture/docs/status questions over the source set
2352
+ locate find likely files or symbols and return local line refs
2353
+ init create .memdex/config.json and bind a NotebookLM notebook
2354
+ status inspect local config, freshness, and recorded source state
2355
+ ensure prewarm or refresh the index when policy allows
2356
+ refresh force a source replacement
2357
+ pack preview deterministic repomix chunks without provider Q&A
2358
+ """
2359
+ ).strip(),
2360
+ )
2361
+ sub = parser.add_subparsers(title="commands", dest="command", metavar="<command>", required=True)
2362
+
2363
+ ask = sub.add_parser(
2364
+ "ask",
2365
+ help="answer semantic project questions with freshness preflight",
2366
+ description=textwrap.dedent(
2367
+ """
2368
+ Ask a question over the configured source set.
2369
+
2370
+ Use this for architecture, docs, behavior, ownership, or status questions.
2371
+ Memdex checks freshness first, queries NotebookLM, then prints compact
2372
+ provider references. Verify exact claims from local evidence.
2373
+ """
2374
+ ).strip(),
2375
+ )
2376
+ ask.add_argument("question", help="natural-language question to ask over the source set")
2377
+ ask.add_argument("--repo", default=".", help="project root (default: current directory)")
2378
+ ask.add_argument("--yes", action="store_true", help="approve first broad upload if setup is otherwise ready")
2379
+ ask.add_argument("--force-refresh", action="store_true", help="refresh managed sources before asking")
2380
+ ask.add_argument("--json", action="store_true", help="print machine-readable JSON")
2381
+ ask.add_argument("--verbose", action="store_true", help="include freshness and provider metadata")
2382
+ ask.set_defaults(func=cmd_ask)
2383
+
2384
+ locate = sub.add_parser(
2385
+ "locate",
2386
+ help="find likely files or symbols and verify local line refs",
2387
+ description=textwrap.dedent(
2388
+ """
2389
+ Locate implementation, docs, tests, or symbols and verify local line refs.
2390
+
2391
+ Use this when the user asks "where is X?" or needs candidate paths.
2392
+ Memdex queries the semantic provider for candidates, then checks local
2393
+ files with exact line references when possible.
2394
+ """
2395
+ ).strip(),
2396
+ )
2397
+ locate.add_argument("query", help="natural-language thing to find")
2398
+ locate.add_argument("--repo", default=".", help="project root (default: current directory)")
2399
+ locate.add_argument("--yes", action="store_true", help="approve first broad upload if setup is otherwise ready")
2400
+ locate.add_argument("--force-refresh", action="store_true", help="refresh managed sources before locating")
2401
+ locate.add_argument("--include-provider-answer", action="store_true", help="include the raw provider answer in output")
2402
+ locate.add_argument("--json", action="store_true", help="print machine-readable JSON")
2403
+ locate.add_argument("--verbose", action="store_true", help="include freshness metadata")
2404
+ locate.set_defaults(func=cmd_locate)
2405
+
2406
+ init = sub.add_parser(
2407
+ "init",
2408
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2409
+ help="create .memdex/config.json and bind a NotebookLM notebook",
2410
+ description="Create project-local Memdex config and bind it to a NotebookLM notebook.",
2411
+ epilog=textwrap.dedent(
2412
+ """
2413
+ Examples:
2414
+ memdex init --repo . --create-notebook
2415
+ memdex init --repo . --reuse-existing-notebook
2416
+ memdex init --repo . --notebook-id <id>
2417
+ """
2418
+ ).strip(),
2419
+ )
2420
+ init.add_argument("--repo", default=".", help="project, repo, vault, or source-set root (default: current directory)")
2421
+ init.add_argument("--notebook-id", default="", help="bind an existing NotebookLM notebook by ID")
2422
+ init.add_argument("--project-name", default="", help="stable project key for notebook and source titles (default: repo basename)")
2423
+ init.add_argument("--notebook-title-prefix", default=DEFAULT_NOTEBOOK_TITLE_PREFIX, help="NotebookLM title prefix (default: memdex)")
2424
+ init.add_argument("--notebook-title", default="", help="exact NotebookLM title to create or reuse")
2425
+ init.add_argument("--reuse-existing-notebook", action="store_true", help="reuse an exact title match; do not create cloud state")
2426
+ init.add_argument("--create-notebook", action="store_true", help="create the NotebookLM notebook when no exact title match exists")
2427
+ init.add_argument("--source-title-prefix", default="", help="prefix for managed NotebookLM source titles (default: memdex)")
2428
+ init.add_argument("--include", default="", help="comma-separated include roots or files for the source set")
2429
+ init.add_argument("--force", action="store_true", help="overwrite existing .memdex/config.json")
2342
2430
  init.set_defaults(func=cmd_init)
2343
2431
 
2344
- status = sub.add_parser("status")
2345
- status.add_argument("--repo", default=".")
2346
- status.add_argument("--json", action="store_true")
2432
+ status = sub.add_parser(
2433
+ "status",
2434
+ help="inspect config, freshness, and recorded source state",
2435
+ description="Inspect local Memdex config, freshness fingerprints, and NotebookLM source state.",
2436
+ )
2437
+ status.add_argument("--repo", default=".", help="project root (default: current directory)")
2438
+ status.add_argument("--json", action="store_true", help="print machine-readable JSON")
2347
2439
  status.set_defaults(func=cmd_status)
2348
2440
 
2349
- pack = sub.add_parser("pack")
2350
- pack.add_argument("--repo", default=".")
2351
- pack.add_argument("--set-id", default="")
2352
- pack.add_argument("--dry-run", action="store_true")
2353
- pack.add_argument("--include-files", action="store_true")
2354
- pack.add_argument("--json", action="store_true")
2441
+ pack = sub.add_parser(
2442
+ "pack",
2443
+ help="preview deterministic repomix chunks",
2444
+ description="Preview or build deterministic whole-file chunks for the configured source set.",
2445
+ )
2446
+ pack.add_argument("--repo", default=".", help="project root (default: current directory)")
2447
+ pack.add_argument("--set-id", default="", help="stable source-set ID for rendered chunk titles")
2448
+ pack.add_argument("--dry-run", action="store_true", help="show planned chunks without running repomix")
2449
+ pack.add_argument("--include-files", action="store_true", help="include per-chunk file lists in output")
2450
+ pack.add_argument("--json", action="store_true", help="print machine-readable JSON")
2355
2451
  pack.set_defaults(func=cmd_pack)
2356
2452
 
2357
- ensure = sub.add_parser("ensure")
2358
- ensure.add_argument("--repo", default=".")
2359
- ensure.add_argument("--force", action="store_true")
2360
- ensure.add_argument("--yes", action="store_true")
2361
- ensure.add_argument("--json", action="store_true")
2453
+ ensure = sub.add_parser(
2454
+ "ensure",
2455
+ help="prewarm or refresh the index when policy allows",
2456
+ description="Run freshness preflight and upload/refresh sources only when policy allows.",
2457
+ )
2458
+ ensure.add_argument("--repo", default=".", help="project root (default: current directory)")
2459
+ ensure.add_argument("--force", action="store_true", help="bypass freshness TTL and rebuild source state")
2460
+ ensure.add_argument("--yes", action="store_true", help="approve the first broad upload for this run")
2461
+ ensure.add_argument("--json", action="store_true", help="print machine-readable JSON")
2362
2462
  ensure.set_defaults(func=cmd_ensure)
2363
2463
 
2364
- refresh = sub.add_parser("refresh")
2365
- refresh.add_argument("--repo", default=".")
2366
- refresh.add_argument("--force", action="store_true")
2367
- refresh.add_argument("--json", action="store_true")
2464
+ refresh = sub.add_parser(
2465
+ "refresh",
2466
+ help="force source replacement",
2467
+ description="Refresh managed NotebookLM sources, replacing old recorded sources after success.",
2468
+ )
2469
+ refresh.add_argument("--repo", default=".", help="project root (default: current directory)")
2470
+ refresh.add_argument("--force", action="store_true", help="force refresh even when freshness checks would skip it")
2471
+ refresh.add_argument("--json", action="store_true", help="print machine-readable JSON")
2368
2472
  refresh.set_defaults(func=cmd_refresh)
2369
2473
 
2370
- ask = sub.add_parser("ask")
2371
- ask.add_argument("question")
2372
- ask.add_argument("--repo", default=".")
2373
- ask.add_argument("--yes", action="store_true")
2374
- ask.add_argument("--force-refresh", action="store_true")
2375
- ask.add_argument("--json", action="store_true")
2376
- ask.add_argument("--verbose", action="store_true")
2377
- ask.set_defaults(func=cmd_ask)
2378
-
2379
- locate = sub.add_parser("locate")
2380
- locate.add_argument("query")
2381
- locate.add_argument("--repo", default=".")
2382
- locate.add_argument("--yes", action="store_true")
2383
- locate.add_argument("--force-refresh", action="store_true")
2384
- locate.add_argument("--include-provider-answer", action="store_true")
2385
- locate.add_argument("--json", action="store_true")
2386
- locate.add_argument("--verbose", action="store_true")
2387
- locate.set_defaults(func=cmd_locate)
2388
-
2389
- temp = sub.add_parser("temp-source")
2390
- temp_sub = temp.add_subparsers(dest="temp_command", required=True)
2391
-
2392
- temp_upload = temp_sub.add_parser("upload")
2393
- temp_upload.add_argument("--repo", default=".")
2394
- temp_upload.add_argument("--kind", required=True)
2395
- temp_upload.add_argument("--title", required=True)
2396
- temp_upload.add_argument("--file", required=True)
2397
- temp_upload.add_argument("--origin-chunk", action="append", default=[])
2398
- temp_upload.add_argument("--origin-file", action="append", default=[])
2399
- temp_upload.add_argument("--ttl-seconds", type=int, default=0)
2400
- temp_upload.add_argument("--json", action="store_true")
2474
+ temp = sub.add_parser(
2475
+ "temp-source",
2476
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2477
+ help="manage temporary derived NotebookLM sources",
2478
+ description="Upload, list, or clean temporary derived sources such as notes or study aids.",
2479
+ )
2480
+ temp_sub = temp.add_subparsers(title="temp-source commands", dest="temp_command", metavar="<command>", required=True)
2481
+
2482
+ temp_upload = temp_sub.add_parser("upload", help="upload a temporary source file")
2483
+ temp_upload.add_argument("--repo", default=".", help="project root (default: current directory)")
2484
+ temp_upload.add_argument("--kind", required=True, help="temporary source kind, for example notes or flashcard")
2485
+ temp_upload.add_argument("--title", required=True, help="human-readable title slug for this temporary source")
2486
+ temp_upload.add_argument("--file", required=True, help="local markdown/text file to upload")
2487
+ temp_upload.add_argument("--origin-chunk", action="append", default=[], help="origin active chunk key; repeatable")
2488
+ temp_upload.add_argument("--origin-file", action="append", default=[], help="origin local file path; repeatable")
2489
+ temp_upload.add_argument("--ttl-seconds", type=int, default=0, help="optional expiry TTL in seconds")
2490
+ temp_upload.add_argument("--json", action="store_true", help="print machine-readable JSON")
2401
2491
  temp_upload.set_defaults(func=cmd_temp_source_upload)
2402
2492
 
2403
- temp_list = temp_sub.add_parser("list")
2404
- temp_list.add_argument("--repo", default=".")
2405
- temp_list.add_argument("--kind", default="")
2406
- temp_list.add_argument("--json", action="store_true")
2493
+ temp_list = temp_sub.add_parser("list", help="list recorded temporary sources")
2494
+ temp_list.add_argument("--repo", default=".", help="project root (default: current directory)")
2495
+ temp_list.add_argument("--kind", default="", help="filter by temporary source kind")
2496
+ temp_list.add_argument("--json", action="store_true", help="print machine-readable JSON")
2407
2497
  temp_list.set_defaults(func=cmd_temp_source_list)
2408
2498
 
2409
- temp_cleanup = temp_sub.add_parser("cleanup")
2410
- temp_cleanup.add_argument("--repo", default=".")
2411
- temp_cleanup.add_argument("--kind", default="")
2412
- temp_cleanup.add_argument("--set-id", default="")
2413
- temp_cleanup.add_argument("--expired", action="store_true")
2414
- temp_cleanup.add_argument("--include-untracked-prefix", action="store_true")
2415
- temp_cleanup.add_argument("--yes", action="store_true")
2416
- temp_cleanup.add_argument("--json", action="store_true")
2499
+ temp_cleanup = temp_sub.add_parser("cleanup", help="delete recorded temporary sources")
2500
+ temp_cleanup.add_argument("--repo", default=".", help="project root (default: current directory)")
2501
+ temp_cleanup.add_argument("--kind", default="", help="filter by temporary source kind")
2502
+ temp_cleanup.add_argument("--set-id", default="", help="filter by temporary source-set ID")
2503
+ temp_cleanup.add_argument("--expired", action="store_true", help="clean only expired temporary sources")
2504
+ temp_cleanup.add_argument("--include-untracked-prefix", action="store_true", help="also delete untracked prefix matches; requires --yes")
2505
+ temp_cleanup.add_argument("--yes", action="store_true", help="confirm deletion")
2506
+ temp_cleanup.add_argument("--json", action="store_true", help="print machine-readable JSON")
2417
2507
  temp_cleanup.set_defaults(func=cmd_temp_source_cleanup)
2418
2508
  return parser
2419
2509