brainpick 0.8.2__tar.gz → 0.8.4__tar.gz

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.
Files changed (124) hide show
  1. {brainpick-0.8.2 → brainpick-0.8.4}/PKG-INFO +1 -1
  2. {brainpick-0.8.2 → brainpick-0.8.4}/pyproject.toml +1 -1
  3. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/__init__.py +1 -1
  4. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_releases/releases.yaml +53 -0
  5. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/cli.py +8 -2
  6. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/federation.py +5 -3
  7. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/sync.py +27 -4
  8. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick.egg-info/PKG-INFO +1 -1
  9. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_cli.py +22 -0
  10. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_sync.py +58 -0
  11. {brainpick-0.8.2 → brainpick-0.8.4}/README.md +0 -0
  12. {brainpick-0.8.2 → brainpick-0.8.4}/setup.cfg +0 -0
  13. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/__main__.py +0 -0
  14. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_ritual/RITUAL.md +0 -0
  15. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_skill/SKILL.md +0 -0
  16. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/assets/Editor-K9XANZX_.js +0 -0
  17. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/assets/index-DOjNNQV2.js +0 -0
  18. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/assets/index-Dn6TTKMy.css +0 -0
  19. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/assets/virtual_pwa-register-vAnKLON8.js +0 -0
  20. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/assets/workbox-window.prod.es5-BBnX5xw4.js +0 -0
  21. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/assets/worker-CVB4_RMu.js +0 -0
  22. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/icons/apple-touch-icon.png +0 -0
  23. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/icons/favicon.svg +0 -0
  24. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/icons/icon-192.png +0 -0
  25. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/icons/icon-512.png +0 -0
  26. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/icons/icon-maskable-512.png +0 -0
  27. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/index.html +0 -0
  28. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/manifest.webmanifest +0 -0
  29. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/sw.js +0 -0
  30. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/_static/workbox-a3c94b52.js +0 -0
  31. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/auth.py +0 -0
  32. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/compile/__init__.py +0 -0
  33. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/compile/conventions.py +0 -0
  34. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/compile/pipeline.py +0 -0
  35. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/compile/similarity_gaps.py +0 -0
  36. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/compile/skills.py +0 -0
  37. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/compile/t1.py +0 -0
  38. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/compile/t2.py +0 -0
  39. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/compile/t3.py +0 -0
  40. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/compile/todos.py +0 -0
  41. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/config.py +0 -0
  42. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/core/__init__.py +0 -0
  43. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/core/bundle.py +0 -0
  44. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/core/canonical.py +0 -0
  45. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/core/frontmatter.py +0 -0
  46. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/core/fs.py +0 -0
  47. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/core/links.py +0 -0
  48. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/deltas.py +0 -0
  49. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/detect.py +0 -0
  50. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/embed.py +0 -0
  51. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/integrate.py +0 -0
  52. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/kg.py +0 -0
  53. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/kgadapt/__init__.py +0 -0
  54. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/kgadapt/algorithmic.py +0 -0
  55. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/kgadapt/protocol.py +0 -0
  56. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/llm.py +0 -0
  57. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/mcp_server.py +0 -0
  58. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/merge.py +0 -0
  59. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/migrate.py +0 -0
  60. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/query/__init__.py +0 -0
  61. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/query/half_life.py +0 -0
  62. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/query/keyword.py +0 -0
  63. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/query/present.py +0 -0
  64. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/query/router.py +0 -0
  65. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/query/vectors.py +0 -0
  66. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/releases.py +0 -0
  67. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/scaffold.py +0 -0
  68. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/serve/__init__.py +0 -0
  69. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/serve/app.py +0 -0
  70. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/serve/live.py +0 -0
  71. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/serve/rest.py +0 -0
  72. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/serve/state.py +0 -0
  73. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/serve/watcher.py +0 -0
  74. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/skill_cmd.py +0 -0
  75. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/timeline.py +0 -0
  76. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/update.py +0 -0
  77. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick/vectorstore.py +0 -0
  78. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick.egg-info/SOURCES.txt +0 -0
  79. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick.egg-info/dependency_links.txt +0 -0
  80. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick.egg-info/entry_points.txt +0 -0
  81. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick.egg-info/requires.txt +0 -0
  82. {brainpick-0.8.2 → brainpick-0.8.4}/src/brainpick.egg-info/top_level.txt +0 -0
  83. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_auth.py +0 -0
  84. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_bundle.py +0 -0
  85. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_config.py +0 -0
  86. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_conformance.py +0 -0
  87. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_conventions.py +0 -0
  88. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_deltas.py +0 -0
  89. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_detect.py +0 -0
  90. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_e2e_mcp.py +0 -0
  91. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_e2e_serve.py +0 -0
  92. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_federation.py +0 -0
  93. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_frontmatter.py +0 -0
  94. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_half_life.py +0 -0
  95. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_integrate.py +0 -0
  96. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_keyword.py +0 -0
  97. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_kg.py +0 -0
  98. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_links.py +0 -0
  99. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_llm.py +0 -0
  100. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_mcp_tools.py +0 -0
  101. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_merge.py +0 -0
  102. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_migrate.py +0 -0
  103. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_pipeline.py +0 -0
  104. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_present.py +0 -0
  105. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_releases.py +0 -0
  106. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_report.py +0 -0
  107. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_router.py +0 -0
  108. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_scaffold.py +0 -0
  109. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_serve_state.py +0 -0
  110. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_similarity_gaps.py +0 -0
  111. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_similarity_gaps_stage.py +0 -0
  112. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_skills.py +0 -0
  113. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_t1.py +0 -0
  114. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_t2_chunker.py +0 -0
  115. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_t2_embed.py +0 -0
  116. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_t2_stage.py +0 -0
  117. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_t2_store.py +0 -0
  118. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_t3_algorithmic.py +0 -0
  119. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_t3_backend.py +0 -0
  120. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_t3_export.py +0 -0
  121. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_t3_stage.py +0 -0
  122. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_timeline.py +0 -0
  123. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_todos.py +0 -0
  124. {brainpick-0.8.2 → brainpick-0.8.4}/tests/test_update.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: brainpick
3
- Version: 0.8.2
3
+ Version: 0.8.4
4
4
  Summary: A turn-key brain stack for agents: compile an OKF markdown bundle into a queryable, servable, visualizable brain.
5
5
  Author: Benquemax
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "brainpick"
7
- version = "0.8.2"
7
+ version = "0.8.4"
8
8
  description = "A turn-key brain stack for agents: compile an OKF markdown bundle into a queryable, servable, visualizable brain."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -1,4 +1,4 @@
1
1
  """brainpick — a turn-key brain stack for agents."""
2
2
 
3
- __version__ = "0.8.2"
3
+ __version__ = "0.8.4"
4
4
  SPEC_VERSION = "0.1"
@@ -15,6 +15,59 @@
15
15
  # area: brain | cli | mcp | search | config | compile | webui | docs
16
16
 
17
17
  releases:
18
+ - version: 0.8.4
19
+ date: 2026-09-25
20
+ brain_format: 3
21
+ summary: >-
22
+ `brain_push` also stages the AGENTS.md report its own compile refreshed,
23
+ so a push of a subdirectory bundle no longer leaves the repo-root report
24
+ modified behind it.
25
+ agent_action: >-
26
+ If `brain_status` reports the checkout dirty right after a successful
27
+ `brain_push` and the only modified file is AGENTS.md, upgrade — the next
28
+ push carries it. Nothing to undo.
29
+ changes:
30
+ - kind: fixed
31
+ area: mcp
32
+ text: >-
33
+ The push staged the bundle pathspec only. The compile it runs first
34
+ rewrites the opt-in report block at the bundle root and at the repo
35
+ root above it (spec/20), both outside that pathspec for a
36
+ subdirectory bundle, so every push left the report uncommitted and
37
+ the remote's copy stale. The report files that carry the block are
38
+ now staged with the bundle; nothing is created.
39
+ - version: 0.8.3
40
+ date: 2026-09-25
41
+ brain_format: 3
42
+ summary: >-
43
+ Two more places where one path meant two roots. `brainpick register REPO`
44
+ now registers the bundle a repo-root `brainpick.toml` points at, and
45
+ `brain_push` runs `henxels check --all` instead of handing henxels the
46
+ bundle directory as if it were a file.
47
+ agent_action: >-
48
+ If a registry entry shows `bundle_path = ""` for a repo whose config has
49
+ `[bundle] root`, remove it and register again (`brainpick register REPO
50
+ --remove`, then `brainpick register REPO --cortex`), and delete any
51
+ `index.md` or `.brainpick/` the old entry left at the repo root. Upgrade
52
+ henxels to 0.19.2 as well: it now expands a directory argument, so both
53
+ sides of brain_push agree.
54
+ changes:
55
+ - kind: fixed
56
+ area: cli
57
+ text: >-
58
+ `register` and `register --from-hosts` resolve `[bundle] root` before
59
+ writing the entry, and the bundle id is read from the repo's config.
60
+ A repo-root path used to be stored as the bundle, so the registry-mode
61
+ server compiled the whole repo as the brain and wrote its artifacts
62
+ at the repo root.
63
+ - kind: fixed
64
+ area: mcp
65
+ text: >-
66
+ `brain_push` verifies the contract with `henxels check --all` — the
67
+ same run the pre-commit hook does, repo-level henxels included. With
68
+ the bundle path as the argument, henxels before 0.19.2 judged the
69
+ directory entry as a file ("_brain — should be .md") and refused
70
+ every push of a subdirectory bundle.
18
71
  - version: 0.8.2
19
72
  date: 2026-09-25
20
73
  brain_format: 3
@@ -488,7 +488,12 @@ def _cmd_register(args: argparse.Namespace) -> int:
488
488
  print(f"registry: {registry}")
489
489
  return 0
490
490
 
491
- root = Path(args.path).resolve()
491
+ from brainpick.config import resolve_bundle
492
+
493
+ # PATH may be a repo root above its bundle ([bundle] root, spec/80) — register
494
+ # the bundle it governs, as `mcp --root` would, or the registry-mode server
495
+ # compiles the whole repo as the brain and reads its config from nowhere.
496
+ root, _ = resolve_bundle(args.path, env)
492
497
  if args.remove:
493
498
  if unregister_brain(root, registry):
494
499
  print(f"removed {root} from {registry}")
@@ -513,6 +518,7 @@ def _register_from_hosts(args: argparse.Namespace, registry, env, shown_alias) -
513
518
  """spec/75: the one-command migration — every `mcp --root DIR` in the agent
514
519
  host configs becomes a registry entry; then ONE replacement entry is shown.
515
520
  Never edits a host config."""
521
+ from brainpick.config import resolve_bundle
516
522
  from brainpick.federation import entry_root, load_registry, register_brain, scan_hosts
517
523
  from brainpick.scaffold import brainpick_command
518
524
 
@@ -526,7 +532,7 @@ def _register_from_hosts(args: argparse.Namespace, registry, env, shown_alias) -
526
532
  registered = 0
527
533
  for item in found:
528
534
  via = ", ".join(item.hosts)
529
- root = item.root.resolve()
535
+ root, _ = resolve_bundle(item.root, env) # a `--root` repo root → its bundle (spec/80)
530
536
  if root in existing:
531
537
  print(f" already registered {root} ({via})")
532
538
  continue
@@ -225,10 +225,12 @@ def _split_root(root: Path) -> tuple[str, str]:
225
225
  return str(repo), root.relative_to(repo).as_posix()
226
226
 
227
227
 
228
- def _bundle_id(root: Path) -> str:
228
+ def _bundle_id(config_root: Path) -> str:
229
+ """`[bundle] id` from the config that governs the bundle — at the repo, not
230
+ the bundle, when they differ — else a fresh id."""
229
231
  from brainpick.config import generate_bundle_id, load_config
230
232
 
231
- return load_config(root).bundle.id or generate_bundle_id()
233
+ return load_config(config_root).bundle.id or generate_bundle_id()
232
234
 
233
235
 
234
236
  def register_brain(root: str | Path, path: str | Path | None = None, alias: str | None = None,
@@ -248,7 +250,7 @@ def register_brain(root: str | Path, path: str | Path | None = None, alias: str
248
250
  while port in used_ports:
249
251
  port += 1
250
252
  entry = dict(existing) if existing else {
251
- "id": _bundle_id(root), "repo": repo, "bundle_path": bundle_path, "port": port,
253
+ "id": _bundle_id(Path(repo)), "repo": repo, "bundle_path": bundle_path, "port": port,
252
254
  "enabled": True, "host": DEFAULT_HOST,
253
255
  }
254
256
  if alias:
@@ -327,9 +327,11 @@ def run_contract(root: str | Path, config=None) -> tuple[str, str | None]:
327
327
  "`uv tool install henxels` — or commit and push from a shell where it is "
328
328
  "available. Refusing to publish an unverified commit.")
329
329
  cwd = contract.parent if contract is not None else root
330
- target = os.path.relpath(root, cwd) or "."
330
+ # `--all`, not the bundle path: a push verifies the whole contract the way the
331
+ # pre-commit hook does (repo-level henxels included), and henxels given a
332
+ # directory argument tests the directory entry itself as a file.
331
333
  try:
332
- proc = subprocess.run([executable, "check", target], cwd=cwd,
334
+ proc = subprocess.run([executable, "check", "--all"], cwd=cwd,
333
335
  capture_output=True, text=True, timeout=120)
334
336
  except subprocess.TimeoutExpired:
335
337
  return "fail", "henxels check timed out after 120s — nothing was committed"
@@ -340,6 +342,23 @@ def run_contract(root: str | Path, config=None) -> tuple[str, str | None]:
340
342
  return "pass", None
341
343
 
342
344
 
345
+ def _report_pathspecs(root: Path, repo: Path) -> list[str]:
346
+ """Repo-relative paths of the AGENTS.md files carrying a brainpick report block
347
+ (spec/20): the bundle root's and, when the bundle is a subdirectory, the repo
348
+ root's. Only files that exist and hold the block — never created here."""
349
+ from brainpick.compile.t1 import REPORT_BEGIN_PREFIX
350
+
351
+ out: list[str] = []
352
+ for base in {root.resolve(), repo.resolve()}:
353
+ agents = base / "AGENTS.md"
354
+ try:
355
+ if REPORT_BEGIN_PREFIX in agents.read_text(encoding="utf-8"):
356
+ out.append(os.path.relpath(agents, repo))
357
+ except OSError:
358
+ continue
359
+ return sorted(out)
360
+
361
+
343
362
  def push_brain(state, message: str) -> dict:
344
363
  """spec/100 brain_push: compile, run the contract, stage the bundle, commit, push.
345
364
  Hooks always run — no engine may pass --no-verify."""
@@ -399,12 +418,16 @@ def push_brain(state, message: str) -> dict:
399
418
  # not the brain, and a tool that publishes on an agent's word must not sweep up
400
419
  # work nobody reviewed.
401
420
  pathspec = os.path.relpath(root, repo) or "."
402
- code, _, err = run_git(repo, "add", "--", pathspec)
421
+ # ...plus the opt-in AGENTS.md report the compile above just refreshed: it lives
422
+ # at the bundle root and, for a subdirectory bundle, at the repo root — outside
423
+ # the bundle pathspec, so it stayed modified after every push.
424
+ pathspecs = [pathspec] + _report_pathspecs(root, repo)
425
+ code, _, err = run_git(repo, "add", "--", *pathspecs)
403
426
  if code != 0:
404
427
  result["hint"] = f"git add failed: {err.strip()}"
405
428
  return result
406
429
 
407
- code, staged, _ = run_git(repo, "diff", "--cached", "--name-only", "--", pathspec)
430
+ code, staged, _ = run_git(repo, "diff", "--cached", "--name-only", "--", *pathspecs)
408
431
  if not staged.strip():
409
432
  ahead = status["ahead"]
410
433
  if ahead > 0: # nothing new to commit, but local commits still need sending
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: brainpick
3
- Version: 0.8.2
3
+ Version: 0.8.4
4
4
  Summary: A turn-key brain stack for agents: compile an OKF markdown bundle into a queryable, servable, visualizable brain.
5
5
  Author: Benquemax
6
6
  License: MIT
@@ -1,4 +1,5 @@
1
1
  """CLI wiring: the serve/mcp/compile/init/doctor subcommands exist and describe themselves."""
2
+ import subprocess
2
3
  import io
3
4
  import json
4
5
 
@@ -344,3 +345,24 @@ def test_compile_prints_the_update_notice_when_one_is_known(kotiaurinko, capsys,
344
345
  assert main(["compile", "--root", str(kotiaurinko)]) == 0
345
346
  out = capsys.readouterr().out
346
347
  assert "note: brainpick 9.9.9 is available" in out and "pip install -U brainpick" in out
348
+
349
+
350
+ def test_cli_register_resolves_a_repo_root_to_its_bundle(kotiaurinko, tmp_path, monkeypatch, capsys):
351
+ # `register REPO` where REPO/brainpick.toml points at a subdirectory bundle must
352
+ # store the bundle (repo + bundle_path), like `mcp --root REPO` resolves it — or
353
+ # the registry-mode server compiles the whole repo as the brain and serves every
354
+ # .md in it, with its config read from nowhere.
355
+ from brainpick.federation import entry_root, load_registry
356
+
357
+ registry = tmp_path / "brains.toml"
358
+ monkeypatch.setenv("BRAINPICK_REGISTRY", str(registry))
359
+ repo = kotiaurinko.parent
360
+ (repo / "brainpick.toml").write_text('[bundle]\nroot = "kotiaurinko"\n', encoding="utf-8")
361
+ subprocess.run(["git", "init", "-q", str(repo)], check=True) # repo + bundle_path needs a repo above
362
+ assert main(["register", str(repo), "--cortex"]) == 0
363
+ capsys.readouterr()
364
+ entries = load_registry(registry)
365
+ assert entries[0]["bundle_path"] == "kotiaurinko"
366
+ assert entry_root(entries[0]) == kotiaurinko.resolve()
367
+ assert main(["register", str(repo), "--remove"]) == 0 # the same spelling removes it
368
+ assert load_registry(registry) == []
@@ -526,3 +526,61 @@ def test_contract_optional_requirements_never_fail_the_whole(tmp_path):
526
526
  fmt = next(r for r in payload["requirements"] if r["id"] == "brain-format")
527
527
  assert fmt["required"] is False
528
528
  assert payload["satisfied"] is True # satisfied tracks the REQUIRED floor
529
+
530
+
531
+ def test_push_runs_the_whole_contract_not_the_bundle_path(tmp_path, monkeypatch):
532
+ """brain_push verifies the contract the way the pre-commit hook does — every
533
+ henxel, over the whole tree — so it must call `henxels check --all`. Passing
534
+ the bundle directory as a path made henxels test the directory entry itself
535
+ as a file ("_brain — should be .md"), which failed every push of a
536
+ subdirectory bundle governed by a repo-root contract."""
537
+ import subprocess as sp
538
+
539
+ local, _ = make_pair(tmp_path)
540
+ (local / "henxels.yaml").write_text("henxels: []\n", encoding="utf-8")
541
+ (local / "uusi.md").write_text("---\ntype: Concept\n---\n\n# U\n", encoding="utf-8")
542
+ monkeypatch.setattr("brainpick.sync.find_henxels", lambda *a, **k: "henxels")
543
+ seen = []
544
+ real_run = sp.run
545
+
546
+ def fake_run(argv, **kwargs): # intercept henxels only; git still runs for real
547
+ if argv[0] != "henxels":
548
+ return real_run(argv, **kwargs)
549
+ seen.append(argv)
550
+ return sp.CompletedProcess(argv, 0, stdout="", stderr="")
551
+
552
+ monkeypatch.setattr("brainpick.sync.subprocess.run", fake_run)
553
+ result = push_brain(state_for(local), "add uusi")
554
+ assert result["contract"] == "pass"
555
+ assert seen and seen[0][1:] == ["check", "--all"]
556
+
557
+
558
+ def test_push_stages_the_report_the_compile_refreshed_above_the_bundle(tmp_path):
559
+ """brain_push compiles first, and a compile refreshes the opt-in AGENTS.md report
560
+ at the repo root above a subdirectory bundle. Staging only the bundle left that
561
+ report modified after every push — the remote's copy went stale and the next
562
+ brain_status called the checkout dirty."""
563
+ from brainpick.integrate import _REPORT_PLACEHOLDER
564
+
565
+ repo = tmp_path / "repo"
566
+ repo.mkdir()
567
+ shutil.copytree(FIXTURE_BUNDLES / "kotiaurinko", repo / "_brain")
568
+ (repo / "brainpick.toml").write_text('[bundle]\nroot = "_brain"\n', encoding="utf-8")
569
+ (repo / "AGENTS.md").write_text("# Agents\n\n" + _REPORT_PLACEHOLDER + "\n", encoding="utf-8")
570
+ git(tmp_path, "init", "-q", str(repo))
571
+ git(repo, "config", "user.email", "t@example.com")
572
+ git(repo, "config", "user.name", "T")
573
+ git(repo, "add", "-A")
574
+ git(repo, "commit", "-qm", "seed")
575
+ origin = tmp_path / "origin.git"
576
+ git(tmp_path, "clone", "-q", "--bare", str(repo), str(origin))
577
+ git(repo, "remote", "add", "origin", str(origin))
578
+ git(repo, "fetch", "-q", "origin")
579
+ git(repo, "branch", "--set-upstream-to", f"origin/{branch_of(repo)}", branch_of(repo))
580
+ (repo / "_brain" / "uusi.md").write_text(
581
+ "---\ntype: Concept\ntitle: Uusi\ndescription: d\n---\n\n# Uusi\n", encoding="utf-8")
582
+
583
+ result = push_brain(ServeState(repo / "_brain", load_config(repo)), "add uusi")
584
+ assert result["ok"] is True and result["pushed"] is True
585
+ assert "brainpick:begin report" in (repo / "AGENTS.md").read_text(encoding="utf-8")
586
+ assert "AGENTS.md" not in git(repo, "status", "--porcelain")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes