(args: argparse.Namespace)
| 162 | |
| 163 | |
| 164 | def cmd_init(args: argparse.Namespace) -> None: |
| 165 | cwd = os.path.abspath(args.cwd or os.getcwd()) |
| 166 | host = args.host or "127.0.0.1" |
| 167 | port = args.port or 3000 |
| 168 | base = f"http://{host}:{port}/api/v1" |
| 169 | |
| 170 | # Check server health first |
| 171 | try: |
| 172 | health = _request("GET", f"{base}/health") |
| 173 | except SystemExit: |
| 174 | return |
| 175 | |
| 176 | # Create session |
| 177 | result = _request("POST", f"{base}/sessions", data={"cwd": cwd}) |
| 178 | state = { |
| 179 | "session_id": result["session_id"], |
| 180 | "host": host, |
| 181 | "port": port, |
| 182 | "project": cwd, |
| 183 | "created_at": result.get("created_at", ""), |
| 184 | } |
| 185 | _save_state(state) |
| 186 | |
| 187 | print(f"Session created: {result['session_id']}") |
| 188 | print(f"Project: {cwd}") |
| 189 | print(f"Server: {health.get('status', 'ok')} " |
| 190 | f"({health.get('projects', 0)} projects, " |
| 191 | f"{health.get('active_sessions', 0)} sessions)") |
| 192 | |
| 193 | |
| 194 | def cmd_status(args: argparse.Namespace) -> None: |
nothing calls this directly
no test coverage detected