sessionmemory 0.13.0__tar.gz → 0.15.0__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 (52) hide show
  1. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/PKG-INFO +9 -5
  2. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/README.md +8 -4
  3. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/pyproject.toml +1 -1
  4. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/pyproject.toml.orig +1 -1
  5. sessionmemory-0.15.0/src/sessionmemory/cli.py +101 -0
  6. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/commands/_common.py +3 -1
  7. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/commands/export.py +9 -5
  8. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/commands/inject.py +12 -5
  9. sessionmemory-0.15.0/src/sessionmemory/commands/local.py +604 -0
  10. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/commands/log.py +3 -3
  11. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/commands/new.py +19 -9
  12. sessionmemory-0.15.0/src/sessionmemory/commands/path.py +66 -0
  13. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/commands/project.py +76 -32
  14. sessionmemory-0.15.0/src/sessionmemory/commands/reconcile.py +80 -0
  15. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/commands/reindex.py +2 -2
  16. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/commands/search.py +12 -7
  17. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/atomic.py +12 -2
  18. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/bootstrap.py +49 -4
  19. sessionmemory-0.15.0/src/sessionmemory/lib/changes.py +126 -0
  20. sessionmemory-0.15.0/src/sessionmemory/lib/commits.py +529 -0
  21. sessionmemory-0.15.0/src/sessionmemory/lib/doctor.py +685 -0
  22. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/field.py +12 -2
  23. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/gitinfo.py +10 -2
  24. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/inject.py +4 -28
  25. sessionmemory-0.15.0/src/sessionmemory/lib/localmanifest.py +267 -0
  26. sessionmemory-0.15.0/src/sessionmemory/lib/localmd.py +1568 -0
  27. sessionmemory-0.15.0/src/sessionmemory/lib/localtree.py +206 -0
  28. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/paths.py +12 -6
  29. sessionmemory-0.15.0/src/sessionmemory/lib/reconcile.py +388 -0
  30. sessionmemory-0.15.0/src/sessionmemory/lib/settingsdiff.py +133 -0
  31. sessionmemory-0.13.0/src/sessionmemory/cli.py +0 -83
  32. sessionmemory-0.13.0/src/sessionmemory/commands/local.py +0 -134
  33. sessionmemory-0.13.0/src/sessionmemory/commands/path.py +0 -44
  34. sessionmemory-0.13.0/src/sessionmemory/lib/doctor.py +0 -375
  35. sessionmemory-0.13.0/src/sessionmemory/lib/localmd.py +0 -430
  36. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/__init__.py +0 -0
  37. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/commands/__init__.py +0 -0
  38. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/commands/delete.py +0 -0
  39. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/commands/doctor.py +0 -0
  40. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/commands/init.py +0 -0
  41. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/__init__.py +0 -0
  42. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/backlog.py +0 -0
  43. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/config.py +0 -0
  44. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/embed.py +0 -0
  45. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/export.py +0 -0
  46. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/fieldindex.py +0 -0
  47. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/frontmatter.py +0 -0
  48. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/ids.py +0 -0
  49. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/log.py +0 -0
  50. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/registry.py +0 -0
  51. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/resolve.py +0 -0
  52. {sessionmemory-0.13.0 → sessionmemory-0.15.0}/src/sessionmemory/lib/specs.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sessionmemory
3
- Version: 0.13.0
3
+ Version: 0.15.0
4
4
  Summary: Durable memory for coding agents, one folder of searchable pages per project.
5
5
  Author: Nathaniel Landau
6
6
  Author-email: Nathaniel Landau <github@natelandau.com>
@@ -44,9 +44,13 @@ speaks the format.
44
44
  - Python 3.13 or 3.14. `uv` downloads one when none is installed.
45
45
  - git. The vault is a git repository, and a project is registered by its git remote.
46
46
  - Claude Code, to run the plugin. The CLI works on its own without it.
47
+ - Optional: the [GitHub CLI](https://cli.github.com/) (`gh`), signed in. `sessionmemory
48
+ reconcile` uses it to find the commit a squash-merged pull request landed as, when a
49
+ project's `origin` is on GitHub.
47
50
 
48
51
  The first search downloads the `nomic-embed-text-v1.5` embedding model, about 520MB, and
49
- caches it under `~/.cache/sessionmemory/models`. Nothing else touches the network.
52
+ caches it under `~/.cache/sessionmemory/models`. `sessionmemory reconcile` runs
53
+ `git fetch origin` and asks GitHub through `gh`. Nothing else touches the network.
50
54
 
51
55
  ## Install
52
56
 
@@ -141,7 +145,7 @@ yourself, run the command once:
141
145
 
142
146
  ```bash
143
147
  cd ~/repos/invoice-api
144
- sessionmemory project --register --cwd .
148
+ sessionmemory project register --cwd .
145
149
  ```
146
150
 
147
151
  ```
@@ -217,8 +221,8 @@ loaded for you: the titles are what the vault holds, and each is one `sessionmem
217
221
  away. The project's folder has `learnings/` and `logs/`, searched by meaning, beside
218
222
  `specs/`, `runbooks/`, `reference/`, and `backlog.md`, which are ordinary files you Read
219
223
  and Edit. `sessionmemory path <kind>` prints one path, where kind is project, learnings,
220
- logs, specs, runbooks, reference, or backlog; `sessionmemory project --json` prints
221
- them all for a script.
224
+ logs, specs, runbooks, reference, or backlog; `sessionmemory path --json` prints them
225
+ all for a script.
222
226
 
223
227
  - Before assuming nothing was written down, search: `sessionmemory search "<words>"`
224
228
  prints each hit's path, title, and summary, and `--read` prints every hit's whole
@@ -29,9 +29,13 @@ speaks the format.
29
29
  - Python 3.13 or 3.14. `uv` downloads one when none is installed.
30
30
  - git. The vault is a git repository, and a project is registered by its git remote.
31
31
  - Claude Code, to run the plugin. The CLI works on its own without it.
32
+ - Optional: the [GitHub CLI](https://cli.github.com/) (`gh`), signed in. `sessionmemory
33
+ reconcile` uses it to find the commit a squash-merged pull request landed as, when a
34
+ project's `origin` is on GitHub.
32
35
 
33
36
  The first search downloads the `nomic-embed-text-v1.5` embedding model, about 520MB, and
34
- caches it under `~/.cache/sessionmemory/models`. Nothing else touches the network.
37
+ caches it under `~/.cache/sessionmemory/models`. `sessionmemory reconcile` runs
38
+ `git fetch origin` and asks GitHub through `gh`. Nothing else touches the network.
35
39
 
36
40
  ## Install
37
41
 
@@ -126,7 +130,7 @@ yourself, run the command once:
126
130
 
127
131
  ```bash
128
132
  cd ~/repos/invoice-api
129
- sessionmemory project --register --cwd .
133
+ sessionmemory project register --cwd .
130
134
  ```
131
135
 
132
136
  ```
@@ -202,8 +206,8 @@ loaded for you: the titles are what the vault holds, and each is one `sessionmem
202
206
  away. The project's folder has `learnings/` and `logs/`, searched by meaning, beside
203
207
  `specs/`, `runbooks/`, `reference/`, and `backlog.md`, which are ordinary files you Read
204
208
  and Edit. `sessionmemory path <kind>` prints one path, where kind is project, learnings,
205
- logs, specs, runbooks, reference, or backlog; `sessionmemory project --json` prints
206
- them all for a script.
209
+ logs, specs, runbooks, reference, or backlog; `sessionmemory path --json` prints them
210
+ all for a script.
207
211
 
208
212
  - Before assuming nothing was written down, search: `sessionmemory search "<words>"`
209
213
  prints each hit's path, title, and summary, and `--read` prints every hit's whole
@@ -11,7 +11,7 @@ description = "Durable memory for coding agents, one folder of searchable pages
11
11
  name = "sessionmemory"
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.13,<3.15"
14
- version = "0.13.0"
14
+ version = "0.15.0"
15
15
 
16
16
  [[project.authors]]
17
17
  name = "Nathaniel Landau"
@@ -12,7 +12,7 @@
12
12
  name = "sessionmemory"
13
13
  readme = "README.md"
14
14
  requires-python = ">=3.13,<3.15"
15
- version = "0.13.0"
15
+ version = "0.15.0"
16
16
 
17
17
  [project.scripts]
18
18
  sessionmemory = "sessionmemory.cli:main"
@@ -0,0 +1,101 @@
1
+ """Session memory CLI invoked as `sessionmemory` by a user."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib.metadata
6
+
7
+ import typer
8
+
9
+ from sessionmemory.commands import delete as delete_commands
10
+ from sessionmemory.commands import doctor as doctor_commands
11
+ from sessionmemory.commands import export as export_commands
12
+ from sessionmemory.commands import init as init_commands
13
+ from sessionmemory.commands import inject as inject_commands
14
+ from sessionmemory.commands import local as local_commands
15
+ from sessionmemory.commands import log as log_commands
16
+ from sessionmemory.commands import new as new_commands
17
+ from sessionmemory.commands import path as path_commands
18
+ from sessionmemory.commands import project
19
+ from sessionmemory.commands import reconcile as reconcile_commands
20
+ from sessionmemory.commands import reindex as reindex_commands
21
+ from sessionmemory.commands import search as search_commands
22
+ from sessionmemory.commands._common import VersionedGroup, emit_value
23
+
24
+ app = typer.Typer(
25
+ cls=VersionedGroup,
26
+ no_args_is_help=True,
27
+ context_settings={"help_option_names": ["-h", "--help"]},
28
+ )
29
+
30
+ # Panels order the top-level help by who runs a command, so a newcomer reads the
31
+ # everyday commands first and the plugin's plumbing last.
32
+ EVERYDAY = "Everyday"
33
+ SETUP = "Setup"
34
+ MAINTENANCE = "Maintenance"
35
+ PLUGIN = "Plugin internals"
36
+
37
+
38
+ def _print_version(value: bool) -> None: # noqa: FBT001
39
+ """Print the installed version bare and exit, for a caller that compares it."""
40
+ if value:
41
+ emit_value(importlib.metadata.version("sessionmemory"))
42
+ raise typer.Exit
43
+
44
+
45
+ @app.callback()
46
+ def _root(
47
+ version: bool = typer.Option( # noqa: FBT001
48
+ False, # noqa: FBT003
49
+ "--version",
50
+ callback=_print_version,
51
+ is_eager=True,
52
+ help="Print the version and exit.",
53
+ ),
54
+ ) -> None:
55
+ """Manage a project's memory in a vault of markdown pages."""
56
+
57
+
58
+ app.command(
59
+ "search", help="Search learnings by meaning, or logs or specs.", rich_help_panel=EVERYDAY
60
+ )(search_commands.search_command)
61
+ app.add_typer(new_commands.app, name="new", rich_help_panel=EVERYDAY)
62
+ app.command("path", help="Print this project's vault paths.", rich_help_panel=EVERYDAY)(
63
+ path_commands.path_command
64
+ )
65
+ app.command("delete", help="Delete files from the vault permanently.", rich_help_panel=EVERYDAY)(
66
+ delete_commands.delete_command
67
+ )
68
+ app.command("init", help="Create the files a new vault needs.", rich_help_panel=SETUP)(
69
+ init_commands.init
70
+ )
71
+ app.add_typer(project.app, name="project", rich_help_panel=SETUP)
72
+ app.add_typer(local_commands.app, name="local", rich_help_panel=SETUP)
73
+ app.command(
74
+ "doctor", help="Report pages, projects, and indexes worth a look.", rich_help_panel=MAINTENANCE
75
+ )(doctor_commands.doctor_command)
76
+ app.command(
77
+ "reindex",
78
+ help="Rebuild this project's search indexes, or every project's.",
79
+ rich_help_panel=MAINTENANCE,
80
+ )(reindex_commands.reindex_command)
81
+ app.command(
82
+ "reconcile",
83
+ help="Update this project's session logs to match the commits on its default branch.",
84
+ rich_help_panel=MAINTENANCE,
85
+ )(reconcile_commands.reconcile_command)
86
+ app.command(
87
+ "export",
88
+ help="Write this project's learnings or logs as a .memoryfield.zip.",
89
+ rich_help_panel=MAINTENANCE,
90
+ )(export_commands.export_command)
91
+ app.command("inject", help="Print the block a session starts with.", rich_help_panel=PLUGIN)(
92
+ inject_commands.inject_command
93
+ )
94
+ app.command(
95
+ "log", help="Write this session's log page, replacing its body.", rich_help_panel=PLUGIN
96
+ )(log_commands.log_command)
97
+
98
+
99
+ def main() -> None:
100
+ """Run the CLI. This is the console script entry point."""
101
+ app()
@@ -33,6 +33,8 @@ if TYPE_CHECKING:
33
33
 
34
34
  EMBEDDER_ENV_VAR = "SESSIONMEMORY_EMBEDDER"
35
35
 
36
+ CWD_OPTION = typer.Option(None, "--cwd", "-C", help="Directory to resolve the project from.")
37
+
36
38
 
37
39
  # The two ways to name the vault, offered together whenever neither is set.
38
40
  VAULT_FIX = [
@@ -257,7 +259,7 @@ def require_project(vault: Path, cwd: Path | None = None) -> str:
257
259
  if not result.registered or result.slug is None:
258
260
  pp.error(
259
261
  "this directory is not a registered project",
260
- details=["run: sessionmemory project --register"],
262
+ details=["run: sessionmemory project register"],
261
263
  )
262
264
  raise typer.Exit(1)
263
265
  return result.slug
@@ -1,4 +1,4 @@
1
- """The `export` command: write a project's field as a .memoryfield.zip."""
1
+ """The `export` command: write a project's learnings or logs as a .memoryfield.zip."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
@@ -8,6 +8,7 @@ import typer
8
8
  from nclutils import pp
9
9
 
10
10
  from sessionmemory.commands._common import (
11
+ CWD_OPTION,
11
12
  build_embedder,
12
13
  emit_json,
13
14
  fail,
@@ -16,24 +17,27 @@ from sessionmemory.commands._common import (
16
17
  )
17
18
  from sessionmemory.lib import export, field, paths
18
19
 
19
- CWD = typer.Option(None, "--cwd", help="Directory to resolve the project from.")
20
20
  LOGS = typer.Option(False, "--logs", help="Export the logs field instead of learnings.") # noqa: FBT003
21
21
  OUTPUT = typer.Option(
22
22
  None,
23
23
  "--output",
24
- help="Where to write the zip. Defaults to <slug>.memoryfield.zip in the current directory.",
24
+ "-o",
25
+ help=(
26
+ "Where to write the zip. Defaults to <slug>.memoryfield.zip in the current "
27
+ "directory, which is usually the checkout."
28
+ ),
25
29
  )
26
30
  JSON = typer.Option(False, "--json", help="Emit JSON instead of prose.") # noqa: FBT003
27
31
 
28
32
 
29
33
  def export_command(
30
- cwd: Path | None = CWD,
34
+ cwd: Path | None = CWD_OPTION,
31
35
  *,
32
36
  logs: bool = LOGS,
33
37
  output: Path | None = OUTPUT,
34
38
  as_json: bool = JSON,
35
39
  ) -> None:
36
- """Write this project's field as a .memoryfield.zip."""
40
+ """Write this project's learnings, or its logs, as a .memoryfield.zip."""
37
41
  vault = require_vault()
38
42
  slug = require_project(vault, cwd)
39
43
  embedder = build_embedder()
@@ -2,23 +2,30 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from pathlib import Path
5
+ from pathlib import Path # noqa: TC003
6
6
 
7
7
  import typer
8
8
 
9
- from sessionmemory.commands._common import emit_json, emit_value, require_project, require_vault
9
+ from sessionmemory.commands._common import (
10
+ CWD_OPTION,
11
+ emit_json,
12
+ emit_value,
13
+ require_project,
14
+ require_vault,
15
+ )
10
16
  from sessionmemory.lib import inject
11
17
 
12
- CWD = typer.Option(None, "--cwd", help="Directory to resolve the project from.")
13
18
  COMMAND = typer.Option("sessionmemory", "--command", help="How the guidance names this CLI.")
14
19
  JSON = typer.Option(False, "--json", help="Emit JSON instead of prose.") # noqa: FBT003
15
20
 
16
21
 
17
- def inject_command(cwd: Path | None = CWD, command: str = COMMAND, *, as_json: bool = JSON) -> None:
22
+ def inject_command(
23
+ cwd: Path | None = CWD_OPTION, command: str = COMMAND, *, as_json: bool = JSON
24
+ ) -> None:
18
25
  """Print what this project's session should start with."""
19
26
  vault = require_vault()
20
27
  slug = require_project(vault, cwd)
21
- injection = inject.build(vault, slug, cwd=cwd if cwd is not None else Path.cwd())
28
+ injection = inject.build(vault, slug)
22
29
  if as_json:
23
30
  emit_json(inject.payload(injection, command=command))
24
31
  return