sessionmemory 0.15.0__tar.gz → 0.16.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.
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/PKG-INFO +1 -1
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/pyproject.toml +1 -1
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/pyproject.toml.orig +1 -1
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/_common.py +90 -2
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/init.py +13 -5
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/local.py +326 -108
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/project.py +84 -4
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/doctor.py +2 -1
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/localmanifest.py +2 -2
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/localmd.py +158 -7
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/settingsdiff.py +27 -17
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/README.md +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/__init__.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/cli.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/__init__.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/delete.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/doctor.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/export.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/inject.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/log.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/new.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/path.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/reconcile.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/reindex.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/commands/search.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/__init__.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/atomic.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/backlog.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/bootstrap.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/changes.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/commits.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/config.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/embed.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/export.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/field.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/fieldindex.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/frontmatter.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/gitinfo.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/ids.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/inject.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/localtree.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/log.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/paths.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/reconcile.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/registry.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/resolve.py +0 -0
- {sessionmemory-0.15.0 → sessionmemory-0.16.0}/src/sessionmemory/lib/specs.py +0 -0
|
@@ -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.
|
|
14
|
+
version = "0.16.0"
|
|
15
15
|
|
|
16
16
|
[[project.authors]]
|
|
17
17
|
name = "Nathaniel Landau"
|
|
@@ -11,14 +11,14 @@ from typing import TYPE_CHECKING, NoReturn
|
|
|
11
11
|
|
|
12
12
|
import typer
|
|
13
13
|
import typer.core
|
|
14
|
-
from nclutils import pp
|
|
14
|
+
from nclutils import ask, pp
|
|
15
15
|
|
|
16
16
|
# Typer vendors Click, so the `click` package's classes never match its errors.
|
|
17
17
|
from typer._click import core as click_core
|
|
18
18
|
from typer._click import exceptions as click_exceptions
|
|
19
19
|
|
|
20
20
|
from sessionmemory.lib import embed, registry
|
|
21
|
-
from sessionmemory.lib.bootstrap import is_empty
|
|
21
|
+
from sessionmemory.lib.bootstrap import InitResult, initialize, is_empty
|
|
22
22
|
from sessionmemory.lib.config import (
|
|
23
23
|
CONFIG_FILE,
|
|
24
24
|
VaultNotConfiguredError,
|
|
@@ -164,6 +164,78 @@ def emit_json(payload: object) -> None:
|
|
|
164
164
|
emit_value(json.dumps(payload, indent=2))
|
|
165
165
|
|
|
166
166
|
|
|
167
|
+
def interactive() -> bool:
|
|
168
|
+
"""Report whether a person can answer a prompt, so an agent's call never blocks.
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
bool: True when both stdin and stdout are terminals.
|
|
172
|
+
"""
|
|
173
|
+
return sys.stdin.isatty() and sys.stdout.isatty()
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def confirm(question: str, yes: str) -> bool:
|
|
177
|
+
"""Ask one yes-or-no question whose answers say what each choice does.
|
|
178
|
+
|
|
179
|
+
Args:
|
|
180
|
+
question (str): The question.
|
|
181
|
+
yes (str): The yes answer, naming what it does.
|
|
182
|
+
|
|
183
|
+
Returns:
|
|
184
|
+
bool: True only when the person chose yes; cancelling counts as no.
|
|
185
|
+
"""
|
|
186
|
+
choices = [(yes, "yes"), ("No, leave it alone", "no")]
|
|
187
|
+
return ask.choose_one_from_list(choices=choices, message=question) == "yes"
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def init_question(vault: Path, *, force: bool) -> tuple[str, str]:
|
|
191
|
+
"""Word the question that offers to initialize a vault, and its yes answer.
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
vault (Path): The directory to initialize.
|
|
195
|
+
force (bool): Whether the directory holds files but no vault marker.
|
|
196
|
+
|
|
197
|
+
Returns:
|
|
198
|
+
tuple[str, str]: The question and the yes answer.
|
|
199
|
+
"""
|
|
200
|
+
if force:
|
|
201
|
+
return (
|
|
202
|
+
f"{vault} holds files but no vault marker. Initialize a vault there anyway?",
|
|
203
|
+
"Yes, initialize it (its files are kept)",
|
|
204
|
+
)
|
|
205
|
+
return f"{vault} is not a vault yet. Initialize one there?", "Yes, initialize it"
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def offer_init(vault: Path) -> InitResult | None:
|
|
209
|
+
"""Ask a person at a terminal whether to initialize `vault`, and do it on a yes.
|
|
210
|
+
|
|
211
|
+
Args:
|
|
212
|
+
vault (Path): The uninitialized directory.
|
|
213
|
+
|
|
214
|
+
Returns:
|
|
215
|
+
InitResult | None: What was created, or None when the person declined.
|
|
216
|
+
"""
|
|
217
|
+
force = not is_empty(vault)
|
|
218
|
+
question, yes = init_question(vault, force=force)
|
|
219
|
+
if not confirm(question=question, yes=yes):
|
|
220
|
+
return None
|
|
221
|
+
return initialize(vault, force=force)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def ask_text(message: str) -> str | None:
|
|
225
|
+
"""Ask a person at a terminal to type an answer.
|
|
226
|
+
|
|
227
|
+
Args:
|
|
228
|
+
message (str): The prompt.
|
|
229
|
+
|
|
230
|
+
Returns:
|
|
231
|
+
str | None: The answer, or None when the person cancelled.
|
|
232
|
+
"""
|
|
233
|
+
try:
|
|
234
|
+
return str(typer.prompt(message)).strip() or None
|
|
235
|
+
except typer.Abort:
|
|
236
|
+
return None
|
|
237
|
+
|
|
238
|
+
|
|
167
239
|
def require_vault() -> Path:
|
|
168
240
|
"""Return an initialized vault root, or exit with the command that fixes it.
|
|
169
241
|
|
|
@@ -184,6 +256,13 @@ def require_vault() -> Path:
|
|
|
184
256
|
pp.error(str(error), details=VAULT_FIX)
|
|
185
257
|
raise typer.Exit(1) from error
|
|
186
258
|
|
|
259
|
+
if not is_initialized(vault) and interactive():
|
|
260
|
+
if offer_init(vault) is None:
|
|
261
|
+
pp.error(f"{vault} is not a vault")
|
|
262
|
+
raise typer.Exit(1)
|
|
263
|
+
pp.success(f"initialized {vault}")
|
|
264
|
+
return vault
|
|
265
|
+
|
|
187
266
|
if not is_initialized(vault):
|
|
188
267
|
# An empty directory is the ordinary bootstrap case, and `sessionmemory init` is safe
|
|
189
268
|
# for a caller, human or agent, to run there. A non-empty directory holding no
|
|
@@ -257,6 +336,15 @@ def require_project(vault: Path, cwd: Path | None = None) -> str:
|
|
|
257
336
|
report_malformed_registry(vault, error)
|
|
258
337
|
|
|
259
338
|
if not result.registered or result.slug is None:
|
|
339
|
+
if interactive():
|
|
340
|
+
# Imported here, since the project command imports this module.
|
|
341
|
+
from sessionmemory.commands.project import offer_registration
|
|
342
|
+
|
|
343
|
+
target = (cwd if cwd is not None else Path.cwd()).resolve()
|
|
344
|
+
if offer_registration(vault, target):
|
|
345
|
+
return require_project(vault, target)
|
|
346
|
+
pp.error("this directory is not a registered project")
|
|
347
|
+
raise typer.Exit(1)
|
|
260
348
|
pp.error(
|
|
261
349
|
"this directory is not a registered project",
|
|
262
350
|
details=["run: sessionmemory project register"],
|
|
@@ -9,6 +9,7 @@ from pathlib import Path # noqa: TC003
|
|
|
9
9
|
import typer
|
|
10
10
|
from nclutils import pp
|
|
11
11
|
|
|
12
|
+
from sessionmemory.commands import _common
|
|
12
13
|
from sessionmemory.commands._common import VAULT_FIX, emit_json
|
|
13
14
|
from sessionmemory.lib.bootstrap import InitResult, NotAVaultError, initialize
|
|
14
15
|
from sessionmemory.lib.config import VaultNotConfiguredError, vault_root
|
|
@@ -58,9 +59,10 @@ def init(
|
|
|
58
59
|
) -> None:
|
|
59
60
|
"""Create the files a new vault needs.
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
Off a terminal, `require_vault` refuses an uninitialized directory, and this command is
|
|
63
|
+
what fixes that. When no directory is given, the configured root is read directly
|
|
64
|
+
instead. On a terminal, a directory holding unrelated files is initialized once the
|
|
65
|
+
person agrees, as if `--force` were given.
|
|
64
66
|
|
|
65
67
|
Raises:
|
|
66
68
|
Exit: When no directory is given and no vault root is configured or the
|
|
@@ -82,7 +84,13 @@ def init(
|
|
|
82
84
|
try:
|
|
83
85
|
result = initialize(vault, force=force)
|
|
84
86
|
except NotAVaultError as error:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
if not _common.interactive():
|
|
88
|
+
pp.error(str(error))
|
|
89
|
+
raise typer.Exit(1) from error
|
|
90
|
+
question, yes = _common.init_question(vault, force=True)
|
|
91
|
+
if not _common.confirm(question=question, yes=yes):
|
|
92
|
+
pp.error(f"{vault} was not initialized")
|
|
93
|
+
raise typer.Exit(1) from error
|
|
94
|
+
result = initialize(vault, force=True)
|
|
87
95
|
|
|
88
96
|
_report(result, as_json=as_json)
|