orchid-cli 0.1.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.
@@ -0,0 +1,22 @@
1
+ root = true
2
+
3
+ [*]
4
+ end_of_line = lf
5
+ insert_final_newline = true
6
+ trim_trailing_whitespace = true
7
+ charset = utf-8
8
+
9
+ [*.py]
10
+ indent_style = space
11
+ indent_size = 4
12
+ max_line_length = 120
13
+
14
+ [*.{yml,yaml,json,toml}]
15
+ indent_style = space
16
+ indent_size = 2
17
+
18
+ [Makefile]
19
+ indent_style = tab
20
+
21
+ [*.md]
22
+ trim_trailing_whitespace = false
@@ -0,0 +1,157 @@
1
+ # orchid-cli (Typer CLI) — CI + Semantic Release
2
+
3
+ name: CI
4
+
5
+ on:
6
+ pull_request:
7
+ branches: [main]
8
+ push:
9
+ branches: [main]
10
+
11
+ jobs:
12
+ # ── Lint ────────────────────────────────────────────────────
13
+
14
+ ruff:
15
+ name: Ruff lint & format
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.13"
22
+ - run: pip install ruff
23
+ - run: ruff check orchid_cli/
24
+ - run: ruff format --check orchid_cli/
25
+
26
+ commit-lint:
27
+ name: Commit message check
28
+ if: github.event_name == 'pull_request'
29
+ runs-on: ubuntu-latest
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+ with:
33
+ fetch-depth: 0
34
+ - uses: actions/setup-python@v5
35
+ with:
36
+ python-version: "3.13"
37
+ - run: pip install gitlint
38
+ - run: gitlint --commits "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
39
+
40
+ # ── Test ────────────────────────────────────────────────────
41
+
42
+ test:
43
+ name: Tests + coverage
44
+ runs-on: ubuntu-latest
45
+ steps:
46
+ - uses: actions/checkout@v4
47
+ - uses: actions/setup-python@v5
48
+ with:
49
+ python-version: "3.13"
50
+ cache: pip
51
+ cache-dependency-path: pyproject.toml
52
+ - run: pip install -e ".[dev]" pytest-cov
53
+ - name: Run tests
54
+ run: |
55
+ pytest tests/ \
56
+ --cov=orchid_cli \
57
+ --cov-report=term-missing \
58
+ --cov-report=xml:coverage.xml \
59
+ --junitxml=report.xml \
60
+ -x
61
+ - name: Upload coverage
62
+ if: always()
63
+ uses: actions/upload-artifact@v4
64
+ with:
65
+ name: coverage
66
+ path: coverage.xml
67
+ if-no-files-found: ignore
68
+ - name: Upload test report
69
+ if: always()
70
+ uses: actions/upload-artifact@v4
71
+ with:
72
+ name: test-report
73
+ path: report.xml
74
+ if-no-files-found: ignore
75
+ - name: Coverage summary
76
+ if: hashFiles('coverage.xml') != ''
77
+ uses: irongut/CodeCoverageSummary@v1.3.0
78
+ with:
79
+ filename: "**/coverage.xml"
80
+ format: markdown
81
+ output: both
82
+ badge: true
83
+ fail_below_min: false
84
+ thresholds: "50 75"
85
+ - name: Add coverage PR comment
86
+ if: github.event_name == 'pull_request' && hashFiles('code-coverage-results.md') != ''
87
+ uses: marocchino/sticky-pull-request-comment@v2
88
+ with:
89
+ header: coverage
90
+ path: code-coverage-results.md
91
+
92
+ # ── Build ───────────────────────────────────────────────────
93
+
94
+ build:
95
+ name: Build wheel
96
+ runs-on: ubuntu-latest
97
+ needs: [ruff, test]
98
+ steps:
99
+ - uses: actions/checkout@v4
100
+ - uses: actions/setup-python@v5
101
+ with:
102
+ python-version: "3.13"
103
+ - run: pip install build
104
+ - run: python -m build
105
+ - uses: actions/upload-artifact@v4
106
+ with:
107
+ name: dist
108
+ path: dist/
109
+ retention-days: 7
110
+
111
+ # ── Release (semantic-release on main push) ─────────────────
112
+
113
+ release:
114
+ name: Semantic release
115
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
116
+ runs-on: ubuntu-latest
117
+ needs: [ruff, test, build]
118
+ permissions:
119
+ contents: write
120
+ id-token: write # required for PyPI trusted publishing
121
+ steps:
122
+ - uses: actions/checkout@v4
123
+ with:
124
+ fetch-depth: 0
125
+ token: ${{ secrets.GITHUB_TOKEN }}
126
+ - uses: actions/setup-python@v5
127
+ with:
128
+ python-version: "3.13"
129
+ - run: pip install python-semantic-release build
130
+ - name: Configure git
131
+ run: |
132
+ git config user.name "github-actions[bot]"
133
+ git config user.email "github-actions[bot]@users.noreply.github.com"
134
+ - name: Bump version & tag
135
+ id: version
136
+ env:
137
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138
+ run: |
139
+ OUTPUT=$(semantic-release version --push --tag --commit 2>&1) || true
140
+ echo "$OUTPUT"
141
+ if echo "$OUTPUT" | grep -q "no release will be made"; then
142
+ echo "released=false" >> "$GITHUB_OUTPUT"
143
+ else
144
+ echo "released=true" >> "$GITHUB_OUTPUT"
145
+ fi
146
+ - name: Build distribution
147
+ if: steps.version.outputs.released == 'true'
148
+ run: python -m build
149
+ - name: Publish GitHub Release
150
+ if: steps.version.outputs.released == 'true'
151
+ env:
152
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
153
+ run: semantic-release publish
154
+ # 4. Publish to PyPI via trusted publishing (OIDC)
155
+ - name: Publish to PyPI
156
+ if: steps.version.outputs.released == 'true'
157
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,46 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.egg-info/
6
+ *.egg
7
+ dist/
8
+ build/
9
+ *.whl
10
+
11
+ # Virtual environments
12
+ .venv/
13
+ venv/
14
+ ENV/
15
+
16
+ # IDE
17
+ .idea/
18
+ .vscode/
19
+ *.swp
20
+ *.swo
21
+ *~
22
+
23
+ # Ruff
24
+ .ruff_cache/
25
+
26
+ # pytest
27
+ .pytest_cache/
28
+ htmlcov/
29
+ .coverage
30
+ coverage.xml
31
+
32
+ # Environment
33
+ .env
34
+ .env.local
35
+ .env.*.local
36
+
37
+ # OS
38
+ .DS_Store
39
+ Thumbs.db
40
+
41
+ # SQLite (local dev databases)
42
+ *.db
43
+ *.sqlite3
44
+
45
+ # mypy
46
+ .mypy_cache/
@@ -0,0 +1,15 @@
1
+ # Gitlint — enforce Conventional Commits for semantic-release
2
+ # https://jorisroovers.com/gitlint/
3
+
4
+ [general]
5
+ contrib = contrib-title-conventional-commits
6
+ ignore = merge-commit,revert-commit
7
+
8
+ [title-max-length]
9
+ line-length = 72
10
+
11
+ [body-max-line-length]
12
+ line-length = 120
13
+
14
+ [contrib-title-conventional-commits]
15
+ types = feat,fix,perf,refactor,docs,style,test,build,ci,chore
@@ -0,0 +1,16 @@
1
+ # Pre-commit hooks — run automatically before each commit
2
+ # Install: pip install pre-commit && pre-commit install
3
+ # Manual: pre-commit run --all-files
4
+
5
+ repos:
6
+ - repo: https://github.com/astral-sh/ruff-pre-commit
7
+ rev: v0.9.10
8
+ hooks:
9
+ - id: ruff
10
+ args: [--fix, --exit-non-zero-on-fix]
11
+ - id: ruff-format
12
+
13
+ - repo: https://github.com/jorisroovers/gitlint
14
+ rev: v0.19.1
15
+ hooks:
16
+ - id: gitlint
@@ -0,0 +1,130 @@
1
+ # orchid-cli — AI Context
2
+
3
+ ## What This Package Is
4
+
5
+ **orchid-cli** is the Typer-based command-line interface for the Orchid multi-agent AI framework. It imports `orchid` (the library) as a dependency and provides terminal access to all chat operations, config validation, RAG indexing, and Claude Code skill generation. It mirrors the full functionality of `orchid-api` but runs locally with no server, Docker, or external database required (defaults to SQLite).
6
+
7
+ ## Package Structure
8
+
9
+ ```
10
+ orchid-cli/
11
+ orchid_cli/
12
+ main.py Typer entry point — registers sub-commands
13
+ bootstrap.py Shared startup: load config, build graph, init SQLite storage
14
+ commands/
15
+ chat.py Full CRUD: create, list, delete, history, send, interactive, rename, share
16
+ config.py validate command (checks agents.yaml)
17
+ index.py seed command (batch-index RAG data)
18
+ skill.py generate command (Claude Code skills from agents.yaml)
19
+ pyproject.toml
20
+ ```
21
+
22
+ ## Key Dependencies
23
+
24
+ | Package | Role |
25
+ |---------|------|
26
+ | `orchid` | Core framework (agents, graph, RAG, persistence) |
27
+ | `typer` | CLI framework |
28
+ | `rich` | Terminal formatting |
29
+ | `pyyaml` | YAML config loading |
30
+ | `pydantic-settings` | Environment config |
31
+ | `httpx` | Async HTTP (for MCP calls) |
32
+ | `langchain-core` | LangGraph message types |
33
+
34
+ ## Architecture Rules (Apply When Editing This Package)
35
+
36
+ 1. **This is a thin CLI layer.** It calls `orchid` SDK functions and displays results. Business logic belongs in `orchid/`, not here.
37
+
38
+ 2. **`bootstrap.py` mirrors `orchid-api/main.py:lifespan()`.** Both load config, build the graph, and initialize storage. Keep them in sync when adding new startup steps.
39
+
40
+ 3. **`OrchidContext` dataclass holds runtime state.** Created once by `bootstrap()`, passed to commands. Contains: `graph`, `reader`, `chat_repo`, `config`, `model`.
41
+
42
+ 4. **Default storage is SQLite** at `~/.orchid/chats.db` (no Docker, no PostgreSQL needed). Overridable via `CHAT_STORAGE_CLASS` and `CHAT_DB_DSN` env vars.
43
+
44
+ 5. **No agent or framework code here.** No `BaseAgent` subclasses, no graph wiring, no RAG logic. Those belong in `orchid/` or consumer projects.
45
+
46
+ 6. **Config resolution:** CLI args > env vars > `orchid.yml` > hardcoded defaults.
47
+
48
+ ## Commands
49
+
50
+ ```bash
51
+ # Chat operations
52
+ orchid chat create --config <path> # Create new chat session
53
+ orchid chat list --config <path> # List all chats
54
+ orchid chat delete --config <path> <id> # Delete a chat
55
+ orchid chat history --config <path> <id> # Show chat messages
56
+ orchid chat send --config <path> "msg" # Send single message
57
+ orchid chat interactive --config <path> # Interactive REPL mode
58
+ orchid chat rename --config <path> <id> # Rename a chat
59
+ orchid chat share --config <path> <id> # Promote RAG to user scope
60
+
61
+ # Config
62
+ orchid config validate <agents.yaml> # Validate agent config
63
+
64
+ # RAG indexing
65
+ orchid index seed --config <path> # Batch-index RAG data
66
+
67
+ # Skill generation (Claude Code)
68
+ orchid skill generate <agents.yaml> # Generate Claude Code skills
69
+ orchid skill generate <agents.yaml> -o ./out # Custom output directory
70
+ orchid skill generate <agents.yaml> --include agent1,agent2 # Filter by name
71
+ orchid skill generate <agents.yaml> --overwrite # Overwrite existing
72
+ orchid skill generate <agents.yaml> --zip # Create zip archive
73
+ ```
74
+
75
+ ### Interactive Mode Slash Commands
76
+
77
+ | Command | Purpose |
78
+ |---------|---------|
79
+ | `/switch <id>` | Switch to another chat |
80
+ | `/list` | List all chats |
81
+ | `/new` | Create new chat |
82
+ | `/history` | Show current chat history |
83
+ | `/rename <name>` | Rename current chat |
84
+ | `/quit` | Exit interactive mode |
85
+
86
+ Chat ID prefix matching is supported (type first few chars of UUID).
87
+
88
+ ## Bootstrap Defaults
89
+
90
+ | Parameter | Default | Env Override |
91
+ |-----------|---------|-------------|
92
+ | LLM model | `ollama/llama3.2` | `LITELLM_MODEL` |
93
+ | Vector backend | `qdrant` | `VECTOR_BACKEND` |
94
+ | Qdrant URL | `http://qdrant:6333` | `QDRANT_URL` |
95
+ | Embedding model | `text-embedding-3-small` | `EMBEDDING_MODEL` |
96
+ | Storage class | `orchid_ai.persistence.sqlite.SQLiteChatStorage` | `CHAT_STORAGE_CLASS` |
97
+ | Storage DSN | `~/.orchid/chats.db` | `CHAT_DB_DSN` |
98
+
99
+ ## Running
100
+
101
+ ```bash
102
+ # Install:
103
+ pip install -e ../orchid -e .
104
+
105
+ # Quick test:
106
+ orchid chat send "Tell me about LeBron" --config ../examples/basketball/orchid.yml
107
+
108
+ # Interactive session:
109
+ orchid chat interactive --config ../examples/basketball/orchid.yml
110
+
111
+ # Validate config:
112
+ orchid config validate ../examples/basketball/agents.yaml
113
+ ```
114
+
115
+ Requires Ollama running on host with models: `llama3.2`, `nomic-embed-text`.
116
+
117
+ ## Code Style
118
+
119
+ - Python 3.11+, Ruff, line length 120
120
+ - `from __future__ import annotations` in every file
121
+ - Imports: `from orchid_ai.xxx` (never `from src.xxx`)
122
+ - All async operations use `asyncio.run()` or Typer's async support
123
+ - No vendor-specific code — platform integrations belong in consumers
124
+
125
+ ## Common Pitfalls
126
+
127
+ - The `--config` flag points to `orchid.yml` (top-level config), not `agents.yaml`. The agents config path is resolved from `AGENTS_CONFIG_PATH` inside `orchid.yml`.
128
+ - `bootstrap()` sets `ORCHID_CONFIG` as an env var so the orchid library can find the YAML. Don't remove this.
129
+ - Chat persistence auto-creates `~/.orchid/chats.db` on first run. The directory is created automatically.
130
+ - Embedding dimension mismatch (768 vs 1536 vs 3072) causes silent retrieval failures. Switching models requires re-indexing Qdrant.
@@ -0,0 +1 @@
1
+ AGENTS.md
@@ -0,0 +1,83 @@
1
+ # Contributing to orchid-cli
2
+
3
+ ## Development Setup
4
+
5
+ ```bash
6
+ cd orchid-cli
7
+ python -m venv .venv
8
+ source .venv/bin/activate
9
+ pip install -e ../orchid -e ".[dev]"
10
+ pre-commit install
11
+ ```
12
+
13
+ The last command installs git hooks that **automatically run ruff (lint + format) and gitlint (commit message check) before every commit**.
14
+
15
+ ## Commit Message Convention
16
+
17
+ This project uses **[Conventional Commits](https://www.conventionalcommits.org/)** to enable automatic semantic versioning. Every commit message must follow this format:
18
+
19
+ ```
20
+ <type>(<scope>): <description>
21
+
22
+ [optional body]
23
+
24
+ [optional footer(s)]
25
+ ```
26
+
27
+ ### Types
28
+
29
+ | Type | Description | Version Bump |
30
+ |------|-------------|-------------|
31
+ | `feat` | New feature | **minor** (0.X.0) |
32
+ | `fix` | Bug fix | **patch** (0.0.X) |
33
+ | `perf` | Performance improvement | **patch** (0.0.X) |
34
+ | `refactor` | Code refactor (no feature/fix) | none |
35
+ | `docs` | Documentation only | none |
36
+ | `style` | Formatting, whitespace | none |
37
+ | `test` | Adding/updating tests | none |
38
+ | `build` | Build system, dependencies | none |
39
+ | `ci` | CI/CD configuration | none |
40
+ | `chore` | Maintenance tasks | none |
41
+
42
+ ### Breaking Changes
43
+
44
+ Append `!` after the type or add `BREAKING CHANGE:` in the footer for a **major** bump:
45
+
46
+ ```
47
+ feat!: rename orchid chat send to orchid chat message
48
+ ```
49
+
50
+ ### Examples
51
+
52
+ ```
53
+ feat(commands): add orchid chat export command
54
+ fix(bootstrap): handle missing orchid.yml gracefully
55
+ docs: update command reference in README
56
+ test(chat): add interactive mode edge case tests
57
+ ci: add coverage reporting to GitLab pipeline
58
+ ```
59
+
60
+ ### Validation
61
+
62
+ Commit messages are validated in CI via [gitlint](https://jorisroovers.com/gitlint/). To check locally:
63
+
64
+ ```bash
65
+ pip install gitlint
66
+ gitlint
67
+ ```
68
+
69
+ ## Running Tests
70
+
71
+ ```bash
72
+ pytest tests/ -x # all tests
73
+ pytest tests/ --cov=orchid_cli # with coverage
74
+ ruff check orchid_cli/ # lint
75
+ ruff format orchid_cli/ # format
76
+ ```
77
+
78
+ ## Merge Requests
79
+
80
+ 1. Create a feature branch from `main`
81
+ 2. Use conventional commit messages
82
+ 3. Ensure tests pass and linting is clean
83
+ 4. Keep MRs focused -- one feature or fix per MR
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Orchid Contributors
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.
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.4
2
+ Name: orchid-cli
3
+ Version: 0.1.0
4
+ Summary: Orchid CLI — command-line interface for the Orchid agent framework
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: httpx>=0.28.0
8
+ Requires-Dist: langchain-core>=0.3.0
9
+ Requires-Dist: orchid-ai>=1.1.0
10
+ Requires-Dist: pydantic-settings>=2.7.0
11
+ Requires-Dist: pyyaml>=6.0
12
+ Requires-Dist: rich>=13.0
13
+ Requires-Dist: typer>=0.12.0
14
+ Provides-Extra: dev
15
+ Requires-Dist: gitlint>=0.19.0; extra == 'dev'
16
+ Requires-Dist: pre-commit>=4.0; extra == 'dev'
17
+ Requires-Dist: pytest-asyncio>=0.25.0; extra == 'dev'
18
+ Requires-Dist: pytest-cov>=6.0; extra == 'dev'
19
+ Requires-Dist: pytest>=8.0; extra == 'dev'
20
+ Requires-Dist: ruff>=0.9.0; extra == 'dev'