feat: update profile path resolution and enhance scripts for improved project adaptability
This commit is contained in:
@@ -34,7 +34,7 @@ The service manager unifies startup and status. It does not move capture behavio
|
||||
|
||||
## Local project-knowledge index
|
||||
|
||||
The workspace includes a dependency-free local indexer for canonical Markdown memory. The index is derived from `project-knowledge/` and written under `.aiw/indexes/<profile>/`; it is safe to delete and rebuild.
|
||||
The workspace includes a dependency-free local indexer for canonical Markdown memory. The index is derived from the profile's configured `knowledge_dir` and written under the profile's configured `index_dir`; it is safe to delete and rebuild.
|
||||
|
||||
```bash
|
||||
python3 scripts/aiw/indexer.py build --profile fidelity
|
||||
@@ -62,7 +62,7 @@ Current fields:
|
||||
}
|
||||
```
|
||||
|
||||
Use `scripts/aiw/profile.py` from new scripts instead of hardcoding root-level `project-knowledge/` or `ai/inbox/` paths.
|
||||
Use `scripts/aiw/profile.py` from new scripts instead of hardcoding root-level project memory or inbox paths.
|
||||
|
||||
## Robustness features
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ instead of hardcoding root-level project paths.
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -70,3 +71,37 @@ def relative_to_root(path: Path, root: Path | None = None) -> str:
|
||||
return str(path.relative_to(base))
|
||||
except ValueError:
|
||||
return str(path)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
subparsers = parser.add_subparsers(dest="command", required=True)
|
||||
|
||||
path_parser = subparsers.add_parser("path", help="Print a resolved profile path.")
|
||||
path_parser.add_argument("kind", choices=["knowledge", "inbox", "index"])
|
||||
path_parser.add_argument("--profile", default="fidelity")
|
||||
|
||||
config_parser = subparsers.add_parser("config", help="Print resolved workspace configuration as JSON.")
|
||||
config_parser.add_argument("--profile", default="fidelity")
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.command == "path":
|
||||
if args.kind == "knowledge":
|
||||
print(knowledge_dir(args.profile))
|
||||
elif args.kind == "inbox":
|
||||
print(inbox_dir(args.profile))
|
||||
else:
|
||||
print(index_dir(args.profile))
|
||||
return
|
||||
|
||||
config = load_workspace_config(args.profile)
|
||||
config["resolved"] = {
|
||||
"knowledge_dir": str(knowledge_dir(args.profile)),
|
||||
"inbox_dir": str(inbox_dir(args.profile)),
|
||||
"index_dir": str(index_dir(args.profile)),
|
||||
}
|
||||
print(json.dumps(config, ensure_ascii=False, indent=2, sort_keys=True))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -42,6 +42,12 @@ class ProfileTests(unittest.TestCase):
|
||||
self.assertEqual(profile.inbox_dir("missing", root=root), root / "ai" / "inbox")
|
||||
self.assertEqual(profile.index_dir("missing", root=root), root / ".aiw" / "indexes" / "missing")
|
||||
|
||||
def test_relative_to_root_handles_external_paths(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
self.assertEqual(profile.relative_to_root(root / "a" / "b", root=root), "a/b")
|
||||
self.assertEqual(profile.relative_to_root(Path("/external/path"), root=root), "/external/path")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user