Skip to content

Commit c74f44a

Browse files
committed
Add provider config layer (Phase 7)
1 parent 3a76de8 commit c74f44a

9 files changed

Lines changed: 554 additions & 100 deletions

File tree

Cargo.lock

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ path = "src/main.rs"
1414
serde = { version = "1.0", features = ["derive"] }
1515
serde_json = "1.0"
1616
ureq = "2.9"
17+
toml = "0.8"
18+

PROJEKT.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ CompText CLI is an experimental terminal context client for building determinist
1919

2020
### Current State
2121
```text
22-
CURRENT_PHASE: 7
23-
CURRENT_TASK: Provider Config Layer
24-
LAST_GREEN_PHASE: 6
22+
CURRENT_PHASE: 8
23+
CURRENT_TASK: OpenAI-Compatible Adapter
24+
LAST_GREEN_PHASE: 7
2525
STATUS: active
2626
```
2727

@@ -81,8 +81,8 @@ git push
8181
| **Phase 4C** | Long-Run Autonomy Hardening | Harden state machine progression rules and git safety boundaries | **COMPLETE** |
8282
| **Phase 5** | Proposal Mode | Implement `ctxt propose` to output changes as structured proposals | **COMPLETE** |
8383
| **Phase 6** | Apply Gate | Implement `ctxt apply` to confirm/apply changes and run verification | **COMPLETE** |
84-
| **Phase 7** | Provider Config Layer | Support dynamic provider profile switching and configurations | **ACTIVE** |
85-
| **Phase 8** | OpenAI-Compatible Adapter | Implement OpenAI adapter skeleton | *QUEUED* |
84+
| **Phase 7** | Provider Config Layer | Support dynamic provider profile switching and configurations | **COMPLETE** |
85+
| **Phase 8** | OpenAI-Compatible Adapter | Implement OpenAI adapter skeleton | **ACTIVE** |
8686
| **Phase 9** | Validate and Benchmark | Local validation, dry-runs, and deterministic benchmark flows | *QUEUED* |
8787

8888
---

comptext.example.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,29 @@ proposal_required = true
77
kind = "dummy"
88
network = false
99

10-
[providers.ollama_local]
10+
[providers.ollama-local]
1111
kind = "ollama"
1212
base_url = "http://localhost:11434"
1313
auth = "none"
1414

15-
[providers.ollama_cloud_via_local]
15+
[providers.ollama-cloud-via-local]
1616
kind = "ollama"
1717
base_url = "http://localhost:11434"
1818
auth = "ollama_signin"
1919
model_suffix = "-cloud"
2020

21-
[providers.ollama_cloud_direct]
21+
[providers.ollama-cloud-direct]
2222
kind = "ollama"
2323
base_url = "https://ollama.com"
2424
auth_env = "OLLAMA_API_KEY"
2525

26-
[providers.openai_compatible]
26+
27+
[providers.openai-compatible]
2728
kind = "openai-compatible"
2829
base_url = "http://localhost:11434/v1"
2930
auth_env = "OPTIONAL_API_KEY"
3031

32+
3133
[policy]
3234
network_default = "deny"
3335
allow_provider_network = false

docs/PROVIDER_CONFIG.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Provider Configuration Layer (Phase 7)
2+
3+
`ctxt` supports repository-local and user-supplied configuration files formatted in TOML to define default execution flags, provider profiles, and network policies.
4+
5+
## Config File Resolution
6+
7+
When executing commands, the configuration path is resolved in the following priority order:
8+
1. Custom path specified via the global `--config <path>` command-line option.
9+
2. Default repository-local configuration `comptext.toml` in the working directory.
10+
3. Fallback repository-local configuration `comptext.example.toml` in the working directory.
11+
12+
## TOML Schema Structure
13+
14+
The configuration file supports three main tables:
15+
16+
### 1. `[defaults]`
17+
* **`provider`** (string): The default provider profile name to use when no `--provider` parameter is specified in commands.
18+
* **`dry_run_default`** (boolean): Default dry-run behavior for actions.
19+
* **`proposal_required`** (boolean): Enforces checking proposal artifacts prior to executing code mutations.
20+
21+
### 2. `[providers.<profile-name>]`
22+
* **`kind`** (string): The adapter kind (e.g. `"dummy"`, `"ollama"`, or `"openai-compatible"`).
23+
* **`network`** (boolean, optional): Determines if the provider profile requires active network sockets.
24+
* **`base_url`** (string, optional): Base endpoint for local or direct cloud providers.
25+
* **`auth`** (string, optional): Auth mode metadata description (e.g., `"none"` or `"ollama_signin"`).
26+
* **`auth_env`** (string, optional): The name of the environment variable containing the API credential (never the key itself).
27+
* **`model_suffix`** (string, optional): A suffix to append to requested models.
28+
29+
### 3. `[policy]`
30+
* **`network_default`** (string): Default network gate behavior (e.g. `"deny"`).
31+
* **`allow_provider_network`** (boolean): Restricts provider execution from initializing network connections.
32+
* **`secrets_redaction`** (boolean): Enforces secret redaction on Context Pack artifacts.
33+
* **`apply_requires_confirmation`** (boolean): Forces manual human-in-the-loop confirmation before applying proposals.
34+
35+
---
36+
37+
## Example Usage
38+
39+
### View Available Profiles
40+
```bash
41+
ctxt providers list
42+
```
43+
44+
### View Config Diagnostics
45+
```bash
46+
ctxt doctor
47+
```
48+
49+
### Override Config Path
50+
```bash
51+
ctxt --config path/to/my_config.toml ask "How do I build this project?"
52+
```

proposals/proposal.latest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{
1313
"op": "patch",
1414
"path": "src/cli.rs",
15-
"detail": "Mock patch generated by dummy provider: \"Mock LLM response from CompText Dummy Provider. Received prompt: \"Add context inspect\" Workspace context analyzed successfully: 55 files included. Dummy status: offline-test-provider ok.\""
15+
"detail": "Mock patch generated by dummy provider: \"Mock LLM response from CompText Dummy Provider. Received prompt: \"Add context inspect\" Workspace context analyzed successfully: 56 files included. Dummy status: offline-test-provider ok.\""
1616
}
1717
],
1818
"validation_commands": [

proposals/proposal_add_context_inspect.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{
1313
"op": "patch",
1414
"path": "src/cli.rs",
15-
"detail": "Mock patch generated by dummy provider: \"Mock LLM response from CompText Dummy Provider. Received prompt: \"Add context inspect\" Workspace context analyzed successfully: 55 files included. Dummy status: offline-test-provider ok.\""
15+
"detail": "Mock patch generated by dummy provider: \"Mock LLM response from CompText Dummy Provider. Received prompt: \"Add context inspect\" Workspace context analyzed successfully: 56 files included. Dummy status: offline-test-provider ok.\""
1616
}
1717
],
1818
"validation_commands": [

reports/phase_7_status.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# CompText CLI — Phase 7 Status Report
2+
3+
## Standard Return Schema
4+
PHASE: Phase 7: Provider Config Layer
5+
STATUS: success
6+
FILES_CHANGED:
7+
- Cargo.toml
8+
- comptext.example.toml
9+
- src/cli.rs
10+
- docs/PROVIDER_CONFIG.md
11+
- reports/phase_7_status.md
12+
- PROJEKT.md
13+
COMMANDS_RUN:
14+
- `cargo fmt --all --check`
15+
- `cargo check`
16+
- `cargo test`
17+
- `cargo clippy -- -D warnings`
18+
- `cargo run --bin ctxt -- providers list`
19+
- `cargo run --bin ctxt -- doctor`
20+
VALIDATION:
21+
- Verified formatting, lint checks, compilation and testing cleanly.
22+
- Added unit tests for parsing valid configuration files, throwing parse errors on malformed structures, and redacting secret keys in summary outputs. All 19 tests pass.
23+
- Added integration test verification mapping hyphenated adapter names.
24+
ARTIFACTS:
25+
- None
26+
GIT:
27+
- Stage, commit, and push pending.
28+
NETWORK:
29+
- offline-only (validations performed entirely offline).
30+
SECRETS:
31+
- verified-redacted (Secret metadata keys/tokens found in loaded provider configurations are redacted before formatting to terminal summaries).
32+
POLICY_DECISIONS:
33+
- Enforce fail-closed verification: malformed configuration files immediately throw errors and abort command execution.
34+
RISKS:
35+
- Handled profile name alignment (hyphen vs underscore keys) in `comptext.example.toml` to guarantee compatibility with pre-existing integration checks.
36+
SKILLS_USED:
37+
- `.agents/skills/ctxt-long-run-autonomy/SKILL.md`
38+
- `.agents/skills/ctxt-security/SKILL.md`
39+
- `.agents/skills/ctxt-provider-boundary/SKILL.md`
40+
- `.agents/skills/ctxt-context-pack/SKILL.md`
41+
- `.agent/skills/03_provider_adapter.md`
42+
- `.agent/skills/04_ollama_adapter.md`
43+
NEXT:
44+
- Phase 8: OpenAI-Compatible Adapter
45+
46+
---
47+
48+
## Detailed Notes & Output Samples
49+
50+
### Configuration-based Command Execution
51+
`run` extracts `--config <path>` globally and loads configuration defaults (`default provider`, `dry_run_default`, `proposal_required`) and provider profile definitions.
52+
53+
Sample of `ctxt providers list`:
54+
```text
55+
dummy kind=dummy network=false
56+
ollama-cloud-direct kind=ollama network=true base_url=https://ollama.com auth_env=OLLAMA_API_KEY
57+
ollama-cloud-via-local kind=ollama network=true base_url=http://localhost:11434 auth=ollama_signin
58+
ollama-local kind=ollama network=true base_url=http://localhost:11434 auth=none
59+
openai-compatible kind=openai-compatible network=true base_url=http://localhost:11434/v1 auth_env=OPTIONAL_API_KEY
60+
```
61+
62+
Sample of `ctxt doctor`:
63+
```text
64+
CompText doctor
65+
status: ok
66+
network_default: deny
67+
provider_default: dummy
68+
proposal_required: true
69+
secrets_policy: redact-before-artifact
70+
```

0 commit comments

Comments
 (0)