memory-seed 1.2.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.
- memory_seed-1.2.0/LICENSE +22 -0
- memory_seed-1.2.0/PKG-INFO +110 -0
- memory_seed-1.2.0/README.md +90 -0
- memory_seed-1.2.0/memory_seed/__init__.py +2 -0
- memory_seed-1.2.0/memory_seed/cli.py +69 -0
- memory_seed-1.2.0/memory_seed/core.py +150 -0
- memory_seed-1.2.0/memory_seed/seed/.AGENTS/agent-rules.md +214 -0
- memory_seed-1.2.0/memory_seed/seed/.AGENTS/project-bootstrap.md +308 -0
- memory_seed-1.2.0/memory_seed/seed/AGENTS.md +39 -0
- memory_seed-1.2.0/memory_seed/seed/CLAUDE.md +18 -0
- memory_seed-1.2.0/memory_seed/seed/GEMINI.md +17 -0
- memory_seed-1.2.0/memory_seed.egg-info/PKG-INFO +110 -0
- memory_seed-1.2.0/memory_seed.egg-info/SOURCES.txt +17 -0
- memory_seed-1.2.0/memory_seed.egg-info/dependency_links.txt +1 -0
- memory_seed-1.2.0/memory_seed.egg-info/entry_points.txt +2 -0
- memory_seed-1.2.0/memory_seed.egg-info/top_level.txt +1 -0
- memory_seed-1.2.0/pyproject.toml +38 -0
- memory_seed-1.2.0/setup.cfg +4 -0
- memory_seed-1.2.0/tests/test_memory_seed.py +116 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 John Tshibuyi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: memory-seed
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Summary: Portable local memory seed for file-reading AI coding agents
|
|
5
|
+
Author: John Tshibuyi
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: ai,agents,memory,markdown,local-first
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Topic :: Software Development
|
|
15
|
+
Classifier: Topic :: Utilities
|
|
16
|
+
Requires-Python: >=3.11
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# Memory Seed
|
|
22
|
+
|
|
23
|
+
Memory Seed is a portable local memory system for AI coding agents.
|
|
24
|
+
|
|
25
|
+
It provides a small set of plain Markdown control-plane files that can be planted into a new or existing project. During bootstrap, the seed generates project-specific operating memory so future agent sessions can recover the project's purpose, current state, conventions, risks, and recent decisions without depending on vendor-hosted memory.
|
|
26
|
+
|
|
27
|
+
## Goals
|
|
28
|
+
|
|
29
|
+
- Keep project memory local, inspectable, and portable.
|
|
30
|
+
- Support file-reading AI coding agents through predictable Markdown files.
|
|
31
|
+
- Route tool-specific entry files into one shared `.AGENTS/` memory core.
|
|
32
|
+
- Generate project-specific `index.md`, `context.md`, `style.md`, and session logs during bootstrap.
|
|
33
|
+
- Archive reusable control-plane versions while keeping generated project memory outside version archives.
|
|
34
|
+
|
|
35
|
+
## Reusable Seed Files
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
AGENTS.md
|
|
39
|
+
CLAUDE.md
|
|
40
|
+
GEMINI.md
|
|
41
|
+
.AGENTS/
|
|
42
|
+
agent-rules.md
|
|
43
|
+
project-bootstrap.md
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Generated Per-Project Files
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
.AGENTS/
|
|
50
|
+
index.md
|
|
51
|
+
context.md
|
|
52
|
+
style.md
|
|
53
|
+
sessions/
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Current Version
|
|
57
|
+
|
|
58
|
+
The current reusable control-plane version is `1.2`.
|
|
59
|
+
|
|
60
|
+
Archived reusable versions are stored under `.AGENTS/archive/<version>/`.
|
|
61
|
+
|
|
62
|
+
## Python CLI
|
|
63
|
+
|
|
64
|
+
Memory Seed includes a small Python CLI.
|
|
65
|
+
|
|
66
|
+
From this repository, run:
|
|
67
|
+
|
|
68
|
+
```powershell
|
|
69
|
+
python -m memory_seed.cli version
|
|
70
|
+
python -m memory_seed.cli doctor
|
|
71
|
+
python -m memory_seed.cli init --dry-run
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The `init` command copies only the reusable seed files into the current folder:
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
AGENTS.md
|
|
78
|
+
CLAUDE.md
|
|
79
|
+
GEMINI.md
|
|
80
|
+
.AGENTS/agent-rules.md
|
|
81
|
+
.AGENTS/project-bootstrap.md
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
It does not copy generated project memory such as `.AGENTS/context.md`, `.AGENTS/index.md`, `.AGENTS/style.md`, `.AGENTS/sessions/`, or `.AGENTS/archive/`.
|
|
85
|
+
|
|
86
|
+
Use `--dry-run` to preview without changing files. Use `--force` only when you intentionally want to back up and replace existing seed files.
|
|
87
|
+
|
|
88
|
+
When `--force` creates backups, Memory Seed adds `.AGENTS/backups/` to the target project's `.gitignore` to reduce the chance of committing replaced local memory files.
|
|
89
|
+
|
|
90
|
+
## Public Memory Hygiene
|
|
91
|
+
|
|
92
|
+
Memory Seed files are plain Markdown and may be committed with a project. Treat `.AGENTS` files as publishable unless the project is explicitly private.
|
|
93
|
+
|
|
94
|
+
Do not put secrets, credentials, tokens, private keys, sensitive account details, client confidential information, or unnecessary personal data into generated memory files or session logs.
|
|
95
|
+
|
|
96
|
+
## Publishing
|
|
97
|
+
|
|
98
|
+
This repository is configured for PyPI trusted publishing from GitHub Actions.
|
|
99
|
+
|
|
100
|
+
PyPI pending publisher settings should match:
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
PyPI Project Name: memory-seed
|
|
104
|
+
Owner: jnl-tshi
|
|
105
|
+
Repository name: memory-seed
|
|
106
|
+
Workflow name: publish.yml
|
|
107
|
+
Environment name: pypi
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The publish workflow lives at `.github/workflows/publish.yml`. It runs tests, builds the package with `uv build`, and publishes through PyPI's trusted publisher flow.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Memory Seed
|
|
2
|
+
|
|
3
|
+
Memory Seed is a portable local memory system for AI coding agents.
|
|
4
|
+
|
|
5
|
+
It provides a small set of plain Markdown control-plane files that can be planted into a new or existing project. During bootstrap, the seed generates project-specific operating memory so future agent sessions can recover the project's purpose, current state, conventions, risks, and recent decisions without depending on vendor-hosted memory.
|
|
6
|
+
|
|
7
|
+
## Goals
|
|
8
|
+
|
|
9
|
+
- Keep project memory local, inspectable, and portable.
|
|
10
|
+
- Support file-reading AI coding agents through predictable Markdown files.
|
|
11
|
+
- Route tool-specific entry files into one shared `.AGENTS/` memory core.
|
|
12
|
+
- Generate project-specific `index.md`, `context.md`, `style.md`, and session logs during bootstrap.
|
|
13
|
+
- Archive reusable control-plane versions while keeping generated project memory outside version archives.
|
|
14
|
+
|
|
15
|
+
## Reusable Seed Files
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
AGENTS.md
|
|
19
|
+
CLAUDE.md
|
|
20
|
+
GEMINI.md
|
|
21
|
+
.AGENTS/
|
|
22
|
+
agent-rules.md
|
|
23
|
+
project-bootstrap.md
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Generated Per-Project Files
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
.AGENTS/
|
|
30
|
+
index.md
|
|
31
|
+
context.md
|
|
32
|
+
style.md
|
|
33
|
+
sessions/
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Current Version
|
|
37
|
+
|
|
38
|
+
The current reusable control-plane version is `1.2`.
|
|
39
|
+
|
|
40
|
+
Archived reusable versions are stored under `.AGENTS/archive/<version>/`.
|
|
41
|
+
|
|
42
|
+
## Python CLI
|
|
43
|
+
|
|
44
|
+
Memory Seed includes a small Python CLI.
|
|
45
|
+
|
|
46
|
+
From this repository, run:
|
|
47
|
+
|
|
48
|
+
```powershell
|
|
49
|
+
python -m memory_seed.cli version
|
|
50
|
+
python -m memory_seed.cli doctor
|
|
51
|
+
python -m memory_seed.cli init --dry-run
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The `init` command copies only the reusable seed files into the current folder:
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
AGENTS.md
|
|
58
|
+
CLAUDE.md
|
|
59
|
+
GEMINI.md
|
|
60
|
+
.AGENTS/agent-rules.md
|
|
61
|
+
.AGENTS/project-bootstrap.md
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
It does not copy generated project memory such as `.AGENTS/context.md`, `.AGENTS/index.md`, `.AGENTS/style.md`, `.AGENTS/sessions/`, or `.AGENTS/archive/`.
|
|
65
|
+
|
|
66
|
+
Use `--dry-run` to preview without changing files. Use `--force` only when you intentionally want to back up and replace existing seed files.
|
|
67
|
+
|
|
68
|
+
When `--force` creates backups, Memory Seed adds `.AGENTS/backups/` to the target project's `.gitignore` to reduce the chance of committing replaced local memory files.
|
|
69
|
+
|
|
70
|
+
## Public Memory Hygiene
|
|
71
|
+
|
|
72
|
+
Memory Seed files are plain Markdown and may be committed with a project. Treat `.AGENTS` files as publishable unless the project is explicitly private.
|
|
73
|
+
|
|
74
|
+
Do not put secrets, credentials, tokens, private keys, sensitive account details, client confidential information, or unnecessary personal data into generated memory files or session logs.
|
|
75
|
+
|
|
76
|
+
## Publishing
|
|
77
|
+
|
|
78
|
+
This repository is configured for PyPI trusted publishing from GitHub Actions.
|
|
79
|
+
|
|
80
|
+
PyPI pending publisher settings should match:
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
PyPI Project Name: memory-seed
|
|
84
|
+
Owner: jnl-tshi
|
|
85
|
+
Repository name: memory-seed
|
|
86
|
+
Workflow name: publish.yml
|
|
87
|
+
Environment name: pypi
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The publish workflow lives at `.github/workflows/publish.yml`. It runs tests, builds the package with `uv build`, and publishes through PyPI's trusted publisher flow.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from .core import doctor, get_version, init_project
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main(argv: list[str] | None = None) -> int:
|
|
10
|
+
parser = argparse.ArgumentParser(prog="memory-seed")
|
|
11
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
12
|
+
|
|
13
|
+
init_parser = subparsers.add_parser("init", help="copy Memory Seed into this project")
|
|
14
|
+
init_parser.add_argument("--dry-run", action="store_true", help="show planned files without writing")
|
|
15
|
+
init_parser.add_argument("--force", action="store_true", help="backup and overwrite existing seed files")
|
|
16
|
+
|
|
17
|
+
subparsers.add_parser("doctor", help="check Memory Seed control-plane files")
|
|
18
|
+
subparsers.add_parser("version", help="print Memory Seed control-plane version")
|
|
19
|
+
|
|
20
|
+
args = parser.parse_args(argv)
|
|
21
|
+
|
|
22
|
+
if args.command == "version":
|
|
23
|
+
print(get_version())
|
|
24
|
+
return 0
|
|
25
|
+
|
|
26
|
+
if args.command == "doctor":
|
|
27
|
+
result = doctor()
|
|
28
|
+
if result.ok:
|
|
29
|
+
print("Memory Seed control plane looks healthy.")
|
|
30
|
+
return 0
|
|
31
|
+
for missing in result.missing:
|
|
32
|
+
print(f"Missing: {missing}")
|
|
33
|
+
for mismatch in result.version_mismatches:
|
|
34
|
+
print(
|
|
35
|
+
"Version mismatch: "
|
|
36
|
+
f"{mismatch['file']} expected {mismatch['expected']} "
|
|
37
|
+
f"but found {mismatch['actual']}"
|
|
38
|
+
)
|
|
39
|
+
return 1
|
|
40
|
+
|
|
41
|
+
if args.command == "init":
|
|
42
|
+
try:
|
|
43
|
+
result = init_project(dry_run=args.dry_run, force=args.force)
|
|
44
|
+
except FileExistsError as exc:
|
|
45
|
+
print(str(exc), file=sys.stderr)
|
|
46
|
+
print("Use --force to backup and replace existing seed files.", file=sys.stderr)
|
|
47
|
+
return 1
|
|
48
|
+
|
|
49
|
+
if args.dry_run:
|
|
50
|
+
for planned in result.planned:
|
|
51
|
+
print(f"Would copy: {planned}")
|
|
52
|
+
print("No files changed.")
|
|
53
|
+
return 0
|
|
54
|
+
|
|
55
|
+
for created in result.created:
|
|
56
|
+
print(f"Copied: {created}")
|
|
57
|
+
for backup in result.backed_up:
|
|
58
|
+
print(f"Backed up: {backup}")
|
|
59
|
+
if result.backed_up:
|
|
60
|
+
print("Added .AGENTS/backups/ to .gitignore to reduce accidental backup leaks.")
|
|
61
|
+
print("Next: open AGENTS.md and follow bootstrap mode.")
|
|
62
|
+
return 0
|
|
63
|
+
|
|
64
|
+
parser.error(f"Unknown command: {args.command}")
|
|
65
|
+
return 2
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
if __name__ == "__main__":
|
|
69
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
import shutil
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
PACKAGE_ROOT = Path(__file__).resolve().parent
|
|
11
|
+
SEED_ROOT = PACKAGE_ROOT / "seed"
|
|
12
|
+
VERSION = "1.2"
|
|
13
|
+
BACKUP_IGNORE_ENTRY = ".AGENTS/backups/"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass(frozen=True)
|
|
17
|
+
class SeedFile:
|
|
18
|
+
source: Path
|
|
19
|
+
destination: str
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class InitResult:
|
|
24
|
+
changed: bool
|
|
25
|
+
planned: list[str] = field(default_factory=list)
|
|
26
|
+
created: list[str] = field(default_factory=list)
|
|
27
|
+
backed_up: list[str] = field(default_factory=list)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class DoctorResult:
|
|
32
|
+
ok: bool
|
|
33
|
+
missing: list[str] = field(default_factory=list)
|
|
34
|
+
version_mismatches: list[dict[str, str]] = field(default_factory=list)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
SEED_FILES = [
|
|
38
|
+
SeedFile(SEED_ROOT / "AGENTS.md", "AGENTS.md"),
|
|
39
|
+
SeedFile(SEED_ROOT / "CLAUDE.md", "CLAUDE.md"),
|
|
40
|
+
SeedFile(SEED_ROOT / "GEMINI.md", "GEMINI.md"),
|
|
41
|
+
SeedFile(SEED_ROOT / ".AGENTS" / "agent-rules.md", ".AGENTS/agent-rules.md"),
|
|
42
|
+
SeedFile(
|
|
43
|
+
SEED_ROOT / ".AGENTS" / "project-bootstrap.md",
|
|
44
|
+
".AGENTS/project-bootstrap.md",
|
|
45
|
+
),
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def get_version() -> str:
|
|
50
|
+
return VERSION
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def init_project(cwd: str | Path = ".", dry_run: bool = False, force: bool = False) -> InitResult:
|
|
54
|
+
target_root = Path(cwd).resolve()
|
|
55
|
+
planned = [seed_file.destination for seed_file in SEED_FILES]
|
|
56
|
+
existing = [
|
|
57
|
+
seed_file.destination
|
|
58
|
+
for seed_file in SEED_FILES
|
|
59
|
+
if (target_root / seed_file.destination).exists()
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
if dry_run:
|
|
63
|
+
return InitResult(changed=False, planned=planned)
|
|
64
|
+
|
|
65
|
+
if existing and not force:
|
|
66
|
+
raise FileExistsError(
|
|
67
|
+
"Refusing to overwrite existing files: " + ", ".join(existing)
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
timestamp = datetime.now().strftime("%Y%m%d-%H%M%S")
|
|
71
|
+
created: list[str] = []
|
|
72
|
+
backed_up: list[str] = []
|
|
73
|
+
|
|
74
|
+
for seed_file in SEED_FILES:
|
|
75
|
+
destination = target_root / seed_file.destination
|
|
76
|
+
|
|
77
|
+
if destination.exists() and force:
|
|
78
|
+
_ensure_backup_gitignore(target_root)
|
|
79
|
+
backup_relative = Path(".AGENTS") / "backups" / timestamp / seed_file.destination
|
|
80
|
+
backup_path = target_root / backup_relative
|
|
81
|
+
backup_path.parent.mkdir(parents=True, exist_ok=True)
|
|
82
|
+
shutil.copy2(destination, backup_path)
|
|
83
|
+
backed_up.append(backup_relative.as_posix())
|
|
84
|
+
|
|
85
|
+
destination.parent.mkdir(parents=True, exist_ok=True)
|
|
86
|
+
shutil.copy2(seed_file.source, destination)
|
|
87
|
+
created.append(seed_file.destination)
|
|
88
|
+
|
|
89
|
+
return InitResult(
|
|
90
|
+
changed=True,
|
|
91
|
+
planned=planned,
|
|
92
|
+
created=created,
|
|
93
|
+
backed_up=backed_up,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def doctor(cwd: str | Path = ".") -> DoctorResult:
|
|
98
|
+
target_root = Path(cwd).resolve()
|
|
99
|
+
missing: list[str] = []
|
|
100
|
+
version_mismatches: list[dict[str, str]] = []
|
|
101
|
+
|
|
102
|
+
for seed_file in SEED_FILES:
|
|
103
|
+
candidate = target_root / seed_file.destination
|
|
104
|
+
if not candidate.exists():
|
|
105
|
+
missing.append(seed_file.destination)
|
|
106
|
+
continue
|
|
107
|
+
|
|
108
|
+
actual = _read_memory_system_version(candidate)
|
|
109
|
+
if actual != VERSION:
|
|
110
|
+
version_mismatches.append(
|
|
111
|
+
{
|
|
112
|
+
"file": seed_file.destination,
|
|
113
|
+
"expected": VERSION,
|
|
114
|
+
"actual": actual or "missing",
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
return DoctorResult(
|
|
119
|
+
ok=not missing and not version_mismatches,
|
|
120
|
+
missing=missing,
|
|
121
|
+
version_mismatches=version_mismatches,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _read_memory_system_version(path: Path) -> str | None:
|
|
126
|
+
match = re.search(
|
|
127
|
+
r"^memory-system-version:\s*([^\s]+)\s*$",
|
|
128
|
+
path.read_text(encoding="utf-8"),
|
|
129
|
+
re.MULTILINE,
|
|
130
|
+
)
|
|
131
|
+
if not match:
|
|
132
|
+
return None
|
|
133
|
+
return match.group(1)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def _ensure_backup_gitignore(target_root: Path) -> None:
|
|
137
|
+
gitignore = target_root / ".gitignore"
|
|
138
|
+
if gitignore.exists():
|
|
139
|
+
content = gitignore.read_text(encoding="utf-8")
|
|
140
|
+
else:
|
|
141
|
+
content = ""
|
|
142
|
+
|
|
143
|
+
lines = content.splitlines()
|
|
144
|
+
if BACKUP_IGNORE_ENTRY in lines:
|
|
145
|
+
return
|
|
146
|
+
|
|
147
|
+
prefix = content
|
|
148
|
+
if prefix and not prefix.endswith(("\n", "\r\n")):
|
|
149
|
+
prefix += "\n"
|
|
150
|
+
gitignore.write_text(prefix + BACKUP_IGNORE_ENTRY + "\n", encoding="utf-8")
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
---
|
|
2
|
+
memory-system-version: 1.2
|
|
3
|
+
tags:
|
|
4
|
+
- ai-memory
|
|
5
|
+
- agent-rules
|
|
6
|
+
- operating-mode
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Agent Rules
|
|
10
|
+
|
|
11
|
+
These rules define how AI agents should use this project's local memory system.
|
|
12
|
+
|
|
13
|
+
## Core Principle
|
|
14
|
+
|
|
15
|
+
The `.AGENTS` folder is the source of operational memory for this repository. Keep it small, navigable, and local-first so an agent can quickly understand the project without loading historical noise by default.
|
|
16
|
+
|
|
17
|
+
Memory Seed targets file-reading AI coding agents. Keep shared memory in plain Markdown, use predictable paths, keep read order explicit, and avoid vendor-specific assumptions in the memory core. Tool-specific routing files may exist, but they must point into the same `.AGENTS/` system.
|
|
18
|
+
|
|
19
|
+
## Reusable Seed Files
|
|
20
|
+
|
|
21
|
+
The reusable seed control plane is:
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
AGENTS.md # Generic agent entry point
|
|
25
|
+
CLAUDE.md # Claude Code routing file
|
|
26
|
+
GEMINI.md # Gemini CLI routing file
|
|
27
|
+
.AGENTS/
|
|
28
|
+
agent-rules.md
|
|
29
|
+
project-bootstrap.md
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Project-specific operating files are generated during bootstrap and are not version-archived with the seed:
|
|
33
|
+
|
|
34
|
+
```text
|
|
35
|
+
.AGENTS/
|
|
36
|
+
index.md
|
|
37
|
+
context.md
|
|
38
|
+
style.md
|
|
39
|
+
sessions/
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Active Memory Structure
|
|
43
|
+
|
|
44
|
+
Required files and folders:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
.AGENTS/
|
|
48
|
+
agent-rules.md # This workflow contract
|
|
49
|
+
index.md # Top-level pointer and read order
|
|
50
|
+
context.md # Authoritative project context, current state, durable facts
|
|
51
|
+
style.md # Writing, naming, and formatting conventions
|
|
52
|
+
sessions/ # Append-only dated session logs
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`project-bootstrap.md` may exist but is not part of the operating-mode read order.
|
|
56
|
+
|
|
57
|
+
## Start-of-Work Routine
|
|
58
|
+
|
|
59
|
+
At the start of a session:
|
|
60
|
+
|
|
61
|
+
1. Read `.AGENTS/agent-rules.md`.
|
|
62
|
+
2. Read `.AGENTS/index.md`.
|
|
63
|
+
3. Read `.AGENTS/context.md`, especially `Fast Orientation` and `Current State`.
|
|
64
|
+
4. Read `.AGENTS/style.md` when writing or editing project documentation.
|
|
65
|
+
5. Read recent `.AGENTS/sessions/*` only when historical detail is needed.
|
|
66
|
+
|
|
67
|
+
If the repository root is unclear, identify it first and note any uncertainty in `context.md` only if it is durable project context.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## File Change Permission Model
|
|
71
|
+
|
|
72
|
+
Agents must treat `.AGENTS` and agent-routing files according to these buckets.
|
|
73
|
+
|
|
74
|
+
### Locked Unless Explicitly Requested
|
|
75
|
+
|
|
76
|
+
These files define the reusable control plane for agents. Do not modify them unless the user explicitly asks for agent workflow, bootstrap, routing, or memory-structure changes.
|
|
77
|
+
|
|
78
|
+
- `AGENTS.md`
|
|
79
|
+
- `CLAUDE.md`
|
|
80
|
+
- `GEMINI.md`
|
|
81
|
+
- `.AGENTS/agent-rules.md`
|
|
82
|
+
- `.AGENTS/project-bootstrap.md`
|
|
83
|
+
|
|
84
|
+
Also locked unless explicitly requested:
|
|
85
|
+
|
|
86
|
+
- Adding new top-level `.AGENTS` files.
|
|
87
|
+
- Deleting existing `.AGENTS` files.
|
|
88
|
+
- Renaming `.AGENTS` files or folders.
|
|
89
|
+
- Reorganizing the `.AGENTS` structure.
|
|
90
|
+
- Recreating obsolete files such as `current.md`, `project-memory.md`, or `memory.md`.
|
|
91
|
+
- Editing prior session logs except for explicit repair, archival cleanup, or user-requested correction.
|
|
92
|
+
|
|
93
|
+
### End-Of-Session Restricted Updates
|
|
94
|
+
|
|
95
|
+
These files should normally be updated only during the end-of-session routine, after the agent has enough context to distinguish durable facts from temporary work.
|
|
96
|
+
|
|
97
|
+
- `.AGENTS/context.md`: Update when durable/current project facts changed, including project structure, current priorities, artifact paths, stable decisions, operational risks, or project type/risk classification.
|
|
98
|
+
- `.AGENTS/index.md`: Update only when read order, hot facts, active workflow, or key project pointers changed.
|
|
99
|
+
- `.AGENTS/style.md`: Update only when durable conventions, project type/risk implications, security posture, coding standards, documentation standards, or workflow conventions changed.
|
|
100
|
+
|
|
101
|
+
Do not edit these files for ordinary implementation details, temporary observations, or raw session history. Put that detail in `.AGENTS/sessions/YYYY-MM-DD.md`.
|
|
102
|
+
|
|
103
|
+
Immediate-update exception: update `.AGENTS/context.md`, `.AGENTS/index.md`, or `.AGENTS/style.md` during a session only when leaving the current content stale would immediately mislead the active work, route an agent to the wrong files, preserve an unsafe assumption, or cause repeated incorrect actions.
|
|
104
|
+
|
|
105
|
+
For restricted files, the agent must be able to explain why the file's ownership scope was affected.
|
|
106
|
+
|
|
107
|
+
### Routine Append
|
|
108
|
+
|
|
109
|
+
- `.AGENTS/sessions/YYYY-MM-DD.md`: Append concise notes for meaningful work completed on that date. Do not log trivial edits, routine command output, or temporary observations unless they affect future handoff, risk, or decisions.
|
|
110
|
+
|
|
111
|
+
Session logs are append-only. Today's file may be appended during normal work or at the end of the session. Prior dated session files must not be edited unless the user explicitly asks for repair, archival cleanup, or correction.
|
|
112
|
+
|
|
113
|
+
## End-of-Work Routine
|
|
114
|
+
|
|
115
|
+
At the end of meaningful work:
|
|
116
|
+
|
|
117
|
+
1. Append a concise note to `.AGENTS/sessions/YYYY-MM-DD.md`.
|
|
118
|
+
2. Review whether `.AGENTS/context.md` needs consolidation because project structure, current priorities, workflow logic, artifacts, durable decisions, or operational risks changed.
|
|
119
|
+
3. Update `.AGENTS/index.md` only when read order, hot facts, active workflow, or key project pointers changed.
|
|
120
|
+
4. Update `.AGENTS/style.md` only when durable conventions, project type/risk implications, security posture, coding standards, documentation standards, or workflow conventions changed.
|
|
121
|
+
|
|
122
|
+
Session logs are append-only. Do not rewrite or compress old session entries unless the user explicitly asks for archival cleanup.
|
|
123
|
+
|
|
124
|
+
## Context Ownership
|
|
125
|
+
|
|
126
|
+
`context.md` owns:
|
|
127
|
+
|
|
128
|
+
- Project purpose and business goal.
|
|
129
|
+
- Fast orientation for new agents.
|
|
130
|
+
- Current state, active priorities, and immediate risks.
|
|
131
|
+
- Repository traversal guidance and important folders/files.
|
|
132
|
+
- Stable model, routing, production, and artifact decisions.
|
|
133
|
+
- Memory workflow rules that affect future agents.
|
|
134
|
+
|
|
135
|
+
`index.md` owns:
|
|
136
|
+
|
|
137
|
+
- Minimal read order.
|
|
138
|
+
- Short pointers to the files that matter.
|
|
139
|
+
- Current hot facts that prevent loading the wrong notebook or stale artifact path.
|
|
140
|
+
|
|
141
|
+
`sessions/*` owns:
|
|
142
|
+
|
|
143
|
+
- Chronological work logs.
|
|
144
|
+
- Experiments, failed attempts, temporary observations, and detailed implementation notes.
|
|
145
|
+
- Evidence that may later be promoted into `context.md`.
|
|
146
|
+
|
|
147
|
+
## Consolidation Routine
|
|
148
|
+
|
|
149
|
+
Periodically review recent session logs and promote only stable, reusable facts into `context.md`. Keep `context.md` concise enough for fast agent orientation, but complete enough to traverse the repository and understand why the project is structured as it is.
|
|
150
|
+
|
|
151
|
+
Examples of facts worth promoting:
|
|
152
|
+
|
|
153
|
+
- Notebook ownership changes.
|
|
154
|
+
- Stable artifact paths.
|
|
155
|
+
- Workflow objective changes.
|
|
156
|
+
- Production runtime assumptions.
|
|
157
|
+
- Current evaluation criteria.
|
|
158
|
+
- Known stale outputs or rerun requirements.
|
|
159
|
+
|
|
160
|
+
Examples that should usually stay in sessions only:
|
|
161
|
+
|
|
162
|
+
- One-off debugging traces.
|
|
163
|
+
- Temporary hypotheses.
|
|
164
|
+
- Intermediate command outputs.
|
|
165
|
+
- Superseded experiments.
|
|
166
|
+
|
|
167
|
+
## Memory Doctor Checklist
|
|
168
|
+
|
|
169
|
+
A clean `.AGENTS` folder should satisfy all of the following:
|
|
170
|
+
|
|
171
|
+
- `AGENTS.md` exists and routes initialized projects to operating mode.
|
|
172
|
+
- `.AGENTS/project-bootstrap.md` exists, is marked bootstrap-only, and is not required in the operating-mode read order.
|
|
173
|
+
- `.AGENTS/index.md` points to the active files only.
|
|
174
|
+
- `.AGENTS/context.md` contains `Fast Orientation`, `Current State`, and `Project Type And Risk`.
|
|
175
|
+
- `.AGENTS/sessions/` contains dated append-only logs.
|
|
176
|
+
- `.AGENTS/agent-rules.md` describes operating-mode files without requiring bootstrap guidance.
|
|
177
|
+
- The file change permission buckets are present and distinguish locked, restricted, and routine append files.
|
|
178
|
+
- End-of-session restricted files are consolidated deliberately, not edited for temporary observations.
|
|
179
|
+
- Important workflow/output/artifact changes are represented in `context.md`, not only in a session log.
|
|
180
|
+
|
|
181
|
+
## Session Log Format
|
|
182
|
+
|
|
183
|
+
Use dated files under `.AGENTS/sessions/` with short entries such as:
|
|
184
|
+
|
|
185
|
+
```markdown
|
|
186
|
+
## 2026-05-02 - Project setup and workflow update
|
|
187
|
+
|
|
188
|
+
- Updated the project workflow or implementation area touched today.
|
|
189
|
+
- Recorded the key decision, artifact, or file path that future agents need.
|
|
190
|
+
- Follow-up: note any rerun, validation, review, or unresolved risk.
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Prefer concise bullets. Capture meaningful decisions, durable changes, follow-up risk, or handoff context. Do not log trivial work or every command.
|
|
194
|
+
|
|
195
|
+
## Public Memory Hygiene
|
|
196
|
+
|
|
197
|
+
Treat `.AGENTS` files as potentially publishable unless the user explicitly says the repository will always remain private. Do not write secrets, credentials, tokens, private keys, sensitive account details, client confidential information, or unnecessary personal data into `context.md`, `style.md`, `index.md`, or session logs.
|
|
198
|
+
|
|
199
|
+
When a project may become public, keep session entries focused on durable technical decisions and omit private local paths, private identities, and sensitive operational details unless the user explicitly asks to preserve them.
|
|
200
|
+
|
|
201
|
+
## Bootstrap Boundary
|
|
202
|
+
|
|
203
|
+
This repository is in operating mode because `.AGENTS/index.md`, `.AGENTS/context.md`, `.AGENTS/style.md`, and `.AGENTS/sessions/` exist.
|
|
204
|
+
|
|
205
|
+
Do not read or apply `.AGENTS/project-bootstrap.md` during operating mode. That file is only for brand-new projects or incomplete `.AGENTS` folders where `.AGENTS/` is void except for `agent-rules.md` and `project-bootstrap.md`.
|
|
206
|
+
|
|
207
|
+
If a user explicitly asks to bootstrap a new project, use `.AGENTS/project-bootstrap.md` as the bootstrap procedure for that new project. Do not apply bootstrap rules to this initialized project unless the user explicitly asks to rebuild the memory system.
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
---
|
|
2
|
+
memory-system-version: 1.2
|
|
3
|
+
tags:
|
|
4
|
+
- ai-memory
|
|
5
|
+
- project-bootstrap
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Project Bootstrap Guide
|
|
9
|
+
|
|
10
|
+
This file is only for initializing a brand-new project or repairing an incomplete `.AGENTS` folder.
|
|
11
|
+
|
|
12
|
+
Do not read or apply this file during normal operating mode. If `.AGENTS/index.md`, `.AGENTS/context.md`, `.AGENTS/style.md`, and `.AGENTS/sessions/` already exist, use `.AGENTS/agent-rules.md` and `.AGENTS/index.md` instead.
|
|
13
|
+
|
|
14
|
+
## When This File Applies
|
|
15
|
+
|
|
16
|
+
Use this file only when the project is empty or the target project is still at the reusable seed state:
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
AGENTS.md
|
|
20
|
+
CLAUDE.md
|
|
21
|
+
GEMINI.md
|
|
22
|
+
.AGENTS/
|
|
23
|
+
agent-rules.md
|
|
24
|
+
project-bootstrap.md
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Once `.AGENTS/index.md`, `.AGENTS/context.md`, `.AGENTS/style.md`, and `.AGENTS/sessions/` exist, bootstrap mode is complete.
|
|
28
|
+
|
|
29
|
+
## Template Hygiene
|
|
30
|
+
|
|
31
|
+
- YAML tags in newly created files must be generated from the new project name, project type, and file role. Do not copy source-project tags such as a previous repository name.
|
|
32
|
+
- `context.md` and `style.md` must not inherit source-project facts, paths, model names, stack assumptions, risks, or workflow details from the project where this bootstrap guide was copied from.
|
|
33
|
+
- Reuse the memory structure and process, not the source project's domain content.
|
|
34
|
+
- Keep the memory core usable by file-reading AI coding agents: plain Markdown, predictable paths, explicit read order, and minimal vendor-specific assumptions.
|
|
35
|
+
- `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.AGENTS/agent-rules.md`, and `.AGENTS/project-bootstrap.md` are reusable control-plane files. Copy the standard baseline for these files unless the user explicitly requests a different memory workflow.
|
|
36
|
+
- Tool-specific routing files should route into `AGENTS.md` and the shared `.AGENTS/` memory core rather than creating separate vendor memories.
|
|
37
|
+
- Keep the same operating/bootstrap boundary across projects so initialized projects do not drift into incompatible agent-routing structures.
|
|
38
|
+
- Treat generated memory files as potentially publishable unless the user explicitly says the target repository will remain private. Never seed secrets, credentials, tokens, private keys, sensitive account details, client confidential information, or unnecessary personal data into generated memory.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## Version Policy
|
|
42
|
+
|
|
43
|
+
`AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.AGENTS/agent-rules.md`, and `.AGENTS/project-bootstrap.md` must share the same `memory-system-version` value because they define the reusable control plane together.
|
|
44
|
+
|
|
45
|
+
When the standard baseline changes:
|
|
46
|
+
|
|
47
|
+
- Update the shared `memory-system-version` only when the control-plane behaviour changes materially.
|
|
48
|
+
- Keep all reusable control-plane files aligned to the same version.
|
|
49
|
+
- Before replacing reusable control-plane files, archive the previous versions under `.AGENTS/archive/<version>/`.
|
|
50
|
+
- Record the change in `.AGENTS/sessions/YYYY-MM-DD.md` for the project where the change is made.
|
|
51
|
+
- Do not change the version for project-specific `context.md`, `index.md`, or `style.md` updates.
|
|
52
|
+
|
|
53
|
+
## Bootstrap Goal
|
|
54
|
+
|
|
55
|
+
Create a minimal, project-specific memory system that lets future agents understand:
|
|
56
|
+
|
|
57
|
+
- what the project is
|
|
58
|
+
- why it exists
|
|
59
|
+
- how to navigate it
|
|
60
|
+
- what conventions to follow
|
|
61
|
+
- what risks matter
|
|
62
|
+
- where chronological work history is recorded
|
|
63
|
+
|
|
64
|
+
## Step 1: Inspect Local Evidence
|
|
65
|
+
|
|
66
|
+
Before asking questions, inspect available project evidence:
|
|
67
|
+
|
|
68
|
+
- folder and file names
|
|
69
|
+
- README or notes
|
|
70
|
+
- dependency files
|
|
71
|
+
- notebooks
|
|
72
|
+
- source folders
|
|
73
|
+
- docs folders
|
|
74
|
+
- deployment files
|
|
75
|
+
- data folders
|
|
76
|
+
- existing conventions
|
|
77
|
+
|
|
78
|
+
If the folder is empty or ambiguous, ask targeted bootstrap questions.
|
|
79
|
+
|
|
80
|
+
## Step 2: Ask Bootstrap Questions
|
|
81
|
+
|
|
82
|
+
Ask no more than five questions. Ask only questions that materially change `context.md` or `style.md`.
|
|
83
|
+
|
|
84
|
+
Recommended questions:
|
|
85
|
+
|
|
86
|
+
1. What type of project is this: data science/ML, production app/API, website, library/package, writing/diary/second brain, research notes, automation script, or something else?
|
|
87
|
+
2. Is this intended for production, public release, internal use, private/local use only, or exploratory work?
|
|
88
|
+
3. Does it handle sensitive data, user data, credentials, payments, personal notes, or proprietary business data?
|
|
89
|
+
4. What outputs matter most: code quality, reproducible analysis, polished writing, visualisation, deployment reliability, fast iteration, or knowledge capture?
|
|
90
|
+
5. Will this project be synced, published, deployed, shared, or connected to external services?
|
|
91
|
+
|
|
92
|
+
If the user already gave enough information, proceed without asking.
|
|
93
|
+
|
|
94
|
+
## Step 3: Classify The Project
|
|
95
|
+
|
|
96
|
+
Record these fields in `.AGENTS/context.md`:
|
|
97
|
+
|
|
98
|
+
- Project type.
|
|
99
|
+
- Intended use.
|
|
100
|
+
- Primary audience.
|
|
101
|
+
- Risk level: private/local, internal, public, production, or regulated/sensitive.
|
|
102
|
+
- Security posture.
|
|
103
|
+
- Primary outputs.
|
|
104
|
+
- Expected workflow.
|
|
105
|
+
|
|
106
|
+
Use a cautious security posture when risk is unclear and the project may include secrets, credentials, personal data, user data, payments, proprietary data, network exposure, or destructive automation.
|
|
107
|
+
|
|
108
|
+
If the project may be public, record privacy constraints in `.AGENTS/context.md` and keep `.AGENTS/sessions/` entries free of sensitive details.
|
|
109
|
+
|
|
110
|
+
## Step 4: Create The Files
|
|
111
|
+
|
|
112
|
+
Create or update every required bootstrap output. Bootstrap is incomplete until all of these exist:
|
|
113
|
+
|
|
114
|
+
```text
|
|
115
|
+
AGENTS.md
|
|
116
|
+
CLAUDE.md
|
|
117
|
+
GEMINI.md
|
|
118
|
+
.AGENTS/
|
|
119
|
+
agent-rules.md
|
|
120
|
+
project-bootstrap.md
|
|
121
|
+
index.md
|
|
122
|
+
context.md
|
|
123
|
+
style.md
|
|
124
|
+
sessions/
|
|
125
|
+
YYYY-MM-DD.md
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Create root `AGENTS.md` as the entry point for future agents if it does not already exist.
|
|
129
|
+
Create root `CLAUDE.md` as the Claude Code routing file if it does not already exist.
|
|
130
|
+
Create root `GEMINI.md` as the Gemini CLI routing file if it does not already exist.
|
|
131
|
+
|
|
132
|
+
`AGENTS.md` should say:
|
|
133
|
+
|
|
134
|
+
- In operating mode, read `.AGENTS/agent-rules.md`, `.AGENTS/index.md`, and `.AGENTS/context.md`.
|
|
135
|
+
- Do not read or apply `.AGENTS/project-bootstrap.md` once `.AGENTS/index.md`, `.AGENTS/context.md`, `.AGENTS/style.md`, and `.AGENTS/sessions/` exist.
|
|
136
|
+
- Use `.AGENTS/project-bootstrap.md` only when `.AGENTS/` is void except for `agent-rules.md` and `project-bootstrap.md`.
|
|
137
|
+
|
|
138
|
+
`CLAUDE.md` should say:
|
|
139
|
+
|
|
140
|
+
- The canonical agent instructions for the repository are in `AGENTS.md`.
|
|
141
|
+
- Claude Code should open `AGENTS.md` before planning, editing, reviewing, or running commands.
|
|
142
|
+
- Tool-specific behavior may adapt tooling, but not policy.
|
|
143
|
+
- `CLAUDE.md` is a routing file, not a replacement memory system.
|
|
144
|
+
|
|
145
|
+
`GEMINI.md` should say:
|
|
146
|
+
|
|
147
|
+
- The canonical agent instructions for the repository are in `AGENTS.md`.
|
|
148
|
+
- Gemini CLI should open `AGENTS.md` before planning, editing, reviewing, or running commands.
|
|
149
|
+
- Tool-specific behavior may adapt tooling, but not policy.
|
|
150
|
+
- `GEMINI.md` is a routing file, not a replacement memory system.
|
|
151
|
+
|
|
152
|
+
## Step 5: Seed context.md
|
|
153
|
+
|
|
154
|
+
Minimum sections:
|
|
155
|
+
|
|
156
|
+
```markdown
|
|
157
|
+
# Project Context
|
|
158
|
+
|
|
159
|
+
## Purpose
|
|
160
|
+
## Fast Orientation
|
|
161
|
+
## Current State
|
|
162
|
+
## Project Type And Risk
|
|
163
|
+
## Agent Start Here
|
|
164
|
+
## Project Folder Structure
|
|
165
|
+
## Core Workflow
|
|
166
|
+
## Key Outputs
|
|
167
|
+
## Security And Privacy Notes
|
|
168
|
+
## Memory Rules
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
`context.md` must be enough for an agent to traverse the project without guessing.
|
|
172
|
+
|
|
173
|
+
## Step 6: Seed index.md
|
|
174
|
+
|
|
175
|
+
Keep `index.md` short:
|
|
176
|
+
|
|
177
|
+
```markdown
|
|
178
|
+
# Agent Memory Index
|
|
179
|
+
|
|
180
|
+
## Always Read
|
|
181
|
+
|
|
182
|
+
- `.AGENTS/agent-rules.md`
|
|
183
|
+
- `.AGENTS/context.md`
|
|
184
|
+
- `.AGENTS/style.md` when editing code, docs, or project conventions
|
|
185
|
+
|
|
186
|
+
## Historical Memory
|
|
187
|
+
|
|
188
|
+
- `.AGENTS/sessions/*.md`
|
|
189
|
+
|
|
190
|
+
## Hot Facts
|
|
191
|
+
|
|
192
|
+
- Project type:
|
|
193
|
+
- Current priority:
|
|
194
|
+
- Main output:
|
|
195
|
+
- Current risk:
|
|
196
|
+
|
|
197
|
+
## Bootstrap Boundary
|
|
198
|
+
|
|
199
|
+
Do not read or apply `.AGENTS/project-bootstrap.md` during operating mode.
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Step 7: Select Style Profile And Generate style.md
|
|
203
|
+
|
|
204
|
+
Do not copy a generic style guide. Bootstrap owns the style decision because `style.md` does not exist yet in a brand-new target project. Generate `style.md` from the classified project type, intended use, audience, outputs, workflow, and risk.
|
|
205
|
+
|
|
206
|
+
Include a short classification block:
|
|
207
|
+
|
|
208
|
+
```markdown
|
|
209
|
+
## Style Basis
|
|
210
|
+
|
|
211
|
+
- Project type:
|
|
212
|
+
- Intended use:
|
|
213
|
+
- Risk level:
|
|
214
|
+
- Why these conventions apply:
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Select one primary style profile, then add any secondary profile needed for risk or workflow. Record the selected profile in both `context.md` and `style.md`.
|
|
218
|
+
|
|
219
|
+
Style profiles:
|
|
220
|
+
|
|
221
|
+
- Memory-system development: use when the target project develops, tests, or distributes the memory seed itself. Emphasize control-plane vs generated-file boundaries, version policy, archive rules, portability, and session-log rationale.
|
|
222
|
+
- Software or production project: use for apps, APIs, websites, packages, libraries, and tools. Emphasize architecture, setup commands, test commands, dependency hygiene, secure defaults, logging without sensitive data, deployment assumptions, and rollback-aware changes.
|
|
223
|
+
- Data science or ML: use for notebooks, experiments, model training, analysis, and data pipelines. Emphasize reproducibility, data leakage prevention, train/validation/test boundaries, experiment tracking, notebook execution order, artifact versioning, and metric discipline.
|
|
224
|
+
- Writing, essay, or research: use for drafts, long-form writing, source synthesis, and argument development. Emphasize source traceability, audience, thesis, outline, citation expectations, assumptions, methodology, and separation of evidence from interpretation.
|
|
225
|
+
- Second-brain or ideation: use for personal knowledge bases, diary-like workspaces, idea development, and exploratory notes. Emphasize low-friction capture, privacy, durable naming, linking conventions, uncertainty, and sync/backup awareness.
|
|
226
|
+
- Automation or scripting: use for local utilities, initialization scripts, data movement, and repeatable operational tasks. Emphasize idempotency, dry-run behavior where useful, explicit paths, logging, safe failure modes, and protection against destructive commands.
|
|
227
|
+
- Sensitive or private project: add as a secondary profile when the target may contain personal data, user data, credentials, payments, proprietary material, client data, health data, financial data, or other sensitive information. Emphasize minimization, redaction, secrets handling, and explicit export/sync/publication risks.
|
|
228
|
+
|
|
229
|
+
Minimum generated `style.md` structure:
|
|
230
|
+
|
|
231
|
+
```markdown
|
|
232
|
+
# Project Style Guide
|
|
233
|
+
|
|
234
|
+
## Style Basis
|
|
235
|
+
|
|
236
|
+
- Project type:
|
|
237
|
+
- Primary style profile:
|
|
238
|
+
- Secondary style profile:
|
|
239
|
+
- Intended use:
|
|
240
|
+
- Primary audience:
|
|
241
|
+
- Risk level:
|
|
242
|
+
- Why these conventions apply:
|
|
243
|
+
|
|
244
|
+
## Global Conventions
|
|
245
|
+
|
|
246
|
+
## Project-Specific Conventions
|
|
247
|
+
|
|
248
|
+
## Security And Privacy Conventions
|
|
249
|
+
|
|
250
|
+
## File-Specific Guidance
|
|
251
|
+
|
|
252
|
+
### `index.md`
|
|
253
|
+
|
|
254
|
+
### `context.md`
|
|
255
|
+
|
|
256
|
+
### `style.md`
|
|
257
|
+
|
|
258
|
+
### `sessions/YYYY-MM-DD.md`
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Profile-specific guidance:
|
|
262
|
+
|
|
263
|
+
- Data science or ML: reproducibility, data leakage prevention, train/validation/test boundaries, experiment tracking, notebook execution order, artifact versioning, metric discipline.
|
|
264
|
+
- Production app, API, website, or SaaS: secure defaults, input validation, authentication/authorization expectations, secrets handling, dependency hygiene, logging without sensitive data, tests, deployment checks, rollback-aware changes.
|
|
265
|
+
- Library or package: API stability, semantic versioning, typing, tests, public documentation, compatibility policy, changelog expectations.
|
|
266
|
+
- Writing, diary, notes, or second brain: clarity, linking conventions, metadata/tagging, privacy expectations, durable naming, low-friction capture, sync/backup awareness.
|
|
267
|
+
- Automation or scripting: idempotency, dry-run behaviour where useful, explicit paths, logging, safe failure modes, protection against destructive commands.
|
|
268
|
+
- Research project: source traceability, assumptions, methodology notes, reproducibility, separation of evidence from interpretation.
|
|
269
|
+
|
|
270
|
+
Security must be proportional:
|
|
271
|
+
|
|
272
|
+
- Production-facing, public, networked, or user-data projects require explicit security best practices.
|
|
273
|
+
- Private local knowledge projects require privacy and backup guidance, not unnecessary production process.
|
|
274
|
+
- If uncertain, protect secrets, credentials, personal data, and destructive operations by default.
|
|
275
|
+
|
|
276
|
+
## Step 8: Create First Session Log
|
|
277
|
+
|
|
278
|
+
Create `.AGENTS/sessions/YYYY-MM-DD.md` and record:
|
|
279
|
+
|
|
280
|
+
- bootstrap date
|
|
281
|
+
- project classification
|
|
282
|
+
- questions asked and answers received
|
|
283
|
+
- files created
|
|
284
|
+
- assumptions
|
|
285
|
+
- follow-up gaps
|
|
286
|
+
|
|
287
|
+
Keep sessions append-only.
|
|
288
|
+
|
|
289
|
+
## Step 9: Validate Bootstrap
|
|
290
|
+
|
|
291
|
+
Bootstrap is incomplete until all checks pass:
|
|
292
|
+
|
|
293
|
+
- `AGENTS.md` exists.
|
|
294
|
+
- `CLAUDE.md` exists and routes Claude Code to `AGENTS.md`.
|
|
295
|
+
- `GEMINI.md` exists and routes Gemini CLI to `AGENTS.md`.
|
|
296
|
+
- `.AGENTS/agent-rules.md` exists and defines operating-mode memory rules.
|
|
297
|
+
- `.AGENTS/project-bootstrap.md` exists and is marked bootstrap-only.
|
|
298
|
+
- `.AGENTS/index.md` exists, is concise, and points only to active files.
|
|
299
|
+
- `.AGENTS/context.md` exists and includes project type, risk, purpose, current state, traversal guidance, and memory rules.
|
|
300
|
+
- `.AGENTS/style.md` exists and matches the project type, intended use, and risk level.
|
|
301
|
+
- `.AGENTS/sessions/YYYY-MM-DD.md` exists and records bootstrap decisions.
|
|
302
|
+
- No required bootstrap output is missing.
|
|
303
|
+
- No stale file references point agents to obsolete memory files.
|
|
304
|
+
- Security posture matches risk level.
|
|
305
|
+
- `context.md` is enough for repo traversal without guessing.
|
|
306
|
+
- No active operating-mode file requires agents to read bootstrap guidance after initialization.
|
|
307
|
+
|
|
308
|
+
After validation, switch to operating mode and stop using this file.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
memory-system-version: 1.2
|
|
3
|
+
tags:
|
|
4
|
+
- agent-entry
|
|
5
|
+
- ai-memory
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Agent Entry Point
|
|
9
|
+
|
|
10
|
+
This repository uses `.AGENTS/` as its agent memory and onboarding system.
|
|
11
|
+
|
|
12
|
+
Memory Seed is designed for file-reading AI coding agents. Keep the shared memory core in plain Markdown with predictable paths, explicit read order, and minimal vendor-specific assumptions. Tool-specific routing files should point into the same `.AGENTS/` memory core.
|
|
13
|
+
|
|
14
|
+
## Operating Mode
|
|
15
|
+
|
|
16
|
+
This repository is already initialized. Start here:
|
|
17
|
+
|
|
18
|
+
1. Read `.AGENTS/agent-rules.md`.
|
|
19
|
+
2. Read `.AGENTS/index.md` for the compact memory index.
|
|
20
|
+
3. Read `.AGENTS/context.md` for project orientation and current state.
|
|
21
|
+
4. Follow the start-of-work and end-of-work routines in `.AGENTS/agent-rules.md`.
|
|
22
|
+
|
|
23
|
+
Do not read or apply `.AGENTS/project-bootstrap.md` during operating mode.
|
|
24
|
+
|
|
25
|
+
## Bootstrap Mode
|
|
26
|
+
|
|
27
|
+
Use `.AGENTS/project-bootstrap.md` only when initializing a brand-new project or repairing a missing/incomplete `.AGENTS` memory system. The normal bootstrap seed state is:
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
AGENTS.md
|
|
31
|
+
CLAUDE.md
|
|
32
|
+
GEMINI.md
|
|
33
|
+
.AGENTS/
|
|
34
|
+
agent-rules.md
|
|
35
|
+
project-bootstrap.md
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If `.AGENTS/` is missing, partial, or corrupted, use `.AGENTS/project-bootstrap.md` only long enough to restore the standard structure. Once `.AGENTS/index.md`, `.AGENTS/context.md`, `.AGENTS/style.md`, and `.AGENTS/sessions/` exist, bootstrap mode is complete and future agents must use operating mode.
|
|
39
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
memory-system-version: 1.2
|
|
3
|
+
tags:
|
|
4
|
+
- agent-entry
|
|
5
|
+
- ai-memory
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Claude Instructions
|
|
9
|
+
|
|
10
|
+
The canonical agent instructions for this repository are in `AGENTS.md`.
|
|
11
|
+
|
|
12
|
+
Before planning, editing, reviewing, or running commands:
|
|
13
|
+
1. Open `AGENTS.md`.
|
|
14
|
+
2. Follow its instructions.
|
|
15
|
+
3. If tool-specific behavior is needed, adapt only the tooling, not the policy.
|
|
16
|
+
|
|
17
|
+
Do not treat this file as a replacement for `AGENTS.md`.
|
|
18
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
memory-system-version: 1.2
|
|
3
|
+
tags:
|
|
4
|
+
- agent-entry
|
|
5
|
+
- ai-memory
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Gemini Instructions
|
|
9
|
+
|
|
10
|
+
The canonical agent instructions for this repository are in `AGENTS.md`.
|
|
11
|
+
|
|
12
|
+
Before planning, editing, reviewing, or running commands:
|
|
13
|
+
1. Open `AGENTS.md`.
|
|
14
|
+
2. Follow its instructions.
|
|
15
|
+
3. If tool-specific behavior is needed, adapt only the tooling, not the policy.
|
|
16
|
+
|
|
17
|
+
Do not treat this file as a replacement for `AGENTS.md`.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: memory-seed
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Summary: Portable local memory seed for file-reading AI coding agents
|
|
5
|
+
Author: John Tshibuyi
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: ai,agents,memory,markdown,local-first
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Topic :: Software Development
|
|
15
|
+
Classifier: Topic :: Utilities
|
|
16
|
+
Requires-Python: >=3.11
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# Memory Seed
|
|
22
|
+
|
|
23
|
+
Memory Seed is a portable local memory system for AI coding agents.
|
|
24
|
+
|
|
25
|
+
It provides a small set of plain Markdown control-plane files that can be planted into a new or existing project. During bootstrap, the seed generates project-specific operating memory so future agent sessions can recover the project's purpose, current state, conventions, risks, and recent decisions without depending on vendor-hosted memory.
|
|
26
|
+
|
|
27
|
+
## Goals
|
|
28
|
+
|
|
29
|
+
- Keep project memory local, inspectable, and portable.
|
|
30
|
+
- Support file-reading AI coding agents through predictable Markdown files.
|
|
31
|
+
- Route tool-specific entry files into one shared `.AGENTS/` memory core.
|
|
32
|
+
- Generate project-specific `index.md`, `context.md`, `style.md`, and session logs during bootstrap.
|
|
33
|
+
- Archive reusable control-plane versions while keeping generated project memory outside version archives.
|
|
34
|
+
|
|
35
|
+
## Reusable Seed Files
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
AGENTS.md
|
|
39
|
+
CLAUDE.md
|
|
40
|
+
GEMINI.md
|
|
41
|
+
.AGENTS/
|
|
42
|
+
agent-rules.md
|
|
43
|
+
project-bootstrap.md
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Generated Per-Project Files
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
.AGENTS/
|
|
50
|
+
index.md
|
|
51
|
+
context.md
|
|
52
|
+
style.md
|
|
53
|
+
sessions/
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Current Version
|
|
57
|
+
|
|
58
|
+
The current reusable control-plane version is `1.2`.
|
|
59
|
+
|
|
60
|
+
Archived reusable versions are stored under `.AGENTS/archive/<version>/`.
|
|
61
|
+
|
|
62
|
+
## Python CLI
|
|
63
|
+
|
|
64
|
+
Memory Seed includes a small Python CLI.
|
|
65
|
+
|
|
66
|
+
From this repository, run:
|
|
67
|
+
|
|
68
|
+
```powershell
|
|
69
|
+
python -m memory_seed.cli version
|
|
70
|
+
python -m memory_seed.cli doctor
|
|
71
|
+
python -m memory_seed.cli init --dry-run
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The `init` command copies only the reusable seed files into the current folder:
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
AGENTS.md
|
|
78
|
+
CLAUDE.md
|
|
79
|
+
GEMINI.md
|
|
80
|
+
.AGENTS/agent-rules.md
|
|
81
|
+
.AGENTS/project-bootstrap.md
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
It does not copy generated project memory such as `.AGENTS/context.md`, `.AGENTS/index.md`, `.AGENTS/style.md`, `.AGENTS/sessions/`, or `.AGENTS/archive/`.
|
|
85
|
+
|
|
86
|
+
Use `--dry-run` to preview without changing files. Use `--force` only when you intentionally want to back up and replace existing seed files.
|
|
87
|
+
|
|
88
|
+
When `--force` creates backups, Memory Seed adds `.AGENTS/backups/` to the target project's `.gitignore` to reduce the chance of committing replaced local memory files.
|
|
89
|
+
|
|
90
|
+
## Public Memory Hygiene
|
|
91
|
+
|
|
92
|
+
Memory Seed files are plain Markdown and may be committed with a project. Treat `.AGENTS` files as publishable unless the project is explicitly private.
|
|
93
|
+
|
|
94
|
+
Do not put secrets, credentials, tokens, private keys, sensitive account details, client confidential information, or unnecessary personal data into generated memory files or session logs.
|
|
95
|
+
|
|
96
|
+
## Publishing
|
|
97
|
+
|
|
98
|
+
This repository is configured for PyPI trusted publishing from GitHub Actions.
|
|
99
|
+
|
|
100
|
+
PyPI pending publisher settings should match:
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
PyPI Project Name: memory-seed
|
|
104
|
+
Owner: jnl-tshi
|
|
105
|
+
Repository name: memory-seed
|
|
106
|
+
Workflow name: publish.yml
|
|
107
|
+
Environment name: pypi
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The publish workflow lives at `.github/workflows/publish.yml`. It runs tests, builds the package with `uv build`, and publishes through PyPI's trusted publisher flow.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
memory_seed/__init__.py
|
|
5
|
+
memory_seed/cli.py
|
|
6
|
+
memory_seed/core.py
|
|
7
|
+
memory_seed.egg-info/PKG-INFO
|
|
8
|
+
memory_seed.egg-info/SOURCES.txt
|
|
9
|
+
memory_seed.egg-info/dependency_links.txt
|
|
10
|
+
memory_seed.egg-info/entry_points.txt
|
|
11
|
+
memory_seed.egg-info/top_level.txt
|
|
12
|
+
memory_seed/seed/AGENTS.md
|
|
13
|
+
memory_seed/seed/CLAUDE.md
|
|
14
|
+
memory_seed/seed/GEMINI.md
|
|
15
|
+
memory_seed/seed/.AGENTS/agent-rules.md
|
|
16
|
+
memory_seed/seed/.AGENTS/project-bootstrap.md
|
|
17
|
+
tests/test_memory_seed.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
memory_seed
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "memory-seed"
|
|
7
|
+
version = "1.2.0"
|
|
8
|
+
description = "Portable local memory seed for file-reading AI coding agents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "John Tshibuyi" }]
|
|
13
|
+
keywords = ["ai", "agents", "memory", "markdown", "local-first"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Topic :: Software Development",
|
|
22
|
+
"Topic :: Utilities",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
memory-seed = "memory_seed.cli:main"
|
|
27
|
+
|
|
28
|
+
[tool.setuptools]
|
|
29
|
+
packages = ["memory_seed"]
|
|
30
|
+
|
|
31
|
+
[tool.setuptools.package-data]
|
|
32
|
+
memory_seed = [
|
|
33
|
+
"seed/AGENTS.md",
|
|
34
|
+
"seed/CLAUDE.md",
|
|
35
|
+
"seed/GEMINI.md",
|
|
36
|
+
"seed/.AGENTS/agent-rules.md",
|
|
37
|
+
"seed/.AGENTS/project-bootstrap.md",
|
|
38
|
+
]
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
import tempfile
|
|
3
|
+
import unittest
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from memory_seed.core import SEED_FILES, doctor, get_version, init_project
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class MemorySeedTests(unittest.TestCase):
|
|
10
|
+
def make_project(self):
|
|
11
|
+
path = Path(tempfile.mkdtemp(prefix="memory-seed-test-"))
|
|
12
|
+
self.addCleanup(lambda: shutil.rmtree(path, ignore_errors=True))
|
|
13
|
+
return path
|
|
14
|
+
|
|
15
|
+
def test_version_reads_reusable_control_plane_version(self):
|
|
16
|
+
self.assertEqual(get_version(), "1.2")
|
|
17
|
+
|
|
18
|
+
def test_init_dry_run_reports_seed_files_without_writing(self):
|
|
19
|
+
cwd = self.make_project()
|
|
20
|
+
|
|
21
|
+
result = init_project(cwd=cwd, dry_run=True)
|
|
22
|
+
|
|
23
|
+
self.assertFalse(result.changed)
|
|
24
|
+
self.assertEqual(result.created, [])
|
|
25
|
+
self.assertEqual(
|
|
26
|
+
sorted(result.planned),
|
|
27
|
+
sorted(seed_file.destination for seed_file in SEED_FILES),
|
|
28
|
+
)
|
|
29
|
+
self.assertFalse((cwd / "AGENTS.md").exists())
|
|
30
|
+
self.assertFalse((cwd / ".AGENTS").exists())
|
|
31
|
+
|
|
32
|
+
def test_init_dry_run_does_not_require_force_when_files_exist(self):
|
|
33
|
+
cwd = self.make_project()
|
|
34
|
+
(cwd / "AGENTS.md").write_text("existing", encoding="utf-8")
|
|
35
|
+
|
|
36
|
+
result = init_project(cwd=cwd, dry_run=True)
|
|
37
|
+
|
|
38
|
+
self.assertFalse(result.changed)
|
|
39
|
+
self.assertEqual((cwd / "AGENTS.md").read_text(encoding="utf-8"), "existing")
|
|
40
|
+
|
|
41
|
+
def test_init_writes_only_reusable_seed_files(self):
|
|
42
|
+
cwd = self.make_project()
|
|
43
|
+
|
|
44
|
+
result = init_project(cwd=cwd)
|
|
45
|
+
|
|
46
|
+
self.assertTrue(result.changed)
|
|
47
|
+
for seed_file in SEED_FILES:
|
|
48
|
+
self.assertTrue(
|
|
49
|
+
(cwd / seed_file.destination).exists(),
|
|
50
|
+
f"{seed_file.destination} should exist",
|
|
51
|
+
)
|
|
52
|
+
self.assertFalse((cwd / ".AGENTS" / "context.md").exists())
|
|
53
|
+
self.assertFalse((cwd / ".AGENTS" / "index.md").exists())
|
|
54
|
+
self.assertFalse((cwd / ".AGENTS" / "style.md").exists())
|
|
55
|
+
self.assertFalse((cwd / ".AGENTS" / "sessions").exists())
|
|
56
|
+
|
|
57
|
+
def test_init_refuses_to_overwrite_existing_files_without_force(self):
|
|
58
|
+
cwd = self.make_project()
|
|
59
|
+
(cwd / "AGENTS.md").write_text("existing", encoding="utf-8")
|
|
60
|
+
|
|
61
|
+
with self.assertRaisesRegex(
|
|
62
|
+
FileExistsError, r"Refusing to overwrite existing files: AGENTS\.md"
|
|
63
|
+
):
|
|
64
|
+
init_project(cwd=cwd)
|
|
65
|
+
|
|
66
|
+
self.assertEqual((cwd / "AGENTS.md").read_text(encoding="utf-8"), "existing")
|
|
67
|
+
|
|
68
|
+
def test_init_force_backs_up_existing_files_before_replacement(self):
|
|
69
|
+
cwd = self.make_project()
|
|
70
|
+
(cwd / "AGENTS.md").write_text("existing", encoding="utf-8")
|
|
71
|
+
|
|
72
|
+
result = init_project(cwd=cwd, force=True)
|
|
73
|
+
|
|
74
|
+
self.assertTrue(result.changed)
|
|
75
|
+
self.assertEqual(len(result.backed_up), 1)
|
|
76
|
+
self.assertTrue(result.backed_up[0].startswith(".AGENTS/backups/"))
|
|
77
|
+
self.assertEqual((cwd / result.backed_up[0]).read_text(encoding="utf-8"), "existing")
|
|
78
|
+
self.assertIn(
|
|
79
|
+
"memory-system-version: 1.2",
|
|
80
|
+
(cwd / "AGENTS.md").read_text(encoding="utf-8"),
|
|
81
|
+
)
|
|
82
|
+
self.assertIn(".AGENTS/backups/", (cwd / ".gitignore").read_text(encoding="utf-8"))
|
|
83
|
+
|
|
84
|
+
def test_init_force_preserves_existing_gitignore_when_adding_backup_ignore(self):
|
|
85
|
+
cwd = self.make_project()
|
|
86
|
+
(cwd / "AGENTS.md").write_text("existing", encoding="utf-8")
|
|
87
|
+
(cwd / ".gitignore").write_text("dist/\n", encoding="utf-8")
|
|
88
|
+
|
|
89
|
+
init_project(cwd=cwd, force=True)
|
|
90
|
+
|
|
91
|
+
gitignore = (cwd / ".gitignore").read_text(encoding="utf-8")
|
|
92
|
+
self.assertIn("dist/\n", gitignore)
|
|
93
|
+
self.assertEqual(gitignore.count(".AGENTS/backups/"), 1)
|
|
94
|
+
|
|
95
|
+
def test_doctor_reports_missing_and_version_mismatched_control_plane_files(self):
|
|
96
|
+
cwd = self.make_project()
|
|
97
|
+
init_project(cwd=cwd)
|
|
98
|
+
gemini = cwd / "GEMINI.md"
|
|
99
|
+
gemini.write_text(
|
|
100
|
+
gemini.read_text(encoding="utf-8").replace("1.2", "1.1"),
|
|
101
|
+
encoding="utf-8",
|
|
102
|
+
)
|
|
103
|
+
(cwd / "CLAUDE.md").unlink()
|
|
104
|
+
|
|
105
|
+
result = doctor(cwd=cwd)
|
|
106
|
+
|
|
107
|
+
self.assertFalse(result.ok)
|
|
108
|
+
self.assertEqual(result.missing, ["CLAUDE.md"])
|
|
109
|
+
self.assertEqual(
|
|
110
|
+
result.version_mismatches,
|
|
111
|
+
[{"file": "GEMINI.md", "expected": "1.2", "actual": "1.1"}],
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
if __name__ == "__main__":
|
|
116
|
+
unittest.main()
|