Skip to content

Commit d265c59

Browse files
committed
Add proposal generation mode (Phase 5)
1 parent 5b66db7 commit d265c59

7 files changed

Lines changed: 390 additions & 13 deletions

File tree

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: 5
23-
CURRENT_TASK: Proposal Mode
24-
LAST_GREEN_PHASE: 4C
22+
CURRENT_PHASE: 6
23+
CURRENT_TASK: Apply Gate
24+
LAST_GREEN_PHASE: 5
2525
STATUS: active
2626
```
2727

@@ -79,8 +79,8 @@ git push
7979
| **Phase 4** | Ollama Local Adapter | Support local Ollama integrations with explicit network boundaries | **COMPLETE** |
8080
| **Phase 4B** | Skill Registry Normalization | Normalize the local Antigravity skill structure and crystallize autonomy rules | **COMPLETE** |
8181
| **Phase 4C** | Long-Run Autonomy Hardening | Harden state machine progression rules and git safety boundaries | **COMPLETE** |
82-
| **Phase 5** | Proposal Mode | Implement `ctxt propose` to output changes as structured proposals | **ACTIVE** |
83-
| **Phase 6** | Apply Gate | Implement `ctxt apply` to confirm/apply changes and run verification | *QUEUED* |
82+
| **Phase 5** | Proposal Mode | Implement `ctxt propose` to output changes as structured proposals | **COMPLETE** |
83+
| **Phase 6** | Apply Gate | Implement `ctxt apply` to confirm/apply changes and run verification | **ACTIVE** |
8484
| **Phase 7** | Provider Config Layer | Support dynamic provider profile switching and configurations | *QUEUED* |
8585
| **Phase 8** | OpenAI-Compatible Adapter | Implement OpenAI adapter skeleton | *QUEUED* |
8686
| **Phase 9** | Validate and Benchmark | Local validation, dry-runs, and deterministic benchmark flows | *QUEUED* |

docs/PROPOSAL_MODE.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Proposal Mode (Phase 5)
2+
3+
Proposal Mode allows `ctxt` to build a Context Pack, query a provider (e.g. the offline `dummy` provider), and generate a structured, deterministic proposal JSON under `proposals/` without mutating the active repository source files.
4+
5+
## Command Usage
6+
7+
```bash
8+
ctxt propose --provider dummy "Add context inspect"
9+
```
10+
11+
## Generated Artifacts
12+
13+
Executing proposal mode produces two files:
14+
1. `proposals/proposal_<slugified_task>.json` — A task-specific proposal file where `<slugified_task>` is the slugified version of the task description (e.g. `add_context_inspect`).
15+
2. `proposals/proposal.latest.json` — A pointer file containing a copy of the latest generated proposal for quick references and integration checks.
16+
17+
## Schema Specification
18+
19+
The proposal JSON format uses the following schema fields:
20+
21+
* `schema_version`: The version of the proposal schema format (e.g. `"0.1"`).
22+
* `task`: The original user task prompt.
23+
* `rationale`: Descriptive reason for the change.
24+
* `preconditions`: List of build/check commands to verify preconditions.
25+
* `affected_files`: List of files that this proposal suggests modifying.
26+
* `operations`: List of operations to perform. Each operation contains:
27+
* `op`: Type of operation (e.g. `"patch"`).
28+
* `path`: Relative path to the target file.
29+
* `detail`: Detailed description of the proposed patch or edits.
30+
* `validation_commands`: List of verification commands to run after the changes are applied.
31+
* `rollback_strategy`: Command or action to undo the changes.
32+
* `risk_notes`: Potential risks identified for this proposal.
33+
34+
## Offline Execution / Dummy Provider
35+
36+
During offline validation and testing, using the `--provider dummy` argument retrieves a deterministic mock response from the Dummy Provider, ensuring no network calls are executed. The proposal output is fully generated using this mock model output.

proposals/proposal.latest.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"schema_version": "0.1",
3+
"task": "Add context inspect",
4+
"rationale": "Proposed changes based on task: Add context inspect",
5+
"preconditions": [
6+
"cargo check"
7+
],
8+
"affected_files": [
9+
"src/cli.rs"
10+
],
11+
"operations": [
12+
{
13+
"op": "patch",
14+
"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: 54 files included. Dummy status: offline-test-provider ok.\""
16+
}
17+
],
18+
"validation_commands": [
19+
"cargo test"
20+
],
21+
"rollback_strategy": "git restore src/cli.rs",
22+
"risk_notes": "None identified for offline mock run"
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"schema_version": "0.1",
3+
"task": "Add context inspect",
4+
"rationale": "Proposed changes based on task: Add context inspect",
5+
"preconditions": [
6+
"cargo check"
7+
],
8+
"affected_files": [
9+
"src/cli.rs"
10+
],
11+
"operations": [
12+
{
13+
"op": "patch",
14+
"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: 54 files included. Dummy status: offline-test-provider ok.\""
16+
}
17+
],
18+
"validation_commands": [
19+
"cargo test"
20+
],
21+
"rollback_strategy": "git restore src/cli.rs",
22+
"risk_notes": "None identified for offline mock run"
23+
}

reports/phase_5_status.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# CompText CLI — Phase 5 Status Report
2+
3+
## Standard Return Schema
4+
PHASE: Phase 5: Proposal Mode
5+
STATUS: success
6+
FILES_CHANGED:
7+
- src/cli.rs
8+
- tests/cli_smoke.rs
9+
- docs/PROPOSAL_MODE.md
10+
- reports/phase_5_status.md
11+
- PROJEKT.md
12+
COMMANDS_RUN:
13+
- `cargo fmt --all --check`
14+
- `cargo check`
15+
- `cargo test`
16+
- `cargo clippy -- -D warnings`
17+
- `cargo run --bin ctxt -- propose --provider dummy "Add context inspect"`
18+
VALIDATION:
19+
- Formatting verified clean with `cargo fmt --all --check`.
20+
- Build successfully verified via `cargo check`.
21+
- 15 total unit and integration tests passed, including `propose_dummy_provider_succeeds`.
22+
- Clippy checks passed with zero warnings.
23+
ARTIFACTS:
24+
- `proposals/proposal_add_context_inspect.json`
25+
- `proposals/proposal.latest.json`
26+
GIT:
27+
- Stage, commit, and push pending.
28+
NETWORK:
29+
- offline-only (Dummy provider runs completely offline).
30+
SECRETS:
31+
- verified-redacted (Input secrets parsed in Context Pack creation redacted before processing).
32+
POLICY_DECISIONS:
33+
- Proposal Mutability Boundary strictly maintained: proposal generated in `proposals/` and has not mutated active repository source files.
34+
RISKS:
35+
- None identified for offline mock run. Later phases must ensure apply operations are gated behind explicit confirm steps.
36+
NEXT:
37+
- Phase 6: Apply Gate
38+
39+
---
40+
41+
## Detailed Notes & Output Samples
42+
43+
### Dry-run / Offline Proposal Generation
44+
The proposal file is created by compiling the deterministic Context Pack first, then writing standard model inputs/outputs under `.comptext/` cache, and finally mapping the LLM response to a structured Proposal JSON file under `proposals/`.
45+
46+
Sample output of `cargo run --bin ctxt -- propose --provider dummy "Add context inspect"`:
47+
```text
48+
Proposal generated successfully.
49+
Proposal file: proposals/proposal_add_context_inspect.json
50+
Latest reference: proposals/proposal.latest.json
51+
```
52+
53+
Sample of generated JSON in `proposals/proposal_add_context_inspect.json`:
54+
```json
55+
{
56+
"schema_version": "0.1",
57+
"task": "Add context inspect",
58+
"rationale": "Proposed changes based on task: Add context inspect",
59+
"preconditions": [
60+
"cargo check"
61+
],
62+
"affected_files": [
63+
"src/cli.rs"
64+
],
65+
"operations": [
66+
{
67+
"op": "patch",
68+
"path": "src/cli.rs",
69+
"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.\""
70+
}
71+
],
72+
"validation_commands": [
73+
"cargo test"
74+
],
75+
"rollback_strategy": "git restore src/cli.rs",
76+
"risk_notes": "None identified for offline mock run"
77+
}
78+
```

0 commit comments

Comments
 (0)