-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevmind.py
More file actions
124 lines (93 loc) · 3.5 KB
/
Copy pathdevmind.py
File metadata and controls
124 lines (93 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
"""DevMind CLI -- setup, seed, status, and brief commands."""
import argparse
import asyncio
import sys
def cmd_setup(args):
"""Create the SurrealDB schema."""
from db.client import DevMindDB
async def _run():
db = DevMindDB()
await db.connect()
try:
await db.setup_schema()
finally:
await db.disconnect()
asyncio.run(_run())
print("[DevMind] schema created")
def cmd_seed(args):
"""Seed the database with demo data."""
project = args.project or "auth-service"
async def _run():
from seed.seed_data import run_seed
await run_seed(project)
asyncio.run(_run())
def cmd_status(args):
"""Query and display node counts from SurrealDB."""
from db.client import DevMindDB, extract_count
async def _run():
db = DevMindDB()
await db.connect()
try:
tables = {
"errors": "error",
"fixes": "fix",
"decisions": "decision",
"patterns": "pattern",
"files": "file",
}
counts = {}
for label, table in tables.items():
result = await db.query(
f"SELECT count() FROM {table} WHERE project = $p GROUP ALL;",
{"p": args.project},
)
counts[label] = extract_count(result)
lm_result = await db.query(
"SELECT count() FROM error WHERE project = $p AND landmine = true GROUP ALL;",
{"p": args.project},
)
landmine_count = extract_count(lm_result)
print(f"\n DevMind Status -- {args.project}")
print(" " + "-" * 35)
print(f" errors: {counts.get('errors', 0):>4} (landmines: {landmine_count})")
print(f" fixes: {counts.get('fixes', 0):>4}")
print(f" decisions: {counts.get('decisions', 0):>4}")
print(f" patterns: {counts.get('patterns', 0):>4}")
print(f" files: {counts.get('files', 0):>4}")
print()
finally:
await db.disconnect()
asyncio.run(_run())
def cmd_brief(args):
"""Generate and print the project brief."""
from brief.generator import generate_brief
result = asyncio.run(generate_brief(args.project))
print(result)
def main():
parser = argparse.ArgumentParser(
prog="devmind",
description="DevMind -- graph-native project memory for AI dev teams",
)
subparsers = parser.add_subparsers(dest="command", help="Available commands")
# setup
sp_setup = subparsers.add_parser("setup", help="Create SurrealDB schema")
sp_setup.set_defaults(func=cmd_setup)
# seed
sp_seed = subparsers.add_parser("seed", help="Seed database with demo data")
sp_seed.add_argument("--project", default=None, help="Project name (default: auth-service)")
sp_seed.set_defaults(func=cmd_seed)
# status
sp_status = subparsers.add_parser("status", help="Show node counts")
sp_status.add_argument("--project", required=True, help="Project name")
sp_status.set_defaults(func=cmd_status)
# brief
sp_brief = subparsers.add_parser("brief", help="Generate project brief")
sp_brief.add_argument("--project", required=True, help="Project name")
sp_brief.set_defaults(func=cmd_brief)
args = parser.parse_args()
if not args.command:
parser.print_help()
sys.exit(1)
args.func(args)
if __name__ == "__main__":
main()