generated from coulomb/repo-seed
Refresh agent instruction files
This commit is contained in:
@@ -1,58 +1,8 @@
|
||||
## Architecture
|
||||
|
||||
llm-connect is structured as a **GAAF-2026 layered library**. See
|
||||
`ARCHITECTURE-LAYERS.md` for the full layer map and scorecard.
|
||||
<!-- TODO: Describe the key design decisions and component structure.
|
||||
Key modules, data flows, external integrations, state machines, etc. -->
|
||||
|
||||
### Layer summary
|
||||
## Quick Reference
|
||||
|
||||
```
|
||||
Core (frozen after v1)
|
||||
LLMAdapter ABC adapter.py
|
||||
RunConfig / LLMResponse models.py
|
||||
LLMError hierarchy exceptions.py
|
||||
MockLLMAdapter adapter.py ← test primitive, belongs with Core
|
||||
|
||||
Functional (evolvable, independently shippable)
|
||||
OpenAIAdapter openai.py
|
||||
GeminiAdapter gemini.py
|
||||
OpenRouterAdapter openrouter.py
|
||||
ClaudeCodeAdapter claude_code.py
|
||||
EmbeddingAdapter ABC embedding_adapter.py
|
||||
OpenAICompatibleEmbeddingAdapter embedding_openai.py
|
||||
EmbeddingCache embedding_cache.py
|
||||
create_adapter() factory.py
|
||||
create_embedding_adapter() embedding_factory.py
|
||||
_token_estimator _token_estimator.py
|
||||
similarity utilities similarity.py
|
||||
|
||||
Configuration (user-controlled declarative state)
|
||||
resolve_llm() chain toml_config.py ← 7-level TOML priority chain
|
||||
LLMConfig / load_config config.py
|
||||
_http shared utility _http.py ← also used by Functional adapters
|
||||
```
|
||||
|
||||
### Dependency rule
|
||||
|
||||
Core ← Functional ← Configuration
|
||||
No upward dependencies. `_http.py` is consumed by Functional only.
|
||||
|
||||
### Key design decisions
|
||||
|
||||
**API key resolution** (`config.resolve_api_key`): three-step chain —
|
||||
explicit argument → environment variable → plaintext key file in project root.
|
||||
Adapters raise `LLMConfigurationError` at construction time if no key is found
|
||||
(except `ClaudeCodeAdapter` which needs no key).
|
||||
|
||||
**TOML config chain** (`toml_config.resolve_llm`): 7 priority levels allow
|
||||
per-project and per-user LLM preferences. Currently defaults to `markitect`
|
||||
app_name for backward compatibility — consumers pass their own `app_name`.
|
||||
|
||||
**Factory pattern** (`factory.create_adapter`): lazy imports prevent pulling
|
||||
all provider SDKs at module load. Add a new provider by registering its FQN
|
||||
in `_PROVIDERS`.
|
||||
|
||||
**ClaudeCodeAdapter subprocess model**: prompt is piped via stdin (not CLI
|
||||
arg) to avoid shell argument length limits on large prompts (>30 KB).
|
||||
|
||||
**Retry logic**: `OpenAIAdapter` and `OpenRouterAdapter` retry on 429 and 5xx
|
||||
with exponential backoff. `GeminiAdapter` does not (rate-limit handling deferred).
|
||||
`~/state-hub/mcp_server/TOOLS.md` — MCP tool reference
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
## Repo boundary
|
||||
|
||||
This repo owns **llm-connect** — the multi-provider LLM client library — only.
|
||||
This repo owns **llm-connect** only. It does not own:
|
||||
|
||||
It does NOT own:
|
||||
|
||||
- **API key storage / secret management** → caller's environment (env vars,
|
||||
key files, vault). llm-connect resolves keys but does not store them.
|
||||
- **Consumer routing logic** → `inter-hub/AgentBridge.hs`, `markitect` etc.
|
||||
`RoutingPolicy` (WP-0003) provides primitives; policy data belongs in the consumer.
|
||||
- **The Claude Code CLI binary** → installed separately; `ClaudeCodeAdapter`
|
||||
shells out to it.
|
||||
- **markitect application code** → `markitect.llm` is a shim that re-exports
|
||||
from here; all implementation lives in this repo.
|
||||
- **State hub / custodian infrastructure** → `the-custodian/state-hub/`
|
||||
- **IHF bridge scripts** → `inter-hub/scripts/llm_bridge.py` lives in inter-hub,
|
||||
not here. llm-connect is a dependency of that script.
|
||||
<!-- TODO: List what belongs in adjacent repos, e.g.:
|
||||
- SSH key management → railiance-infra/
|
||||
- State hub code → state-hub/
|
||||
-->
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## Session Protocol
|
||||
|
||||
State Hub: http://127.0.0.1:8000 (local) · http://127.0.0.1:18000 (CoulombCore via ops-bridge)
|
||||
State Hub: http://127.0.0.1:8000
|
||||
|
||||
**Step 1 — Orient**
|
||||
|
||||
@@ -8,24 +8,38 @@ Read the offline-safe brief first — it works without a live hub connection:
|
||||
```bash
|
||||
cat .custodian-brief.md
|
||||
```
|
||||
Then call the MCP tool for richer cross-domain context (skip if unreachable):
|
||||
Then call the MCP tool for richer cross-domain context when MCP tools are exposed:
|
||||
```
|
||||
get_domain_summary("custodian")
|
||||
```
|
||||
If the hub is offline: `cd ~/the-custodian/state-hub && make api`
|
||||
If MCP tools are unavailable in the current agent session, use the REST API:
|
||||
```bash
|
||||
curl -s "http://127.0.0.1:8000/state/summary" | python3 -m json.tool
|
||||
```
|
||||
If the hub is offline: `cd ~/state-hub && make api`
|
||||
|
||||
**Step 2 — Check inbox**
|
||||
With MCP tools:
|
||||
```
|
||||
get_messages(to_agent="llm-connect", unread_only=True)
|
||||
```
|
||||
Mark read with `mark_message_read(message_id)`. Reply or act on coordination
|
||||
requests before proceeding.
|
||||
|
||||
Without MCP tools:
|
||||
```bash
|
||||
curl -s "http://127.0.0.1:8000/messages/?to_agent=llm-connect&unread_only=true" \
|
||||
| python3 -m json.tool
|
||||
curl -s -X PATCH "http://127.0.0.1:8000/messages/<id>/read" \
|
||||
-H "Content-Type: application/json" -d '{}'
|
||||
```
|
||||
|
||||
**Step 3 — Scan workplans**
|
||||
```bash
|
||||
ls workplans/
|
||||
```
|
||||
For each file with `status: active`, note pending `todo`/`in_progress` tasks.
|
||||
For each file with `status: ready`, `active`, or `blocked`, note pending
|
||||
`todo`/`in_progress` tasks.
|
||||
|
||||
**Step 4 — Present brief**
|
||||
|
||||
@@ -45,18 +59,25 @@ If no workstreams: follow First Session Protocol (`first-session.md`).
|
||||
> are First Session Protocol only. Work structure belongs in repo files (ADR-001).
|
||||
|
||||
**Session close:**
|
||||
With MCP tools:
|
||||
```
|
||||
add_progress_event(summary="...", topic_id="cee7bedf-2b48-46ef-8601-006474f2ad7a", workstream_id="<uuid>")
|
||||
```
|
||||
Without MCP tools:
|
||||
```bash
|
||||
curl -s -X POST http://127.0.0.1:8000/progress/ \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"topic_id":"cee7bedf-2b48-46ef-8601-006474f2ad7a","workstream_id":"<uuid>","event_type":"note","summary":"what changed","author":"codex"}'
|
||||
```
|
||||
If workplan files were modified, ensure the local copy is up to date first:
|
||||
```bash
|
||||
git -C <repo_path> pull --ff-only
|
||||
cd ~/the-custodian/state-hub && make fix-consistency REPO=llm-connect
|
||||
cd ~/state-hub && make fix-consistency REPO=llm-connect
|
||||
```
|
||||
For repos where implementation runs on a remote machine (e.g. CoulombCore),
|
||||
use the combined target which pulls before fixing:
|
||||
```bash
|
||||
cd ~/the-custodian/state-hub && make fix-consistency-remote REPO=llm-connect
|
||||
cd ~/state-hub && make fix-consistency-remote REPO=llm-connect
|
||||
```
|
||||
**C-15** (DB task ahead of file) is normal in multi-machine workflows — writeback
|
||||
will sync the file to match DB. **C-16** (repo behind remote) blocks all writes
|
||||
|
||||
@@ -1,59 +1,19 @@
|
||||
## Stack
|
||||
|
||||
- **Language:** Python 3.10+
|
||||
- **Key deps (runtime):** `toml` (TOML config parsing)
|
||||
- **Key deps (dev):** `pytest`, `ruff`, `mypy`
|
||||
- **HTTP:** stdlib `urllib` via `_http.py` (no requests/httpx runtime dep)
|
||||
- **Build:** setuptools / uv
|
||||
<!-- TODO: Fill in language, frameworks, and key dependencies -->
|
||||
- **Language:**
|
||||
- **Key deps:**
|
||||
|
||||
## Dev Commands
|
||||
|
||||
```bash
|
||||
# Install (editable, with dev extras)
|
||||
uv pip install -e ".[dev]"
|
||||
# or
|
||||
pip install -e ".[dev]"
|
||||
# TODO: Fill in the standard commands for this repo
|
||||
|
||||
# Install dependencies
|
||||
|
||||
# Run tests
|
||||
uv run pytest
|
||||
# or
|
||||
pytest
|
||||
|
||||
# Lint
|
||||
uv run ruff check .
|
||||
# Lint / type check
|
||||
|
||||
# Type check
|
||||
uv run mypy llm_connect
|
||||
|
||||
# Run a single test file
|
||||
uv run pytest tests/test_models.py -v
|
||||
|
||||
# Build package (dry run)
|
||||
uv build --no-sources
|
||||
```
|
||||
|
||||
## Project layout
|
||||
|
||||
```
|
||||
llm_connect/ source package
|
||||
adapter.py LLMAdapter ABC + Mock/ErrorLLMAdapter
|
||||
models.py RunConfig, LLMResponse
|
||||
exceptions.py LLMError hierarchy
|
||||
factory.py create_adapter()
|
||||
openai.py OpenAIAdapter
|
||||
gemini.py GeminiAdapter
|
||||
openrouter.py OpenRouterAdapter
|
||||
claude_code.py ClaudeCodeAdapter
|
||||
embedding_adapter.py EmbeddingAdapter ABC
|
||||
embedding_openai.py OpenAICompatibleEmbeddingAdapter
|
||||
embedding_cache.py EmbeddingCache
|
||||
embedding_factory.py create_embedding_adapter()
|
||||
toml_config.py 7-level TOML config resolution
|
||||
config.py LLMConfig, resolve_api_key, find_project_root
|
||||
_http.py shared HTTP POST utility
|
||||
_token_estimator.py rough token count estimate
|
||||
similarity.py cosine similarity utilities
|
||||
tests/ pytest test suite
|
||||
contracts/ GAAF-2026 contract docs
|
||||
workplans/ workplan files (LLM-WP-NNNN)
|
||||
# Build / package (if applicable)
|
||||
```
|
||||
|
||||
@@ -5,6 +5,22 @@ ID prefix: `LLM-WP`
|
||||
|
||||
Work items originate as files in this repo **before** being registered in the hub.
|
||||
|
||||
Canonical workplan/workstream frontmatter statuses are:
|
||||
`proposed`, `ready`, `active`, `blocked`, `backlog`, `finished`, `archived`.
|
||||
Use `proposed` for a newly drafted plan, `ready` after review against current
|
||||
repo state, and `finished` when implementation is complete. `stalled` and
|
||||
`needs_review` are derived health labels, not stored statuses.
|
||||
|
||||
Closed workplans may be moved to `workplans/archived/` with a completion-date
|
||||
prefix: `YYMMDD-llm-connect-WP-NNNN-<slug>.md`. The frontmatter id remains
|
||||
unchanged; the prefix is only for quick visual reference.
|
||||
|
||||
Small opportunistic tasks discovered during another session use **Ad Hoc Tasks**:
|
||||
`workplans/ADHOC-YYYY-MM-DD.md`, workstream slug `adhoc-YYYY-MM-DD`, and task ids
|
||||
`ADHOC-YYYY-MM-DD-T01`, `T02`, etc. Use adhocs only for low-risk work completed
|
||||
directly. Promote anything requiring analysis, design, approval, dependencies, or
|
||||
multiple planned phases into a normal workplan.
|
||||
|
||||
Ecosystem todos from other agents arrive as `[repo:llm-connect]` hub tasks —
|
||||
visible at session start. Pick one up by creating the workplan file, then registering
|
||||
the workstream.
|
||||
|
||||
Reference in New Issue
Block a user