Metadata-Version: 2.5
Name: shevam
Version: 0.2.0
Summary: A project & tools management CLI
Requires-Python: >=3.10
Requires-Dist: gitpython>=3.1.0
Requires-Dist: rich>=13.0.0
Requires-Dist: textual>=0.60.0
Requires-Dist: typer[all]>=0.12.0
Provides-Extra: git-info
Description-Content-Type: text/markdown

# Shevam ◈  v0.2.0

**Shevam** is a modular project & tools manager with a full **plugin system**.
Built with [Typer](https://typer.tiangolo.com/) + [Textual](https://textual.textualize.io/).  
Pure-Python JSON storage — zero external DB required.

Visit Our [Website](https://shevamv-website.web.app/)

---

## Install

```bash
pip install shevam   # Python 3.10+
```

---

## Core workflow

```bash
shevam init [dir]    # writes project.json into dir (npm init style)
shevam add  [dir]    # reads project.json → registers in ~/.shevam/db.json
shevam list          # table of all projects
shevam show <n>      # full detail panel
shevam update <n>    # update fields + rewrite project.json
shevam remove <n>    # remove from DB
shevam recent        # recently accessed
shevam ui            # full Textual TUI
```

## Authentication plugin (optional)

Install the Shevam auth SDK extra. The built-in client is registered as a
**public OAuth client** with the callback
`http://127.0.0.1:8765/callback`:

```bash
pip install "shevam[auth]"
```

The extra depends on the `shauth` Python SDK published from
`packages/python`; publish that SDK before releasing Shevam with the auth extra.

The auth plugin uses the registered public client ID by default. You can
override it with an environment variable or `--client-id`:

```powershell
shevam auth login
shevam auth logout
```

The plugin uses the Cloudflare gateway at
`https://shevam-auth-gateway.vermans-svr.workers.dev` and the hosted
**Continue with Shevam** page. `SHEVAM_AUTH_REDIRECT_URI` and
`SHEVAM_AUTH_CONSENT_PAGE_URL` can override
the callback and consent page for development; use `--base-url` to target a
different gateway explicitly. The auth plugin is a built-in plugin under
`shevam/plugins_builtin/auth`; it can be enabled or disabled like other
plugins. OAuth access tokens are stored in `~/.shevam/auth.json`; logout clears
the local token, which expires automatically at the gateway.

Built-in plugins are included in the Shevam wheel. The `git_info` extra is
available as `pip install "shevam[git_info]"`; it does not install extra Python
packages because `git_info` uses the Git executable directly. Install Git
separately if it is not already available.

## Script aliases

Create a shortcut that runs one of a registered project's scripts:

```bash
shevam alias set dev my-project start
shevam dev --port 8080
shevam alias list
shevam alias remove dev
```

Aliases are stored in `~/.shevam/aliases.json`. They cannot override built-in
or installed plugin commands, and any arguments after the alias are passed to
the configured script.

## Run a project script at sign-in

Register one script per project to launch when you log in to your computer.
Arguments are passed to the project script; by default, it runs in the
background without opening a terminal or a shell. Use `--terminal` when you
want a visible terminal window:

```bash
shevam startup add my-project update-checker --no-shell --quiet
shevam startup add my-gui-app start --terminal
shevam startup list
shevam startup remove my-project
```

The startup registration runs at user sign-in and uses the script and project
path from the current project record. Update the registration after changing
that script or its arguments. Login entries are installed using the current
user's startup mechanism (Windows Startup folder, Linux XDG autostart, or
macOS LaunchAgents). macOS LaunchAgents run without a terminal; `--terminal`
is not supported there. `--no-shell` starts the configured command directly
with the arguments supplied to the startup entry; shell operators and
expansions are not interpreted in this mode. `--terminal` executes the
project's script as a shell command in a visible terminal.

---

## Plugin system

### Storage

```
~/.shevam/
  db.json          registered projects
  recent.json      access history
  plugins.json     enabled/disabled state
  plugins/
    <name>/
      plugin.py    user-installed plugins
shevam/plugins_builtin/
  stats_widget/    built-in: type breakdown widget + CLI
  git_info/        built-in: git status TUI view + CLI
```

### What plugins can do

| Capability            | How                                                                       |
| --------------------- | ------------------------------------------------------------------------- |
| **Dashboard widget**  | `self.add_dashboard_widget(label, factory, position)`                     |
| **New TUI view**      | `self.add_tui_view(view_id, label, factory, nav_key)`                     |
| **Theme / CSS patch** | `self.add_css(css_string)` or full replace via `theme_registry.replace()` |
| **CLI sub-app**       | `self.add_cli_app(typer_app)` → `shevam <plugin_id> <cmd>`                |
| **CLI top-level cmd** | `self.add_cli_command(fn)`                                                |
| **Hooks**             | `self.add_hook("before_add", fn)` etc.                                    |

### Available hooks

| Hook            | When fired                             | Context keys                   |
| --------------- | -------------------------------------- | ------------------------------ |
| `before_init`   | Before project.json is written         | `name`, `path`                 |
| `after_init`    | After project.json written             | `name`, `path`                 |
| `before_add`    | Before registering in DB               | all project fields             |
| `after_add`     | After registering in DB                | `name`, `path`, `project_type` |
| `before_update` | Before update                          | `name`, `fields`               |
| `after_update`  | After update                           | `name`                         |
| `before_remove` | Before removal (return False to abort) | `name`                         |
| `after_remove`  | After removal                          | `name`                         |

### Module mode (plugin CLI)

```bash
shevam -m stats_widget summary
shevam -m git_info status my-app
shevam -m git_info log my-app -n 20

# or directly as sub-commands:
shevam stats_widget summary
shevam git_info status all
```

### Plugin management

```bash
shevam plugin list
shevam plugin install /path/to/my_plugin/
shevam plugin disable git_info
shevam plugin enable  git_info
```

### Writing a plugin

Create `~/.shevam/plugins/my_plugin/plugin.py`:

```python
from shevam.plugin_engine import ShevamPlugin
import typer

cli = typer.Typer()

@cli.command("hello")
def hello():
    print("Hello from my_plugin!")

class MyPlugin(ShevamPlugin):
    plugin_id   = "my_plugin"
    plugin_name = "My Plugin"
    version     = "0.1.0"
    description = "Example user plugin"

    def load(self):
        # Add dashboard widget
        from textual.widgets import Static
        self.add_dashboard_widget(
            label="MY WIDGET",
            factory=lambda: Static("Hello from plugin!"),
            position="bottom",
        )
        # Add CLI
        self.add_cli_app(cli)
        # Add hook
        self.add_hook("after_add", lambda ctx: print(f"Added: {ctx['name']}"))
        # Patch CSS
        self.add_css("/* custom styles */")
```

Then: `shevam plugin install ~/.shevam/plugins/my_plugin/`

---

## TUI key bindings

| Key | Action                     |
| --- | -------------------------- |
| `1` | Dashboard                  |
| `2` | Projects list              |
| `3` | Git view (git_info plugin) |
| `9` | Plugin registry            |
| `a` | Add project                |
| `e` | Edit selected              |
| `d` | Delete selected            |
| `r` | Refresh                    |
| `q` | Quit                       |
