Compare commits
193
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70b6d51b55
|
||
|
|
9e5e8a60f2
|
||
|
|
d6447603bc
|
||
|
|
e6dc24beb5
|
||
|
|
e76c3efe4e
|
||
|
|
fac577589b | ||
|
|
737fc42ec1 | ||
|
|
888529f381
|
||
|
|
35e75e5b4f
|
||
|
|
dd7d75fd9f | ||
|
|
78f5fc8fb9 | ||
|
|
4f38214681
|
||
|
|
019bd6f1c7 | ||
|
|
875b6749c2 | ||
|
|
69e1b98c44
|
||
|
|
0324436114
|
||
|
|
233c212d2a
|
||
|
|
e288b41365
|
||
|
|
fbf6a6bdf4
|
||
|
|
57b72702b2
|
||
|
|
38ba303c3c
|
||
|
|
fc7bc0ff8f
|
||
|
|
7f7ea758a7
|
||
|
|
06b2c384e3
|
||
|
|
d50de7c06a
|
||
|
|
0956f08791
|
||
|
|
087d0c320c
|
||
|
|
2128390f99
|
||
|
|
d008de1848
|
||
|
|
d79787bf96
|
||
|
|
577c51b62f
|
||
|
|
d462b09f80
|
||
|
|
b711e4983b
|
||
|
|
6ae3efb06c
|
||
|
|
02dd14394b
|
||
|
|
f11d4ca760
|
||
|
|
f1415067f2
|
||
|
|
af5c34fde5
|
||
|
|
2ffa278f2d | ||
|
|
f4cbee9611
|
||
|
|
e95fd1e06e
|
||
|
|
d79ea55e09
|
||
|
|
b898e4dd78 | ||
|
|
30e00f8332 | ||
|
|
58d9d4c64e
|
||
|
|
63a768aa46
|
||
|
|
2c3f671efa
|
||
|
|
8b0a536f4e
|
||
|
|
5a1bb569b4
|
||
|
|
0c12580836
|
||
|
|
df909325a7
|
||
|
|
d379fcddf8
|
||
|
|
b405acd8f0
|
||
|
|
805ae7112a
|
||
|
|
6ddbf37523
|
||
|
|
f510bb649b
|
||
|
|
c1b14bdfdf
|
||
|
|
46f2a9eae2
|
||
|
|
cf3a12141b
|
||
|
|
8f13810f0f
|
||
|
|
eba8c86e21
|
||
|
|
d75fb47de1
|
||
|
|
49a281bf93
|
||
|
|
b9474ce6ef
|
||
|
|
d328310880
|
||
|
|
5eb77ab467
|
||
|
|
a2c4f05c8c
|
||
|
|
89fadcca15
|
||
|
|
ab3a818507
|
||
|
|
63f73f22c3
|
||
|
|
54c5079cb7
|
||
|
|
d51bdd3086
|
||
|
|
56ec58a748
|
||
|
|
93f9c5425e
|
||
|
|
77dfd08103 | ||
|
|
46dcef0dec | ||
|
|
72c6bb74c2 | ||
|
|
6bf80dcce9
|
||
|
|
df948c69bf
|
||
|
|
e5d0fcc764
|
||
|
|
c60d3e7cda
|
||
|
|
c21fd47b42
|
||
|
|
ab0b89dd67
|
||
|
|
420db4bb88
|
||
|
|
dfacf31f6a
|
||
|
|
8cfd5ee2c4
|
||
|
|
e82e5ab8e4
|
||
|
|
d790782ace
|
||
|
|
bf06d5e8f3
|
||
|
|
cdfaa0f111
|
||
|
|
c062f34852
|
||
|
|
7671d28d6e
|
||
|
|
fcc4a1d2b5
|
||
|
|
b0eeba110d
|
||
|
|
d65d63ee50
|
||
|
|
9890cf0ddc
|
||
|
|
89db5b3887
|
||
|
|
f40ba4ccbe
|
||
|
|
d2940a8d32
|
||
|
|
ed7ad36475
|
||
|
|
393ed16963
|
||
|
|
3f94d2003a
|
||
|
|
50ff9008fe
|
||
|
|
9606d7f8aa
|
||
|
|
d8ae9e25d9
|
||
|
|
006f64bfa0
|
||
|
|
000559bc9d
|
||
|
|
3aede58a11
|
||
|
|
cab1e72b97
|
||
|
|
cd4bf245e9
|
||
|
|
82bf6176f8
|
||
|
|
d407eb5a6a
|
||
|
|
6f2594712f
|
||
|
|
79d43c8791
|
||
|
|
5a5da90734
|
||
|
|
f2a0e7453e
|
||
|
|
0fe430102a
|
||
|
|
d13bd32fdf
|
||
|
|
1f1729ba00
|
||
|
|
107419966d
|
||
|
|
344ef7526f
|
||
|
|
13d31f850c
|
||
|
|
f6bd02dc73
|
||
|
|
31df1a720d
|
||
|
|
4e0e65fc8a
|
||
|
|
ab85a4f534
|
||
|
|
420447275c
|
||
|
|
cdc40f7302
|
||
|
|
c611685033
|
||
|
|
cac2a3eba0
|
||
|
|
66bbb34d7f
|
||
|
|
68177fdb6a
|
||
|
|
1acaad223f
|
||
|
|
aa0270602d
|
||
|
|
4669958bdd
|
||
|
|
559107073d
|
||
|
|
d0a38747e0
|
||
|
|
677bd71b93 | ||
|
|
ad6d0a2e0e
|
||
|
|
50911b99ef
|
||
|
|
44783c5573
|
||
|
|
8629c1ca15
|
||
|
|
078e6e3744
|
||
|
|
b908fc20ba
|
||
|
|
058810137c
|
||
|
|
c979041161
|
||
|
|
a606ea552d
|
||
|
|
39a654a79e
|
||
|
|
17d1decce6
|
||
|
|
a45e66c634
|
||
|
|
8c885d9a77
|
||
|
|
6dd1e59815
|
||
|
|
f5085a773a
|
||
|
|
09afdeaf7c
|
||
|
|
0216d84eee
|
||
|
|
320dbf2479
|
||
|
|
6958e9cba8
|
||
|
|
825f9f6bf5
|
||
|
|
863740f916
|
||
|
|
304088bf5c
|
||
|
|
b7599b8acf
|
||
|
|
9b3ae761f3
|
||
|
|
0f7877aafc
|
||
|
|
5843a9ac15
|
||
|
|
4bfaabcb99
|
||
|
|
f16f858074
|
||
|
|
e9a8c01dc4
|
||
|
|
5bbf1b2d71 | ||
|
|
e9c52566b8
|
||
|
|
4c7de650c0
|
||
|
|
6127d964ee
|
||
|
|
8bbbd71fec
|
||
|
|
7f89a80f7e
|
||
|
|
19cca06db6
|
||
|
|
e8df9f119c
|
||
|
|
8abe297bfe
|
||
|
|
4ec6daff30
|
||
|
|
9c1067e544
|
||
|
|
2fe6704fbc | ||
|
|
dd40892ad5 | ||
|
|
ed86b7bfc3 | ||
|
|
f32d72a3f2 | ||
|
|
7b00638476 | ||
|
|
6733b3600f
|
||
|
|
de6010d525
|
||
|
|
9b0e26bade
|
||
|
|
ac40043c00
|
||
|
|
d8eec1d427
|
||
|
|
382916c3ee
|
||
|
|
bc3cc10a7b
|
||
|
|
b91f738209
|
||
|
|
4f0dae9b49
|
||
|
|
deb673ebc9
|
@@ -8,9 +8,9 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
bump_type:
|
bump_type:
|
||||||
description: "Specify the type of version bump"
|
description: 'Specify the type of version bump'
|
||||||
required: true
|
required: true
|
||||||
default: "patch"
|
default: 'patch'
|
||||||
type: choice
|
type: choice
|
||||||
options:
|
options:
|
||||||
- patch
|
- patch
|
||||||
@@ -46,7 +46,7 @@ jobs:
|
|||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: '3.10'
|
||||||
|
|
||||||
- name: Install Commitizen
|
- name: Install Commitizen
|
||||||
run: |
|
run: |
|
||||||
@@ -108,17 +108,19 @@ jobs:
|
|||||||
|
|
||||||
cargo update || true
|
cargo update || true
|
||||||
|
|
||||||
|
sed -i "s|image: 'darkalex17/coyote:v[^']*'|image: 'darkalex17/coyote:v${VERSION}'|" assets/sbx-kit/spec.yaml
|
||||||
|
|
||||||
# Git config that helps in Act
|
# Git config that helps in Act
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
|
|
||||||
git status --porcelain
|
git status --porcelain
|
||||||
git diff --name-only -- Cargo.toml Cargo.lock || true
|
git diff --name-only -- Cargo.toml Cargo.lock assets/sbx-kit/spec.yaml || true
|
||||||
|
|
||||||
if ! git diff --quiet -- Cargo.toml Cargo.lock; then
|
if ! git diff --quiet -- Cargo.toml Cargo.lock assets/sbx-kit/spec.yaml; then
|
||||||
git add -u -- Cargo.toml Cargo.lock
|
git add -u -- Cargo.toml Cargo.lock assets/sbx-kit/spec.yaml
|
||||||
git commit -m "chore: bump Cargo.toml to $VERSION"
|
git commit -m "chore: bump Cargo.toml and sandbox image to $VERSION"
|
||||||
else
|
else
|
||||||
echo "No changes to commit (already at $VERSION)"
|
echo "No changes to commit (already at $VERSION)"
|
||||||
fi
|
fi
|
||||||
@@ -163,28 +165,28 @@ jobs:
|
|||||||
- target: aarch64-unknown-linux-musl
|
- target: aarch64-unknown-linux-musl
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
use-cross: true
|
use-cross: true
|
||||||
cargo-flags: ""
|
cargo-flags: ''
|
||||||
- target: aarch64-apple-darwin
|
- target: aarch64-apple-darwin
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
use-cross: true
|
use-cross: true
|
||||||
cargo-flags: ""
|
cargo-flags: ''
|
||||||
- target: aarch64-pc-windows-msvc
|
- target: aarch64-pc-windows-msvc
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
use-cross: true
|
use-cross: true
|
||||||
cargo-flags: ""
|
cargo-flags: ''
|
||||||
- target: x86_64-apple-darwin
|
- target: x86_64-apple-darwin
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
cargo-flags: ""
|
cargo-flags: ''
|
||||||
- target: x86_64-pc-windows-msvc
|
- target: x86_64-pc-windows-msvc
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
cargo-flags: ""
|
cargo-flags: ''
|
||||||
- target: x86_64-unknown-linux-musl
|
- target: x86_64-unknown-linux-musl
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
use-cross: true
|
use-cross: true
|
||||||
cargo-flags: ""
|
cargo-flags: ''
|
||||||
- target: x86_64-unknown-linux-gnu
|
- target: x86_64-unknown-linux-gnu
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
cargo-flags: ""
|
cargo-flags: ''
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check if actor is repository owner
|
- name: Check if actor is repository owner
|
||||||
@@ -338,7 +340,7 @@ jobs:
|
|||||||
${{ steps.package.outputs.archive }}
|
${{ steps.package.outputs.archive }}
|
||||||
${{ steps.package.outputs.sha }}
|
${{ steps.package.outputs.sha }}
|
||||||
tag_name: v${{ env.RELEASE_VERSION }}
|
tag_name: v${{ env.RELEASE_VERSION }}
|
||||||
name: "v${{ env.RELEASE_VERSION }}"
|
name: 'v${{ env.RELEASE_VERSION }}'
|
||||||
body_path: artifacts/changelog.md
|
body_path: artifacts/changelog.md
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
|
||||||
@@ -455,4 +457,64 @@ jobs:
|
|||||||
- uses: katyo/publish-crates@v2
|
- uses: katyo/publish-crates@v2
|
||||||
if: env.ACT != 'true'
|
if: env.ACT != 'true'
|
||||||
with:
|
with:
|
||||||
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
publish-sandbox-image:
|
||||||
|
needs: [publish-github-release]
|
||||||
|
name: Publish Sandbox Docker Image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check if actor is repository owner
|
||||||
|
if: ${{ github.actor != github.repository_owner && env.ACT != 'true' }}
|
||||||
|
run: |
|
||||||
|
echo "You are not authorized to run this workflow."
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Ensure repository is up-to-date
|
||||||
|
if: env.ACT != 'true'
|
||||||
|
run: |
|
||||||
|
git fetch --all
|
||||||
|
git pull
|
||||||
|
|
||||||
|
- name: Get release artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: artifacts
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Set version variable
|
||||||
|
run: |
|
||||||
|
version="$(cat artifacts/release-version)"
|
||||||
|
echo "version=$version" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Validate release environment variables
|
||||||
|
run: |
|
||||||
|
echo "Release version: ${{ env.version }}"
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
if: env.ACT != 'true'
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Push to Docker Hub
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: ${{ env.ACT != 'true' }}
|
||||||
|
tags: darkalex17/coyote:latest, darkalex17/coyote:v${{ env.version }}
|
||||||
|
build-args: COYOTE_VERSION=${{ env.version }}
|
||||||
|
|||||||
@@ -1,371 +0,0 @@
|
|||||||
# Graph RAG Design Spec
|
|
||||||
|
|
||||||
## Status: COMPLETE
|
|
||||||
|
|
||||||
### Verified From Code (all claims backed by actual file reads)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Goal
|
|
||||||
|
|
||||||
Extend the existing two-signal hybrid search (vector HNSW + BM25 → RRF) to a three-signal hybrid
|
|
||||||
(vector + BM25 + knowledge graph → RRF). The graph captures entity/relationship knowledge extracted
|
|
||||||
from documents at ingestion time via an LLM call per chunk. At query time, graph traversal expands
|
|
||||||
context beyond semantic similarity.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Verified Current Architecture
|
|
||||||
|
|
||||||
### `Rag` struct (`src/rag/mod.rs:48`)
|
|
||||||
```rust
|
|
||||||
pub struct Rag {
|
|
||||||
app_config: Arc<AppConfig>,
|
|
||||||
name: String,
|
|
||||||
path: String,
|
|
||||||
embedding_model: Model,
|
|
||||||
hnsw: Hnsw<'static, f32, DistCosine>, // ephemeral, rebuilt on load
|
|
||||||
bm25: SearchEngine<DocumentId>, // ephemeral, rebuilt on load
|
|
||||||
data: RagData, // serialized to YAML
|
|
||||||
last_sources: RwLock<Option<String>>,
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### `RagData` struct (`src/rag/mod.rs:892`)
|
|
||||||
```rust
|
|
||||||
pub struct RagData {
|
|
||||||
pub embedding_model: String,
|
|
||||||
pub chunk_size: usize,
|
|
||||||
pub chunk_overlap: usize,
|
|
||||||
pub reranker_model: Option<String>,
|
|
||||||
pub top_k: usize,
|
|
||||||
pub batch_size: Option<usize>,
|
|
||||||
pub next_file_id: FileId,
|
|
||||||
pub document_paths: Vec<String>,
|
|
||||||
pub files: IndexMap<FileId, RagFile>,
|
|
||||||
#[serde(with = "serde_vectors")]
|
|
||||||
pub vectors: IndexMap<DocumentId, Vec<f32>>,
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### `RagData::new` callers (both need updating):
|
|
||||||
1. `Rag::init` (`src/rag/mod.rs:219`) — interactive init path
|
|
||||||
2. `Rag::resolve_init_data` (`src/rag/mod.rs:195`) — config-driven init path
|
|
||||||
|
|
||||||
### `Rag::create` (`src/rag/mod.rs:253`) — all init paths converge here:
|
|
||||||
```rust
|
|
||||||
pub fn create(app: &AppConfig, name: &str, path: &Path, data: RagData) -> Result<Self> {
|
|
||||||
let hnsw = data.build_hnsw();
|
|
||||||
let bm25 = data.build_bm25();
|
|
||||||
let embedding_model = Model::retrieve_model(app, &data.embedding_model, ModelType::Embedding)?;
|
|
||||||
let rag = Rag { app_config: Arc::new(app.clone()), name: name.to_string(),
|
|
||||||
path: path.display().to_string(), data, embedding_model, hnsw, bm25,
|
|
||||||
last_sources: RwLock::new(None) };
|
|
||||||
Ok(rag)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### `hybrid_search` (`src/rag/mod.rs:710`)
|
|
||||||
```rust
|
|
||||||
async fn hybrid_search(&self, query: &str, top_k: usize, rerank_model: Option<&str>)
|
|
||||||
-> Result<Vec<(DocumentId, String)>>
|
|
||||||
```
|
|
||||||
Runs `vector_search` + `keyword_search` in parallel via `tokio::join!`, then either reranks or
|
|
||||||
applies `reciprocal_rank_fusion(vec![vector_ids, keyword_ids], vec![1.125, 1.0], top_k)`.
|
|
||||||
|
|
||||||
### `reciprocal_rank_fusion` (`src/rag/mod.rs:1186`) — standalone fn, already weight-parameterized:
|
|
||||||
```rust
|
|
||||||
fn reciprocal_rank_fusion(
|
|
||||||
list_of_document_ids: Vec<Vec<DocumentId>>,
|
|
||||||
list_of_weights: Vec<f32>,
|
|
||||||
top_k: usize,
|
|
||||||
) -> Vec<DocumentId>
|
|
||||||
```
|
|
||||||
|
|
||||||
### `RagData::del` (`src/rag/mod.rs:953`):
|
|
||||||
```rust
|
|
||||||
pub fn del(&mut self, file_ids: Vec<FileId>) {
|
|
||||||
for file_id in file_ids {
|
|
||||||
if let Some(file) = self.files.swap_remove(&file_id) {
|
|
||||||
for (document_index, _) in file.documents.iter().enumerate() {
|
|
||||||
let document_id = DocumentId::new(file_id, document_index);
|
|
||||||
self.vectors.swap_remove(&document_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### `RagNode` (`src/graph/types.rs:331`):
|
|
||||||
```rust
|
|
||||||
pub struct RagNode {
|
|
||||||
pub documents: Vec<String>,
|
|
||||||
pub query: Option<String>,
|
|
||||||
pub top_k: Option<usize>,
|
|
||||||
pub embedding_model: Option<String>,
|
|
||||||
pub chunk_size: Option<usize>,
|
|
||||||
pub chunk_overlap: Option<usize>,
|
|
||||||
pub reranker_model: Option<String>,
|
|
||||||
pub batch_size: Option<usize>,
|
|
||||||
pub state_updates: Option<HashMap<String, String>>,
|
|
||||||
pub timeout: Option<u64>,
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### `Client` trait (`src/client/common.rs:40`):
|
|
||||||
- `async fn chat_completions(&self, input: Input) -> Result<ChatCompletionsOutput>` — needs `Input`
|
|
||||||
- `async fn chat_completions_inner(&self, client: &ReqwestClient, data: ChatCompletionsData) -> Result<ChatCompletionsOutput>` — accessible on `Box<dyn Client>` via vtable
|
|
||||||
- `async fn embeddings(&self, data: &EmbeddingsData) -> Result<Vec<Vec<f32>>>`
|
|
||||||
- `async fn rerank(&self, data: &RerankData) -> Result<RerankOutput>`
|
|
||||||
- `fn build_client(&self) -> Result<ReqwestClient>`
|
|
||||||
- `fn model(&self) -> &Model`
|
|
||||||
|
|
||||||
**Key finding**: `Input` cannot be constructed without `RequestContext` (which `Rag` doesn't have).
|
|
||||||
Instead, `extract_entities` uses `chat_completions_inner` directly with manually built
|
|
||||||
`ChatCompletionsData`. This is accessible via `Box<dyn Client>`.
|
|
||||||
|
|
||||||
### `Message` (`src/client/message.rs:22`):
|
|
||||||
```rust
|
|
||||||
pub fn new(role: MessageRole, content: MessageContent) -> Self
|
|
||||||
```
|
|
||||||
`MessageRole::User`, `MessageContent::Text(String)` — both confirmed.
|
|
||||||
|
|
||||||
### `AppConfig` RAG fields (`src/config/app_config.rs:71`):
|
|
||||||
```rust
|
|
||||||
pub rag_embedding_model: Option<String>,
|
|
||||||
pub rag_reranker_model: Option<String>,
|
|
||||||
pub rag_top_k: usize, // default: 5
|
|
||||||
pub rag_chunk_size: Option<usize>,
|
|
||||||
pub rag_chunk_overlap: Option<usize>,
|
|
||||||
pub rag_template: Option<String>,
|
|
||||||
```
|
|
||||||
|
|
||||||
### `patch_messages` — confirmed exported from `crate::client::*` (used in `input.rs:5`)
|
|
||||||
|
|
||||||
### `init_client(app_config, model)` — works for any `ModelType`, including `Chat`
|
|
||||||
|
|
||||||
### `ModelType` variants: `Chat`, `Embedding`, `Reranker` (confirmed in `model.rs`)
|
|
||||||
|
|
||||||
### petgraph serde: `NodeIndex` serializes as inner `u32`; `StableGraph` preserves index positions
|
|
||||||
through roundtrip. `IndexMap<DocumentId, Vec<NodeIndex>>` safe for YAML (DocumentId is newtype over
|
|
||||||
usize, serializes as integer key).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## New Dependency
|
|
||||||
|
|
||||||
```toml
|
|
||||||
petgraph = { version = "0.7", features = ["serde-1"] }
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## New File: `src/rag/graph.rs`
|
|
||||||
|
|
||||||
All graph types and extraction logic. Module declared in `mod.rs` as `mod graph; use self::graph::*;`.
|
|
||||||
|
|
||||||
### Types:
|
|
||||||
- `Entity { name: String, entity_type: String, description: Option<String> }`
|
|
||||||
- `Relationship { relation_type: String, weight: f32 }`
|
|
||||||
- `ExtractionResult { entities: Vec<ExtractedEntity>, relationships: Vec<ExtractedRelationship> }`
|
|
||||||
- `ExtractedEntity { name: String, r#type: String, description: Option<String> }`
|
|
||||||
- `ExtractedRelationship { from: String, to: String, r#type: String, weight: Option<f32> }`
|
|
||||||
- `KnowledgeGraph { graph: StableGraph<Entity, Relationship>, entity_index: IndexMap<String, NodeIndex>, document_entities: IndexMap<DocumentId, Vec<NodeIndex>> }`
|
|
||||||
|
|
||||||
### Key methods on `KnowledgeGraph`:
|
|
||||||
- `merge(doc_id: DocumentId, result: ExtractionResult)` — merges extraction into graph
|
|
||||||
- `remove_documents(ids: &[DocumentId])` — removes entities exclusive to deleted documents
|
|
||||||
- `build_node_to_docs(&self) -> IndexMap<NodeIndex, Vec<DocumentId>>` — ephemeral reverse map
|
|
||||||
|
|
||||||
### `extract_entities(client: &dyn Client, chunk: &str) -> Result<ExtractionResult>`:
|
|
||||||
- Builds `ChatCompletionsData` manually (no `Input` needed)
|
|
||||||
- Calls `patch_messages` then `client.chat_completions_inner(&reqwest_client, data).await`
|
|
||||||
- Strips markdown code fences from response before JSON parse
|
|
||||||
- Temperature: `Some(0.0)` for deterministic extraction
|
|
||||||
|
|
||||||
### Extraction prompt: structured JSON output requesting entities + relationships
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Changes to `src/rag/mod.rs`
|
|
||||||
|
|
||||||
### `Rag` struct — add one ephemeral field:
|
|
||||||
```rust
|
|
||||||
node_to_docs: IndexMap<NodeIndex, Vec<DocumentId>>, // ephemeral, rebuilt on load
|
|
||||||
```
|
|
||||||
|
|
||||||
### `Rag::create` — build node_to_docs before moving data:
|
|
||||||
```rust
|
|
||||||
let node_to_docs = data.knowledge_graph.build_node_to_docs();
|
|
||||||
// then add to struct literal
|
|
||||||
```
|
|
||||||
|
|
||||||
### `Rag` Clone impl — add:
|
|
||||||
```rust
|
|
||||||
node_to_docs: self.data.knowledge_graph.build_node_to_docs(),
|
|
||||||
```
|
|
||||||
|
|
||||||
### `RagData` struct — three new fields (all `#[serde(default)]` for backward compat):
|
|
||||||
```rust
|
|
||||||
#[serde(default)]
|
|
||||||
pub graph_enabled: bool,
|
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
||||||
pub extractor_model: Option<String>,
|
|
||||||
#[serde(default)]
|
|
||||||
pub knowledge_graph: KnowledgeGraph,
|
|
||||||
```
|
|
||||||
|
|
||||||
### `RagData::new` — two new params: `graph_enabled: bool, extractor_model: Option<String>`
|
|
||||||
|
|
||||||
### `RagData::del` — collect doc_ids during existing loop, call `remove_documents` at end:
|
|
||||||
```rust
|
|
||||||
let mut doc_ids_to_remove = vec![];
|
|
||||||
for file_id in file_ids {
|
|
||||||
if let Some(file) = self.files.swap_remove(&file_id) {
|
|
||||||
for (document_index, _) in file.documents.iter().enumerate() {
|
|
||||||
let document_id = DocumentId::new(file_id, document_index);
|
|
||||||
self.vectors.swap_remove(&document_id);
|
|
||||||
doc_ids_to_remove.push(document_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.knowledge_graph.remove_documents(&doc_ids_to_remove);
|
|
||||||
```
|
|
||||||
|
|
||||||
### `Rag::init` (line 219) — add two params to `RagData::new`:
|
|
||||||
```rust
|
|
||||||
app.rag_graph_enabled,
|
|
||||||
app.rag_extractor_model.clone(),
|
|
||||||
```
|
|
||||||
|
|
||||||
### `resolve_init_data` — resolve from config+app, pass to `RagData::new`:
|
|
||||||
```rust
|
|
||||||
let graph_enabled = config.graph_enabled.unwrap_or(app.rag_graph_enabled);
|
|
||||||
let extractor_model = config.extractor_model.clone().or_else(|| app.rag_extractor_model.clone());
|
|
||||||
```
|
|
||||||
|
|
||||||
### `sync_documents` — entity extraction block after `rag_files` built, before embedding:
|
|
||||||
```rust
|
|
||||||
if self.data.graph_enabled {
|
|
||||||
if let Some(extractor_model_id) = self.data.extractor_model.clone() {
|
|
||||||
let model = Model::retrieve_model(&self.app_config, &extractor_model_id, ModelType::Chat)?;
|
|
||||||
let client = self.create_embeddings_client(model)?;
|
|
||||||
let total_chunks: usize = rag_files.iter().map(|f| f.documents.len()).sum();
|
|
||||||
let mut chunk_num = 0;
|
|
||||||
let file_offset = next_file_id;
|
|
||||||
for (batch_file_idx, rag_file) in rag_files.iter().enumerate() {
|
|
||||||
let file_id = file_offset + batch_file_idx;
|
|
||||||
for (doc_idx, doc) in rag_file.documents.iter().enumerate() {
|
|
||||||
chunk_num += 1;
|
|
||||||
progress(&spinner, format!("Extracting entities [{chunk_num}/{total_chunks}]"));
|
|
||||||
let doc_id = DocumentId::new(file_id, doc_idx);
|
|
||||||
match extract_entities(client.as_ref(), &doc.page_content).await {
|
|
||||||
Ok(result) => self.data.knowledge_graph.merge(doc_id, result),
|
|
||||||
Err(e) => debug!("Entity extraction failed for {doc_id:?}: {e}"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### After line 705 (after hnsw/bm25 rebuild in sync_documents):
|
|
||||||
```rust
|
|
||||||
self.node_to_docs = self.data.knowledge_graph.build_node_to_docs();
|
|
||||||
```
|
|
||||||
|
|
||||||
### `hybrid_search` — add third signal:
|
|
||||||
```rust
|
|
||||||
let graph_search_ids: Vec<DocumentId> = if self.data.graph_enabled
|
|
||||||
&& !self.data.knowledge_graph.entity_index.is_empty()
|
|
||||||
{
|
|
||||||
self.graph_search(query, &keyword_search_ids, top_k)
|
|
||||||
} else {
|
|
||||||
vec![]
|
|
||||||
};
|
|
||||||
// RRF: extend to 3-way when graph has results, fall back to 2-way otherwise
|
|
||||||
```
|
|
||||||
|
|
||||||
### New `graph_search` method (sync):
|
|
||||||
```rust
|
|
||||||
fn graph_search(&self, query: &str, bm25_anchor_ids: &[DocumentId], top_k: usize) -> Vec<DocumentId>
|
|
||||||
```
|
|
||||||
Phase 1: entity names from query via substring match in `entity_index`.
|
|
||||||
Phase 2: fallback — entities from top BM25 document chunks.
|
|
||||||
Phase 3: expand 1-hop neighbors in `StableGraph`.
|
|
||||||
Phase 4: score docs by entity overlap ratio, return top_k.
|
|
||||||
|
|
||||||
### `RagInitConfig` — two new fields:
|
|
||||||
```rust
|
|
||||||
pub graph_enabled: Option<bool>,
|
|
||||||
pub extractor_model: Option<String>,
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Changes to `src/config/app_config.rs`
|
|
||||||
|
|
||||||
New fields alongside existing `rag_*` block:
|
|
||||||
```rust
|
|
||||||
pub rag_graph_enabled: bool, // default: false
|
|
||||||
pub rag_extractor_model: Option<String>, // default: None
|
|
||||||
```
|
|
||||||
Defaults, env var overrides, and propagation all follow the same pattern as existing `rag_*` fields.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Changes to `src/graph/types.rs` — `RagNode`
|
|
||||||
|
|
||||||
```rust
|
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
||||||
pub graph_enabled: Option<bool>,
|
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
||||||
pub extractor_model: Option<String>,
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Changes to `src/config/agent.rs`
|
|
||||||
|
|
||||||
Pass new fields through to `RagInitConfig`:
|
|
||||||
```rust
|
|
||||||
graph_enabled: rag_node.graph_enabled,
|
|
||||||
extractor_model: rag_node.extractor_model.clone(),
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Backward Compatibility
|
|
||||||
|
|
||||||
- All new `RagData` fields have `#[serde(default)]` — old YAML files load without migration
|
|
||||||
- `graph_enabled` defaults `false` — existing RAG instances unchanged
|
|
||||||
- `graph_search_ids` empty → 2-way RRF runs (identical to current behavior)
|
|
||||||
- `node_to_docs` rebuild on `create()` is O(n) over empty map for old instances
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## V1 Scope Exclusions
|
|
||||||
|
|
||||||
- LLM entity extraction from query at search time (V1 uses substring match + BM25 anchoring)
|
|
||||||
- Multi-hop traversal (field reserved, 1-hop only in V1)
|
|
||||||
- Entity embeddings / fuzzy entity lookup
|
|
||||||
- Bincode for large-corpus graph storage
|
|
||||||
- Gleaning / multi-pass extraction
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Implementation Progress
|
|
||||||
|
|
||||||
- [x] Cargo.toml — petgraph dependency
|
|
||||||
- [x] src/rag/graph.rs — new file
|
|
||||||
- [x] src/rag/mod.rs — mod/use, Rag struct, create, clone
|
|
||||||
- [x] src/rag/mod.rs — RagData fields, new, del
|
|
||||||
- [x] src/rag/mod.rs — Rag::init, resolve_init_data
|
|
||||||
- [x] src/rag/mod.rs — sync_documents extraction block
|
|
||||||
- [x] src/rag/mod.rs — hybrid_search + graph_search
|
|
||||||
- [x] src/rag/mod.rs — RagInitConfig fields
|
|
||||||
- [x] src/config/app_config.rs — new fields
|
|
||||||
- [x] src/config/mod.rs — propagation
|
|
||||||
- [x] src/graph/types.rs — RagNode fields
|
|
||||||
- [x] src/config/agent.rs — propagation
|
|
||||||
- [x] cargo check — clean (0 warnings, 1065 tests passing)
|
|
||||||
+194
@@ -1,3 +1,197 @@
|
|||||||
|
## v0.8.3 (2026-08-03)
|
||||||
|
|
||||||
|
### Fix
|
||||||
|
|
||||||
|
- infinite loop bug when attempting to interrupt a prompt exchange right before a session compression
|
||||||
|
- ctrl-c inside of an auto-continue loop created an infinite loop
|
||||||
|
|
||||||
|
## v0.8.2 (2026-07-31)
|
||||||
|
|
||||||
|
### Fix
|
||||||
|
|
||||||
|
- sbx update doesn't allow undefined fields in sbx spec
|
||||||
|
|
||||||
|
## v0.8.1 (2026-07-30)
|
||||||
|
|
||||||
|
### Feat
|
||||||
|
|
||||||
|
- ctrl-c interrupts ongoing prompt in a session, but lets the user inject more instructions mid-stream
|
||||||
|
- improved function calling performance by allowing parallel tool calling
|
||||||
|
- created the architect and gatekeeper agents for dramatically improved coding performance
|
||||||
|
- Improved readability of session message exchange replays
|
||||||
|
- apply --agent/--role/--rag/--model flags in --acp-server mode
|
||||||
|
- add headless profile to sbx-kit spec
|
||||||
|
- implement ACP user-interaction to request_permission bridge
|
||||||
|
- implement ACP session/load and session/cancel
|
||||||
|
- implement ACP session/prompt
|
||||||
|
- add ACP server skeleton with stdout-purity test
|
||||||
|
- add --headless flag for unattended operation
|
||||||
|
|
||||||
|
### Fix
|
||||||
|
|
||||||
|
- ctrl-c interruption doesn't discard session messages when throbber is showing
|
||||||
|
- improper handling of fd-style globbing for directories in fs_glob
|
||||||
|
- properly templated architect design doc path in starter commands
|
||||||
|
- .copy works when sessions are resumed
|
||||||
|
- ACP session/prompt now drives the full tool-execution loop
|
||||||
|
- ACP spec conformance — ContentBlock prompt params and protocolVersion type
|
||||||
|
- restore stdout output for standalone --headless mode
|
||||||
|
- suppress tool-call display in headless mode; initialize session on session/new
|
||||||
|
- skip stdin drain and set silent render mode when --acp-server is active
|
||||||
|
- include graph-agent descriptions in .agent <TAB> completions
|
||||||
|
|
||||||
|
### Refactor
|
||||||
|
|
||||||
|
- move ACP server dispatch into run() for shared flag setup
|
||||||
|
|
||||||
|
## v0.8.0 (2026-07-25)
|
||||||
|
|
||||||
|
### Feat
|
||||||
|
|
||||||
|
- Dynamically detect if a selected client in the sandbox first run wizard supports oauth
|
||||||
|
- Add support for the --fresh flag again with host environment configuration injection
|
||||||
|
- force overwrite global sbx secrets
|
||||||
|
- add sbx secrets globally
|
||||||
|
- only create secrets local to a sandbox
|
||||||
|
- Improved credentials management for docker sandboxes
|
||||||
|
- renamed --contents arg for fs_write/patch to --content since most models attempt that first and error otherwise
|
||||||
|
- Used improved theme selections for tool call highlighting colors
|
||||||
|
- Improved theme-derived syntax highlighting for LLM tool call logging
|
||||||
|
- Improved coloring of LLM tool invocation outputs to make LLM output more readable and cohesive
|
||||||
|
- renamed the user__ask to user__select and improved descriptions to improve model usage
|
||||||
|
- Improved coloring/highlighting of tool calls to make LLM invocation logs easier to read
|
||||||
|
- long-running session improvements
|
||||||
|
- Made sisyphus suite of agents all auto-approved for tool usage
|
||||||
|
- added ast_grep tool to Sisyphus suite agents
|
||||||
|
- created the adversay agent and adversarial-review skill
|
||||||
|
- new spawnable_agents field in agents to let users restrict what agents can be spawned by a parent agent
|
||||||
|
- replay pre-compressed messages as well when resuming sessions for users to see
|
||||||
|
- created a new builtin function for agents who can spawn other agents to list available agents via agent__list_available
|
||||||
|
- **render**: hanging-indent line wrapping for lists and blockquotes
|
||||||
|
- **render**: wire table state machine and finalize hook
|
||||||
|
- **render**: render markdown tables with comfy-table
|
||||||
|
- **render**: parse table cells and column alignments
|
||||||
|
- **render**: detect markdown table rows and separators
|
||||||
|
- **render**: add comfy-table dependency and table border style
|
||||||
|
- **render**: activate rich markdown renderer as default
|
||||||
|
- **render**: rich block-level markdown rendering (headings, quotes, lists, hr)
|
||||||
|
- **render**: rich inline markdown rendering (bold, italic, code, links)
|
||||||
|
- **render**: detect markdown block-level line types
|
||||||
|
- **render**: precompute markdown scope styles for rich rendering
|
||||||
|
- Created the raw_markdown configuration flag
|
||||||
|
- added a .fork command to fork a new session from a running conversation
|
||||||
|
- **oauth**: enable browser-paste PKCE flow for OpenAI-compatible providers
|
||||||
|
- copy host OAuth tokens into sandbox at launch
|
||||||
|
- implement OAuth 2.0 Device Authorization Grant (RFC 8628)
|
||||||
|
- hint that browser 'paste code' pages can be ignored during callback capture
|
||||||
|
- openai-compatible wizard offers OAuth when provider has bundled oauth defaults
|
||||||
|
- validate unique client names at config load
|
||||||
|
- bundle xAI OAuth defaults in models.yaml
|
||||||
|
- OAuth branch in openai_compatible prepare_* fns
|
||||||
|
- get_oauth_provider_for_client dispatcher + client_config_info update
|
||||||
|
- OpenAICompatibleOAuthProvider (config-driven OAuthProvider impl)
|
||||||
|
- add auth + oauth fields to OpenAICompatibleConfig
|
||||||
|
- add oauth field to ProviderModels
|
||||||
|
- add client_credentials support to prepare_oauth_access_token
|
||||||
|
- add OAuthConfig + OAuthFlow types to oauth.rs
|
||||||
|
- Added reasoning effort to the right prompt
|
||||||
|
- Improved support for Anthropic's extended thinking
|
||||||
|
- Also support GEMINI.md workspace instructions
|
||||||
|
- Improved workspace instructions support
|
||||||
|
- also detect .mcp.json configurations at workspace roots
|
||||||
|
- Created new .tool enable/disable and .mcp enable/disable aliases to make REPL usage more egonomic
|
||||||
|
- Created a new .list <kind> REPL command to make discoveribility easier in the REPL
|
||||||
|
- Support claude-style hidden workspace MCP configuration files via .mcp.json
|
||||||
|
- Allow users to customize the workspace-specific configuration directory name so they can use Coyote with other CLI clients like .claude
|
||||||
|
- Add reasoning_effort validation for the main configuration file
|
||||||
|
- Add validation for reasoning_effort settings to prevent users from specifying erroneous values
|
||||||
|
- Added support for modifying the reasoning effort of reasoning models
|
||||||
|
- Explicitly Prevent .undo usage in graph agents
|
||||||
|
- Added an .undo command to the REPL to let users have more control over the conversation
|
||||||
|
- Improve sandbox startup time by using the prebuilt Coyote image
|
||||||
|
- Make coyote available as a docker image
|
||||||
|
- Made fs_patch more flexible for different model preferences of patch formats
|
||||||
|
- Installed nano into the sandbox so that users can edit config files in the sandbox directly
|
||||||
|
- Support workspace-local skill definitions and MCP configurations
|
||||||
|
- fully functional graph-based RAG
|
||||||
|
- Implemented graph-based RAG
|
||||||
|
- Added a --dangerously-skip-permissions flag to skip permission prompts for tool invocations
|
||||||
|
- Remove the temperature hyperparameter from the diagnose role
|
||||||
|
- Added a new oauth.redirectHost field to make it possible to further extend MCP support
|
||||||
|
- Updated the REPL mcp auth path to use the prettified error messaging
|
||||||
|
- Improved error messaging for failed MCP starts because of auth issues
|
||||||
|
- Added support for specifying the oauth port and client ID in MCP server configs
|
||||||
|
- Implemented OAuth support for OpenAI models via Codex endpoints
|
||||||
|
- merge MCP config when installing bundled mcp config
|
||||||
|
- Implemented durable state for sisyphus
|
||||||
|
- Installed ast-grep for the explore agent to use for better code exploration
|
||||||
|
- Created the step-runner graph agent for more deterministic coding workflows to produce even more reliable and higher-quality results
|
||||||
|
- Improved oracle and sisyphus agents with skill integrations for the new skills
|
||||||
|
- Created new sisyphus family skills to improve performance
|
||||||
|
- Created new diagnostic role and skill for use in other contexts
|
||||||
|
- Added new memory functions for deleting and renaming memory files, as well as new lints for memory expiration dates and staleness of memories to improve the memory system
|
||||||
|
- Created a new iwe skill and installed the iwe MCP server for utilizing large knowledgebases
|
||||||
|
- Session-specific, file-backed history in the REPL
|
||||||
|
- Replay session output when a user re-enters a session so all output can be seen again
|
||||||
|
- Added confirmation message after MCP Oauth succeeds when invoked from --auth-mcp
|
||||||
|
- Created the --auth-mcp CLI flag to let users auth with remote MCP servers without needing to be in the REPL
|
||||||
|
- add OAuth authentication support for remote MCP servers
|
||||||
|
- Added mixin for sisyphus so the ddg MCP server can search arbitrary domains
|
||||||
|
- added improved error messaging on MCP server initialization
|
||||||
|
- prefer musl versions for linux when running --update/.update
|
||||||
|
|
||||||
|
### Fix
|
||||||
|
|
||||||
|
- fresh wizard openai-compatible support
|
||||||
|
- config existence check for --fresh sandboxes
|
||||||
|
- Improve coyote sandbox startup time
|
||||||
|
- bypass forgotten sandbox mode check for MCP secret interpolation
|
||||||
|
- properly wrap sub-style changes in markdown rendering
|
||||||
|
- removed accidental duplicate ast_grep tool in explore agent
|
||||||
|
- npm and npx need the /usr/local/share/npm-global/lib directory to exist to run properly so I've added it to the dockerfile
|
||||||
|
- added executable bit to adversary agent tools script
|
||||||
|
- fetch descriptions from graph agent configs as well when listing agents
|
||||||
|
- **render**: suppress blank lines above rendered table
|
||||||
|
- chown the full sandbox cache dir, not just the coyote subdir
|
||||||
|
- chown the whole coyote cache dir not just the oauth dir in the sandbox
|
||||||
|
- fix typo in Gemini's generation_config property to use camelCase exclusively
|
||||||
|
- **oauth**: treat missing expires_in as non-expiring device_code token
|
||||||
|
- **oauth**: send Accept: application/json in device flow requests
|
||||||
|
- OAuth callback listener skips speculative/malformed browser connections
|
||||||
|
- resolve reasoning effort for the prompt for global defaults as well
|
||||||
|
- Account for default model reasoning_effort when supplying that value for the REPL prompts
|
||||||
|
- model narration included in history and between tool calls to prevent repetition
|
||||||
|
- Don't terminate agent loops early for null tool output
|
||||||
|
- reduce code duplication by reusing the new concrete_tool_names function in .list tools
|
||||||
|
- Agent tools can only be modified via .tool enable/disable using tools in the allowed whitelist in the agent
|
||||||
|
- re-render agent sessions when entering agents with either pre-configured agent_session or when entering an agent directly into a session
|
||||||
|
- Per RFC 9728, enable dynamic discovery of OAuth endpoints in MCP using path-aware discovery
|
||||||
|
- hot-attach to MCP servers that require auth after running .mcp auth <name>
|
||||||
|
- Correctly inherit graph-global model for extractor model if none is defined
|
||||||
|
- no cursor timeout when user scrolls away from ongoing streaming output
|
||||||
|
- default to the nano or notepad when a configured editor is not found
|
||||||
|
- When EDITOR, VISUAL, or config.editor is defined, don't verify via which
|
||||||
|
- Added a loop exit condition for the diagnostics skill
|
||||||
|
- Added directness clause to the diganose role to improve prompt
|
||||||
|
- fs tools now output better error handling to guide the model more effectively
|
||||||
|
- Make fs_read more tolerant of various arg invocation formats.
|
||||||
|
- todo functions are injected properly to roles when roles have auto_continue: true and the REPL is started directly into the role
|
||||||
|
- updated the redirect URI for OAuth MCP to use localhost since that's what is whitelisted, not 127.0.0.1
|
||||||
|
- allow MCP OAuth refresh_token to be absent from initial token exchanges
|
||||||
|
- Overrode the default JSON content-type for MCP OAuth so its properly application/x-www-form-urlencoded
|
||||||
|
- typo in mcp file name
|
||||||
|
- Added uvx wrapper for macos-based sandboxes
|
||||||
|
|
||||||
|
### Refactor
|
||||||
|
|
||||||
|
- Standardized paths module function names to not use 'path' in the name and to just always be either 'dir' or 'file'
|
||||||
|
- main.rs resolve_oauth_client uses new dispatcher
|
||||||
|
- split run_oauth_flow into pkce + client_credentials dispatchers
|
||||||
|
|
||||||
|
### Perf
|
||||||
|
|
||||||
|
- updated the memory injection warning so it only logs once, rather than after each keystroke
|
||||||
|
|
||||||
## v0.7.4 (2026-07-02)
|
## v0.7.4 (2026-07-02)
|
||||||
|
|
||||||
### Feat
|
### Feat
|
||||||
|
|||||||
+10
-1
@@ -28,4 +28,13 @@ While Coyote has since diverged significantly and is now developed as an
|
|||||||
independent project, its early foundation and inspiration came from the
|
independent project, its early foundation and inspiration came from the
|
||||||
AIChat project.
|
AIChat project.
|
||||||
|
|
||||||
AIChat is licensed under the MIT License.
|
AIChat is licensed under the MIT License. The MIT license text and its
|
||||||
|
copyright notice are preserved in the [LICENSE-MIT](./LICENSE-MIT) file.
|
||||||
|
|
||||||
|
## Licensing
|
||||||
|
|
||||||
|
Coyote as a whole is licensed under the GNU Affero General Public License
|
||||||
|
v3.0 only (AGPL-3.0-only); see [LICENSE](./LICENSE). Substantial portions
|
||||||
|
derived from AIChat remain under the MIT License (Copyright (c) sigoden),
|
||||||
|
preserved in [LICENSE-MIT](./LICENSE-MIT). See [NOTICE](./NOTICE) for the
|
||||||
|
combined-licensing summary.
|
||||||
Generated
+539
-433
File diff suppressed because it is too large
Load Diff
+4
-2
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "coyote-ai"
|
name = "coyote-ai"
|
||||||
version = "0.7.4"
|
version = "0.8.3"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["Alex Clarke <alex.j.tusa@gmail.com>"]
|
authors = ["Alex Clarke <alex.j.tusa@gmail.com>"]
|
||||||
description = "An all-in-one, batteries included LLM CLI Tool"
|
description = "An all-in-one, batteries included LLM CLI Tool"
|
||||||
@@ -9,7 +9,7 @@ homepage = "https://github.com/Dark-Alex-17/coyote"
|
|||||||
repository = "https://github.com/Dark-Alex-17/coyote"
|
repository = "https://github.com/Dark-Alex-17/coyote"
|
||||||
categories = ["command-line-utilities"]
|
categories = ["command-line-utilities"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = "MIT"
|
license = "AGPL-3.0-only"
|
||||||
rust-version = "1.95.0"
|
rust-version = "1.95.0"
|
||||||
exclude = [".github", "CONTRIBUTING.md"]
|
exclude = [".github", "CONTRIBUTING.md"]
|
||||||
|
|
||||||
@@ -17,6 +17,7 @@ exclude = [".github", "CONTRIBUTING.md"]
|
|||||||
anyhow = "1.0.69"
|
anyhow = "1.0.69"
|
||||||
bytes = "1.4.0"
|
bytes = "1.4.0"
|
||||||
clap = { version = "4.5.40", features = ["cargo", "derive", "wrap_help"] }
|
clap = { version = "4.5.40", features = ["cargo", "derive", "wrap_help"] }
|
||||||
|
comfy-table = { version = "7.2.2", features = ["custom_styling"] }
|
||||||
dirs = "6.0.0"
|
dirs = "6.0.0"
|
||||||
dunce = "1.0.5"
|
dunce = "1.0.5"
|
||||||
futures-util = "0.3.29"
|
futures-util = "0.3.29"
|
||||||
@@ -107,6 +108,7 @@ self_update = { version = "0.44", default-features = false, features = [
|
|||||||
"archive-zip",
|
"archive-zip",
|
||||||
"compression-zip-deflate",
|
"compression-zip-deflate",
|
||||||
] }
|
] }
|
||||||
|
qrcode = "0.14"
|
||||||
|
|
||||||
[dependencies.reqwest]
|
[dependencies.reqwest]
|
||||||
version = "0.13.3"
|
version = "0.13.3"
|
||||||
|
|||||||
+95
@@ -0,0 +1,95 @@
|
|||||||
|
ARG COYOTE_VERSION
|
||||||
|
FROM docker/sandbox-templates:shell-docker AS build
|
||||||
|
|
||||||
|
ARG COYOTE_VERSION
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
|
ENV PATH="/home/agent/.cargo/bin:/home/agent/.local/bin:${PATH}"
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
jq curl git \
|
||||||
|
build-essential pkg-config \
|
||||||
|
cmake \
|
||||||
|
clang libclang-dev \
|
||||||
|
musl-tools \
|
||||||
|
libssl-dev \
|
||||||
|
pandoc \
|
||||||
|
bzip2 \
|
||||||
|
nano && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN set -euo pipefail; \
|
||||||
|
USQL_VERSION=0.21.4; \
|
||||||
|
case "${TARGETARCH}" in \
|
||||||
|
amd64) USQL_ARCH=amd64 ;; \
|
||||||
|
arm64) USQL_ARCH=arm64 ;; \
|
||||||
|
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \
|
||||||
|
esac; \
|
||||||
|
TMPDIR=$(mktemp -d); \
|
||||||
|
curl -fsSL --retry 3 \
|
||||||
|
"https://github.com/xo/usql/releases/download/v${USQL_VERSION}/usql_static-${USQL_VERSION}-linux-${USQL_ARCH}.tar.bz2" \
|
||||||
|
-o "$TMPDIR/usql.tar.bz2"; \
|
||||||
|
tar -xjf "$TMPDIR/usql.tar.bz2" -C "$TMPDIR"; \
|
||||||
|
install -m 0755 "$TMPDIR/usql_static" /usr/local/bin/usql; \
|
||||||
|
rm -rf "$TMPDIR"
|
||||||
|
|
||||||
|
USER 1000
|
||||||
|
|
||||||
|
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
|
||||||
|
printf '#!/bin/sh\nexec uv tool run "$@"\n' > "$HOME/.local/bin/uvx" && \
|
||||||
|
chmod +x "$HOME/.local/bin/uvx"
|
||||||
|
|
||||||
|
RUN mkdir -p /usr/local/share/npm-global/lib
|
||||||
|
|
||||||
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
|
||||||
|
sh -s -- -y --default-toolchain stable --profile minimal && \
|
||||||
|
. "$HOME/.cargo/env" && \
|
||||||
|
cargo install --locked iwec && \
|
||||||
|
cargo install --locked ast-grep
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
RUN set -euo pipefail; \
|
||||||
|
case "${TARGETARCH}" in \
|
||||||
|
amd64) MUSL_TARGET=x86_64-unknown-linux-musl ;; \
|
||||||
|
arm64) MUSL_TARGET=aarch64-unknown-linux-musl ;; \
|
||||||
|
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \
|
||||||
|
esac; \
|
||||||
|
TMPDIR=$(mktemp -d); \
|
||||||
|
curl -fsSL --retry 3 \
|
||||||
|
"https://github.com/Dark-Alex-17/coyote/releases/download/v${COYOTE_VERSION}/coyote-${MUSL_TARGET}.tar.gz" \
|
||||||
|
-o "$TMPDIR/coyote.tar.gz"; \
|
||||||
|
tar -xzf "$TMPDIR/coyote.tar.gz" -C "$TMPDIR"; \
|
||||||
|
install -m 0755 "$TMPDIR/coyote" /home/agent/.cargo/bin/coyote; \
|
||||||
|
chown 1000:1000 /home/agent/.cargo/bin/coyote; \
|
||||||
|
rm -rf "$TMPDIR"
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
|
||||||
|
ARG COYOTE_VERSION
|
||||||
|
|
||||||
|
COPY --from=build / /
|
||||||
|
|
||||||
|
ENV PATH="/home/agent/.cargo/bin:/home/agent/.local/bin:/usr/local/share/npm-global/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
|
||||||
|
NPM_CONFIG_PREFIX="/usr/local/share/npm-global" \
|
||||||
|
NO_PROXY="localhost,127.0.0.1,::1,172.17.0.0/16" \
|
||||||
|
no_proxy="localhost,127.0.0.1,::1,172.17.0.0/16" \
|
||||||
|
BASH_ENV="/etc/sandbox-persistent.sh"
|
||||||
|
|
||||||
|
LABEL com.docker.sandboxes="templates" \
|
||||||
|
com.docker.sandboxes.base="ubuntu:questing" \
|
||||||
|
com.docker.sandboxes.flavor="shell-docker" \
|
||||||
|
com.docker.sandboxes.start-docker="true" \
|
||||||
|
org.opencontainers.image.title="coyote" \
|
||||||
|
org.opencontainers.image.description="An all-in-one, batteries-included LLM CLI tool: Shell Assistant, CLI & REPL mode, RAG, AI tools & agents, MCP servers, skills, and macros." \
|
||||||
|
org.opencontainers.image.source="https://github.com/Dark-Alex-17/coyote" \
|
||||||
|
org.opencontainers.image.version="${COYOTE_VERSION}"
|
||||||
|
|
||||||
|
WORKDIR /home/agent/workspace
|
||||||
|
|
||||||
|
USER 1000
|
||||||
|
|
||||||
|
ENTRYPOINT ["coyote"]
|
||||||
@@ -1,22 +1,661 @@
|
|||||||
The MIT License (MIT)
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
Copyright (c) 2025 sigoden
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
Copyright (c) 2025 Alexander J. Clarke
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Preamble
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
copies or substantial portions of the Software.
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
The licenses for most software and other practical works are designed
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
to take away your freedom to share and change the works. By contrast,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
share and change all versions of a program--to make sure it remains free
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
software for all its users.
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
Developers that use our General Public Licenses protect your rights
|
||||||
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
|
you this License which gives you legal permission to copy, distribute
|
||||||
|
and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that
|
||||||
|
improvements made in alternate versions of the program, if they
|
||||||
|
receive widespread use, become available for other developers to
|
||||||
|
incorporate. Many developers of free software are heartened and
|
||||||
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
|
The GNU Affero General Public License is designed specifically to
|
||||||
|
ensure that, in such cases, the modified source code becomes available
|
||||||
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
|
An older license, called the Affero General Public License and
|
||||||
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
|
this license.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your version
|
||||||
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
|
Source of your version by providing access to the Corresponding Source
|
||||||
|
from a network server at no charge, through some standard or customary
|
||||||
|
means of facilitating copying of software. This Corresponding Source
|
||||||
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
|
following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the work with which it is combined will remain governed by version
|
||||||
|
3 of the GNU General Public License.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If your software can interact with users remotely through a computer
|
||||||
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
|
interface could display a "Source" link that leads users to an archive
|
||||||
|
of the code. There are many ways you could offer source, and different
|
||||||
|
solutions will be better for different programs; see section 13 for the
|
||||||
|
specific requirements.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2025 sigoden
|
||||||
|
Copyright (c) 2025 Alexander J. Clarke
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
Coyote
|
||||||
|
Copyright (c) 2025 Alexander J. Clarke
|
||||||
|
|
||||||
|
This project as a whole is licensed under the GNU Affero General Public
|
||||||
|
License, version 3.0 only (AGPL-3.0-only). The full text of that license is
|
||||||
|
provided in the LICENSE file.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
Upstream / third-party notices
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Coyote began as a fork of AIChat (https://github.com/sigoden/aichat),
|
||||||
|
Copyright (c) sigoden, which is distributed under the MIT License. Substantial
|
||||||
|
portions of Coyote are derived from AIChat and remain available under the terms
|
||||||
|
of the MIT License. The MIT License text and its required copyright and
|
||||||
|
permission notices are preserved in the LICENSE-MIT file.
|
||||||
|
|
||||||
|
As permitted by the MIT License, these portions have been incorporated into a
|
||||||
|
larger work that is distributed under the AGPL-3.0-only license. When you
|
||||||
|
receive Coyote as a combined work, your rights and obligations for the work as
|
||||||
|
a whole are governed by the AGPL-3.0-only license; the MIT notice is retained
|
||||||
|
to satisfy the attribution requirements of the MIT-licensed portions.
|
||||||
|
|
||||||
|
See CREDITS.md for additional background and attribution.
|
||||||
@@ -5,6 +5,8 @@
|
|||||||

|

|
||||||

|

|
||||||
[](https://github.com/Dark-Alex-17/coyote/releases)
|
[](https://github.com/Dark-Alex-17/coyote/releases)
|
||||||
|

|
||||||
|
[](./LICENSE)
|
||||||
|
|
||||||
Coyote is an all-in-one, batteries-included, LLM CLI tool featuring Shell Assistant, CLI & REPL Mode, RAG, AI Tools &
|
Coyote is an all-in-one, batteries-included, LLM CLI tool featuring Shell Assistant, CLI & REPL Mode, RAG, AI Tools &
|
||||||
Agents, and More.
|
Agents, and More.
|
||||||
@@ -38,6 +40,7 @@ Coming from [AIChat](https://github.com/sigoden/aichat)? Follow the [migration g
|
|||||||
* [RAG](https://github.com/Dark-Alex-17/coyote/wiki/RAG): Retrieval-Augmented Generation for enhanced information retrieval and generation.
|
* [RAG](https://github.com/Dark-Alex-17/coyote/wiki/RAG): Retrieval-Augmented Generation for enhanced information retrieval and generation.
|
||||||
* [Sessions](https://github.com/Dark-Alex-17/coyote/wiki/Sessions): Manage and persist conversational contexts and settings across multiple interactions.
|
* [Sessions](https://github.com/Dark-Alex-17/coyote/wiki/Sessions): Manage and persist conversational contexts and settings across multiple interactions.
|
||||||
* [Memory](https://github.com/Dark-Alex-17/coyote/wiki/Memory): Persistent file-based memory that survives across sessions. Bootstrap with `coyote --init-memory [global|workspace]`.
|
* [Memory](https://github.com/Dark-Alex-17/coyote/wiki/Memory): Persistent file-based memory that survives across sessions. Bootstrap with `coyote --init-memory [global|workspace]`.
|
||||||
|
* [Workspace Instructions](https://github.com/Dark-Alex-17/coyote/wiki/Workspace-Instructions): Human-curated project instructions (`COYOTE.md`) injected into every prompt, with `AGENTS.md`/`CLAUDE.md`/`GEMINI.md` fallbacks for cross-tool compatibility. Scaffold with `coyote --init-instructions`.
|
||||||
* [Roles](https://github.com/Dark-Alex-17/coyote/wiki/Roles): Customize model behavior for specific tasks or domains.
|
* [Roles](https://github.com/Dark-Alex-17/coyote/wiki/Roles): Customize model behavior for specific tasks or domains.
|
||||||
* [Skills](https://github.com/Dark-Alex-17/coyote/wiki/Skills): Modular knowledge or capability packs the LLM can load and unload mid-conversation. Multiple skills compose; instructions stack, tools and MCPs union.
|
* [Skills](https://github.com/Dark-Alex-17/coyote/wiki/Skills): Modular knowledge or capability packs the LLM can load and unload mid-conversation. Multiple skills compose; instructions stack, tools and MCPs union.
|
||||||
* [Agents](https://github.com/Dark-Alex-17/coyote/wiki/Agents): Leverage AI agents to perform complex tasks and workflows, including sub-agent spawning, teammate messaging, and user interaction tools.
|
* [Agents](https://github.com/Dark-Alex-17/coyote/wiki/Agents): Leverage AI agents to perform complex tasks and workflows, including sub-agent spawning, teammate messaging, and user interaction tools.
|
||||||
@@ -60,7 +63,7 @@ Coyote requires the following tools to be installed on your system:
|
|||||||
* [uv](https://docs.astral.sh/uv/getting-started/installation/)
|
* [uv](https://docs.astral.sh/uv/getting-started/installation/)
|
||||||
* `curl -LsSf https://astral.sh/uv/install.sh | sh`
|
* `curl -LsSf https://astral.sh/uv/install.sh | sh`
|
||||||
* [iwe](https://github.com/iwe-org/iwe) (`iwec`, for the built-in `iwe` MCP server that navigates large markdown knowledgebases)
|
* [iwe](https://github.com/iwe-org/iwe) (`iwec`, for the built-in `iwe` MCP server that navigates large markdown knowledgebases)
|
||||||
* **Homebrew:** `brew tap iwe-org/iwe && brew install iwe`
|
* **Homebrew:** `brew tap iwe-org/iwe && brew trust --formula iwe-org/iwe/iwe && brew install iwe`
|
||||||
* **Cargo:** `cargo install iwec`
|
* **Cargo:** `cargo install iwec`
|
||||||
* [ast-grep](https://ast-grep.github.io/) (for the built-in `ast_grep` structural code search tool, used by the `explore` agent)
|
* [ast-grep](https://ast-grep.github.io/) (for the built-in `ast_grep` structural code search tool, used by the `explore` agent)
|
||||||
* **Homebrew:** `brew install ast-grep`
|
* **Homebrew:** `brew install ast-grep`
|
||||||
@@ -100,6 +103,32 @@ To upgrade `coyote` using Homebrew:
|
|||||||
brew upgrade coyote
|
brew upgrade coyote
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Docker
|
||||||
|
Coyote is available as a Docker image on Docker Hub (`darkalex17/coyote`) for Linux amd64 and arm64.
|
||||||
|
Useful for CI, ephemeral environments, or anywhere you prefer not to install it natively.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker pull darkalex17/coyote
|
||||||
|
docker run --rm -it darkalex17/coyote
|
||||||
|
```
|
||||||
|
|
||||||
|
To persist your configuration across container runs, mount your existing config directory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -it \
|
||||||
|
-v ~/.config/coyote:/home/agent/.config/coyote \
|
||||||
|
darkalex17/coyote
|
||||||
|
```
|
||||||
|
|
||||||
|
If you use the local vault provider and want your vault credentials available in the container, also mount the password file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -it \
|
||||||
|
-v ~/.config/coyote:/home/agent/.config/coyote \
|
||||||
|
-v ~/.coyote_password:/home/agent/.coyote_password:ro \
|
||||||
|
darkalex17/coyote
|
||||||
|
```
|
||||||
|
|
||||||
### Scripts
|
### Scripts
|
||||||
#### Linux/MacOS (`bash`)
|
#### Linux/MacOS (`bash`)
|
||||||
You can use the following command to run a bash script that downloads and installs the latest version of `coyote` for your
|
You can use the following command to run a bash script that downloads and installs the latest version of `coyote` for your
|
||||||
@@ -303,3 +332,16 @@ See [CREDITS.md](./CREDITS.md) for full attribution and background.
|
|||||||
|
|
||||||
## Creator
|
## Creator
|
||||||
* [Alex Clarke](https://github.com/Dark-Alex-17)
|
* [Alex Clarke](https://github.com/Dark-Alex-17)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Coyote is licensed under the [GNU Affero General Public License v3.0](./LICENSE)
|
||||||
|
(AGPL-3.0-only).
|
||||||
|
|
||||||
|
Coyote began as a fork of [AIChat](https://github.com/sigoden/aichat)
|
||||||
|
(Copyright (c) sigoden), which is licensed under the MIT License. Substantial
|
||||||
|
portions of Coyote are derived from AIChat and remain available under the MIT
|
||||||
|
License, preserved in [LICENSE-MIT](./LICENSE-MIT). See [NOTICE](./NOTICE) and
|
||||||
|
[CREDITS.md](./CREDITS.md) for details.
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
# Adversary
|
||||||
|
|
||||||
|
An **adversarial plan-conformance reviewer**. Where [`code-reviewer`](../code-reviewer/README.md)
|
||||||
|
asks *"is this code good?"*, `adversary` asks a different, harder question:
|
||||||
|
|
||||||
|
> **"Is this the code the plan asked for — all of it, and only it?"**
|
||||||
|
|
||||||
|
It hunts the gap between what a task/plan *specified* and what the implementer actually *built*:
|
||||||
|
silently skipped acceptance criteria, scope creep, interface substitution, approach drift, and the
|
||||||
|
requirements that never showed up in the diff at all ("the dog that didn't bark"). It assumes the
|
||||||
|
implementer drifted until the diff proves otherwise — the independence is the value.
|
||||||
|
|
||||||
|
## Why it's separate from `code-reviewer`
|
||||||
|
|
||||||
|
| | `code-reviewer` | `adversary` |
|
||||||
|
|---|---|---|
|
||||||
|
| Question | Is the code correct/clean/safe? | Does the code match the plan? |
|
||||||
|
| Input | The diff | The diff **+ the plan's acceptance criteria** |
|
||||||
|
| Blind spot it covers | slop, bugs, coupling, footguns | skipped criteria, scope drift, contract breakage |
|
||||||
|
| Output | severity-tagged findings (🔴🟡🟢) | a blocking verdict: `CONFORMS` / `DIVERGES` |
|
||||||
|
|
||||||
|
They are **complementary passes**, not substitutes. `sisyphus` runs both on non-trivial work: one
|
||||||
|
guards quality, the other guards fidelity to the plan.
|
||||||
|
|
||||||
|
## Verdict (blocking)
|
||||||
|
|
||||||
|
The agent ends every review with one sentinel:
|
||||||
|
|
||||||
|
```
|
||||||
|
ADVERSARIAL_REVIEW: CONFORMS
|
||||||
|
Criteria: N/N met (all with tests).
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
ADVERSARIAL_REVIEW: DIVERGES
|
||||||
|
Criteria: X/N met, Y partial, Z unmet/diverged.
|
||||||
|
Complaints:
|
||||||
|
1. Acceptance criterion "<quoted>" — <Unmet|Partial|Diverged> — <what the diff does/omits, file:line> — <fix>
|
||||||
|
2. ...
|
||||||
|
```
|
||||||
|
|
||||||
|
A `DIVERGES` verdict **blocks** completion. The caller (sisyphus/architect) must reconcile it —
|
||||||
|
resume the SAME coder/sisyphus session with the complaints pasted verbatim — or escalate. It mirrors
|
||||||
|
the `oracle` + `plan-review` gate used before implementation, but applied *after* implementation.
|
||||||
|
|
||||||
|
Every complaint ties to a quoted acceptance criterion (or a named scope/interface/out-of-scope
|
||||||
|
violation) and cites `file:line`. Vague complaints are not emitted.
|
||||||
|
|
||||||
|
## How it reviews
|
||||||
|
|
||||||
|
Driven by the [`adversarial-review`](../../skills/adversarial-review/SKILL.md) skill:
|
||||||
|
|
||||||
|
1. Map **every** acceptance criterion to specific evidence in the diff → ✅ Met / ⚠️ Partial / ❌ Unmet / 🔀 Diverged. No test proving the behavior ⇒ at best ⚠️ Partial.
|
||||||
|
2. Ground-truth with read-only tools (`fs_grep`/`fs_read`/`ast_grep`): confirm required symbols exist as specified, changes land where they must, new behavior is actually reached, tests target behavior not implementation.
|
||||||
|
3. Hunt adversarially for the **absent**: skipped criteria, scope creep, interface/approach substitution, out-of-scope touches, downstream contract breakage.
|
||||||
|
|
||||||
|
It is **read-only** — it produces a verdict, never a fix.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Typically spawned by `sisyphus` (or `architect`) alongside `code-reviewer`. The spawn prompt IS its
|
||||||
|
entire context, so it must include the diff (or a base ref to fetch) **and** the acceptance criteria:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
agent__spawn --agent adversary --prompt "
|
||||||
|
## TASK
|
||||||
|
Adversarially review the recent changes for TASK-NNN against its plan. Return CONFORMS/DIVERGES.
|
||||||
|
|
||||||
|
## DIFF
|
||||||
|
Run get_diff (or --base main), or: <paste diff>
|
||||||
|
|
||||||
|
## PLAN — acceptance criteria to check against
|
||||||
|
<paste the task index.md body + the relevant PLAN-*.md section, verbatim>
|
||||||
|
"
|
||||||
|
```
|
||||||
|
|
||||||
|
Direct invocation for ad-hoc use:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
coyote -a adversary --agent-variable project_dir /path/to/repo \
|
||||||
|
"Review staged changes against these criteria: <paste criteria>"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Tools
|
||||||
|
|
||||||
|
- `get_diff [--base <ref>]` — staged → unstaged → `HEAD~1` fallback (or an explicit base/PR branch).
|
||||||
|
- `get_changed_files [--base <ref>]` — quick changed-file map.
|
||||||
|
- Plus read-only `fs_*` and `ast_grep` for ground-truth checks.
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
- [`adversarial-review`](../../skills/adversarial-review/SKILL.md) — the conformance methodology it runs on.
|
||||||
|
- [`code-reviewer`](../code-reviewer/README.md) — the quality reviewer it runs alongside.
|
||||||
|
- [`plan-review`](../../skills/plan-review/SKILL.md) — the *pre*-implementation plan gate; `adversary` is its *post*-implementation counterpart.
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
name: adversary
|
||||||
|
description: Adversarial plan-conformance reviewer - judges whether an implementation matches the task/plan it was supposed to satisfy (not code quality). Returns a blocking CONFORMS/DIVERGES verdict. Complements code-reviewer. Designed to be delegated to by sisyphus.
|
||||||
|
version: 1.0.0
|
||||||
|
|
||||||
|
auto_continue: true
|
||||||
|
max_auto_continues: 15
|
||||||
|
inject_todo_instructions: true
|
||||||
|
|
||||||
|
skills_enabled: true
|
||||||
|
enabled_skills:
|
||||||
|
- adversarial-review
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- name: project_dir
|
||||||
|
description: Project directory containing the changes under review
|
||||||
|
default: '.'
|
||||||
|
- name: auto_confirm
|
||||||
|
description: Auto-confirm command execution
|
||||||
|
default: '1'
|
||||||
|
|
||||||
|
global_tools:
|
||||||
|
- ast_grep.sh
|
||||||
|
- fs_read.sh
|
||||||
|
- fs_cat.sh
|
||||||
|
- fs_grep.sh
|
||||||
|
- fs_glob.sh
|
||||||
|
- fs_ls.sh
|
||||||
|
- execute_command.sh
|
||||||
|
|
||||||
|
instructions: |
|
||||||
|
You are an adversarial plan-conformance reviewer. You answer ONE question: **does this
|
||||||
|
implementation match the plan it was supposed to satisfy — all of it, and only it?** You are NOT
|
||||||
|
the code-quality reviewer (that is `code-reviewer`/`file-reviewer`, which judges correctness, slop,
|
||||||
|
and style). You judge CONFORMANCE: skipped acceptance criteria, silent scope drift, interface
|
||||||
|
substitution, and things the plan required that never showed up in the diff.
|
||||||
|
|
||||||
|
Your value is independence and suspicion. Assume the implementer drifted, cut a corner, or misread
|
||||||
|
the plan until the diff proves otherwise.
|
||||||
|
|
||||||
|
## Step 0: Load the skill
|
||||||
|
|
||||||
|
Before anything else, `skill__load` `adversarial-review`. It carries your methodology: the
|
||||||
|
criterion-by-criterion evidence mapping, the adversarial checklist (silently skipped criteria,
|
||||||
|
scope drift, interface drift, ground-truth verification, out-of-scope violations, downstream
|
||||||
|
contract breakage), and the exact verdict format. The skill body is your source of truth for HOW to
|
||||||
|
review and WHAT to flag; these instructions handle workflow and I/O.
|
||||||
|
|
||||||
|
## Input (the spawn prompt IS your entire context)
|
||||||
|
|
||||||
|
You are given:
|
||||||
|
1. **The diff** — pasted inline, or run `get_diff` (optionally `--base <ref>`) if told to fetch it.
|
||||||
|
2. **The plan** — the task's Objective, Tasks, and especially its **Acceptance criteria**, pasted
|
||||||
|
inline (e.g. a task file's What/Steps/Acceptance criteria + the relevant plan section), or a path to read.
|
||||||
|
|
||||||
|
If the plan / acceptance criteria are missing, STOP and say so: conformance cannot be judged
|
||||||
|
without a spec. Do not invent criteria or guess intent.
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
|
||||||
|
1. Load `adversarial-review`.
|
||||||
|
2. Get the diff (inline or via `get_diff`) and identify the changed files.
|
||||||
|
3. For EACH acceptance criterion: find the specific evidence in the diff that satisfies it and
|
||||||
|
classify it ✅ Met / ⚠️ Partial / ❌ Unmet / 🔀 Diverged. A criterion with no test proving its
|
||||||
|
behavior is at best ⚠️ Partial.
|
||||||
|
4. Ground-truth every claim: `fs_grep` the symbols the plan requires (confirm they exist, spelled
|
||||||
|
as specified), `fs_read` around each hunk to confirm the change makes the criterion true, grep
|
||||||
|
callers to confirm new behavior is reached, confirm tests target behavior not implementation.
|
||||||
|
Use `ast_grep` for structural checks (e.g. "was this function signature actually changed?").
|
||||||
|
5. Hunt adversarially for what's ABSENT (the dog that didn't bark), scope creep, interface/approach
|
||||||
|
substitution, out-of-scope touches, and downstream contract breakage — per the skill checklist.
|
||||||
|
6. Emit the verdict in the skill's exact format.
|
||||||
|
|
||||||
|
## Output — verdict (MANDATORY, exact format)
|
||||||
|
|
||||||
|
End with EXACTLY one of these sentinels so the caller can route on it:
|
||||||
|
|
||||||
|
```
|
||||||
|
ADVERSARIAL_REVIEW: CONFORMS
|
||||||
|
Criteria: N/N met (all with tests).
|
||||||
|
<optional: 1-3 non-blocking observations>
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
ADVERSARIAL_REVIEW: DIVERGES
|
||||||
|
Criteria: X/N met, Y partial, Z unmet/diverged.
|
||||||
|
Complaints:
|
||||||
|
1. Acceptance criterion "<quoted>" — <Unmet|Partial|Diverged> — <what the diff does/omits, file:line> — <what would make it conform>
|
||||||
|
2. Scope drift / interface drift / out-of-scope — <file:line> — <the violation> — <the fix>
|
||||||
|
3. ...
|
||||||
|
```
|
||||||
|
|
||||||
|
Every complaint MUST quote the specific acceptance criterion (or name the specific scope/interface/
|
||||||
|
out-of-scope violation) AND cite file:line. A complaint with no criterion reference and no location
|
||||||
|
is noise — do not emit it.
|
||||||
|
|
||||||
|
## Rules
|
||||||
|
|
||||||
|
1. **You are read-only.** Never modify files. You produce a verdict; the implementer owns the fix.
|
||||||
|
2. **Conformance, not quality.** Do not flag style/naming/micro-optimizations unless they cause a
|
||||||
|
criterion to be unmet. If a quality defect breaks a criterion (a race violating a correctness
|
||||||
|
criterion), flag it as a conformance failure and note it is also a quality issue.
|
||||||
|
3. **No test ⇒ not met.** An acceptance criterion is a promise of observable behavior; unproven
|
||||||
|
behavior is at best Partial.
|
||||||
|
4. **Absence is a finding.** Review what SHOULD be in the diff per the plan, not only what IS.
|
||||||
|
5. **Don't re-litigate a settled decision** — but DO flag when the diff silently overrode one the
|
||||||
|
plan recorded ("do X not Y because Z" → diff does Y).
|
||||||
|
6. **The plan can be the culprit.** If the plan is impossible/self-contradictory, that is DIVERGES
|
||||||
|
with the plan named as root cause — never judge against a plan you silently corrected.
|
||||||
|
7. Be terse and decisive. Three real divergences beat fifteen weak ones. If everything is a nitpick,
|
||||||
|
it CONFORMS — say so.
|
||||||
|
|
||||||
|
## Context
|
||||||
|
- Project: {{project_dir}}
|
||||||
|
- CWD: {{__cwd__}}
|
||||||
|
- Shell: {{__shell__}}
|
||||||
|
|
||||||
|
## Available Tools
|
||||||
|
{{__tools__}}
|
||||||
Executable
+78
@@ -0,0 +1,78 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
# @env LLM_OUTPUT=/dev/stdout
|
||||||
|
# @env LLM_AGENT_VAR_PROJECT_DIR=.
|
||||||
|
# @describe Adversarial plan-conformance reviewer tools
|
||||||
|
|
||||||
|
_project_dir() {
|
||||||
|
local dir="${LLM_AGENT_VAR_PROJECT_DIR:-.}"
|
||||||
|
(cd "${dir}" 2>/dev/null && pwd) || echo "${dir}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# @cmd Get the git diff to review for plan conformance. Returns staged changes, or unstaged if nothing is staged, or the HEAD~1 diff if the working tree is clean.
|
||||||
|
# @option --base Optional base ref to diff against (e.g., "main", "HEAD~3", a commit SHA, or a PR base branch)
|
||||||
|
get_diff() {
|
||||||
|
local project_dir
|
||||||
|
project_dir=$(_project_dir)
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
local base="${argc_base:-}"
|
||||||
|
|
||||||
|
local diff_output=""
|
||||||
|
if [[ -n "${base}" ]]; then
|
||||||
|
diff_output=$(cd "${project_dir}" && git diff "${base}" 2>&1) || true
|
||||||
|
else
|
||||||
|
diff_output=$(cd "${project_dir}" && git diff --cached 2>&1) || true
|
||||||
|
if [[ -z "${diff_output}" ]]; then
|
||||||
|
diff_output=$(cd "${project_dir}" && git diff 2>&1) || true
|
||||||
|
fi
|
||||||
|
if [[ -z "${diff_output}" ]]; then
|
||||||
|
diff_output=$(cd "${project_dir}" && git diff HEAD~1 2>&1) || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${diff_output}" ]]; then
|
||||||
|
echo "No changes found to review in ${project_dir}." >> "$LLM_OUTPUT"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
local file_count
|
||||||
|
file_count=$(echo "${diff_output}" | grep -c '^diff --git' || true)
|
||||||
|
{
|
||||||
|
echo "Diff contains changes to ${file_count} file(s):"
|
||||||
|
echo ""
|
||||||
|
echo "${diff_output}"
|
||||||
|
} >> "$LLM_OUTPUT"
|
||||||
|
}
|
||||||
|
|
||||||
|
# @cmd Get the list of changed files with stats (a quick map of what to check against the plan).
|
||||||
|
# @option --base Optional base ref to diff against
|
||||||
|
get_changed_files() {
|
||||||
|
local project_dir
|
||||||
|
project_dir=$(_project_dir)
|
||||||
|
local base="${argc_base:-}"
|
||||||
|
|
||||||
|
local stat_output=""
|
||||||
|
if [[ -n "${base}" ]]; then
|
||||||
|
stat_output=$(cd "${project_dir}" && git diff --stat "${base}" 2>&1) || true
|
||||||
|
else
|
||||||
|
stat_output=$(cd "${project_dir}" && git diff --cached --stat 2>&1) || true
|
||||||
|
if [[ -z "${stat_output}" ]]; then
|
||||||
|
stat_output=$(cd "${project_dir}" && git diff --stat 2>&1) || true
|
||||||
|
fi
|
||||||
|
if [[ -z "${stat_output}" ]]; then
|
||||||
|
stat_output=$(cd "${project_dir}" && git diff --stat HEAD~1 2>&1) || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${stat_output}" ]]; then
|
||||||
|
echo "No changes found in ${project_dir}." >> "$LLM_OUTPUT"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "Changed files:"
|
||||||
|
echo ""
|
||||||
|
echo "${stat_output}"
|
||||||
|
} >> "$LLM_OUTPUT"
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
# Architect
|
||||||
|
|
||||||
|
A **design-doc orchestrator for any project**. Give it one high-level design doc; it decomposes the
|
||||||
|
doc into a quality-gated plan and ~1-engineer-day task files, spawns **one
|
||||||
|
[Sisyphus](../sisyphus/README.md) per task** on a single run branch, verifies each task with an
|
||||||
|
adversarial plan-conformance check, and finishes with **one draft PR** (CI checks watched to green)
|
||||||
|
plus tracked follow-up tasks for the manual work the code can't do for itself.
|
||||||
|
|
||||||
|
Architect does **not** write feature code itself. It owns the *process*; Sisyphus owns each *task*.
|
||||||
|
|
||||||
|
## The pipeline it drives
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart TD
|
||||||
|
user([Design doc]) --> architect["Architect<br/>design-doc orchestrator"]
|
||||||
|
architect --> orient["Phase A — Orient<br/>project conventions · build/test commands · design doc"]
|
||||||
|
orient --> design["Phase B — design-session<br/>plans_dir/PLAN-<slug>.md + 1-day task breakdown"]
|
||||||
|
|
||||||
|
design -. "grounding" .-> explore[["explore<br/>codebase grep<br/>× parallel"]]
|
||||||
|
design -. "unfamiliar libraries" .-> librarian[["librarian<br/>docs + OSS grep"]]
|
||||||
|
explore -. "findings ground<br/>the breakdown" .-> design
|
||||||
|
librarian -. "findings ground<br/>the breakdown" .-> design
|
||||||
|
|
||||||
|
design --> gatekeeper[["gatekeeper<br/>self-containedness audit<br/>(docker-container test)"]]
|
||||||
|
gatekeeper --> g1{"PLAN_GATE?"}
|
||||||
|
g1 -->|"LEAKY (≤ 2 cycles)"| amend["Answer the missing questions<br/>via explore / librarian / docs<br/>(user__ask only for business rules)<br/>→ amend the plan"]
|
||||||
|
amend --> gatekeeper
|
||||||
|
g1 -->|"LEAKY after 2 cycles"| escalate
|
||||||
|
g1 -->|"SEALED"| oracle[["oracle<br/>plan-review<br/>(executability)"]]
|
||||||
|
|
||||||
|
oracle --> g2{"PLAN_REVIEW?"}
|
||||||
|
g2 -->|"REJECT — fix complaints,<br/>re-submit SAME session"| oracle
|
||||||
|
g2 -->|"OKAY"| tasks["Phase D — materialize tasks<br/>plans_dir/tasks/TASK-NNN-*/ (task-tracking)"]
|
||||||
|
|
||||||
|
tasks --> branch["Phase E — run branch<br/>feat/PLAN-<slug> off base_branch"]
|
||||||
|
branch --> claim["Claim task (sequential, dependency order)<br/>status: in-progress + base SHA"]
|
||||||
|
claim --> sisyphus[["sisyphus<br/>implement ONE task on the run branch<br/>commit + push — NO PR"]]
|
||||||
|
sisyphus --> adversary[["adversary<br/>conformance check<br/>diff vs task base SHA"]]
|
||||||
|
|
||||||
|
adversary --> verdict{"ADVERSARIAL_REVIEW?"}
|
||||||
|
verdict -->|"DIVERGES — resume<br/>SAME sisyphus session (once)"| sisyphus
|
||||||
|
verdict -->|"still DIVERGES"| escalate
|
||||||
|
verdict -->|"CONFORMS"| taskdone["Close task<br/>status: complete · log commits + follow-ups"]
|
||||||
|
|
||||||
|
taskdone --> more{"More tasks?"}
|
||||||
|
more -->|"yes"| claim
|
||||||
|
more -->|"no"| finish["Phase F — full build + tests<br/>on the integrated run branch"]
|
||||||
|
|
||||||
|
finish --> pr["ONE DRAFT PR: run branch → base_branch<br/>(never marked ready — user reviews first)<br/>body: task checklist + Follow-up / manual actions"]
|
||||||
|
pr --> checks{"PR runs/checks<br/>green?"}
|
||||||
|
checks -->|"failure — resume responsible<br/>sisyphus session, fix, push"| checks
|
||||||
|
checks -->|"external flake /<br/>broken base branch"| escalate
|
||||||
|
checks -->|"green"| followups["Create follow-up task files<br/>(type: followup, pending)<br/>→ picked up by the user post-merge"]
|
||||||
|
followups --> backfill["Backfill PR link into PLAN + task logs<br/>PLAN status: implemented"]
|
||||||
|
backfill --> validate["task-tracking consistency checks"]
|
||||||
|
validate --> done([Run complete])
|
||||||
|
|
||||||
|
escalate([user__ask — escalate to user])
|
||||||
|
|
||||||
|
branch -. "parallel_tasks=1 (opt-in):<br/>per-task worktrees + task branches,<br/>merged one at a time with<br/>integration tests after every merge" .-> claim
|
||||||
|
```
|
||||||
|
|
||||||
|
## Where state lives
|
||||||
|
|
||||||
|
Everything is file-based in **`plans_dir`** (default `plans/`, resolved against the project):
|
||||||
|
|
||||||
|
```
|
||||||
|
<plans_dir>/
|
||||||
|
PLAN-<slug>.md # problem / approach / alternatives / task breakdown
|
||||||
|
tasks/TASK-NNN-<slug>/
|
||||||
|
index.md # What / Steps / Acceptance criteria; status in frontmatter
|
||||||
|
log.md # append-only audit trail (branch, commits, follow-ups, PR)
|
||||||
|
```
|
||||||
|
|
||||||
|
- `plans_dir` **inside the repo** (default) → planning files ride the run branch and land in the PR
|
||||||
|
(self-documenting review).
|
||||||
|
- `plans_dir` **absolute, outside the repo** (e.g. a common runs directory) → nothing planning-related
|
||||||
|
is ever committed.
|
||||||
|
|
||||||
|
Disk is the durable store: task statuses, logs, and follow-ups survive context compression; chat
|
||||||
|
history does not.
|
||||||
|
|
||||||
|
## The three review gates
|
||||||
|
|
||||||
|
| Gate | Agent | Question | When |
|
||||||
|
|------|-------|----------|------|
|
||||||
|
| Self-containedness | [`gatekeeper`](../gatekeeper/README.md) | "Can a context-free LLM implement from this plan alone?" | Before tasks exist |
|
||||||
|
| Executability | `oracle` + `plan-review` | "Is the approach sound, verifiable, correctly ordered?" | After sealing |
|
||||||
|
| Conformance | [`adversary`](../adversary/README.md) | "Is the built code what the plan asked for?" | After each task |
|
||||||
|
|
||||||
|
## Key conventions it enforces
|
||||||
|
|
||||||
|
- **One task = one engineer-day** — anything larger gets decomposed at the design stage.
|
||||||
|
- **Task state on disk** — `status:` frontmatter lifecycle per the `task-tracking` skill; no state
|
||||||
|
lives only in chat.
|
||||||
|
- **One run branch, one draft PR** — `feat/PLAN-<slug>` off `base_branch`; the PR is never opened
|
||||||
|
per-task, never non-draft, never marked ready-for-review (you flip it yourself).
|
||||||
|
- **CI checks watched to green** — failures are routed back to the responsible Sisyphus session; the
|
||||||
|
run isn't done with red or pending checks.
|
||||||
|
- **No plan references in code comments** — comments never cite the design doc, plan, phases, steps,
|
||||||
|
or TASK numbers (docs drift; comments rot). Plan references live in commit messages only.
|
||||||
|
- **`.env` never lands in a repo** — only `.env.example` with placeholder keys; real values become a
|
||||||
|
follow-up.
|
||||||
|
- **Follow-ups are tracked, never dropped** — every manual action (secrets, cloud roles, console
|
||||||
|
steps, cross-repo changes) is reported per task, logged durably, rolled into the PR's
|
||||||
|
`## Follow-up / manual actions` section (pre-merge items first), and materialized as
|
||||||
|
`type: followup` task files for you to pick up post-merge.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# From the target project root (default autonomy: full)
|
||||||
|
coyote -a architect --agent-variable design_doc docs/design/my-feature.md \
|
||||||
|
"Implement this design doc end to end"
|
||||||
|
|
||||||
|
# Approve the task breakdown once, then run autonomously
|
||||||
|
coyote -a architect \
|
||||||
|
--agent-variable design_doc docs/design/my-feature.md \
|
||||||
|
--agent-variable autonomy plan-gate \
|
||||||
|
"Decompose and implement"
|
||||||
|
|
||||||
|
# Different project / plans outside the repo / PR against a non-main base
|
||||||
|
coyote -a architect \
|
||||||
|
--agent-variable project_dir ~/code/my-service \
|
||||||
|
--agent-variable plans_dir ~/architect-runs/my-service \
|
||||||
|
--agent-variable base_branch develop \
|
||||||
|
--agent-variable design_doc ~/docs/big-refactor.md \
|
||||||
|
"Run the pipeline"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Variables
|
||||||
|
|
||||||
|
| Variable | Default | Meaning |
|
||||||
|
|----------|---------|---------|
|
||||||
|
| `project_dir` | `.` | The target repo — the only WRITE target for feature code. |
|
||||||
|
| `plans_dir` | `plans` | Where PLAN + task files live. Relative → in-repo (rides the PR); absolute → outside git. |
|
||||||
|
| `design_doc` | *(empty)* | Path to the design doc; asked for if unset. |
|
||||||
|
| `base_branch` | `main` | Branch the run branch forks from and the PR targets. |
|
||||||
|
| `autonomy` | `full` | `full` (no gates) · `plan-gate` (approve breakdown once) · `phase-gate` (approve each task). |
|
||||||
|
| `parallel_tasks` | `0` | `0` = sequential (default) · `1` = opt-in worktree-parallel execution for eligible tasks. |
|
||||||
|
| `auto_confirm` | `1` | Skip the shell confirm guard (needed for non-interactive autonomous runs). |
|
||||||
|
|
||||||
|
## Autonomy
|
||||||
|
|
||||||
|
Fully autonomous end-to-end by default — it halts only for genuine blockers: scope-changing
|
||||||
|
ambiguity or unresolved design questions, a task that fails after Sisyphus's own recovery (consults
|
||||||
|
Oracle, then escalates), and any destructive/irreversible action. Use `plan-gate` or `phase-gate`
|
||||||
|
to insert approval checkpoints.
|
||||||
|
|
||||||
|
## Parallel task execution (opt-in)
|
||||||
|
|
||||||
|
By default (`parallel_tasks: 0`) tasks run **sequentially** on the single run branch. Setting
|
||||||
|
`parallel_tasks: 1` enables worktree-based parallelism:
|
||||||
|
|
||||||
|
- Eligible tasks (mutually unblocked, plan-declared file-disjoint, max 3 concurrent) each get an
|
||||||
|
isolated `git worktree` + task branch forked from the run branch tip.
|
||||||
|
- Tasks touching **migrations, generated code, or dependency manifests/lockfiles** are never
|
||||||
|
parallel-eligible — shared hotspots collide even when the plan calls tasks independent.
|
||||||
|
- Architect integrates: completed task branches merge into the run branch **one at a time**, with a
|
||||||
|
full build + test run after every merge. Conflicts go back to that task's Sisyphus session to
|
||||||
|
rebase and re-verify.
|
||||||
|
- Worktrees and task branches are cleaned up after each clean merge. Phase F (single draft PR +
|
||||||
|
CI-check watch) is unchanged in both modes.
|
||||||
|
|
||||||
|
## Sub-agents it spawns
|
||||||
|
|
||||||
|
| Agent | Used for |
|
||||||
|
|-------|----------|
|
||||||
|
| [`sisyphus`](../sisyphus/README.md) | Implement ONE task's code (its own explore→coder→verify→review loop). One per task. |
|
||||||
|
| [`gatekeeper`](../gatekeeper/README.md) | Plan self-containedness gate (`PLAN_GATE: SEALED/LEAKY`). |
|
||||||
|
| [`adversary`](../adversary/README.md) | Per-task plan-conformance verdict (`ADVERSARIAL_REVIEW: CONFORMS/DIVERGES`). |
|
||||||
|
| [`oracle`](../oracle/README.md) | Plan review (`plan-review`); diagnosis when a task fails after Sisyphus recovery. |
|
||||||
|
| [`explore`](../explore/README.md) | Ground the design/plan in real code; read other local repos for library usage and call sites. |
|
||||||
|
| [`librarian`](../librarian/README.md) | External docs / OSS examples for unfamiliar libraries. |
|
||||||
|
|
||||||
|
## Related skills
|
||||||
|
|
||||||
|
- [`design-session`](../../skills/design-session/SKILL.md) — design doc → grounded proposal → PLAN + sized breakdown.
|
||||||
|
- [`task-tracking`](../../skills/task-tracking/SKILL.md) — the task-file schema, lifecycle, and consistency checks.
|
||||||
|
- [`plan-gatekeeping`](../../skills/plan-gatekeeping/SKILL.md) — the gatekeeper's self-containedness manifest.
|
||||||
|
- [`plan-authoring`](../../skills/plan-authoring/SKILL.md) / [`plan-review`](../../skills/plan-review/SKILL.md) — plan schema + oracle's executability review.
|
||||||
|
- [`adversarial-review`](../../skills/adversarial-review/SKILL.md) — the adversary's conformance methodology.
|
||||||
@@ -0,0 +1,460 @@
|
|||||||
|
name: architect
|
||||||
|
description: |
|
||||||
|
Design-doc orchestrator for any project. Consumes a high-level design doc, decomposes it into a
|
||||||
|
gated plan (gatekeeper self-containedness + oracle plan-review) and ~1-engineer-day task files,
|
||||||
|
spawns one Sisyphus per task on a single run branch, verifies each with an adversarial
|
||||||
|
plan-conformance check, and finishes with ONE draft PR (CI checks watched to green) plus tracked
|
||||||
|
follow-up tasks. Task state lives on disk in a plans directory, so runs survive context compression.
|
||||||
|
version: 2.0.0
|
||||||
|
agent_session: temp
|
||||||
|
auto_continue: true
|
||||||
|
max_auto_continues: 100
|
||||||
|
inject_todo_instructions: true
|
||||||
|
|
||||||
|
can_spawn_agents: true
|
||||||
|
spawnable_agents:
|
||||||
|
- sisyphus
|
||||||
|
- oracle
|
||||||
|
- explore
|
||||||
|
- librarian
|
||||||
|
- adversary
|
||||||
|
- gatekeeper
|
||||||
|
max_concurrent_agents: 10
|
||||||
|
max_agent_depth: 10
|
||||||
|
inject_spawn_instructions: true
|
||||||
|
summarization_threshold: 100000
|
||||||
|
|
||||||
|
skills_enabled: true
|
||||||
|
enabled_skills:
|
||||||
|
- design-session
|
||||||
|
- task-tracking
|
||||||
|
- plan-authoring
|
||||||
|
- delegation-protocol
|
||||||
|
- git-master
|
||||||
|
- parallel-research
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- name: project_dir
|
||||||
|
description: Absolute path to the target project repo — the ONLY write target for feature code
|
||||||
|
default: '.'
|
||||||
|
- name: plans_dir
|
||||||
|
description: Where the PLAN file and task dirs live. Relative paths resolve against project_dir (and then ride the run branch into the PR); an absolute path outside the repo keeps planning files out of git entirely.
|
||||||
|
default: 'plans'
|
||||||
|
- name: design_doc
|
||||||
|
description: Path to the high-level design doc to implement (absolute, or relative to project_dir)
|
||||||
|
default: ''
|
||||||
|
- name: base_branch
|
||||||
|
description: The branch the run branch forks from and the PR targets
|
||||||
|
default: 'main'
|
||||||
|
- name: autonomy
|
||||||
|
description: 'How autonomous the run is: full (no gates), plan-gate (approve breakdown once, then autonomous), phase-gate (approve each task)'
|
||||||
|
default: full
|
||||||
|
- name: auto_confirm
|
||||||
|
description: Auto-confirm command execution (1 = skip the shell guard_operation TTY prompt, needed for non-interactive autonomous runs)
|
||||||
|
default: '1'
|
||||||
|
- name: parallel_tasks
|
||||||
|
description: 'Opt-in worktree-based parallel task execution: 0 = sequential (default, one task at a time on the run branch), 1 = eligible tasks run as concurrent Sisyphus agents in isolated git worktrees, merged back one at a time'
|
||||||
|
default: '0'
|
||||||
|
|
||||||
|
global_tools:
|
||||||
|
- ast_grep.sh
|
||||||
|
- fs_read.sh
|
||||||
|
- fs_grep.sh
|
||||||
|
- fs_glob.sh
|
||||||
|
- fs_ls.sh
|
||||||
|
- fs_write.sh
|
||||||
|
- fs_patch.sh
|
||||||
|
- fs_mkdir.sh
|
||||||
|
- execute_command.sh
|
||||||
|
|
||||||
|
instructions: |
|
||||||
|
You are **Architect** — an orchestrator that takes a single high-level design doc and drives it
|
||||||
|
end-to-end to implementation on ANY project. You do NOT write feature code yourself. You decompose,
|
||||||
|
gate the plan, delegate one task to one **Sisyphus** sub-agent, verify conformance, track state on
|
||||||
|
disk, and finish with a single draft PR — repeating until the entire design doc is implemented.
|
||||||
|
|
||||||
|
## Ground rules — READ BEFORE ANYTHING
|
||||||
|
|
||||||
|
**Write target.** ALL feature code goes in {{project_dir}}. You and your sub-agents MAY freely READ
|
||||||
|
other local repos/directories (internal libraries, legacy patterns, call sites, shared contracts)
|
||||||
|
— reading is encouraged; WRITING anywhere but {{project_dir}} is a scope violation. If the design
|
||||||
|
genuinely requires writing outside {{project_dir}}, STOP and escalate; likely it's a follow-up.
|
||||||
|
|
||||||
|
**Git model — one run branch, one draft PR.** All work lands on a single RUN BRANCH
|
||||||
|
(`feat/PLAN-<slug>`, forked from {{base_branch}}), and exactly ONE DRAFT PR is opened at the END of
|
||||||
|
the run (Phase F) covering the entire design doc — NEVER one PR per task, NEVER a push to
|
||||||
|
{{base_branch}}. Before any `git push`/branch/PR, confirm you are in {{project_dir}}
|
||||||
|
(`git remote get-url origin`).
|
||||||
|
|
||||||
|
**Task state lives on disk.** {{plans_dir}} (relative → resolved against {{project_dir}}, riding
|
||||||
|
the run branch into the PR; absolute → outside git entirely) holds `PLAN-<slug>.md` and
|
||||||
|
`tasks/TASK-NNN-*/`. The `task-tracking` skill defines the schema and lifecycle — load it before
|
||||||
|
touching task files. Disk is your durable store; chat history is not.
|
||||||
|
|
||||||
|
**Read the project's own conventions at startup** — `CLAUDE.md` / `AGENTS.md` / `CONTRIBUTING.md`
|
||||||
|
at the project root. When this prompt and those files disagree on project conventions, the
|
||||||
|
project's files win; note the discrepancy to the user.
|
||||||
|
|
||||||
|
## Autonomy mode: {{autonomy}}
|
||||||
|
|
||||||
|
- **full** — run the entire pipeline with no approval gates. Only stop for a genuine blocker
|
||||||
|
(ambiguity that changes scope, a task that fails after Sisyphus's own recovery, missing critical
|
||||||
|
info, any destructive action). This is the default.
|
||||||
|
- **plan-gate** — after the breakdown is SEALED + OKAY'd, present it ONCE via `user__confirm`
|
||||||
|
before creating any tasks. Then run all tasks autonomously.
|
||||||
|
- **phase-gate** — present each task's result via `user__confirm` before starting the next.
|
||||||
|
|
||||||
|
Even in `full`, you MUST still stop for: scope-changing ambiguity, a task that fails after
|
||||||
|
Sisyphus's own recovery, and any destructive action (`rm -rf`, force-push, dropping data, deleting
|
||||||
|
branches). Exception: in parallel mode, removing a task's worktree and deleting its task branch
|
||||||
|
AFTER its merge landed and integration tests passed is routine documented cleanup, not a
|
||||||
|
destructive action.
|
||||||
|
|
||||||
|
## The pipeline (drive this to completion)
|
||||||
|
|
||||||
|
### Phase A — Orient (once, at startup)
|
||||||
|
|
||||||
|
1. Run `date -u '+%Y-%m-%d %H:%M:%S %Z (%A)'` — trust the shell clock, not the prompt date.
|
||||||
|
2. In {{project_dir}}: `git pull` on {{base_branch}}; read the project's orientation docs
|
||||||
|
(`CLAUDE.md` / `AGENTS.md` / `CONTRIBUTING.md` / `README.md`) and note build/test commands.
|
||||||
|
3. Read the design doc ({{design_doc}} if set; otherwise ask the user for the path).
|
||||||
|
4. `skill__list`, then load `design-session` and `plan-authoring` for decomposition, and
|
||||||
|
`task-tracking` before any task files exist.
|
||||||
|
5. Build a durable todo list — one item per pipeline stage and, once tasks exist, one per TASK-NNN.
|
||||||
|
Embed spawned session_ids in todo text (e.g. `todo__add "Implement TASK-002 (sisyphus
|
||||||
|
ses_abc123)"`) so they survive context compression.
|
||||||
|
|
||||||
|
### Phase B — Design decomposition
|
||||||
|
|
||||||
|
Load and follow the `design-session` skill against the design doc. This produces
|
||||||
|
`{{plans_dir}}/PLAN-<slug>.md` with Problem, Scope, Approach, Alternatives, Constraints/risks,
|
||||||
|
Open questions, and a **Task breakdown** where **each task is sized to ~1 engineer-day** (decompose
|
||||||
|
anything bigger NOW).
|
||||||
|
|
||||||
|
Ground the breakdown in real code: fan out `explore` agents (load `parallel-research`) across
|
||||||
|
{{project_dir}} — and `librarian` for unfamiliar external libraries — to confirm the design's
|
||||||
|
assumptions before sizing. Do NOT guess file/symbol names — verify them.
|
||||||
|
|
||||||
|
In `full` autonomy, if the design session surfaces open questions you cannot answer from the doc or
|
||||||
|
the codebase, ask the user (`user__ask`); an unresolved question that changes scope is a hard stop
|
||||||
|
even in `full`.
|
||||||
|
|
||||||
|
### Phase C — Plan quality gates (BOTH mandatory before any tasks)
|
||||||
|
|
||||||
|
Two independent gates, in order. A plan is finalized ONLY when it is both SEALED and OKAY.
|
||||||
|
|
||||||
|
**Gate 1 — Self-containedness (`gatekeeper`).** The plan must pass the "docker container" test:
|
||||||
|
every question a context-free implementer will hit is answered inline or delegated via a verified
|
||||||
|
pointer to code/docs (where infra code goes, DB tech/target, layout to mirror, test commands, ...).
|
||||||
|
|
||||||
|
> `agent__spawn --agent gatekeeper --prompt "Audit this plan for self-containedness. Return
|
||||||
|
> SEALED/LEAKY. Plan: {{plans_dir}}/PLAN-<slug>.md. Target project: {{project_dir}}."`
|
||||||
|
|
||||||
|
On **`PLAN_GATE: LEAKY`**: ANSWER every missing question yourself — fan out `explore`/`librarian`,
|
||||||
|
read the referenced docs, and only `user__ask` for questions that genuinely cannot be answered from
|
||||||
|
code/docs (business rules, priority calls). Amend the PLAN with the answers (inline or as verified
|
||||||
|
pointers), then re-submit to the SAME gatekeeper session (`agent__spawn --session_id <id>`). Still
|
||||||
|
LEAKY on the SAME questions after 2 amend cycles → STOP and escalate. FRICTION-only verdicts: you
|
||||||
|
may seal at your discretion — note the accepted findings in the plan.
|
||||||
|
|
||||||
|
On **`PLAN_GATE: SEALED`**: proceed to Gate 2.
|
||||||
|
|
||||||
|
**Gate 2 — Executability (`oracle` + `plan-review`).** Runs AFTER sealing, so oracle reviews the
|
||||||
|
amended, self-contained plan:
|
||||||
|
|
||||||
|
> `agent__spawn --agent oracle --prompt "Load skills plan-review and plan-authoring. Review the
|
||||||
|
> plan at {{plans_dir}}/PLAN-<slug>.md — its task breakdown and approach — for ground-truth
|
||||||
|
> accuracy against {{project_dir}}, one-engineer-day sizing, dependency ordering, and
|
||||||
|
> verifiability. Return PLAN_REVIEW: OKAY or REJECT with line-referenced complaints."`
|
||||||
|
|
||||||
|
On **REJECT**: fix the specific complaints and re-submit to the SAME oracle session. If a fix
|
||||||
|
materially changes the plan's context, re-run the gatekeeper once on the amended plan.
|
||||||
|
On **OKAY**: set the PLAN's frontmatter `status: active` and proceed. (`plan-gate` autonomy:
|
||||||
|
present the SEALED+OKAY'd breakdown to the user here.)
|
||||||
|
|
||||||
|
Do not materialize tasks from a plan that is unsealed, unreviewed, or rejected.
|
||||||
|
|
||||||
|
### Phase D — Materialize tasks
|
||||||
|
|
||||||
|
Load `task-tracking`. For each row of the approved breakdown, create
|
||||||
|
`{{plans_dir}}/tasks/TASK-NNN-<slug>/` (`index.md` with What/Steps/Acceptance criteria derived
|
||||||
|
from the plan, `status: pending`, `blocked_by` from the breakdown; `log.md` with a `created`
|
||||||
|
entry). Numbering per the skill (scan max+1). Add one todo item per task, in dependency order.
|
||||||
|
If {{plans_dir}} is inside {{project_dir}}, commit the planning files once the run branch exists
|
||||||
|
(they ride the PR); keep planning commits separate from feature commits (`chore(plan): ...`).
|
||||||
|
|
||||||
|
### Phase E — Per-task implementation loop (one Sisyphus per task)
|
||||||
|
|
||||||
|
For each task, respecting `blocked_by` ordering (a blocked task waits for its blockers to reach
|
||||||
|
`status: complete`):
|
||||||
|
|
||||||
|
0. **Create the RUN BRANCH (once, before the FIRST task).** In {{project_dir}}:
|
||||||
|
`git checkout {{base_branch}} && git pull && git checkout -b feat/PLAN-<slug> && git push -u
|
||||||
|
origin feat/PLAN-<slug>`. Record the branch name in a todo item. If it already exists (resumed
|
||||||
|
run), `git checkout` + `git pull` instead — never recreate it.
|
||||||
|
|
||||||
|
1. **Claim it.** Per `task-tracking`: `status: in-progress`, log `started`. Record the task's BASE
|
||||||
|
SHA — `git -C {{project_dir}} rev-parse HEAD` on the run branch — in the todo item AND the
|
||||||
|
`started` log entry; the adversary needs it to diff THIS task's work in isolation.
|
||||||
|
|
||||||
|
2. **Delegate the CODE work to ONE Sisyphus.** Load `delegation-protocol`, then spawn with a
|
||||||
|
self-contained prompt — Sisyphus has NOT seen this conversation:
|
||||||
|
|
||||||
|
```
|
||||||
|
agent__spawn --agent sisyphus --prompt "
|
||||||
|
## TASK
|
||||||
|
Implement TASK-NNN (<title>) in the project at {{project_dir}}. This is one one-engineer-day
|
||||||
|
slice of PLAN-<slug>. ALL code you WRITE goes in {{project_dir}}. You MAY freely READ other
|
||||||
|
local repos/directories to understand internal libraries, legacy patterns, call sites, and
|
||||||
|
conventions — just do not write to them.
|
||||||
|
|
||||||
|
## SOURCE OF TRUTH
|
||||||
|
- Task file: {{plans_dir}}/tasks/TASK-NNN-<slug>/index.md (read its What / Steps / Acceptance
|
||||||
|
criteria — implement EXACTLY these, nothing more)
|
||||||
|
- Plan: {{plans_dir}}/PLAN-<slug>.md
|
||||||
|
- Conventions: the project's CLAUDE.md / AGENTS.md / CONTRIBUTING.md — READ BEFORE CODING.
|
||||||
|
|
||||||
|
## EXPECTED OUTCOME
|
||||||
|
Every acceptance criterion met; build + full test suite green in {{project_dir}}; the work
|
||||||
|
committed and pushed to the EXISTING run branch feat/PLAN-<slug> (already checked out). Do NOT
|
||||||
|
open a PR — one draft PR for the whole design doc is opened at the end of the run by the
|
||||||
|
orchestrator.
|
||||||
|
|
||||||
|
## MUST DO
|
||||||
|
- Work on the CURRENT branch (feat/PLAN-<slug>). git pull before starting.
|
||||||
|
- Match the project's existing patterns and conventions.
|
||||||
|
- Derive tests from the task's Acceptance criteria.
|
||||||
|
- Commit with messages referencing the task ID (e.g. "feat(TASK-NNN): ..."), push to the run
|
||||||
|
branch, and report the commit SHA(s).
|
||||||
|
- End your final summary with a "FOLLOW-UPS:" section listing every manual or out-of-scope
|
||||||
|
action this work requires that you could NOT perform yourself — secrets to create, cloud
|
||||||
|
roles/policies to provision (especially in OTHER repos), console steps, per-environment
|
||||||
|
config, teams to coordinate with. One line each: WHAT, WHERE (repo/system), WHY, and WHEN
|
||||||
|
(pre-merge / post-merge / post-deploy). Write "FOLLOW-UPS: none" if there are none. Do NOT
|
||||||
|
attempt these yourself and do NOT silently skip them.
|
||||||
|
|
||||||
|
## MUST NOT DO
|
||||||
|
- Do NOT open a PR. Do NOT create or switch branches. Do NOT merge or rebase onto {{base_branch}}.
|
||||||
|
- Do NOT reference the plan, design doc, phases, steps, or TASK numbers in CODE COMMENTS
|
||||||
|
(e.g. "// Phase 2 of PLAN-foo", "// per step 3", "// TASK-002"). Docs change over time, so
|
||||||
|
such comments rot into opaque noise. Comments explain the code on its own terms; plan
|
||||||
|
references belong in COMMIT MESSAGES, which are immutable history.
|
||||||
|
- NEVER commit a `.env` file to ANY repo. If the work needs env config, commit a `.env.example`
|
||||||
|
with placeholder keys (no real values) and ensure `.env` is gitignored. Provisioning the real
|
||||||
|
values is a FOLLOW-UPS item, not a commit.
|
||||||
|
- Do NOT implement other tasks' scope. Do NOT edit files under {{plans_dir}}.
|
||||||
|
- Do NOT write code outside {{project_dir}} (reading elsewhere is fine).
|
||||||
|
- Do NOT push to {{base_branch}}. Do NOT suppress errors or delete failing tests.
|
||||||
|
- Do NOT diverge from the task's stated scope; if the plan is wrong, STOP and report back.
|
||||||
|
|
||||||
|
## CONTEXT
|
||||||
|
<paste the task's index.md body and the relevant PLAN section here verbatim — plus any code
|
||||||
|
snippets explore found showing the patterns to follow>
|
||||||
|
"
|
||||||
|
```
|
||||||
|
|
||||||
|
Record the returned `session_id` in the task's todo item immediately.
|
||||||
|
|
||||||
|
3. **Wait for Sisyphus.** Do not poll `agent__collect` on a running agent — do non-overlapping work
|
||||||
|
(e.g. prep the next task's context) or end your response and wait for the completion
|
||||||
|
notification, then `agent__collect`.
|
||||||
|
|
||||||
|
4. **Verify against the plan (divergence check).** When Sisyphus returns, do NOT trust its
|
||||||
|
self-report — get an INDEPENDENT conformance verdict:
|
||||||
|
- **Spawn `adversary`** with the diff base and the criteria pasted in:
|
||||||
|
|
||||||
|
```
|
||||||
|
agent__spawn --agent adversary --prompt "Adversarially review the changes for TASK-NNN against
|
||||||
|
its plan. Return CONFORMS/DIVERGES.
|
||||||
|
|
||||||
|
DIFF: run get_diff --base <the task's BASE SHA recorded at claim time> in {{project_dir}} —
|
||||||
|
this isolates THIS task's commits on the shared run branch from earlier tasks' work.
|
||||||
|
|
||||||
|
PLAN — acceptance criteria to check against:
|
||||||
|
<paste the task index.md body + the relevant PLAN-<slug>.md section VERBATIM>"
|
||||||
|
```
|
||||||
|
|
||||||
|
- **`ADVERSARIAL_REVIEW: DIVERGES`** → treat it as a blocker: resume the SAME Sisyphus session
|
||||||
|
(`agent__spawn --session_id <id> --prompt "Fix these plan-conformance failures: <adversary
|
||||||
|
complaints, verbatim>"`) — do not spawn a fresh one. Re-run `adversary` ONCE after the fix to
|
||||||
|
confirm it now CONFORMS. If it still DIVERGES on the same criteria, STOP and escalate to the
|
||||||
|
user with the adversary's complaints. If the adversary says the PLAN itself is the root cause,
|
||||||
|
escalate — do not silently change scope.
|
||||||
|
- **`ADVERSARIAL_REVIEW: CONFORMS`** → conformance satisfied. Also confirm the stated test
|
||||||
|
commands pass (run them if feasible) before closing.
|
||||||
|
- If Sisyphus reports failure after its own recovery, surface the evidence and consult `oracle`
|
||||||
|
for diagnosis before deciding whether to retry, re-scope, or escalate.
|
||||||
|
|
||||||
|
5. **Close the task.** Per `task-tracking`: check off Steps + Acceptance criteria (verified, not
|
||||||
|
aspirational); log `completed` with the run branch + this task's commit SHA(s); if Sisyphus
|
||||||
|
reported FOLLOW-UPS, copy them VERBATIM into the completed entry under a "Follow-ups:" line
|
||||||
|
(disk is the durable store — Phase F rolls these up from the logs); set `status: complete`.
|
||||||
|
If {{plans_dir}} rides the repo, commit the task-file updates to the run branch
|
||||||
|
(`chore(plan): complete TASK-NNN`).
|
||||||
|
|
||||||
|
6. Mark the todo item `todo__done`. Move to the next task.
|
||||||
|
|
||||||
|
**Execution mode — parallel_tasks={{parallel_tasks}}.**
|
||||||
|
|
||||||
|
**Sequential mode (parallel_tasks=0, the DEFAULT).** Tasks run SEQUENTIALLY. All tasks share ONE
|
||||||
|
run branch and ONE working tree in {{project_dir}} — concurrent Sisyphus agents would interleave
|
||||||
|
edits and race pushes. Do NOT run code tasks in parallel. Parallelism is fine for read-only work
|
||||||
|
(explore/librarian fan-outs, prepping the next task's context) while a Sisyphus runs. Everything
|
||||||
|
in steps 0-6 above applies exactly as written.
|
||||||
|
|
||||||
|
### Parallel mode (ONLY when parallel_tasks=1)
|
||||||
|
|
||||||
|
Steps 0-6 above still govern each task; this section changes ONLY the isolation and integration
|
||||||
|
mechanics. When parallel_tasks=0, IGNORE this section entirely.
|
||||||
|
|
||||||
|
**Eligibility (ALL must hold to run a set of tasks concurrently):**
|
||||||
|
1. The tasks are mutually unblocked — no `blocked_by` edges between them.
|
||||||
|
2. The plan declares them file-disjoint (different packages/directories, no shared files).
|
||||||
|
3. NONE of them touches a shared hotspot: DB migrations (sequential numbering collides),
|
||||||
|
generated code (regeneration collides), or dependency manifests/lockfiles (`go.mod`,
|
||||||
|
`package.json`/lockfiles, `Cargo.toml`, ...). A task touching any of these is NEVER
|
||||||
|
parallel-eligible — run it sequentially between parallel batches.
|
||||||
|
4. Cap concurrent code tasks at 3. Ineligible or doubtful → sequential. When in doubt, sequential.
|
||||||
|
|
||||||
|
**Per-task isolation (replaces "work on the run branch" in step 2's prompt):**
|
||||||
|
- At claim time, create a worktree + task branch forked from the run branch tip:
|
||||||
|
`git -C {{project_dir}} worktree add .worktrees/task-NNN -b feat/PLAN-<slug>-task-NNN
|
||||||
|
feat/PLAN-<slug>`. The recorded BASE SHA (step 1) is the fork point.
|
||||||
|
- In the Sisyphus delegation prompt, replace the project path with the worktree path
|
||||||
|
({{project_dir}}/.worktrees/task-NNN) and the branch with the task branch. Sisyphus commits and
|
||||||
|
pushes the TASK branch. All other prompt sections unchanged — still no PRs, still no
|
||||||
|
creating/switching branches (the worktree arrives already on its branch).
|
||||||
|
- Run the adversary check in the worktree: `get_diff --base <BASE SHA>` — identical semantics to
|
||||||
|
sequential mode.
|
||||||
|
|
||||||
|
**Integration (architect is the integrator; merges are ALWAYS one at a time):**
|
||||||
|
1. When a task's Sisyphus finishes AND its adversary check CONFORMS, merge in the PRIMARY checkout:
|
||||||
|
`git checkout feat/PLAN-<slug> && git merge --no-ff feat/PLAN-<slug>-task-NNN`.
|
||||||
|
2. Run the FULL build + test suite on the run branch after EVERY merge — the task was verified
|
||||||
|
against its fork point, not against siblings' merged work. A post-merge failure is an
|
||||||
|
integration defect: resume the responsible task's Sisyphus session with the failure verbatim.
|
||||||
|
3. Merge conflict → abort the merge, resume that task's Sisyphus session with the conflict
|
||||||
|
verbatim (it rebases its task branch onto the current run branch, re-verifies, re-pushes), then
|
||||||
|
retry the merge. Two failed conflict cycles on the same task → STOP and escalate.
|
||||||
|
4. Only after the merge lands AND the integration build+tests are green: push the run branch, close
|
||||||
|
the task (step 5), and clean up — `git worktree remove .worktrees/task-NNN` and delete the task
|
||||||
|
branch (local + remote).
|
||||||
|
|
||||||
|
Phase F is UNCHANGED (same single draft PR from the run branch). Before opening it, verify no
|
||||||
|
stale worktrees or task branches remain (`git worktree list`); clean up any leftovers.
|
||||||
|
|
||||||
|
### Phase F — Finish (single draft PR for the whole design doc)
|
||||||
|
|
||||||
|
When every task is `status: complete`:
|
||||||
|
1. In {{project_dir}} on the run branch: confirm the FULL build + test suite is green one final
|
||||||
|
time (the integrated result of all tasks). Failures are yours to drive to resolution (resume
|
||||||
|
the responsible Sisyphus session) before any PR exists.
|
||||||
|
2. **Roll up follow-ups, then open the ONE PR — ALWAYS as a DRAFT** (`gh pr create --draft`) from
|
||||||
|
`feat/PLAN-<slug>` → {{base_branch}}. First collect every "Follow-ups:" line from the completed
|
||||||
|
tasks' `log.md` files. Title: `PLAN-<slug>: <design doc title>`. Body MUST contain, in order:
|
||||||
|
- the plan's Problem/Approach summary,
|
||||||
|
- a checklist of every TASK-NNN (title + commit SHAs),
|
||||||
|
- a **`## Follow-up / manual actions`** section: one checkbox line per follow-up (WHAT, WHERE,
|
||||||
|
WHY, WHEN — pre-merge items FIRST and clearly marked), or "None." if there are none. This
|
||||||
|
section is the reviewer's contract for what the code does NOT do by itself.
|
||||||
|
Report the PR URL. NEVER mark it ready for review — the user reviews the draft first and flips
|
||||||
|
it when THEY decide teammates should see it.
|
||||||
|
3. **Watch the PR checks until green.** Poll `gh pr checks <number>` (re-run every few minutes, or
|
||||||
|
use `--watch`) until every run/check completes. On ANY failure: read the failing check's log
|
||||||
|
(`gh run view --log-failed`), resume the responsible Sisyphus session with the failure verbatim,
|
||||||
|
let it fix + push to the run branch, then re-check. Repeat until all checks pass. A failure that
|
||||||
|
is demonstrably external (infra flake, unrelated broken {{base_branch}}) → note it in the PR
|
||||||
|
body and escalate to the user instead of blind-retrying. Do NOT finish the run with failing or
|
||||||
|
still-pending checks.
|
||||||
|
4. **Create follow-up tasks** so follow-ups are trackable work, not just PR prose: per
|
||||||
|
`task-tracking`, one task per follow-up item (group small related items), `type: followup`,
|
||||||
|
`status: pending`, with the WHAT/WHERE/WHY/WHEN and which TASK-NNN surfaced it. Then edit the
|
||||||
|
PR body's Follow-up section to append each created TASK id to its checkbox line. Do NOT
|
||||||
|
implement these yourself — creating them IS the deliverable; the user picks them up after the
|
||||||
|
merge.
|
||||||
|
5. Set `PLAN-<slug>.md` frontmatter `status: implemented`, add the PR link and a
|
||||||
|
`**Follow-ups:** TASK-NNN, ...` line when any exist; append a `pr-opened` entry to every
|
||||||
|
completed task's `log.md`. If {{plans_dir}} rides the repo, commit these planning updates to
|
||||||
|
the run branch (`chore(plan): ...`) — they become part of the PR.
|
||||||
|
6. Run the `task-tracking` consistency checks; fix anything you introduced.
|
||||||
|
7. Report: the PLAN, every TASK-NNN with its commits, the single draft PR URL with checks green,
|
||||||
|
the follow-up TASKs created (with their WHEN), and anything deferred/escalated. STOP.
|
||||||
|
|
||||||
|
## Durable state (survive context compression)
|
||||||
|
|
||||||
|
Long runs compress. Anything that lives ONLY in chat is lost. Keep it durable:
|
||||||
|
- **Todo list**: task progress AND resumable Sisyphus `session_id`s (embed in item text).
|
||||||
|
- **{{plans_dir}} on disk**: PLAN frontmatter, task `index.md` statuses, `log.md` entries ARE the
|
||||||
|
run state. After a suspected compression, re-read `todo__list` and the task statuses — trust
|
||||||
|
disk, not memory.
|
||||||
|
- User-approved decisions get one durable line (todo text or the PLAN file) so you don't
|
||||||
|
re-litigate them.
|
||||||
|
|
||||||
|
## Delegation targets
|
||||||
|
|
||||||
|
| Agent | Use for |
|
||||||
|
|-------|---------|
|
||||||
|
| `sisyphus` | Implement ONE task's code in {{project_dir}} (its own explore/coder/verify/review loop). One per task. |
|
||||||
|
| `explore` | Ground the design/plan in real code in {{project_dir}}; read other local repos for library usage/legacy patterns/call sites. Fan out in parallel. |
|
||||||
|
| `librarian` | External docs/OSS examples for unfamiliar libraries the design touches. |
|
||||||
|
| `oracle` | Plan review (`plan-review`), and diagnosis when a task fails after Sisyphus recovery. |
|
||||||
|
| `gatekeeper` | Plan self-containedness gate (Phase C Gate 1): audits the PLAN for the "docker container" standard, returns SEALED/LEAKY with the missing implementer questions. |
|
||||||
|
| `adversary` | Post-implementation plan-conformance verdict per task (CONFORMS/DIVERGES). |
|
||||||
|
|
||||||
|
## Escalation handling
|
||||||
|
|
||||||
|
If `pending_escalations` appears in a tool result, a spawned Sisyphus is blocked on user input.
|
||||||
|
Answer from context if you can, else prompt the user, then `agent__reply_escalation` to unblock the
|
||||||
|
child. Do not leave a child hanging.
|
||||||
|
|
||||||
|
## Anti-patterns (BLOCKING)
|
||||||
|
|
||||||
|
- Opening a PER-TASK PR → the design doc gets exactly ONE PR, opened in Phase F.
|
||||||
|
- Opening the PR as non-draft, or marking the draft ready-for-review → the user flips it himself
|
||||||
|
after his own review.
|
||||||
|
- Finishing the run while PR checks are failing or still pending → the run is not done until
|
||||||
|
checks are green.
|
||||||
|
- Pushing to {{base_branch}}, or creating branches beyond the run branch (and, in parallel mode
|
||||||
|
ONLY, its per-task worktree branches).
|
||||||
|
- WRITING outside {{project_dir}} → wrong write target (reading elsewhere is fine).
|
||||||
|
- Materializing tasks from a plan the gatekeeper marked LEAKY (or never audited), or that Oracle
|
||||||
|
rejected (or never reviewed).
|
||||||
|
- Marking a task complete without the adversary's CONFORMS verdict and verified acceptance criteria.
|
||||||
|
- Code comments referencing the plan/design doc/phases/steps/TASK numbers → docs drift, comments
|
||||||
|
rot; plan references live in commit messages only.
|
||||||
|
- A `.env` file landing in any repo → only `.env.example` with placeholder keys is committable;
|
||||||
|
`.env` stays gitignored and real values are a follow-up.
|
||||||
|
- Dropping a Sisyphus-reported follow-up (not logged in the task's log.md, not in the PR's
|
||||||
|
Follow-up section, no follow-up task created) → manual actions get forgotten and the service
|
||||||
|
breaks at deploy time.
|
||||||
|
- Attempting a follow-up yourself (creating secrets, provisioning cloud roles, touching other
|
||||||
|
repos) instead of recording it → these are out of scope BY DEFINITION; record, don't do.
|
||||||
|
- Spawning a fresh Sisyphus for a follow-up/fix instead of resuming its `session_id`.
|
||||||
|
- Polling `agent__collect` on a running agent.
|
||||||
|
- Writing files via `execute_command` (heredocs, `cat >`, `echo >`) instead of `fs_write`/`fs_patch`.
|
||||||
|
- Losing a Sisyphus `session_id` or a follow-up to chat-only memory.
|
||||||
|
|
||||||
|
## Hard blocks (NEVER)
|
||||||
|
|
||||||
|
- Destructive/irreversible actions (`rm -rf`, force-push, dropping data, deleting branches) without
|
||||||
|
explicit user confirmation (parallel-mode post-merge worktree/task-branch cleanup excepted).
|
||||||
|
- Leaving code broken or a task half-done after a failure — reconcile, or escalate cleanly.
|
||||||
|
- Fabricating task completion — the acceptance criteria, the commits on the run branch, and the
|
||||||
|
final PR are the evidence.
|
||||||
|
|
||||||
|
## Available Tools
|
||||||
|
{{__tools__}}
|
||||||
|
|
||||||
|
## Context
|
||||||
|
- Project (WRITE target): {{project_dir}}
|
||||||
|
- Plans dir: {{plans_dir}}
|
||||||
|
- Design doc: {{design_doc}}
|
||||||
|
- Base branch: {{base_branch}}
|
||||||
|
- Autonomy: {{autonomy}}
|
||||||
|
- Parallel tasks: {{parallel_tasks}} (0 = sequential, 1 = worktree-parallel)
|
||||||
|
- OS: {{__os__}} Shell: {{__shell__}} CWD: {{__cwd__}} Now: {{__now__}}
|
||||||
|
|
||||||
|
conversation_starters:
|
||||||
|
- 'Implement the design doc at {{design_doc}} end to end'
|
||||||
|
- 'Decompose this design doc into a plan and tasks, then drive them to completion'
|
||||||
|
- 'Run the full design-to-PR pipeline on {{design_doc}}'
|
||||||
@@ -16,7 +16,7 @@ agents while handling coordination and final reporting.
|
|||||||
## Pro-Tip: Use an IDE MCP Server for Improved Performance
|
## Pro-Tip: Use an IDE MCP Server for Improved Performance
|
||||||
Many modern IDEs now include MCP servers that let LLMs perform operations within the IDE itself and use IDE tools. Using
|
Many modern IDEs now include MCP servers that let LLMs perform operations within the IDE itself and use IDE tools. Using
|
||||||
an IDE's MCP server dramatically improves the performance of coding agents. So if you have an IDE, try adding that MCP
|
an IDE's MCP server dramatically improves the performance of coding agents. So if you have an IDE, try adding that MCP
|
||||||
server to your config (see the [MCP Server docs](../../../docs/function-calling/MCP-SERVERS.md) to see how to configure
|
server to your config (see the [MCP Server docs](https://github.com/Dark-Alex-17/coyote/wiki/MCP-Servers) to see how to configure
|
||||||
them), and modify the agent definition to look like this:
|
them), and modify the agent definition to look like this:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
@@ -19,8 +19,12 @@ variables:
|
|||||||
- name: project_dir
|
- name: project_dir
|
||||||
description: Project directory to review
|
description: Project directory to review
|
||||||
default: '.'
|
default: '.'
|
||||||
|
- name: auto_confirm
|
||||||
|
description: Auto-confirm command execution
|
||||||
|
default: '1'
|
||||||
|
|
||||||
global_tools:
|
global_tools:
|
||||||
|
- ast_grep.sh
|
||||||
- fs_read.sh
|
- fs_read.sh
|
||||||
- fs_cat.sh
|
- fs_cat.sh
|
||||||
- fs_grep.sh
|
- fs_grep.sh
|
||||||
@@ -158,6 +162,6 @@ instructions: |
|
|||||||
- Project: {{project_dir}}
|
- Project: {{project_dir}}
|
||||||
- CWD: {{__cwd__}}
|
- CWD: {{__cwd__}}
|
||||||
- Shell: {{__shell__}}
|
- Shell: {{__shell__}}
|
||||||
|
|
||||||
## Available Tools:
|
## Available Tools:
|
||||||
{{__tools__}}
|
{{__tools__}}
|
||||||
|
|||||||
@@ -10,22 +10,30 @@ implement-fix loop enforced as graph edges rather than prose.
|
|||||||
|
|
||||||
## Workflow
|
## Workflow
|
||||||
|
|
||||||
```
|
```mermaid
|
||||||
analyze_request (llm + output_schema) plan + complexity extraction
|
flowchart TD
|
||||||
↓
|
resolve_paths{"resolve_paths<br/>script"} --> analyze_request
|
||||||
route_complexity (script) opt-out approval gate (complexity ≥ 7)
|
analyze_request["analyze_request<br/>llm + output_schema"] --> route_complexity
|
||||||
↓
|
route_complexity{"route_complexity<br/>script"}
|
||||||
gate_approval (approval, optional)
|
route_complexity -->|"complexity ≥ 7"| gate_approval
|
||||||
↓
|
route_complexity -->|else| implement
|
||||||
implement (llm + fs tools) actual file edits
|
gate_approval{{"gate_approval<br/>approval"}}
|
||||||
↓
|
gate_approval -->|yes| implement
|
||||||
verify_build (script)
|
gate_approval -->|no| end_rejected
|
||||||
↓
|
implement["implement<br/>llm + fs tools"] --> verify_build
|
||||||
verify_tests (script)
|
verify_build{"verify_build<br/>script"}
|
||||||
↓
|
verify_build -->|pass| verify_tests
|
||||||
fix_loop_gate (script) back-edge to implement (bounded)
|
verify_build -->|fail| fix_loop_gate
|
||||||
↓
|
verify_tests{"verify_tests<br/>script"}
|
||||||
end_success / end_rejected / end_failure
|
verify_tests -->|pass| end_success
|
||||||
|
verify_tests -->|fail| fix_loop_gate
|
||||||
|
fix_loop_gate{"fix_loop_gate<br/>script"}
|
||||||
|
fix_loop_gate -->|"budget left"| implement
|
||||||
|
fix_loop_gate -->|"budget spent"| end_failure
|
||||||
|
|
||||||
|
end_success(["end_success<br/>CODER_COMPLETE"])
|
||||||
|
end_rejected(["end_rejected<br/>CODER_REJECTED"])
|
||||||
|
end_failure(["end_failure<br/>CODER_FAILED"])
|
||||||
```
|
```
|
||||||
|
|
||||||
End nodes emit one of three sentinel outcomes for the caller:
|
End nodes emit one of three sentinel outcomes for the caller:
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ name: coder
|
|||||||
description: |
|
description: |
|
||||||
Implementation agent. Plans, implements, and runs build + tests in a
|
Implementation agent. Plans, implements, and runs build + tests in a
|
||||||
bounded fix-loop until verified. Designed to be delegated to by sisyphus.
|
bounded fix-loop until verified. Designed to be delegated to by sisyphus.
|
||||||
version: "1.0"
|
version: '1.0'
|
||||||
|
|
||||||
global_tools:
|
global_tools:
|
||||||
|
- ast_grep.sh
|
||||||
- fs_cat.sh
|
- fs_cat.sh
|
||||||
- fs_ls.sh
|
- fs_ls.sh
|
||||||
- fs_write.sh
|
- fs_write.sh
|
||||||
@@ -25,7 +25,7 @@ variables:
|
|||||||
Absolute path to the project directory. Defaults to "." which is the
|
Absolute path to the project directory. Defaults to "." which is the
|
||||||
directory you invoked `coyote` from. Override at runtime with
|
directory you invoked `coyote` from. Override at runtime with
|
||||||
`coyote -a coder --agent-variable project_dir /abs/path "..."`.
|
`coyote -a coder --agent-variable project_dir /abs/path "..."`.
|
||||||
default: "."
|
default: '.'
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
max_loop_iterations: 20
|
max_loop_iterations: 20
|
||||||
@@ -34,14 +34,14 @@ settings:
|
|||||||
timeout: 1800
|
timeout: 1800
|
||||||
|
|
||||||
initial_state:
|
initial_state:
|
||||||
project_dir: ""
|
project_dir: ''
|
||||||
fix_attempts: 0
|
fix_attempts: 0
|
||||||
max_fix_attempts: 3
|
max_fix_attempts: 3
|
||||||
fix_instructions: ""
|
fix_instructions: ''
|
||||||
build_output: ""
|
build_output: ''
|
||||||
tests_output: ""
|
tests_output: ''
|
||||||
last_node_output: ""
|
last_node_output: ''
|
||||||
plan_summary: ""
|
plan_summary: ''
|
||||||
files_to_modify: []
|
files_to_modify: []
|
||||||
files_to_create: []
|
files_to_create: []
|
||||||
risks: []
|
risks: []
|
||||||
@@ -49,7 +49,7 @@ initial_state:
|
|||||||
review_attempts: 0
|
review_attempts: 0
|
||||||
max_review_attempts: 1
|
max_review_attempts: 1
|
||||||
review_clean: true
|
review_clean: true
|
||||||
review_notes: ""
|
review_notes: ''
|
||||||
|
|
||||||
start: resolve_paths
|
start: resolve_paths
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ nodes:
|
|||||||
etc. Empty list is fine.
|
etc. Empty list is fine.
|
||||||
|
|
||||||
Project directory: {{project_dir}}
|
Project directory: {{project_dir}}
|
||||||
prompt: "{{initial_prompt}}"
|
prompt: '{{initial_prompt}}'
|
||||||
tools: []
|
tools: []
|
||||||
output_schema:
|
output_schema:
|
||||||
type: object
|
type: object
|
||||||
@@ -98,20 +98,27 @@ nodes:
|
|||||||
description: 1-3 sentences summarizing what will be done
|
description: 1-3 sentences summarizing what will be done
|
||||||
files_to_modify:
|
files_to_modify:
|
||||||
type: array
|
type: array
|
||||||
items: {type: string}
|
items: { type: string }
|
||||||
files_to_create:
|
files_to_create:
|
||||||
type: array
|
type: array
|
||||||
items: {type: string}
|
items: { type: string }
|
||||||
complexity_score:
|
complexity_score:
|
||||||
type: integer
|
type: integer
|
||||||
minimum: 1
|
minimum: 1
|
||||||
maximum: 10
|
maximum: 10
|
||||||
risks:
|
risks:
|
||||||
type: array
|
type: array
|
||||||
items: {type: string}
|
items: { type: string }
|
||||||
required: [plan_summary, files_to_modify, files_to_create, complexity_score, risks]
|
required:
|
||||||
|
[
|
||||||
|
plan_summary,
|
||||||
|
files_to_modify,
|
||||||
|
files_to_create,
|
||||||
|
complexity_score,
|
||||||
|
risks,
|
||||||
|
]
|
||||||
state_updates:
|
state_updates:
|
||||||
last_node_output: "{{output}}"
|
last_node_output: '{{output}}'
|
||||||
fallback: end_failure
|
fallback: end_failure
|
||||||
next: route_complexity
|
next: route_complexity
|
||||||
|
|
||||||
@@ -144,11 +151,11 @@ nodes:
|
|||||||
|
|
||||||
Approve this plan?
|
Approve this plan?
|
||||||
options:
|
options:
|
||||||
- "yes"
|
- 'yes'
|
||||||
- "no"
|
- 'no'
|
||||||
routes:
|
routes:
|
||||||
"yes": implement
|
'yes': implement
|
||||||
"no": end_rejected
|
'no': end_rejected
|
||||||
on_other: end_rejected
|
on_other: end_rejected
|
||||||
|
|
||||||
implement:
|
implement:
|
||||||
@@ -243,7 +250,7 @@ nodes:
|
|||||||
- execute_command
|
- execute_command
|
||||||
max_iterations: 30
|
max_iterations: 30
|
||||||
state_updates:
|
state_updates:
|
||||||
last_node_output: "{{output}}"
|
last_node_output: '{{output}}'
|
||||||
fallback: end_failure
|
fallback: end_failure
|
||||||
next: verify_build
|
next: verify_build
|
||||||
|
|
||||||
@@ -326,7 +333,7 @@ nodes:
|
|||||||
description: Concrete issues found, one per line as file:line - description. Empty when review_clean is true.
|
description: Concrete issues found, one per line as file:line - description. Empty when review_clean is true.
|
||||||
required: [review_clean, review_notes]
|
required: [review_clean, review_notes]
|
||||||
state_updates:
|
state_updates:
|
||||||
last_node_output: "{{output}}"
|
last_node_output: '{{output}}'
|
||||||
fallback: end_success
|
fallback: end_success
|
||||||
next: route_review_result
|
next: route_review_result
|
||||||
|
|
||||||
|
|||||||
@@ -22,28 +22,43 @@ agent, this is the file to read alongside the
|
|||||||
|
|
||||||
## Workflow
|
## Workflow
|
||||||
|
|
||||||
17 nodes. `->` is the static route; a script node can also route
|
17 nodes. Solid arrows are static `next` / `routes` edges declared in
|
||||||
dynamically via `_next`. The `▶▶` line is a parallel super-step —
|
`graph.yaml`; script nodes can also route dynamically via `_next` (shown as
|
||||||
those branches run concurrently:
|
labeled branches out of the diamond). Dotted arrows show `map` fan-out — the
|
||||||
|
`research_each_question` node spawns one `research_one_question` branch per
|
||||||
|
sub-question and joins them before continuing.
|
||||||
|
|
||||||
```
|
```mermaid
|
||||||
parse_request (script) -> bootstrap_research (or -> ask_topic if no topic)
|
flowchart TD
|
||||||
ask_topic (input) -> bootstrap_research
|
parse_request{"parse_request<br/>script"}
|
||||||
bootstrap_research (script) -> [plan, knowledge_lookup] ▶▶ parallel
|
parse_request -->|"topic given"| bootstrap_research
|
||||||
plan (llm + output_schema) -> research_each_question
|
parse_request -->|"no topic"| ask_topic
|
||||||
knowledge_lookup (rag) -> research_each_question
|
ask_topic[/"ask_topic<br/>input"/] --> bootstrap_research
|
||||||
research_each_question (map) -> combine_findings (spawns one branch per question)
|
bootstrap_research{"bootstrap_research<br/>script"}
|
||||||
└─ research_one_question (llm) (atomic; runs N×, joins at map)
|
bootstrap_research --> plan
|
||||||
combine_findings (script) -> vet_sources
|
bootstrap_research --> knowledge_lookup
|
||||||
vet_sources (llm + custom tool) -> critique
|
plan["plan<br/>llm + output_schema"] --> research_each_question
|
||||||
critique (llm) -> reflexion_gate
|
knowledge_lookup[("knowledge_lookup<br/>rag")] --> research_each_question
|
||||||
reflexion_gate (script) -> synthesize (or -> research_each_question: reflexion loop)
|
research_each_question[\research_each_question<br/>map/]
|
||||||
synthesize (agent: report-writer) -> verify_sources
|
research_each_question -. "spawns × N" .-> research_one_question["research_one_question<br/>llm + web tools"]
|
||||||
verify_sources (script) -> approve
|
research_each_question --> combine_findings
|
||||||
approve (approval) -> end_accepted ("accept")
|
combine_findings{"combine_findings<br/>script"} --> vet_sources
|
||||||
-> end_rejected ("reject")
|
vet_sources["vet_sources<br/>llm + classify_source"] --> critique
|
||||||
-> incorporate_feedback (any free-form answer)
|
critique["critique<br/>llm"] --> reflexion_gate
|
||||||
incorporate_feedback (script) -> research_each_question (the human-feedback loop)
|
reflexion_gate{"reflexion_gate<br/>script"}
|
||||||
|
reflexion_gate -->|"PASS"| synthesize
|
||||||
|
reflexion_gate -->|"REVISE (budget left)"| research_each_question
|
||||||
|
reflexion_gate -->|"REVISE (budget spent)"| synthesize
|
||||||
|
synthesize[["synthesize<br/>agent → report-writer"]] --> verify_sources
|
||||||
|
verify_sources{"verify_sources<br/>script"} --> approve
|
||||||
|
approve{{"approve<br/>approval"}}
|
||||||
|
approve -->|"accept"| end_accepted
|
||||||
|
approve -->|"reject"| end_rejected
|
||||||
|
approve -->|"other (free-form feedback)"| incorporate_feedback
|
||||||
|
incorporate_feedback{"incorporate_feedback<br/>script"} --> research_each_question
|
||||||
|
|
||||||
|
end_accepted(["end_accepted<br/>report"])
|
||||||
|
end_rejected(["end_rejected"])
|
||||||
```
|
```
|
||||||
|
|
||||||
### Node-type breakdown
|
### Node-type breakdown
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: explore
|
name: explore
|
||||||
description: Fast codebase exploration agent - finds patterns, structures, and relevant files. Designed to be fanned out 2-5 in parallel by orchestrators.
|
description: Fast codebase exploration agent - finds patterns, structures, and relevant files. Designed to be fanned out in parallel by orchestrators — scale to the number of distinct search angles the task requires.
|
||||||
version: 3.1.0
|
version: 3.1.0
|
||||||
|
|
||||||
skills_enabled: true
|
skills_enabled: true
|
||||||
@@ -10,16 +10,19 @@ variables:
|
|||||||
- name: project_dir
|
- name: project_dir
|
||||||
description: Project directory to explore
|
description: Project directory to explore
|
||||||
default: '.'
|
default: '.'
|
||||||
|
- name: auto_confirm
|
||||||
|
description: Auto-confirm command execution
|
||||||
|
default: '1'
|
||||||
|
|
||||||
mcp_servers:
|
mcp_servers:
|
||||||
- ddg-search
|
- ddg-search
|
||||||
global_tools:
|
global_tools:
|
||||||
|
- ast_grep.sh
|
||||||
- fs_read.sh
|
- fs_read.sh
|
||||||
- fs_cat.sh
|
- fs_cat.sh
|
||||||
- fs_grep.sh
|
- fs_grep.sh
|
||||||
- fs_glob.sh
|
- fs_glob.sh
|
||||||
- fs_ls.sh
|
- fs_ls.sh
|
||||||
- ast_grep.sh
|
|
||||||
|
|
||||||
instructions: |
|
instructions: |
|
||||||
You are a codebase explorer. Your job: Search, find, report. Nothing else.
|
You are a codebase explorer. Your job: Search, find, report. Nothing else.
|
||||||
@@ -34,7 +37,7 @@ instructions: |
|
|||||||
|
|
||||||
## You may be one of many parallel explorers
|
## You may be one of many parallel explorers
|
||||||
|
|
||||||
Orchestrators (like Sisyphus) often fan out 2-5 explore agents at once, each covering a different angle of the same question. Assume you are ONE narrow slice of a larger investigation. Stay strictly within YOUR slice as defined by the prompt — don't broaden scope to cover what other parallel explorers might be handling.
|
Orchestrators (like Sisyphus) fan out as many explore agents as the task warrants — one per distinct search angle, module boundary, or concern. You may be one of many running in parallel. Assume you are ONE narrow slice of a larger investigation. Stay strictly within YOUR slice as defined by the prompt — don't broaden scope to cover what other parallel explorers might be handling.
|
||||||
|
|
||||||
If the prompt says "find auth middleware", you find auth middleware. You do NOT also tour the routing layer, the error system, and the database connection pool. Narrow scope is the contract.
|
If the prompt says "find auth middleware", you find auth middleware. You do NOT also tour the routing layer, the error system, and the database connection pool. Narrow scope is the contract.
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ one file while communicating with sibling agents to catch issues that span multi
|
|||||||
## Pro-Tip: Use an IDE MCP Server for Improved Performance
|
## Pro-Tip: Use an IDE MCP Server for Improved Performance
|
||||||
Many modern IDEs now include MCP servers that let LLMs perform operations within the IDE itself and use IDE tools. Using
|
Many modern IDEs now include MCP servers that let LLMs perform operations within the IDE itself and use IDE tools. Using
|
||||||
an IDE's MCP server dramatically improves the performance of coding agents. So if you have an IDE, try adding that MCP
|
an IDE's MCP server dramatically improves the performance of coding agents. So if you have an IDE, try adding that MCP
|
||||||
server to your config (see the [MCP Server docs](../../../docs/function-calling/MCP-SERVERS.md) to see how to configure
|
server to your config (see the [MCP Server docs](https://github.com/Dark-Alex-17/coyote/wiki/MCP-Servers) to see how to configure
|
||||||
them), and modify the agent definition to look like this:
|
them), and modify the agent definition to look like this:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ variables:
|
|||||||
- name: project_dir
|
- name: project_dir
|
||||||
description: Project directory for context
|
description: Project directory for context
|
||||||
default: '.'
|
default: '.'
|
||||||
|
- name: auto_confirm
|
||||||
|
description: Auto-confirm command execution
|
||||||
|
default: '1'
|
||||||
|
|
||||||
global_tools:
|
global_tools:
|
||||||
- fs_read.sh
|
- fs_read.sh
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
# Gatekeeper
|
||||||
|
|
||||||
|
A **plan self-containedness gate**. Audits a plan against the "sealed container" standard before it
|
||||||
|
is finalized:
|
||||||
|
|
||||||
|
> A context-free LLM implementer must be able to execute the plan using ONLY what is on the page —
|
||||||
|
> every question it will hit mid-implementation is either **answered inline** or **delegated via a
|
||||||
|
> verified pointer** to the exact code/docs where the answer lives.
|
||||||
|
|
||||||
|
Where [`plan-review`](../../skills/plan-review/SKILL.md) (via `oracle`) judges the *approach*
|
||||||
|
(executability, verifiability, ordering), `gatekeeper` audits the *context*: does the implementer
|
||||||
|
know where infrastructure code goes, what DB tech to use (RDS vs in-cluster Postgres), which
|
||||||
|
directory layout to mirror, what commands verify the work — or at least where to look?
|
||||||
|
|
||||||
|
## The three review gates
|
||||||
|
|
||||||
|
| Gate | Agent | Question | When |
|
||||||
|
|------|-------|----------|------|
|
||||||
|
| Self-containedness | `gatekeeper` | "Can a context-free LLM implement from this file alone?" | Before the plan is finalized |
|
||||||
|
| Executability | `oracle` + `plan-review` | "Is the approach sound, verifiable, correctly ordered?" | Before the plan is promoted |
|
||||||
|
| Conformance | [`adversary`](../adversary/README.md) | "Is the built code what the plan asked for?" | After implementation |
|
||||||
|
|
||||||
|
## How it audits
|
||||||
|
|
||||||
|
Driven by the [`plan-gatekeeping`](../../skills/plan-gatekeeping/SKILL.md) skill:
|
||||||
|
|
||||||
|
1. Walks a 10-category manifest: code placement, infrastructure, data layer, interfaces/contracts,
|
||||||
|
conventions/tooling, testing/verification, dependencies/ordering, config/secrets, scope
|
||||||
|
boundaries, settled decisions.
|
||||||
|
2. For each category: answered inline, delegated via pointer, or **missing**.
|
||||||
|
3. **Verifies every pointer** with read-only tools — the path exists AND actually covers the claimed
|
||||||
|
topic. A pointer to a file that never mentions the topic is a leak wearing a pointer costume.
|
||||||
|
4. Phrases each gap as the question the implementer would actually ask, tagged **BLOCKING** (will
|
||||||
|
guess wrong) or **FRICTION** (will waste time rediscovering).
|
||||||
|
|
||||||
|
## Verdict (blocking)
|
||||||
|
|
||||||
|
```
|
||||||
|
PLAN_GATE: SEALED
|
||||||
|
Categories audited: N applicable, all answered or pointed.
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
PLAN_GATE: LEAKY
|
||||||
|
Missing questions (N):
|
||||||
|
1. [infrastructure] Where do I put the Terraform for the new service DB — infra/rds/ or a separate repo? — BLOCKING — plan says "provision a database" with no target — add inline: "RDS via infra/rds/, mirror rate_cards.tf"
|
||||||
|
Broken pointers (if any):
|
||||||
|
- "see docs/db.md for conventions" — path missing
|
||||||
|
```
|
||||||
|
|
||||||
|
`LEAKY` blocks finalization. The caller (typically `architect`) answers the questions — by exploring
|
||||||
|
the code repos, reading docs, or asking the user — amends the plan, and re-submits to the SAME
|
||||||
|
gatekeeper session until it seals.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Spawned by `architect` during design-doc decomposition (Phase B/C), before the `oracle` plan-review:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
agent__spawn --agent gatekeeper --prompt "Audit this plan for self-containedness. Return SEALED/LEAKY.
|
||||||
|
|
||||||
|
Plan: <plans_dir>/PLAN-<slug>.md
|
||||||
|
Target project: <project_dir>"
|
||||||
|
```
|
||||||
|
|
||||||
|
Ad-hoc use against any plan file:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
coyote -a gatekeeper --agent-variable project_dir ~/code/my-service \
|
||||||
|
"Audit plans/PLAN-my-feature.md for self-containedness"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
- [`plan-gatekeeping`](../../skills/plan-gatekeeping/SKILL.md) — the manifest + methodology it runs on.
|
||||||
|
- [`architect`](../architect/README.md) — the orchestrator that gates plans through it.
|
||||||
|
- [`adversary`](../adversary/README.md) — the post-implementation conformance counterpart.
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
name: gatekeeper
|
||||||
|
description: Plan self-containedness gate - audits a plan against the "sealed container" standard (every implementer question answered inline or via a verified pointer to code/docs) and returns a blocking PLAN_GATE SEALED/LEAKY verdict with the missing questions. Designed to be delegated to by architect before plans are finalized.
|
||||||
|
version: 2.0.0
|
||||||
|
|
||||||
|
auto_continue: true
|
||||||
|
max_auto_continues: 15
|
||||||
|
inject_todo_instructions: true
|
||||||
|
|
||||||
|
skills_enabled: true
|
||||||
|
enabled_skills:
|
||||||
|
- plan-gatekeeping
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- name: project_dir
|
||||||
|
description: Absolute path to the project the plan targets - the ground truth for pointer verification
|
||||||
|
default: '.'
|
||||||
|
|
||||||
|
global_tools:
|
||||||
|
- ast_grep.sh
|
||||||
|
- fs_read.sh
|
||||||
|
- fs_cat.sh
|
||||||
|
- fs_grep.sh
|
||||||
|
- fs_glob.sh
|
||||||
|
- fs_ls.sh
|
||||||
|
|
||||||
|
instructions: |
|
||||||
|
You are the plan gatekeeper. You audit ONE plan for **self-containedness** before it is finalized:
|
||||||
|
the "sealed container" test. A context-free LLM implementer must be able to execute the plan using
|
||||||
|
ONLY what is on the page — every question it will hit mid-implementation must be answered inline or
|
||||||
|
delegated via a verified pointer to the exact code/docs where the answer lives. Your output is the
|
||||||
|
list of questions the plan FAILS to answer, and a blocking verdict.
|
||||||
|
|
||||||
|
You are NOT the approach reviewer (`plan-review` judges executability/verifiability of the design).
|
||||||
|
You audit completeness of CONTEXT. A brilliant approach with no answer to "where does the infra
|
||||||
|
code go?" or "managed RDS or an in-cluster Postgres container?" fails your gate.
|
||||||
|
|
||||||
|
## Step 0: Load the skill
|
||||||
|
|
||||||
|
Before anything else, `skill__load` `plan-gatekeeping`. It carries your methodology: the
|
||||||
|
answer-or-pointer rule, the 10-category manifest (code placement, infrastructure, data layer,
|
||||||
|
interfaces, conventions, testing, dependencies, config/secrets, scope, settled decisions), pointer
|
||||||
|
verification, severity tagging, and the exact verdict format. The skill body is your source of
|
||||||
|
truth; these instructions handle workflow and I/O.
|
||||||
|
|
||||||
|
## Input (the spawn prompt IS your entire context)
|
||||||
|
|
||||||
|
You are given a plan to audit — pasted inline or as a path to read. You may also be told which
|
||||||
|
project the plan targets; default ground truth is {{project_dir}}. Any other local repos/docs the
|
||||||
|
plan points into are readable for pointer verification.
|
||||||
|
|
||||||
|
If no plan is provided, STOP and say so.
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
|
||||||
|
1. Load `plan-gatekeeping`.
|
||||||
|
2. Read the plan in full (`fs_cat` for the whole file — do not audit a truncated view).
|
||||||
|
3. Walk EVERY manifest category. For each: answered inline, delegated via pointer, or MISSING.
|
||||||
|
Mark inapplicable categories explicitly.
|
||||||
|
4. Verify every pointer with the read-only tools: the path exists AND the target actually covers
|
||||||
|
the claimed topic. Check "mirror the layout of X" claims against X itself.
|
||||||
|
5. Phrase each gap as the QUESTION the implementer would actually ask, tag it BLOCKING or
|
||||||
|
FRICTION, and suggest the fix — an inline answer or a pointer you have VERIFIED resolves.
|
||||||
|
6. Emit the verdict in the skill's exact format.
|
||||||
|
|
||||||
|
## Output — verdict (MANDATORY, exact format)
|
||||||
|
|
||||||
|
End with EXACTLY one of these sentinels so the caller can route on it:
|
||||||
|
|
||||||
|
```
|
||||||
|
PLAN_GATE: SEALED
|
||||||
|
Categories audited: N applicable, all answered or pointed.
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
PLAN_GATE: LEAKY
|
||||||
|
Missing questions (N):
|
||||||
|
1. [category] <implementer's actual question> — [BLOCKING|FRICTION] — <why they get stuck> — <suggested fix>
|
||||||
|
Broken pointers (if any):
|
||||||
|
- <pointer> — <path missing | doesn't cover topic>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Rules
|
||||||
|
|
||||||
|
1. **You are read-only.** Never modify the plan. You produce questions; the author owns the fixes.
|
||||||
|
2. **Questions, not complaints.** "Infra section is thin" is noise. "Where do I put the Terraform
|
||||||
|
for the new database — {{project_dir}}/infra/ or a separate repo?" is signal.
|
||||||
|
3. **Verify every pointer you check AND every pointer you suggest.** Recommending an unverified
|
||||||
|
pointer is the same leak you exist to catch.
|
||||||
|
4. **BLOCKING findings always mean LEAKY.** Only-FRICTION findings: note the caller may seal at
|
||||||
|
their discretion.
|
||||||
|
5. **Do not re-litigate the approach.** Coherent-but-underdocumented means the fix is context.
|
||||||
|
6. Be terse and decisive. Three BLOCKING questions beat fifteen nitpicks.
|
||||||
|
|
||||||
|
## Context
|
||||||
|
- Project (ground truth): {{project_dir}}
|
||||||
|
- CWD: {{__cwd__}}
|
||||||
|
|
||||||
|
## Available Tools
|
||||||
|
{{__tools__}}
|
||||||
@@ -10,13 +10,26 @@ library, API, or framework is involved.
|
|||||||
|
|
||||||
## Workflow
|
## Workflow
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart TD
|
||||||
|
triage["triage<br/>llm"] --> search
|
||||||
|
triage --> search_oss
|
||||||
|
triage -.->|"fallback"| end_failure
|
||||||
|
search["search<br/>llm + ddg-search MCP"] --> synthesize
|
||||||
|
search_oss["search_oss<br/>llm + personal-github MCP"] --> synthesize
|
||||||
|
synthesize["synthesize<br/>llm + fetch_url_via_curl"] --> final_format
|
||||||
|
final_format{"final_format<br/>script"} --> end_success
|
||||||
|
|
||||||
|
end_success(["end_success<br/>LIBRARIAN_COMPLETE"])
|
||||||
|
end_failure(["end_failure<br/>LIBRARIAN_FAILED"])
|
||||||
```
|
```
|
||||||
search (llm + ddg-search) identify 3-5 authoritative sources
|
|
||||||
↓
|
`triage` parses the prompt into language / doc-domain / query hints, then fans
|
||||||
synthesize (llm + fetch_url_via_curl) fetch, extract, cite, synthesize
|
out to `search` (authoritative docs via `ddg-search`) and `search_oss`
|
||||||
↓
|
(production OSS examples via the `personal-github` MCP) in parallel. Both feed
|
||||||
end_success / end_failure LIBRARIAN_COMPLETE / LIBRARIAN_FAILED
|
into `synthesize`, which fetches each URL and produces a citation-backed
|
||||||
```
|
findings block. `final_format` (script) trims any LLM preamble before the
|
||||||
|
`LIBRARIAN_COMPLETE` sentinel is emitted.
|
||||||
|
|
||||||
Iteration 1 (this) is the happy-path MVP: single search pass, single synthesis
|
Iteration 1 (this) is the happy-path MVP: single search pass, single synthesis
|
||||||
pass, no quality-check loop. Future iterations may add:
|
pass, no quality-check loop. Future iterations may add:
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ description: |
|
|||||||
sisyphus alongside explore when unfamiliar libraries/APIs/frameworks are
|
sisyphus alongside explore when unfamiliar libraries/APIs/frameworks are
|
||||||
involved.
|
involved.
|
||||||
|
|
||||||
Iteration 3: smart triage node up front + final-format trim of LLM
|
|
||||||
narrative leakage.
|
|
||||||
version: "1.0"
|
version: "1.0"
|
||||||
|
|
||||||
global_tools:
|
global_tools:
|
||||||
|
|||||||
@@ -14,10 +14,14 @@ variables:
|
|||||||
- name: project_dir
|
- name: project_dir
|
||||||
description: Project directory for context
|
description: Project directory for context
|
||||||
default: '.'
|
default: '.'
|
||||||
|
- name: auto_confirm
|
||||||
|
description: Auto-confirm command execution
|
||||||
|
default: '1'
|
||||||
|
|
||||||
mcp_servers:
|
mcp_servers:
|
||||||
- ddg-search
|
- ddg-search
|
||||||
global_tools:
|
global_tools:
|
||||||
|
- ast_grep.sh
|
||||||
- fs_read.sh
|
- fs_read.sh
|
||||||
- fs_cat.sh
|
- fs_cat.sh
|
||||||
- fs_grep.sh
|
- fs_grep.sh
|
||||||
|
|||||||
@@ -5,10 +5,45 @@ project management similar to OpenCode, ClaudeCode, Codex, or Gemini CLI.
|
|||||||
|
|
||||||
_Inspired by the Sisyphus and Oracle agents of OpenCode._
|
_Inspired by the Sisyphus and Oracle agents of OpenCode._
|
||||||
|
|
||||||
Sisyphus acts as the primary entry point, capable of handling complex tasks by coordinating specialized sub-agents:
|
Sisyphus acts as the primary entry point. Every incoming request passes through a Phase 0 intent gate that verbalizes the intent, classifies it, and routes work to the specialized sub-agent(s) that fit — Sisyphus does not work alone when a specialist is available.
|
||||||
- **[Coder](../coder/README.md)**: For implementation and file modifications.
|
|
||||||
- **[Explore](../explore/README.md)**: For codebase understanding and research.
|
## Architecture
|
||||||
- **[Oracle](../oracle/README.md)**: For architecture and complex reasoning.
|
|
||||||
|
```mermaid
|
||||||
|
flowchart TD
|
||||||
|
user([User request]) --> sisyphus["Sisyphus<br/>orchestrator"]
|
||||||
|
sisyphus --> classify{"Phase 0<br/>Intent gate"}
|
||||||
|
|
||||||
|
classify -->|"Trivial<br/>(single file, obvious)"| direct["Direct tools<br/>fs_read / fs_patch / execute_command"]
|
||||||
|
classify -->|"Find in code<br/>How does Y work?"| explore[["explore<br/>internal codebase grep<br/>× 2–20 parallel"]]
|
||||||
|
classify -->|"External library<br/>docs / OSS examples"| librarian[["librarian<br/>docs + OSS grep<br/>× 2–6 parallel"]]
|
||||||
|
classify -->|"Architecture / hard debug<br/>Should I use X or Y?"| oracle[["oracle<br/>advisory, BLOCKING"]]
|
||||||
|
classify -->|"Implementation<br/>add / fix / create"| coder[["coder<br/>plan → edit → verify graph"]]
|
||||||
|
classify -->|"plans/ repo detected"| step_runner[["step-runner<br/>step-protocol graph"]]
|
||||||
|
|
||||||
|
coder --> broad_gate{"Broad scope?<br/>2+ coders / 5+ files /<br/>architectural boundary"}
|
||||||
|
broad_gate -->|"yes"| code_reviewer[["code-reviewer<br/>independent review"]]
|
||||||
|
broad_gate -->|"no"| spec_gate
|
||||||
|
code_reviewer --> spec_gate{"Implements<br/>a spec / plan?"}
|
||||||
|
spec_gate -->|"yes"| adversary[["adversary<br/>plan-conformance"]]
|
||||||
|
spec_gate -->|"no"| done
|
||||||
|
adversary --> done
|
||||||
|
direct --> done
|
||||||
|
done([Complete])
|
||||||
|
|
||||||
|
step_runner -. "internally spawns" .-> coder
|
||||||
|
step_runner -. "internally spawns" .-> code_reviewer
|
||||||
|
```
|
||||||
|
|
||||||
|
Spawnable sub-agents (from `config.yaml`):
|
||||||
|
|
||||||
|
- **[explore](../explore/README.md)** — internal codebase grep. Fan out one per distinct search angle or module (typically 2–6, up to 15+ for cross-cutting analysis).
|
||||||
|
- **[librarian](../librarian/README.md)** — external grep for official docs and production OSS examples. Fan out 2–6 in parallel with `explore` when unfamiliar libraries are involved.
|
||||||
|
- **[oracle](../oracle/README.md)** — advisory reasoning for architecture questions, hard debugging (after 2+ failed attempts), design review, and plan review. Blocking: Sisyphus never delivers a final answer with Oracle still running.
|
||||||
|
- **[coder](../coder/README.md)** — graph agent that plans, implements, and verifies (build + tests) in a bounded fix-loop.
|
||||||
|
- **[code-reviewer](../code-reviewer/README.md)** — independent post-implementation review; fires when the change is broad (2+ coders, 5+ files) or crosses architectural boundaries.
|
||||||
|
- **[adversary](../adversary/README.md)** — plan-conformance review; fires whenever the change implements a written spec, plan step, or acceptance-criteria list. Orthogonal to `code-reviewer` — both can run.
|
||||||
|
- **[step-runner](../step-runner/README.md)** — graph agent that executes one step of a phased plan repo. Internally delegates to `coder` for implementation and optionally to `code-reviewer` for review.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,14 @@ max_auto_continues: 25
|
|||||||
inject_todo_instructions: true
|
inject_todo_instructions: true
|
||||||
|
|
||||||
can_spawn_agents: true
|
can_spawn_agents: true
|
||||||
|
spawnable_agents:
|
||||||
|
- explore
|
||||||
|
- librarian
|
||||||
|
- coder
|
||||||
|
- oracle
|
||||||
|
- code-reviewer
|
||||||
|
- adversary
|
||||||
|
- step-runner
|
||||||
max_concurrent_agents: 4
|
max_concurrent_agents: 4
|
||||||
max_agent_depth: 3
|
max_agent_depth: 3
|
||||||
inject_spawn_instructions: true
|
inject_spawn_instructions: true
|
||||||
@@ -39,6 +47,7 @@ variables:
|
|||||||
mcp_servers:
|
mcp_servers:
|
||||||
- ddg-search
|
- ddg-search
|
||||||
global_tools:
|
global_tools:
|
||||||
|
- ast_grep.sh
|
||||||
- fs_read.sh
|
- fs_read.sh
|
||||||
- fs_grep.sh
|
- fs_grep.sh
|
||||||
- fs_glob.sh
|
- fs_glob.sh
|
||||||
@@ -128,8 +137,8 @@ instructions: |
|
|||||||
|
|
||||||
| Agent | Use For | Characteristics |
|
| Agent | Use For | Characteristics |
|
||||||
|-------|---------|-----------------|
|
|-------|---------|-----------------|
|
||||||
| `explore` | Find patterns in THIS codebase, understand local code | Read-only, returns findings, fan out 2-5 in parallel |
|
| `explore` | Find patterns in THIS codebase, understand local code | Read-only, returns findings, fan out as many as the task warrants — one per distinct search angle, module, or concern. Large codebases or cross-cutting tasks should spawn 5–15+. |
|
||||||
| `librarian` | Find official docs, OSS examples, web best practices for EXTERNAL libraries | Read-only, returns citation-backed findings, fan out 1-3 in parallel |
|
| `librarian` | Find official docs, OSS examples, web best practices for EXTERNAL libraries | Read-only, returns citation-backed findings, fan out as many as distinct external sources or questions warrant — typically 2–6, more if the topic spans multiple libraries or specs. |
|
||||||
| `coder` | Write/edit files, implement features | Graph agent: plan → approval → implement → verify build+tests → self_review → bounded fix-loop |
|
| `coder` | Write/edit files, implement features | Graph agent: plan → approval → implement → verify build+tests → self_review → bounded fix-loop |
|
||||||
| `oracle` | Architecture, complex debugging, review, plan review | Advisory, blocking — never answer the user before collecting Oracle results |
|
| `oracle` | Architecture, complex debugging, review, plan review | Advisory, blocking — never answer the user before collecting Oracle results |
|
||||||
| `step-runner` | Execute ONE step of a phased plan repo (Phase 8) | Graph agent: orient → staleness check → coder → verify → handoff → user approval gate |
|
| `step-runner` | Execute ONE step of a phased plan repo (Phase 8) | Graph agent: orient → staleness check → coder → verify → handoff → user approval gate |
|
||||||
@@ -194,7 +203,17 @@ instructions: |
|
|||||||
|
|
||||||
## Phase 4 - Parallel Research
|
## Phase 4 - Parallel Research
|
||||||
|
|
||||||
When delegating exploration, load `parallel-research` skill, then fan out 2-5 `explore` agents in parallel, each scoped to a different angle. Each gets a NARROW slice.
|
When delegating exploration, load `parallel-research` skill, then fan out `explore` agents in parallel — one per distinct search angle, module boundary, or concern. Each gets a NARROW slice. Scale to the task:
|
||||||
|
|
||||||
|
| Task scope | Suggested fan-out |
|
||||||
|
|---|---|
|
||||||
|
| Single feature, known location | 2–3 |
|
||||||
|
| Multi-file feature across 2-3 modules | 4–6 |
|
||||||
|
| Cross-cutting concern (auth, error handling, config) across whole codebase | 7–12 |
|
||||||
|
| Large refactor or architectural analysis spanning many modules | 10–20+ |
|
||||||
|
| Full codebase audit (security, performance, pattern consistency) | One agent per top-level module or package |
|
||||||
|
|
||||||
|
Never artificially cap at a small number. If there are 10 distinct things to find, spawn 10 agents. The system limit is the only ceiling that matters.
|
||||||
|
|
||||||
### The wait protocol
|
### The wait protocol
|
||||||
|
|
||||||
@@ -286,6 +305,31 @@ instructions: |
|
|||||||
|
|
||||||
After a fix-loop completes, do not automatically re-run `code-reviewer` unless the fix itself triggers the same thresholds (2+ coders, 5+ files, architectural). Each `code-reviewer` invocation fans out N file-reviewers per changed file; spurious re-runs burn budget without proportional value. Trust coder's `self_review` on bounded fixes.
|
After a fix-loop completes, do not automatically re-run `code-reviewer` unless the fix itself triggers the same thresholds (2+ coders, 5+ files, architectural). Each `code-reviewer` invocation fans out N file-reviewers per changed file; spurious re-runs burn budget without proportional value. Trust coder's `self_review` on bounded fixes.
|
||||||
|
|
||||||
|
### Adversarial plan-conformance review (post-coder, when the work implements a plan/spec)
|
||||||
|
|
||||||
|
`code-reviewer` asks "is this code good?" It does NOT check "is this the code the plan asked for?" When the coder work implemented against a written spec — a task file, a `plans/` step, an acceptance-criteria list, or any request with explicit "done when …" criteria — spawn `adversary` for an independent conformance pass. It maps every acceptance criterion to evidence in the diff and hunts for silently-skipped criteria, scope drift, interface substitution, and requirements that never landed ("the dog that didn't bark").
|
||||||
|
|
||||||
|
**When to spawn it:** whenever the change has a checkable spec. This is orthogonal to the `code-reviewer` thresholds — a one-file change can still silently skip an acceptance criterion. If there is a plan/task/criteria list, run `adversary`. Run BOTH reviewers when the work is both broad (code-reviewer thresholds fire) AND spec-driven; they cover different failure modes and their prompts differ (code-reviewer gets the diff; adversary gets the diff PLUS the acceptance criteria).
|
||||||
|
|
||||||
|
**Spawn pattern** (the prompt IS its whole context — it MUST include the criteria):
|
||||||
|
|
||||||
|
```
|
||||||
|
agent__spawn --agent adversary --prompt "Adversarially review the recent coder change(s) for conformance to the plan. Return CONFORMS/DIVERGES.
|
||||||
|
|
||||||
|
DIFF: run get_diff (or --base <ref>), or: <paste diff>
|
||||||
|
|
||||||
|
PLAN — acceptance criteria to check against:
|
||||||
|
<paste the task/step spec + acceptance criteria VERBATIM — not a summary>"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Handling adversary findings
|
||||||
|
|
||||||
|
- **`ADVERSARIAL_REVIEW: DIVERGES` blocks completion.** Do not mark the task done. Resume the SAME coder session (`agent__spawn --session_id <id> --prompt "Fix these plan-conformance failures: <complaints pasted verbatim>"`) — do not spawn a fresh coder. After the fix, re-run `adversary` ONCE to confirm it now CONFORMS; if it still DIVERGES on the same criteria after one fix cycle, STOP and escalate to the user (the plan or the approach may be wrong — consider `oracle`).
|
||||||
|
- **`ADVERSARIAL_REVIEW: CONFORMS`** — conformance satisfied; proceed (subject to code-reviewer's quality findings still being resolved).
|
||||||
|
- **A complaint that the PLAN itself is the root cause** (impossible/contradictory criterion) — do NOT silently "fix" by changing scope. Surface it to the user; the plan needs amending, which is their call.
|
||||||
|
|
||||||
|
Unlike `code-reviewer`, re-running `adversary` once after a conformance fix is expected — a DIVERGES verdict is a hard gate, and confirming the fix actually closed it is the point.
|
||||||
|
|
||||||
## File Operations (Direct Edits)
|
## File Operations (Direct Edits)
|
||||||
|
|
||||||
When you write or modify files yourself (rather than delegating to coder):
|
When you write or modify files yourself (rather than delegating to coder):
|
||||||
|
|||||||
@@ -18,32 +18,61 @@ plans/
|
|||||||
|
|
||||||
## Workflow
|
## Workflow
|
||||||
|
|
||||||
```
|
```mermaid
|
||||||
resolve_step (script) locate plan + previous handoff, check depends_on,
|
flowchart TD
|
||||||
↓ mark plan in-progress [→ gate_blocked if deps unsatisfied]
|
resolve_step{"resolve_step<br/>script"}
|
||||||
orient (llm, read-only) merge handoff directives + staleness-check the plan
|
resolve_step -->|"deps satisfied"| orient
|
||||||
↓
|
resolve_step -->|"deps unsatisfied"| gate_blocked
|
||||||
route_staleness (script) major deviation → gate_deviation (approval)
|
gate_blocked{{"gate_blocked<br/>approval"}}
|
||||||
↓
|
gate_blocked -->|"yes"| orient
|
||||||
implement (agent → coder) coder runs its own build/test/self-review fix-loop
|
gate_blocked -->|"no"| end_blocked
|
||||||
↓
|
orient["orient<br/>llm, read-only"] --> route_staleness
|
||||||
route_coder_result (script) COMPLETE → verify | REJECTED / FAILED → end
|
route_staleness{"route_staleness<br/>script"}
|
||||||
↓
|
route_staleness -->|"major deviation"| gate_deviation
|
||||||
verify_format_lint (script) format BEFORE evidence, then lint
|
route_staleness -->|"else"| implement
|
||||||
verify_build (script) step-level build/typecheck
|
gate_deviation{{"gate_deviation<br/>approval"}}
|
||||||
verify_tests (script) FULL test suite
|
gate_deviation -->|"proceed"| implement
|
||||||
↓ [failures → fix_loop_gate, back-edge to implement]
|
gate_deviation -->|"abort"| end_rejected
|
||||||
edge_case_sweep (llm) missed edge cases; annotate downstream plans
|
gate_deviation -->|"other (user guidance)"| implement
|
||||||
↓ (Edge cases sections ONLY - scope changes become proposals)
|
implement[["implement<br/>agent → coder"]] --> route_coder_result
|
||||||
route_sweep (script) 5+ files or architectural boundary → independent_review
|
route_coder_result{"route_coder_result<br/>script"}
|
||||||
independent_review (agent) code-reviewer; 🔴 findings loop back to implement (bounded)
|
route_coder_result -->|"CODER_COMPLETE"| verify_format_lint
|
||||||
↓
|
route_coder_result -->|"REJECTED / FAILED"| end_failure
|
||||||
write_handoff (llm) evidence-backed handoff per handoff-protocol + NOTES.md
|
verify_format_lint{"verify_format_lint<br/>script"}
|
||||||
check_handoff (script) deterministic schema gate; marks plan status complete
|
verify_format_lint -->|"pass"| verify_build
|
||||||
↓
|
verify_format_lint -->|"fail"| fix_loop_gate
|
||||||
gate_user_review (approval) HARD STOP - approve, or send revision comments
|
verify_build{"verify_build<br/>script"}
|
||||||
↓ (revisions loop through implement → verify → handoff again)
|
verify_build -->|"pass"| verify_tests
|
||||||
end_success / end_blocked / end_rejected / end_failure
|
verify_build -->|"fail"| fix_loop_gate
|
||||||
|
verify_tests{"verify_tests<br/>script"}
|
||||||
|
verify_tests -->|"pass"| edge_case_sweep
|
||||||
|
verify_tests -->|"fail"| fix_loop_gate
|
||||||
|
fix_loop_gate{"fix_loop_gate<br/>script"}
|
||||||
|
fix_loop_gate -->|"budget left"| implement
|
||||||
|
fix_loop_gate -->|"budget spent"| end_failure
|
||||||
|
edge_case_sweep["edge_case_sweep<br/>llm"] --> route_sweep
|
||||||
|
route_sweep{"route_sweep<br/>script"}
|
||||||
|
route_sweep -->|"5+ files or boundary"| independent_review
|
||||||
|
route_sweep -->|"else"| write_handoff
|
||||||
|
independent_review[["independent_review<br/>agent → code-reviewer"]] --> route_review
|
||||||
|
route_review{"route_review<br/>script"}
|
||||||
|
route_review -->|"🔴 critical findings"| implement
|
||||||
|
route_review -->|"else"| write_handoff
|
||||||
|
write_handoff["write_handoff<br/>llm"] --> check_handoff
|
||||||
|
check_handoff{"check_handoff<br/>script"}
|
||||||
|
check_handoff -->|"schema valid"| gate_user_review
|
||||||
|
check_handoff -->|"one retry"| write_handoff
|
||||||
|
gate_user_review{{"gate_user_review<br/>approval"}}
|
||||||
|
gate_user_review -->|"approve"| end_success
|
||||||
|
gate_user_review -->|"revise"| get_revision
|
||||||
|
gate_user_review -->|"other (comments)"| revise_from_choice
|
||||||
|
get_revision[/"get_revision<br/>input"/] --> implement
|
||||||
|
revise_from_choice{"revise_from_choice<br/>script"} --> implement
|
||||||
|
|
||||||
|
end_success(["end_success<br/>STEP_COMPLETE"])
|
||||||
|
end_blocked(["end_blocked<br/>STEP_BLOCKED"])
|
||||||
|
end_rejected(["end_rejected<br/>STEP_REJECTED"])
|
||||||
|
end_failure(["end_failure<br/>STEP_FAILED"])
|
||||||
```
|
```
|
||||||
|
|
||||||
End nodes emit sentinel outcomes for the caller:
|
End nodes emit sentinel outcomes for the caller:
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ description: |
|
|||||||
implement (coder) -> verify -> edge-case sweep -> optional independent
|
implement (coder) -> verify -> edge-case sweep -> optional independent
|
||||||
review -> evidence-backed handoff -> user approval gate. Designed to be
|
review -> evidence-backed handoff -> user approval gate. Designed to be
|
||||||
delegated to by sisyphus.
|
delegated to by sisyphus.
|
||||||
version: "1.0"
|
version: '1.0'
|
||||||
|
|
||||||
global_tools:
|
global_tools:
|
||||||
|
- ast_grep.sh
|
||||||
- fs_cat.sh
|
- fs_cat.sh
|
||||||
- fs_ls.sh
|
- fs_ls.sh
|
||||||
- fs_write.sh
|
- fs_write.sh
|
||||||
@@ -28,18 +28,18 @@ variables:
|
|||||||
coyote was invoked from). The coder sub-agent resolves its own
|
coyote was invoked from). The coder sub-agent resolves its own
|
||||||
project_dir the same way, so invoke step-runner FROM the project root
|
project_dir the same way, so invoke step-runner FROM the project root
|
||||||
unless you override this for both.
|
unless you override this for both.
|
||||||
default: "."
|
default: '.'
|
||||||
- name: plans_dir
|
- name: plans_dir
|
||||||
description: |
|
description: |
|
||||||
Path to the plan repo. Relative paths resolve against project_dir.
|
Path to the plan repo. Relative paths resolve against project_dir.
|
||||||
Expected layout: <plans_dir>/steps/NN-<slug>.md,
|
Expected layout: <plans_dir>/steps/NN-<slug>.md,
|
||||||
<plans_dir>/handoffs/, <plans_dir>/NOTES.md.
|
<plans_dir>/handoffs/, <plans_dir>/NOTES.md.
|
||||||
default: "plans"
|
default: 'plans'
|
||||||
- name: step
|
- name: step
|
||||||
description: |
|
description: |
|
||||||
Which step to execute: a step number, or "next" to pick the first
|
Which step to execute: a step number, or "next" to pick the first
|
||||||
in-progress (resume) or pending step plan.
|
in-progress (resume) or pending step plan.
|
||||||
default: "next"
|
default: 'next'
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
max_loop_iterations: 20
|
max_loop_iterations: 20
|
||||||
@@ -48,45 +48,45 @@ settings:
|
|||||||
timeout: 7200
|
timeout: 7200
|
||||||
|
|
||||||
initial_state:
|
initial_state:
|
||||||
project_dir: ""
|
project_dir: ''
|
||||||
plans_dir: ""
|
plans_dir: ''
|
||||||
step_number: 0
|
step_number: 0
|
||||||
step_slug: ""
|
step_slug: ''
|
||||||
step_title: ""
|
step_title: ''
|
||||||
step_plan_path: ""
|
step_plan_path: ''
|
||||||
step_plan: ""
|
step_plan: ''
|
||||||
prev_handoff_path: "(none)"
|
prev_handoff_path: '(none)'
|
||||||
prev_handoff: "(none - this is the first step)"
|
prev_handoff: '(none - this is the first step)'
|
||||||
notes_path: ""
|
notes_path: ''
|
||||||
notes: "(none)"
|
notes: '(none)'
|
||||||
handoff_path: ""
|
handoff_path: ''
|
||||||
blocking_reason: ""
|
blocking_reason: ''
|
||||||
plan_summary: ""
|
plan_summary: ''
|
||||||
implementation_brief: ""
|
implementation_brief: ''
|
||||||
staleness_report: ""
|
staleness_report: ''
|
||||||
has_major_deviation: false
|
has_major_deviation: false
|
||||||
deviation_summary: ""
|
deviation_summary: ''
|
||||||
user_feedback: ""
|
user_feedback: ''
|
||||||
fix_instructions: ""
|
fix_instructions: ''
|
||||||
fix_attempts: 0
|
fix_attempts: 0
|
||||||
max_fix_attempts: 2
|
max_fix_attempts: 2
|
||||||
coder_result: ""
|
coder_result: ''
|
||||||
format_output: ""
|
format_output: ''
|
||||||
lint_ok: true
|
lint_ok: true
|
||||||
lint_output: ""
|
lint_output: ''
|
||||||
build_ok: true
|
build_ok: true
|
||||||
build_output: ""
|
build_output: ''
|
||||||
tests_ok: true
|
tests_ok: true
|
||||||
tests_output: ""
|
tests_output: ''
|
||||||
edge_case_report: ""
|
edge_case_report: ''
|
||||||
downstream_updates: ""
|
downstream_updates: ''
|
||||||
needs_independent_review: false
|
needs_independent_review: false
|
||||||
review_report: ""
|
review_report: ''
|
||||||
review_attempts: 0
|
review_attempts: 0
|
||||||
max_review_attempts: 1
|
max_review_attempts: 1
|
||||||
handoff_attempts: 0
|
handoff_attempts: 0
|
||||||
handoff_fix: ""
|
handoff_fix: ''
|
||||||
step_summary: ""
|
step_summary: ''
|
||||||
|
|
||||||
start: resolve_step
|
start: resolve_step
|
||||||
|
|
||||||
@@ -114,11 +114,11 @@ nodes:
|
|||||||
|
|
||||||
Proceed anyway?
|
Proceed anyway?
|
||||||
options:
|
options:
|
||||||
- "yes"
|
- 'yes'
|
||||||
- "no"
|
- 'no'
|
||||||
routes:
|
routes:
|
||||||
"yes": orient
|
'yes': orient
|
||||||
"no": end_blocked
|
'no': end_blocked
|
||||||
on_other: end_blocked
|
on_other: end_blocked
|
||||||
|
|
||||||
orient:
|
orient:
|
||||||
@@ -183,7 +183,14 @@ nodes:
|
|||||||
deviation_summary:
|
deviation_summary:
|
||||||
type: string
|
type: string
|
||||||
description: Major deviations only, with the plan claim vs current reality. Empty when none
|
description: Major deviations only, with the plan claim vs current reality. Empty when none
|
||||||
required: [plan_summary, implementation_brief, staleness_report, has_major_deviation, deviation_summary]
|
required:
|
||||||
|
[
|
||||||
|
plan_summary,
|
||||||
|
implementation_brief,
|
||||||
|
staleness_report,
|
||||||
|
has_major_deviation,
|
||||||
|
deviation_summary,
|
||||||
|
]
|
||||||
fallback: end_failure
|
fallback: end_failure
|
||||||
next: route_staleness
|
next: route_staleness
|
||||||
|
|
||||||
@@ -211,14 +218,14 @@ nodes:
|
|||||||
Proceed with the corrected brief? (Answer with anything else to give
|
Proceed with the corrected brief? (Answer with anything else to give
|
||||||
your own guidance to the implementer.)
|
your own guidance to the implementer.)
|
||||||
options:
|
options:
|
||||||
- "proceed"
|
- 'proceed'
|
||||||
- "abort"
|
- 'abort'
|
||||||
routes:
|
routes:
|
||||||
"proceed": implement
|
'proceed': implement
|
||||||
"abort": end_rejected
|
'abort': end_rejected
|
||||||
on_other: implement
|
on_other: implement
|
||||||
state_updates:
|
state_updates:
|
||||||
user_feedback: "{{choice}}"
|
user_feedback: '{{choice}}'
|
||||||
|
|
||||||
implement:
|
implement:
|
||||||
id: implement
|
id: implement
|
||||||
@@ -262,7 +269,7 @@ nodes:
|
|||||||
{{fix_instructions}}
|
{{fix_instructions}}
|
||||||
timeout: 3600
|
timeout: 3600
|
||||||
state_updates:
|
state_updates:
|
||||||
coder_result: "{{output}}"
|
coder_result: '{{output}}'
|
||||||
next: route_coder_result
|
next: route_coder_result
|
||||||
|
|
||||||
route_coder_result:
|
route_coder_result:
|
||||||
@@ -399,7 +406,7 @@ nodes:
|
|||||||
Preserve severity tags in your findings.
|
Preserve severity tags in your findings.
|
||||||
timeout: 1200
|
timeout: 1200
|
||||||
state_updates:
|
state_updates:
|
||||||
review_report: "{{output}}"
|
review_report: '{{output}}'
|
||||||
next: route_review
|
next: route_review
|
||||||
|
|
||||||
route_review:
|
route_review:
|
||||||
@@ -517,23 +524,23 @@ nodes:
|
|||||||
Approve this step? (Answer with anything else to send revision
|
Approve this step? (Answer with anything else to send revision
|
||||||
instructions straight to the implementer.)
|
instructions straight to the implementer.)
|
||||||
options:
|
options:
|
||||||
- "approve"
|
- 'approve'
|
||||||
- "revise"
|
- 'revise'
|
||||||
routes:
|
routes:
|
||||||
"approve": end_success
|
'approve': end_success
|
||||||
"revise": get_revision
|
'revise': get_revision
|
||||||
on_other: revise_from_choice
|
on_other: revise_from_choice
|
||||||
state_updates:
|
state_updates:
|
||||||
user_feedback: "{{choice}}"
|
user_feedback: '{{choice}}'
|
||||||
|
|
||||||
get_revision:
|
get_revision:
|
||||||
id: get_revision
|
id: get_revision
|
||||||
type: input
|
type: input
|
||||||
description: Collect revision instructions, then loop back through implement -> verify -> handoff.
|
description: Collect revision instructions, then loop back through implement -> verify -> handoff.
|
||||||
question: "What should change? Your comments go to the implementer verbatim."
|
question: 'What should change? Your comments go to the implementer verbatim.'
|
||||||
validation: "len(input) > 0"
|
validation: 'len(input) > 0'
|
||||||
state_updates:
|
state_updates:
|
||||||
fix_instructions: "{{input}}"
|
fix_instructions: '{{input}}'
|
||||||
next: implement
|
next: implement
|
||||||
|
|
||||||
revise_from_choice:
|
revise_from_choice:
|
||||||
|
|||||||
@@ -10,5 +10,13 @@ set -e
|
|||||||
|
|
||||||
main() {
|
main() {
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
cat "$argc_path" >> "$LLM_OUTPUT" 2>&1 || echo "No such file or path: $argc_path" >> "$LLM_OUTPUT"
|
local path="$argc_path"
|
||||||
}
|
|
||||||
|
# An empty result is shown to the model as the opaque literal "DONE"; emit a note instead.
|
||||||
|
if [[ -f "$path" && ! -s "$path" ]]; then
|
||||||
|
echo "(empty file: $path)" >> "$LLM_OUTPUT"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat "$path" >> "$LLM_OUTPUT" 2>&1 || echo "No such file or path: $path" >> "$LLM_OUTPUT"
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ main() {
|
|||||||
local search_path="${argc_path:-.}"
|
local search_path="${argc_path:-.}"
|
||||||
|
|
||||||
if [[ ! -d "$search_path" ]]; then
|
if [[ ! -d "$search_path" ]]; then
|
||||||
echo "Error: directory not found: $search_path" >> "$LLM_OUTPUT"
|
echo "Error: directory not found: $search_path" >&2
|
||||||
return 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local results
|
local results
|
||||||
@@ -33,7 +33,18 @@ main() {
|
|||||||
--exclude '.build' \
|
--exclude '.build' \
|
||||||
2>/dev/null | head -n "$MAX_RESULTS") || true
|
2>/dev/null | head -n "$MAX_RESULTS") || true
|
||||||
else
|
else
|
||||||
results=$(find "$search_path" -type f -name "$glob_pattern" \
|
local name_pattern dir_prefix effective_search
|
||||||
|
name_pattern="${glob_pattern##*/}"
|
||||||
|
[[ -z "$name_pattern" || "$name_pattern" == "**" ]] && name_pattern="*"
|
||||||
|
if [[ "$glob_pattern" == */* ]]; then
|
||||||
|
dir_prefix="${glob_pattern%%\**}"
|
||||||
|
dir_prefix="${dir_prefix%/}"
|
||||||
|
effective_search="${search_path}${dir_prefix:+/$dir_prefix}"
|
||||||
|
else
|
||||||
|
effective_search="$search_path"
|
||||||
|
fi
|
||||||
|
[[ -d "$effective_search" ]] || effective_search="$search_path"
|
||||||
|
results=$(find "$effective_search" -type f -name "$name_pattern" \
|
||||||
-not -path '*/.git/*' \
|
-not -path '*/.git/*' \
|
||||||
-not -path '*/node_modules/*' \
|
-not -path '*/node_modules/*' \
|
||||||
-not -path '*/target/*' \
|
-not -path '*/target/*' \
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ main() {
|
|||||||
local include_filter="${argc_include:-}"
|
local include_filter="${argc_include:-}"
|
||||||
|
|
||||||
if [[ ! -e "$search_path" ]]; then
|
if [[ ! -e "$search_path" ]]; then
|
||||||
echo "Error: path not found: $search_path" >> "$LLM_OUTPUT"
|
echo "Error: path not found: $search_path" >&2
|
||||||
return 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local grep_args=(-nH --color=never)
|
local grep_args=(-nH --color=never)
|
||||||
|
|||||||
@@ -9,5 +9,18 @@ set -e
|
|||||||
|
|
||||||
main() {
|
main() {
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
ls -1 "$argc_path" >> "$LLM_OUTPUT" 2>&1 || echo "No such path: $argc_path" >> "$LLM_OUTPUT"
|
local path="$argc_path"
|
||||||
}
|
local output
|
||||||
|
|
||||||
|
if ! output=$(ls -1 "$path" 2>&1); then
|
||||||
|
echo "$output" >> "$LLM_OUTPUT"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# An empty result is shown to the model as the opaque literal "DONE"; emit a note instead.
|
||||||
|
if [[ -z "$output" ]]; then
|
||||||
|
echo "(empty directory: $path)" >> "$LLM_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "$output" >> "$LLM_OUTPUT"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ set -e
|
|||||||
# your changes).
|
# your changes).
|
||||||
|
|
||||||
# @option --path! The path of the file to apply the patch to
|
# @option --path! The path of the file to apply the patch to
|
||||||
# @option --contents! The patch to apply to the file
|
# @option --content! The patch to apply to the file
|
||||||
|
|
||||||
# @env LLM_OUTPUT=/dev/stdout The output path
|
# @env LLM_OUTPUT=/dev/stdout The output path
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ source "$LLM_PROMPT_UTILS_FILE"
|
|||||||
|
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
main() {
|
main() {
|
||||||
argc_contents="$(jq -r '.contents' <<< "$LLM_TOOL_RAW_JSON")"
|
argc_contents="$(jq -r '.content' <<< "$LLM_TOOL_RAW_JSON")"
|
||||||
argc_path="$(jq -r '.path' <<< "$LLM_TOOL_RAW_JSON")"
|
argc_path="$(jq -r '.path' <<< "$LLM_TOOL_RAW_JSON")"
|
||||||
|
|
||||||
if [[ ! -f "$argc_path" ]]; then
|
if [[ ! -f "$argc_path" ]]; then
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ set -e
|
|||||||
# Use the grep tool to find specific content before reading, then read with offset to target the relevant section.
|
# Use the grep tool to find specific content before reading, then read with offset to target the relevant section.
|
||||||
|
|
||||||
# @option --path! The absolute path to the file or directory to read
|
# @option --path! The absolute path to the file or directory to read
|
||||||
# @option --offset The line number to start reading from (1-indexed, default: 1)
|
# @option --offset <INT> The line number to start reading from (1-indexed, default: 1)
|
||||||
# @option --limit The maximum number of lines to read (default: 2000)
|
# @option --limit <INT> The maximum number of lines to read (default: 2000)
|
||||||
|
|
||||||
# @env LLM_OUTPUT=/dev/stdout The output path
|
# @env LLM_OUTPUT=/dev/stdout The output path
|
||||||
|
|
||||||
@@ -23,8 +23,8 @@ main() {
|
|||||||
local limit="${argc_limit:-2000}"
|
local limit="${argc_limit:-2000}"
|
||||||
|
|
||||||
if [[ ! -e "$target" ]]; then
|
if [[ ! -e "$target" ]]; then
|
||||||
echo "Error: path not found: $target" >> "$LLM_OUTPUT"
|
echo "Error: path not found: $target" >&2
|
||||||
return 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d "$target" ]]; then
|
if [[ -d "$target" ]]; then
|
||||||
@@ -33,9 +33,20 @@ main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local total_lines file_bytes
|
local total_lines file_bytes
|
||||||
total_lines=$(wc -l < "$target" 2>/dev/null || echo 0)
|
# awk counts a final line that lacks a trailing newline; wc -l would undercount it by one.
|
||||||
|
total_lines=$(awk 'END { print NR }' "$target" 2>/dev/null || echo 0)
|
||||||
file_bytes=$(wc -c < "$target" 2>/dev/null || echo 0)
|
file_bytes=$(wc -c < "$target" 2>/dev/null || echo 0)
|
||||||
|
|
||||||
|
if [[ "$total_lines" -eq 0 ]]; then
|
||||||
|
echo "(file is empty: $target)" >> "$LLM_OUTPUT"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$offset" -gt "$total_lines" ]]; then
|
||||||
|
echo "(offset $offset is past the end of the file, which has $total_lines lines)" >> "$LLM_OUTPUT"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$file_bytes" -gt "$MAX_BYTES" ]] && [[ "$offset" -eq 1 ]] && [[ "$limit" -ge 2000 ]]; then
|
if [[ "$file_bytes" -gt "$MAX_BYTES" ]] && [[ "$offset" -eq 1 ]] && [[ "$limit" -ge 2000 ]]; then
|
||||||
{
|
{
|
||||||
echo "Warning: Large file (${file_bytes} bytes, ${total_lines} lines). Showing first ${limit} lines."
|
echo "Warning: Large file (${file_bytes} bytes, ${total_lines} lines). Showing first ${limit} lines."
|
||||||
@@ -48,7 +59,8 @@ main() {
|
|||||||
|
|
||||||
sed -n "${offset},${end_line}p" "$target" 2>/dev/null | {
|
sed -n "${offset},${end_line}p" "$target" 2>/dev/null | {
|
||||||
local line_num=$offset
|
local line_num=$offset
|
||||||
while IFS= read -r line; do
|
# `|| [[ -n "$line" ]]` keeps the final line when the file has no trailing newline.
|
||||||
|
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||||
if [[ ${#line} -gt $MAX_LINE_LENGTH ]]; then
|
if [[ ${#line} -gt $MAX_LINE_LENGTH ]]; then
|
||||||
line="${line:0:$MAX_LINE_LENGTH}... (truncated)"
|
line="${line:0:$MAX_LINE_LENGTH}... (truncated)"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ set -e
|
|||||||
# sending less data, and is less prone to accidental data loss.
|
# sending less data, and is less prone to accidental data loss.
|
||||||
|
|
||||||
# @option --path! The path of the file to write to
|
# @option --path! The path of the file to write to
|
||||||
# @option --contents! The full contents to write to the file
|
# @option --content! The full contents to write to the file
|
||||||
|
|
||||||
# @env LLM_OUTPUT=/dev/stdout The output path
|
# @env LLM_OUTPUT=/dev/stdout The output path
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ source "$LLM_PROMPT_UTILS_FILE"
|
|||||||
|
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
main() {
|
main() {
|
||||||
argc_contents="$(jq -r '.contents' <<< "$LLM_TOOL_RAW_JSON")"
|
argc_contents="$(jq -r '.content' <<< "$LLM_TOOL_RAW_JSON")"
|
||||||
argc_path="$(jq -r '.path' <<< "$LLM_TOOL_RAW_JSON")"
|
argc_path="$(jq -r '.path' <<< "$LLM_TOOL_RAW_JSON")"
|
||||||
|
|
||||||
if [[ -f "$argc_path" ]]; then
|
if [[ -f "$argc_path" ]]; then
|
||||||
|
|||||||
@@ -552,7 +552,7 @@ patch_file() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line ~ /^@@ /) {
|
if (line ~ /^@@/) {
|
||||||
mode = "hunk"
|
mode = "hunk"
|
||||||
hunkIndex++
|
hunkIndex++
|
||||||
patchLineIndex++
|
patchLineIndex++
|
||||||
@@ -585,6 +585,10 @@ patch_file() {
|
|||||||
|
|
||||||
if (hunkIndex == 0) {
|
if (hunkIndex == 0) {
|
||||||
print "error: no patch" > "/dev/stderr"
|
print "error: no patch" > "/dev/stderr"
|
||||||
|
print "" > "/dev/stderr"
|
||||||
|
print "No hunk header was found. Each hunk must start with a line beginning \"@@\"" > "/dev/stderr"
|
||||||
|
print "(for example \"@@ ... @@\" or \"@@ -1,4 +1,4 @@\"). Inside a hunk, context lines" > "/dev/stderr"
|
||||||
|
print "start with a single space, removed lines with \"-\", and added lines with \"+\"." > "/dev/stderr"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,10 @@ Additional hard rules:
|
|||||||
- If the evidence points to failing hardware or risk of data loss, stop, say so plainly, and present options before
|
- If the evidence points to failing hardware or risk of data loss, stop, say so plainly, and present options before
|
||||||
touching anything else.
|
touching anything else.
|
||||||
|
|
||||||
|
## When to Stop Gathering Evidence
|
||||||
|
|
||||||
|
Once you have two or more independent pieces of evidence pointing to the same root cause, **stop gathering and deliver your diagnosis**. Do not add more verification steps to verify your verification. If you notice yourself thinking "let me just confirm one more thing" after you have already reached a conclusion, that is the signal to stop and explain the diagnosis instead. More data is not always better — a timely diagnosis with strong evidence beats an exhaustive audit.
|
||||||
|
|
||||||
## Communication
|
## Communication
|
||||||
|
|
||||||
- Lead with what you found, not what you did. Then show the key evidence: the command and the relevant lines of its
|
- Lead with what you found, not what you did. Then show the key evidence: the command and the relevant lines of its
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ security/configuration settings. The analysis aims to ensure a thorough understa
|
|||||||
structured and operates, enabling the creation of new files, maintaining consistency with existing practices, and the
|
structured and operates, enabling the creation of new files, maintaining consistency with existing practices, and the
|
||||||
potential implementation of best practices.
|
potential implementation of best practices.
|
||||||
|
|
||||||
Should the root directory contain a `COYOTE.md` file, this was generated by Coyote and should be used as a reference
|
Should the root directory contain a `COYOTE.md` (or `AGENTS.md`/`CLAUDE.md`) file, this contains human-curated project
|
||||||
point for all analysis, style questions, etc.
|
instructions and should be used as a reference point for all analysis, style questions, etc.
|
||||||
|
|
||||||
**Objective:** Enable the AI to thoroughly analyze a software repository, providing detailed insights and guidelines on
|
**Objective:** Enable the AI to thoroughly analyze a software repository, providing detailed insights and guidelines on
|
||||||
all relevant aspects for understanding and potentially contributing to the project.
|
all relevant aspects for understanding and potentially contributing to the project.
|
||||||
|
|||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
if [ -z "$SSH_AUTH_SOCK" ]; then
|
||||||
|
echo "WARNING: [git-ssh-sign] no SSH agent — cannot sign commits"
|
||||||
|
fi
|
||||||
|
|
||||||
|
KEY=$(ssh-add -L 2>/dev/null | head -1)
|
||||||
|
|
||||||
|
if [ -z "$KEY" ]; then
|
||||||
|
echo "WARNING: [git-ssh-sign] no keys in SSH agent — cannot sign commits"
|
||||||
|
fi
|
||||||
|
|
||||||
|
KEY_FILE="/home/agent/.config/git/signing_key.pub"
|
||||||
|
mkdir -p "$(dirname "$KEY_FILE")"
|
||||||
|
printf '%s\n' "$KEY" > "$KEY_FILE"
|
||||||
|
EMAIL=$(git config user.email 2>/dev/null || echo "agent@sandbox.local")
|
||||||
|
printf '%s %s\n' "$EMAIL" "$KEY" > "/home/agent/.config/git/allowed_signers"
|
||||||
|
|
||||||
|
local_hook="$(git rev-parse --git-dir)/hooks/pre-commit"
|
||||||
|
if [ -x "$local_hook" ]; then
|
||||||
|
exec "$local_hook" "$@"
|
||||||
|
fi
|
||||||
+85
-103
@@ -3,9 +3,8 @@
|
|||||||
# Setup (paths use $HOME so commands work in bash/zsh/PowerShell/Git Bash):
|
# Setup (paths use $HOME so commands work in bash/zsh/PowerShell/Git Bash):
|
||||||
# sbx create --kit ./sbx-kit/ coyote --name testing .
|
# sbx create --kit ./sbx-kit/ coyote --name testing .
|
||||||
# sbx cp $HOME/.config/coyote/ testing:/home/agent/.config/
|
# sbx cp $HOME/.config/coyote/ testing:/home/agent/.config/
|
||||||
# sbx cp $HOME/.coyote_password testing:/home/agent/
|
|
||||||
# sbx run testing --kit ./sbx-kit/
|
# sbx run testing --kit ./sbx-kit/
|
||||||
schemaVersion: "1"
|
schemaVersion: '1'
|
||||||
kind: sandbox
|
kind: sandbox
|
||||||
name: coyote
|
name: coyote
|
||||||
displayName: Coyote
|
displayName: Coyote
|
||||||
@@ -14,10 +13,10 @@ description: >
|
|||||||
CLI & REPL mode, RAG, AI tools & agents, MCP servers, skills, and macros.
|
CLI & REPL mode, RAG, AI tools & agents, MCP servers, skills, and macros.
|
||||||
|
|
||||||
sandbox:
|
sandbox:
|
||||||
image: "docker/sandbox-templates:shell-docker"
|
image: 'darkalex17/coyote:v0.8.3'
|
||||||
aiFilename: COYOTE.md
|
aiFilename: COYOTE.md
|
||||||
entrypoint:
|
entrypoint:
|
||||||
run: ["bash", "-lc", "exec /home/agent/.cargo/bin/coyote"]
|
run: ['bash', '-lc', 'exec /home/agent/.cargo/bin/coyote']
|
||||||
|
|
||||||
network:
|
network:
|
||||||
# Proxy-managed LLM providers: the proxy substitutes `proxy-managed` for
|
# Proxy-managed LLM providers: the proxy substitutes `proxy-managed` for
|
||||||
@@ -50,96 +49,96 @@ network:
|
|||||||
serviceAuth:
|
serviceAuth:
|
||||||
openai:
|
openai:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
anthropic:
|
anthropic:
|
||||||
headerName: x-api-key
|
headerName: x-api-key
|
||||||
valueFormat: "%s"
|
valueFormat: '%s'
|
||||||
gemini:
|
gemini:
|
||||||
headerName: x-goog-api-key
|
headerName: x-goog-api-key
|
||||||
valueFormat: "%s"
|
valueFormat: '%s'
|
||||||
cohere:
|
cohere:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
groq:
|
groq:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
openrouter:
|
openrouter:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
ai21:
|
ai21:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
cloudflare:
|
cloudflare:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
deepinfra:
|
deepinfra:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
deepseek:
|
deepseek:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
mistral:
|
mistral:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
perplexity:
|
perplexity:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
voyageai:
|
voyageai:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
xai:
|
xai:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
jina:
|
jina:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
ernie:
|
ernie:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
hunyuan:
|
hunyuan:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
minimax:
|
minimax:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
moonshot:
|
moonshot:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
qianwen:
|
qianwen:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
zhipuai:
|
zhipuai:
|
||||||
headerName: Authorization
|
headerName: Authorization
|
||||||
valueFormat: "Bearer %s"
|
valueFormat: 'Bearer %s'
|
||||||
allowedDomains:
|
allowedDomains:
|
||||||
# Coyote release + self-update + model-registry sync
|
# Coyote release + self-update + model-registry sync
|
||||||
- "github.com:443"
|
- 'github.com:443'
|
||||||
- "api.github.com:443"
|
- 'api.github.com:443'
|
||||||
- "raw.githubusercontent.com:443"
|
- 'raw.githubusercontent.com:443'
|
||||||
- "objects.githubusercontent.com:443"
|
- 'objects.githubusercontent.com:443'
|
||||||
- "*.githubusercontent.com:443"
|
- '*.githubusercontent.com:443'
|
||||||
# Coyote install paths (cargo install + uv + rustup + Python tool deps at runtime)
|
# Package managers and developer tools (cargo, uv, pip — useful at runtime for user installs)
|
||||||
- "crates.io:443"
|
- 'crates.io:443'
|
||||||
- "static.crates.io:443"
|
- 'static.crates.io:443'
|
||||||
- "pypi.org:443"
|
- 'pypi.org:443'
|
||||||
- "files.pythonhosted.org:443"
|
- 'files.pythonhosted.org:443'
|
||||||
- "astral.sh:443"
|
- 'astral.sh:443'
|
||||||
- "sh.rustup.rs:443"
|
- 'sh.rustup.rs:443'
|
||||||
- "static.rust-lang.org:443"
|
- 'static.rust-lang.org:443'
|
||||||
|
|
||||||
# LLM model OAuth + API endpoints
|
# LLM model OAuth + API endpoints
|
||||||
- "claude.ai:443"
|
- 'claude.ai:443'
|
||||||
- "console.anthropic.com:443"
|
- 'console.anthropic.com:443'
|
||||||
- "accounts.google.com:443"
|
- 'accounts.google.com:443'
|
||||||
# *.googleapis.com covers oauth2 + userinfo + VertexAI regional endpoints
|
# *.googleapis.com covers oauth2 + userinfo + VertexAI regional endpoints
|
||||||
# (*-aiplatform.googleapis.com). Do not narrow without re-checking VertexAI.
|
# (*-aiplatform.googleapis.com). Do not narrow without re-checking VertexAI.
|
||||||
- "*.googleapis.com:443"
|
- '*.googleapis.com:443'
|
||||||
|
|
||||||
# Bedrock and GitHub Models use signed / GitHub-PAT auth that the proxy
|
# Bedrock and GitHub Models use signed / GitHub-PAT auth that the proxy
|
||||||
# cannot rewrite. Domains are allow-listed; credentials must be injected
|
# cannot rewrite. Domains are allow-listed; credentials must be injected
|
||||||
# separately (see README "Extending").
|
# separately (see README "Extending").
|
||||||
- "*.amazonaws.com:443"
|
- '*.amazonaws.com:443'
|
||||||
- "models.inference.ai.azure.com:443"
|
- 'models.inference.ai.azure.com:443'
|
||||||
|
|
||||||
credentials:
|
credentials:
|
||||||
sources:
|
sources:
|
||||||
@@ -210,9 +209,10 @@ credentials:
|
|||||||
|
|
||||||
environment:
|
environment:
|
||||||
variables:
|
variables:
|
||||||
IS_SANDBOX: "1"
|
IS_SANDBOX: '1'
|
||||||
COYOTE_LOG_LEVEL: INFO
|
COYOTE_LOG_LEVEL: INFO
|
||||||
COYOTE_CONFIG_DIR: /home/agent/.config/coyote
|
COYOTE_CONFIG_DIR: /home/agent/.config/coyote
|
||||||
|
EDITOR: nano
|
||||||
proxyManaged:
|
proxyManaged:
|
||||||
- OPENAI_API_KEY
|
- OPENAI_API_KEY
|
||||||
- ANTHROPIC_API_KEY
|
- ANTHROPIC_API_KEY
|
||||||
@@ -238,73 +238,55 @@ environment:
|
|||||||
- ZHIPUAI_API_KEY
|
- ZHIPUAI_API_KEY
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
|
initFiles:
|
||||||
|
- path: /home/agent/.config/git/ssh-signing-key-command
|
||||||
|
mode: '0755'
|
||||||
|
description: Resolve the forwarded SSH agent key for Git SSH signing
|
||||||
|
content: |
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -z "$SSH_AUTH_SOCK" ]; then
|
||||||
|
echo "WARNING: [git-ssh-sign] no SSH agent - cannot sign commits" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
key=$(ssh-add -L 2>/dev/null | head -n 1)
|
||||||
|
if [ -z "$key" ]; then
|
||||||
|
echo "WARNING: [git-ssh-sign] no keys in SSH agent - cannot sign commits" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
config_dir="$GIT_SSH_SIGN_CONFIG_DIR"
|
||||||
|
if [ -z "$config_dir" ]; then
|
||||||
|
config_dir="/home/agent/.config/git"
|
||||||
|
fi
|
||||||
|
mkdir -p "$config_dir"
|
||||||
|
|
||||||
|
email=$(git config user.email 2>/dev/null || printf '%s' "agent@sandbox.local")
|
||||||
|
printf '%s %s\n' "$email" "$key" > "$config_dir/allowed_signers"
|
||||||
|
printf 'key::%s\n' "$key"
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- command: |
|
- command: |
|
||||||
sudo apt-get update &&
|
git config --system gpg.format ssh
|
||||||
sudo apt-get install -y \
|
git config --system --unset-all user.signingKey || true
|
||||||
jq curl git \
|
git config --system commit.gpgSign true
|
||||||
build-essential pkg-config \
|
git config --system tag.gpgSign true
|
||||||
cmake \
|
git config --system gpg.ssh.defaultKeyCommand /home/agent/.config/git/ssh-signing-key-command
|
||||||
clang libclang-dev \
|
git config --system gpg.ssh.allowedSignersFile /home/agent/.config/git/allowed_signers
|
||||||
musl-tools \
|
if [ "$(git config --system --get core.hooksPath || true)" = "/home/agent/.config/git/hooks" ]; then
|
||||||
libssl-dev \
|
git config --system --unset-all core.hooksPath
|
||||||
pandoc \
|
|
||||||
bzip2
|
|
||||||
user: "1000"
|
|
||||||
description: Install system prerequisites (including pandoc for fetch_url_via_curl)
|
|
||||||
- command: |
|
|
||||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
||||||
if [ -f "$HOME/.local/bin/uv" ]; then
|
|
||||||
printf '#!/bin/sh\nexec uv tool run "$@"\n' > "$HOME/.local/bin/uvx"
|
|
||||||
chmod +x "$HOME/.local/bin/uvx"
|
|
||||||
fi
|
fi
|
||||||
user: "1000"
|
user: '0'
|
||||||
description: Install uv and write a uvx shell wrapper (the installer may place a macOS binary at this path on Docker-for-Mac hosts, which the Linux container cannot execute)
|
description: Configure SSH commit signing with a dynamic key command
|
||||||
- command: |
|
|
||||||
set -euo pipefail
|
|
||||||
USQL_VERSION=0.21.4
|
|
||||||
ARCH=$(uname -m)
|
|
||||||
case "$ARCH" in
|
|
||||||
x86_64) USQL_ARCH=amd64 ;;
|
|
||||||
aarch64) USQL_ARCH=arm64 ;;
|
|
||||||
*) echo "Unsupported arch for usql install: $ARCH" >&2; exit 1 ;;
|
|
||||||
esac
|
|
||||||
TMPDIR=$(mktemp -d)
|
|
||||||
trap 'rm -rf "$TMPDIR"' EXIT
|
|
||||||
curl -fsSL --retry 3 "https://github.com/xo/usql/releases/download/v${USQL_VERSION}/usql_static-${USQL_VERSION}-linux-${USQL_ARCH}.tar.bz2" -o "$TMPDIR/usql.tar.bz2"
|
|
||||||
tar -xjf "$TMPDIR/usql.tar.bz2" -C "$TMPDIR"
|
|
||||||
sudo install -m 0755 "$TMPDIR/usql_static" /usr/local/bin/usql
|
|
||||||
user: "1000"
|
|
||||||
description: Install the usql universal SQL CLI (used by the built-in sql agent and execute_sql_code tool)
|
|
||||||
- command: |
|
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
|
|
||||||
sh -s -- -y \
|
|
||||||
--default-toolchain stable \
|
|
||||||
--profile minimal \
|
|
||||||
--target x86_64-unknown-linux-musl
|
|
||||||
. "$HOME/.cargo/env"
|
|
||||||
cargo install --locked coyote-ai
|
|
||||||
user: "1000"
|
|
||||||
description: Install Coyote AI CLI via Rust's Cargo
|
|
||||||
- command: |
|
|
||||||
. "$HOME/.cargo/env"
|
|
||||||
cargo install --locked iwec
|
|
||||||
user: "1000"
|
|
||||||
description: Install the IWE MCP server binary (iwec) used by the built-in iwe MCP server and iwe-knowledge-base skill
|
|
||||||
- command: |
|
|
||||||
. "$HOME/.cargo/env"
|
|
||||||
cargo install --locked ast-grep
|
|
||||||
user: "1000"
|
|
||||||
description: Install ast-grep, used by the built-in ast_grep structural code search tool (and the explore agent)
|
|
||||||
|
|
||||||
startup:
|
startup:
|
||||||
- command:
|
- command:
|
||||||
[
|
[
|
||||||
"sh",
|
'sh',
|
||||||
"-c",
|
'-c',
|
||||||
'test -f "$HOME/.config/coyote/config.yaml" || coyote --info >/dev/null 2>&1 || true',
|
'test -f "$HOME/.config/coyote/config.yaml" || coyote --info >/dev/null 2>&1 || true',
|
||||||
]
|
]
|
||||||
user: "1000"
|
user: '1000'
|
||||||
background: false
|
background: false
|
||||||
description: Bootstrap Coyote config directory on first sandbox start
|
description: Bootstrap Coyote config directory on first sandbox start
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
schemaVersion: "1"
|
|
||||||
kind: mixin
|
|
||||||
name: vault-aws-secrets-manager
|
|
||||||
description: >
|
|
||||||
Installs the AWS CLI v2 so the Coyote vault can read secrets from AWS
|
|
||||||
Secrets Manager inside the sandbox. The AWS Rust SDK does not strictly
|
|
||||||
require the CLI, but most users authenticate via `aws sso login` or
|
|
||||||
`aws configure`, which need the CLI to be installed. After install, run
|
|
||||||
the appropriate auth command in the sandbox; cached credentials persist
|
|
||||||
for the lifetime of the sandbox.
|
|
||||||
|
|
||||||
network:
|
|
||||||
allowedDomains:
|
|
||||||
- "awscli.amazonaws.com:443"
|
|
||||||
- "sts.amazonaws.com:443"
|
|
||||||
- "*.sts.amazonaws.com:443"
|
|
||||||
- "*.secretsmanager.amazonaws.com:443"
|
|
||||||
- "*.amazonaws.com:443"
|
|
||||||
- "*.awsapps.com:443"
|
|
||||||
|
|
||||||
commands:
|
|
||||||
install:
|
|
||||||
- command: |
|
|
||||||
set -euo pipefail
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y unzip
|
|
||||||
ARCH=$(uname -m)
|
|
||||||
curl -sSL "https://awscli.amazonaws.com/awscli-exe-linux-${ARCH}.zip" -o /tmp/awscliv2.zip
|
|
||||||
unzip -q /tmp/awscliv2.zip -d /tmp
|
|
||||||
sudo /tmp/aws/install
|
|
||||||
rm -rf /tmp/awscliv2.zip /tmp/aws
|
|
||||||
user: "1000"
|
|
||||||
description: Install AWS CLI v2 from the official installer
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
schemaVersion: "1"
|
|
||||||
kind: mixin
|
|
||||||
name: vault-azure-key-vault
|
|
||||||
description: >
|
|
||||||
Installs the Azure CLI (`az`) so the Coyote vault can read secrets from
|
|
||||||
Azure Key Vault inside the sandbox. After install, run `az login` in the
|
|
||||||
sandbox to authenticate; the session token persists for the lifetime of
|
|
||||||
the sandbox.
|
|
||||||
|
|
||||||
network:
|
|
||||||
allowedDomains:
|
|
||||||
- "aka.ms:443"
|
|
||||||
- "packages.microsoft.com:443"
|
|
||||||
- "azurecliprod.blob.core.windows.net:443"
|
|
||||||
- "login.microsoftonline.com:443"
|
|
||||||
- "graph.microsoft.com:443"
|
|
||||||
- "management.azure.com:443"
|
|
||||||
- "*.vault.azure.net:443"
|
|
||||||
|
|
||||||
commands:
|
|
||||||
install:
|
|
||||||
- command: "curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash"
|
|
||||||
user: "1000"
|
|
||||||
description: Install Azure CLI via Microsoft's official install script
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
schemaVersion: "1"
|
|
||||||
kind: mixin
|
|
||||||
name: vault-gcp-secret-manager
|
|
||||||
description: >
|
|
||||||
Installs the Google Cloud CLI (`gcloud`) so the Coyote vault can read
|
|
||||||
secrets from GCP Secret Manager inside the sandbox. The GCP Rust SDK does
|
|
||||||
not strictly require the CLI, but most users authenticate via
|
|
||||||
`gcloud auth application-default login`, which needs the CLI to be
|
|
||||||
installed. After install, run that command in the sandbox; the ADC file
|
|
||||||
persists for the lifetime of the sandbox.
|
|
||||||
|
|
||||||
network:
|
|
||||||
allowedDomains:
|
|
||||||
- "packages.cloud.google.com:443"
|
|
||||||
- "accounts.google.com:443"
|
|
||||||
- "oauth2.googleapis.com:443"
|
|
||||||
- "secretmanager.googleapis.com:443"
|
|
||||||
- "cloudresourcemanager.googleapis.com:443"
|
|
||||||
- "*.googleapis.com:443"
|
|
||||||
|
|
||||||
commands:
|
|
||||||
install:
|
|
||||||
- command: |
|
|
||||||
set -euo pipefail
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y apt-transport-https ca-certificates gnupg
|
|
||||||
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" \
|
|
||||||
| sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list >/dev/null
|
|
||||||
curl -sSL https://packages.cloud.google.com/apt/doc/apt-key.gpg \
|
|
||||||
| sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y google-cloud-cli
|
|
||||||
user: "1000"
|
|
||||||
description: Install gcloud CLI from Google's official apt repository
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
schemaVersion: "1"
|
|
||||||
kind: mixin
|
|
||||||
name: vault-gopass
|
|
||||||
description: >
|
|
||||||
Installs `gopass` and `gpg` so the Coyote vault can read secrets from a
|
|
||||||
gopass store inside the sandbox. The store must be cloned manually
|
|
||||||
(gopass walks a user-specific git remote, so v1 only allowlists github.com
|
|
||||||
and gitlab.com; add other hosts via a user mixin if needed). After install,
|
|
||||||
run `gopass setup` or `gopass clone <remote>` in the sandbox.
|
|
||||||
|
|
||||||
network:
|
|
||||||
allowedDomains:
|
|
||||||
- "github.com:443"
|
|
||||||
- "api.github.com:443"
|
|
||||||
- "objects.githubusercontent.com:443"
|
|
||||||
- "gitlab.com:443"
|
|
||||||
|
|
||||||
commands:
|
|
||||||
install:
|
|
||||||
- command: |
|
|
||||||
set -euo pipefail
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y gnupg2 git
|
|
||||||
GOPASS_VERSION="1.15.13"
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
|
||||||
curl -sSL "https://github.com/gopasspw/gopass/releases/download/v${GOPASS_VERSION}/gopass_${GOPASS_VERSION}_linux_${ARCH}.deb" -o /tmp/gopass.deb
|
|
||||||
sudo dpkg -i /tmp/gopass.deb
|
|
||||||
rm -f /tmp/gopass.deb
|
|
||||||
user: "1000"
|
|
||||||
description: Install gnupg2, git, and gopass from the official .deb release
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
schemaVersion: "1"
|
|
||||||
kind: mixin
|
|
||||||
name: vault-one-password
|
|
||||||
description: >
|
|
||||||
Installs the 1Password CLI (`op`) so the Coyote vault can decrypt secrets
|
|
||||||
inside the sandbox. After install, run `op signin` in the sandbox to
|
|
||||||
authenticate; credentials persist for the lifetime of the sandbox.
|
|
||||||
|
|
||||||
network:
|
|
||||||
allowedDomains:
|
|
||||||
- "downloads.1password.com:443"
|
|
||||||
- "cache.agilebits.com:443"
|
|
||||||
- "my.1password.com:443"
|
|
||||||
- "my.1password.eu:443"
|
|
||||||
- "my.1password.ca:443"
|
|
||||||
- "events.1password.com:443"
|
|
||||||
|
|
||||||
commands:
|
|
||||||
install:
|
|
||||||
- command: |
|
|
||||||
set -euo pipefail
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y unzip
|
|
||||||
OP_VERSION="v2.30.3"
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
|
||||||
curl -sSL "https://cache.agilebits.com/dist/1P/op2/pkg/${OP_VERSION}/op_linux_${ARCH}_${OP_VERSION}.zip" -o /tmp/op.zip
|
|
||||||
sudo unzip -od /usr/local/bin /tmp/op.zip op
|
|
||||||
sudo chmod +x /usr/local/bin/op
|
|
||||||
rm -f /tmp/op.zip
|
|
||||||
user: "1000"
|
|
||||||
description: Install 1Password CLI from the official archive
|
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
---
|
||||||
|
description: Adversarial plan-conformance review of an implementation against the task/plan it was supposed to satisfy. Verdict is CONFORMS or DIVERGES with acceptance-criterion-referenced complaints. Grants read-only filesystem access for ground-truth checks. Complements code-review (which judges code quality); this judges whether the code is the RIGHT code per the plan.
|
||||||
|
enabled_tools: fs_read, fs_grep, fs_glob, fs_cat, fs_ls
|
||||||
|
---
|
||||||
|
You are an adversarial plan-conformance reviewer. A code-quality reviewer already asks "is this code good?" — you ask a different, harder question: **"is this the code the plan asked for, and ONLY that?"** You are hunting for the gap between what was specified and what was built. Assume the implementer drifted, cut a corner, or misread the plan until the diff proves otherwise. Your independence is the value: you have no stake in the implementation decisions and no reason to rationalize them.
|
||||||
|
|
||||||
|
You review THE CHANGE against THE PLAN. You are given (a) the diff, (b) the task/plan it implements — its Objective, Tasks, and above all its **Acceptance criteria**. If the plan is missing, say so and stop: you cannot judge conformance without a spec.
|
||||||
|
|
||||||
|
## The core discipline: map every acceptance criterion to evidence
|
||||||
|
|
||||||
|
For EACH acceptance criterion in the plan, find the specific evidence in the diff that satisfies it, and classify:
|
||||||
|
|
||||||
|
| Verdict per criterion | Meaning |
|
||||||
|
|---|---|
|
||||||
|
| ✅ **Met** | The diff contains code that observably satisfies this criterion, AND a test that will fail if it regresses. Cite the file:line. |
|
||||||
|
| ⚠️ **Partial** | Some of the criterion is implemented but a case, path, or sub-requirement is missing. Name what's missing. |
|
||||||
|
| ❌ **Unmet** | No code in the diff satisfies this criterion. The "dog that didn't bark." |
|
||||||
|
| 🔀 **Diverged** | The diff implements something ADJACENT to the criterion but not it — different interface, different behavior, different data shape than specified. |
|
||||||
|
|
||||||
|
A criterion with no corresponding test is at best ⚠️ Partial — "implemented but unverifiable" is not "met." An acceptance criterion is a promise of observable behavior; if nothing proves the behavior, the promise is unkept.
|
||||||
|
|
||||||
|
## What to hunt for (adversarial checklist)
|
||||||
|
|
||||||
|
### 1. Silently skipped criteria (the dog that didn't bark)
|
||||||
|
Read the acceptance criteria list, then the diff. Every criterion with no matching change is a finding. Implementers under-deliver far more often by *omission* than by writing wrong code. The absent migration, the un-added error path, the criterion #4 that quietly became "out of scope" without anyone deciding that — these are your highest-value catches.
|
||||||
|
|
||||||
|
### 2. Silent scope drift
|
||||||
|
- **Scope creep:** code in the diff that no criterion or task asked for. New abstractions, refactors of untouched code, "while I was in here" changes. Flag it — the plan defined the scope, and the implementer doesn't get to redefine it unilaterally.
|
||||||
|
- **Interface drift:** the plan named a symbol/signature/endpoint/column exactly (`RecordPurchase` using `ExternalTierID`, a `tier_id` column, a specific RPC). The diff uses a different name or shape. Even if the code works, it diverged from the contract other steps depend on.
|
||||||
|
- **Approach substitution:** the plan (or a recorded decision) said "do X, not Y, because Z." The diff does Y. The implementer re-litigated a settled decision. Flag it with the plan's stated reason.
|
||||||
|
|
||||||
|
### 3. Ground-truth verification (verify, don't trust the diff's self-description)
|
||||||
|
The diff shows what changed, not whether it's correct against the codebase:
|
||||||
|
- `fs_grep` every symbol the plan requires — confirm the diff actually introduced/changed it, spelled as specified.
|
||||||
|
- `fs_read` around each hunk to confirm the change lands in the right place and the enclosing scope makes the criterion true (not just that a line matching the keyword appears).
|
||||||
|
- `fs_grep` the callers of anything changed — a criterion is not met if the new behavior isn't actually reached.
|
||||||
|
- Confirm tests exist AND target the criterion's behavior, not the implementation. A tautological test (`assert x.is_empty() || !x.is_empty()`) counts as no test.
|
||||||
|
|
||||||
|
### 4. Out-of-scope violations
|
||||||
|
If the plan has an "Out of scope" section, check the diff didn't touch those things. Touching explicitly-excluded surface is a divergence even if the code is fine.
|
||||||
|
|
||||||
|
### 5. Downstream contract breakage
|
||||||
|
If this change creates a surface a LATER step depends on (per the plan's dependency graph), verify the surface matches what those downstream steps will expect. A rename here that breaks step N+2's stated assumption is a divergence you catch now or pay for later.
|
||||||
|
|
||||||
|
## Verdict format
|
||||||
|
|
||||||
|
End with EXACTLY one of:
|
||||||
|
|
||||||
|
```
|
||||||
|
ADVERSARIAL_REVIEW: CONFORMS
|
||||||
|
Criteria: N/N met (all with tests).
|
||||||
|
<optional: 1-3 non-blocking observations>
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
ADVERSARIAL_REVIEW: DIVERGES
|
||||||
|
Criteria: X/N met, Y partial, Z unmet/diverged.
|
||||||
|
Complaints:
|
||||||
|
1. Acceptance criterion "<quote the criterion>" — <Unmet|Partial|Diverged> — <what the diff does or fails to do, with file:line> — <what would make it conform>
|
||||||
|
2. Scope drift — <file:line> — <what was added that no criterion asked for> — remove or get it into scope
|
||||||
|
3. ...
|
||||||
|
```
|
||||||
|
|
||||||
|
Every complaint MUST tie to a specific acceptance criterion (quoted) or a specific scope/interface/out-of-scope violation, and MUST cite file:line. "The implementation seems incomplete" is noise; `criterion "returns 429 after 3 failed attempts" — Unmet — retry.go has no attempt counter; the loop retries forever (retry.go:41) — add a bounded counter and a test asserting the 4th call returns 429` is signal.
|
||||||
|
|
||||||
|
## Scope discipline (what you are NOT)
|
||||||
|
|
||||||
|
- You are NOT the code-quality reviewer. Do not flag style, naming aesthetics, micro-optimizations, or "I'd have written it differently" unless it causes a criterion to be unmet. The `code-review` skill owns quality; you own conformance. If a quality issue is severe enough to break a criterion (a race that violates a correctness criterion), flag it as a conformance failure and note it's also a quality issue.
|
||||||
|
- You do NOT rewrite the code or the plan. You produce a verdict and complaints; the implementer owns the fix.
|
||||||
|
- If the plan itself is wrong (asks for something impossible or self-contradictory), that is a DIVERGES with a complaint that the plan is the root cause — do not paper over it by judging against a plan you silently corrected.
|
||||||
|
- Three decisive divergences beat fifteen weak ones. If every criterion is a nitpick, the change probably CONFORMS — say so.
|
||||||
|
|
||||||
|
## Anti-patterns
|
||||||
|
|
||||||
|
- Rubber-stamping CONFORMS because the code "looks done" without mapping each criterion to evidence.
|
||||||
|
- Judging code quality instead of plan conformance (that's the other reviewer's job).
|
||||||
|
- Accepting a criterion as met with no test proving it.
|
||||||
|
- Missing a silently-skipped criterion because you only reviewed what's IN the diff, never what's ABSENT.
|
||||||
|
- Complaints with no criterion reference and no file:line.
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
---
|
||||||
|
description: AI-first design decomposition for any project. Given a design doc or topic, ground in the actual codebase, produce (or refine) a PLAN file with problem, approach, alternatives, constraints, and a task breakdown sized to ~1 engineer-day per task with measurable acceptance criteria. The plan is written to be a self-contained "sealed container" for context-free implementers. Grants filesystem access for grounding and for writing the plan.
|
||||||
|
enabled_tools: fs_read, fs_grep, fs_glob, fs_ls, fs_cat, fs_write
|
||||||
|
---
|
||||||
|
You are decomposing a design doc (or topic) into an executable plan. The output is ONE plan file plus a task breakdown that context-free LLM implementers will execute later with zero access to this conversation. Everything they need must be on the page or pointed to — see the "sealed container" standard below.
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
- A design doc (path or pasted), or a one-line problem statement.
|
||||||
|
- The target project directory (ground truth for all claims).
|
||||||
|
- The plans directory where the PLAN file lands.
|
||||||
|
|
||||||
|
## Step 1 — Ground before proposing
|
||||||
|
|
||||||
|
Plans written from memory rot on contact with the code. Before writing anything:
|
||||||
|
|
||||||
|
- Read the project's own orientation docs (`CLAUDE.md`, `AGENTS.md`, `CONTRIBUTING.md`, `README.md` at the project root) — conventions constrain the design.
|
||||||
|
- Read the code the design touches: entry points, the modules to be changed, neighboring examples of the patterns to follow, existing tests.
|
||||||
|
- `fs_grep` every symbol the design doc references — confirm it exists and is spelled right. Note explicitly: what already exists, what would be added, what would change.
|
||||||
|
- Verify build/test commands actually exist (`Makefile`, `justfile`, `package.json` scripts, CI config).
|
||||||
|
|
||||||
|
## Step 2 — The proposal
|
||||||
|
|
||||||
|
Produce a structured proposal (iterate with the user when interactive; in autonomous runs, resolve what the doc + code answer and flag the rest as open questions):
|
||||||
|
|
||||||
|
- **Problem** — one paragraph; state assumptions explicitly.
|
||||||
|
- **Scope** — In / Out. Call out tempting adjacent work being deferred.
|
||||||
|
- **Approach** — concrete: name files, symbols, data flow, migrations. Reference existing patterns by path.
|
||||||
|
- **Alternatives considered** — table of alternative → why rejected. Settled decisions carry their one-line reason (an unrecorded decision WILL be re-litigated by an implementer).
|
||||||
|
- **Constraints and risks** — conventions the design must respect; ordering dependencies; things you're uncertain about, flagged clearly.
|
||||||
|
- **Open questions** — ONLY questions the codebase cannot answer (business rules, priority calls). If none, say "No open questions."
|
||||||
|
- **Task breakdown** — see below.
|
||||||
|
|
||||||
|
## Task breakdown rules
|
||||||
|
|
||||||
|
| Rule | Why |
|
||||||
|
|---|---|
|
||||||
|
| **One task ≈ one engineer-day** | Variable task sizes destroy progress signal; anything larger gets decomposed NOW, not mid-run |
|
||||||
|
| Each task independently implementable and verifiable | It builds and its tests pass without later tasks existing |
|
||||||
|
| Explicit, acyclic dependencies (`blocked_by`) | Execution order must be derivable from the breakdown alone |
|
||||||
|
| Each task states WHERE (files/packages) and WHAT (observable outcome) | "Implement service layer" is not a task; "internal/foo/service.go: add Create/Get with validation — returns 400 on missing name" is |
|
||||||
|
| Measurable acceptance criteria per task | Criteria become the tests; "works correctly" is unmeasurable |
|
||||||
|
| Flag ⚠️ low-confidence sizing with the reason | Honest sizing beats optimistic sizing |
|
||||||
|
|
||||||
|
## Step 3 — Write the PLAN file
|
||||||
|
|
||||||
|
Write `PLAN-<slug>.md` (kebab-case slug from the topic; verify no collision) to the plans directory:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
---
|
||||||
|
slug: <slug>
|
||||||
|
status: draft # draft | active | implemented
|
||||||
|
created: YYYY-MM-DD
|
||||||
|
---
|
||||||
|
|
||||||
|
# <Title>
|
||||||
|
|
||||||
|
## Problem
|
||||||
|
## Scope (In / Out)
|
||||||
|
## Approach
|
||||||
|
## Alternatives considered
|
||||||
|
## Constraints and risks
|
||||||
|
## Open questions
|
||||||
|
## Task breakdown
|
||||||
|
|
||||||
|
| # | Task | Size | blocked_by | Notes |
|
||||||
|
|---|------|------|-----------|-------|
|
||||||
|
```
|
||||||
|
|
||||||
|
The plan is the implementers' entire context. Write for the "sealed container" standard: every question an implementer will hit is either answered inline or delegated via a pointer to the exact file/doc that answers it (where infra code goes, what DB tech, which layout to mirror, exact test commands). Paste short code snippets for load-bearing patterns — a path alone forces re-exploration; a stale claim fails the executor mid-implementation.
|
||||||
|
|
||||||
|
## Anti-patterns
|
||||||
|
|
||||||
|
- Proposing before reading the code — a design ungrounded in the actual codebase is fiction.
|
||||||
|
- "As discussed" / "per our conversation" — the implementer has no conversation.
|
||||||
|
- Tasks larger than a day hiding an "and then also…".
|
||||||
|
- Acceptance criteria describing implementation ("uses a for loop") instead of behavior.
|
||||||
|
- Open questions the code could have answered — grep first, ask last.
|
||||||
|
- Unrecorded decisions — every settled fork carries its reason.
|
||||||
@@ -16,6 +16,10 @@ evidence yourself — never ask the user to run commands and paste output back.
|
|||||||
5. **State each hypothesis in one line before testing it.** Pivot openly when disproved.
|
5. **State each hypothesis in one line before testing it.** Pivot openly when disproved.
|
||||||
6. **Fix root cause, then verify** by re-running the original failing operation. No verification, no fix.
|
6. **Fix root cause, then verify** by re-running the original failing operation. No verification, no fix.
|
||||||
|
|
||||||
|
## When to Stop Gathering Evidence
|
||||||
|
|
||||||
|
Once you have two or more independent pieces of evidence pointing to the same root cause, **stop gathering and deliver your diagnosis**. Do not add more verification steps to verify your verification. If you notice yourself thinking "let me just confirm one more thing" after you have already reached a conclusion, that is the signal to stop and explain the diagnosis instead. More data is not always better — a timely diagnosis with strong evidence beats an exhaustive audit.
|
||||||
|
|
||||||
## Command Discipline
|
## Command Discipline
|
||||||
|
|
||||||
- Non-interactive and bounded, always: `--no-pager`, `-n`/`--since` on logs, `timeout 10` on anything that might
|
- Non-interactive and bounded, always: `--no-pager`, `-n`/`--since` on logs, `timeout 10` on anything that might
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ Use IWE tools when the task involves a corpus of markdown documents: plan reposi
|
|||||||
|
|
||||||
Do NOT use IWE tools for:
|
Do NOT use IWE tools for:
|
||||||
|
|
||||||
- **Agent memory** (`.coyote/memory/`, `COYOTE.md`) — use the `memory__*` tools; they own the index conventions there.
|
- **Agent memory** (`.coyote/memory/`) — use the `memory__*` tools; they own the index conventions there.
|
||||||
|
- **Workspace instructions** (`COYOTE.md`, `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`) — human-curated and read-only; never edit them with IWE write tools.
|
||||||
- **Semantic/similarity search over documents** — that is RAG's job. IWE search is fuzzy title/key matching plus structural traversal, not embeddings.
|
- **Semantic/similarity search over documents** — that is RAG's job. IWE search is fuzzy title/key matching plus structural traversal, not embeddings.
|
||||||
- **Source code** — IWE only understands markdown.
|
- **Source code** — IWE only understands markdown.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
---
|
||||||
|
description: Gatekeep a plan for self-containedness before it is finalized. A plan must be a "sealed container" - either it answers every question a context-free LLM implementer will hit, or it points at the exact code/docs where the answer lives. Produces the missing questions and a PLAN_GATE SEALED/LEAKY verdict. Grants read-only filesystem access for verifying pointers actually resolve. Complements plan-review (executability) - this checks completeness of context, not correctness of approach.
|
||||||
|
enabled_tools: fs_read, fs_grep, fs_glob, fs_cat, fs_ls
|
||||||
|
---
|
||||||
|
You are gatekeeping a plan before it is finalized. The standard is the **sealed-container test**: a fresh LLM implementer with ZERO conversation context and ZERO tribal knowledge will execute this plan. Every question that implementer would need answered mid-implementation must be either (a) **answered inline** in the plan, or (b) **delegated via a pointer** — an exact file/doc path that verifiably contains the answer. A plan that assumes the reader "just knows" where infrastructure code lives, which DB tech to use, or how services are laid out is a leaky container: the implementer will guess, and guesses become divergences.
|
||||||
|
|
||||||
|
You are NOT reviewing the approach (that is `plan-review`'s job — executability, verifiability, ordering). You are auditing **completeness of context**. A plan with a flawless approach still fails this gate if it leaves the implementer to rediscover the environment.
|
||||||
|
|
||||||
|
## The answer-or-pointer rule
|
||||||
|
|
||||||
|
For every question in the manifest below, the plan must contain ONE of:
|
||||||
|
|
||||||
|
1. **Inline answer** — the fact stated directly ("the service DB is Postgres on RDS, provisioned via `infra/rds/`", "migrations live in `internal/db/migrations/` and use goose").
|
||||||
|
2. **Verified pointer** — a path to code or docs where the implementer can discover it ("read `CLAUDE.md` § Database conventions", "mirror the layout of `internal/services/rate_cards/`").
|
||||||
|
|
||||||
|
An answer of neither kind = a missing question = a leak. "Follow existing conventions" with no pointer to WHICH file shows the convention is a leak. A pointer to a file that doesn't exist or doesn't actually cover the topic is a leak wearing a pointer costume — which is why you verify.
|
||||||
|
|
||||||
|
## The manifest (question categories to audit)
|
||||||
|
|
||||||
|
Walk EVERY category. For each, ask: "when the implementer hits this, does the plan answer it or point to the answer?"
|
||||||
|
|
||||||
|
| # | Category | Questions the implementer WILL hit |
|
||||||
|
|---|----------|-------------------------------------|
|
||||||
|
| 1 | **Code placement** | Which repo? Which directory/package? Does a new service/module follow an existing layout — which one, exactly? |
|
||||||
|
| 2 | **Infrastructure** | Where does infra code live? What is the deployment target (e.g. new DB in RDS via Terraform vs a Postgres container in Kubernetes)? Who provisions it — this plan's tasks, or a prerequisite? |
|
||||||
|
| 3 | **Data layer** | What DB tech/engine? What migration tool and directory? What naming conventions for tables/columns? Which existing tables does this touch or reference? |
|
||||||
|
| 4 | **Interfaces & contracts** | What protos/APIs/RPCs are consumed or exposed — exact names? Where do proto definitions live and how are they regenerated? What downstream consumers depend on the shapes this plan creates? |
|
||||||
|
| 5 | **Conventions & tooling** | Which language/framework versions? Error-handling and logging patterns — which file shows the canon? Lint/format/build commands? Where is the repo's own CLAUDE.md / contributor doc and does the plan tell the implementer to read it? |
|
||||||
|
| 6 | **Testing & verification** | Test framework and directory conventions? EXACT commands to run tests/build from the repo root? What proves each acceptance criterion? |
|
||||||
|
| 7 | **Dependencies & ordering** | What must exist before this plan starts (other tasks, migrations, provisioned infra)? What does this plan produce that later work depends on? |
|
||||||
|
| 8 | **Config, secrets & environments** | New env vars/config keys — where are they declared and injected? Secrets — vault/parameter store conventions? Staging vs production differences that affect implementation? |
|
||||||
|
| 9 | **Scope boundaries** | Is Out of scope present and specific? Are "tempting adjacent fixes" explicitly deferred? |
|
||||||
|
| 10 | **Settled decisions** | Are choices that were debated recorded WITH their one-line reason ("RDS over in-cluster Postgres because ops owns backups")? An unrecorded decision WILL be re-litigated by the implementer. |
|
||||||
|
|
||||||
|
Not every category applies to every plan (a docs-only plan has no data layer). Mark inapplicable categories as such — silently skipping one is how leaks survive.
|
||||||
|
|
||||||
|
## Pointer verification (do not trust, verify)
|
||||||
|
|
||||||
|
For every pointer the plan offers:
|
||||||
|
|
||||||
|
1. `fs_ls` / `fs_glob` — the referenced path exists.
|
||||||
|
2. `fs_grep` / `fs_read` — the file actually covers the claimed topic. A plan saying "see `docs/database.md` for migration conventions" fails verification if that file never mentions migrations.
|
||||||
|
3. For "mirror the layout of X" pointers — confirm X exists and is a real example of what the plan claims (a service directory held up as the canonical layout should actually contain the layers the plan describes).
|
||||||
|
|
||||||
|
A broken pointer is worse than no pointer: it burns the implementer's time AND their trust in the rest of the plan.
|
||||||
|
|
||||||
|
## Severity honesty
|
||||||
|
|
||||||
|
Not every gap is equal. Tag each finding:
|
||||||
|
|
||||||
|
- **BLOCKING** — the implementer cannot proceed or will guess wrong with expensive consequences (wrong DB target, wrong repo, missing prerequisite).
|
||||||
|
- **FRICTION** — the implementer can discover the answer but will waste significant time re-exploring what the author already knew.
|
||||||
|
|
||||||
|
A plan with only FRICTION findings may still be sealed at the caller's discretion — say so. BLOCKING findings always mean LEAKY.
|
||||||
|
|
||||||
|
## Verdict format
|
||||||
|
|
||||||
|
End with EXACTLY one of:
|
||||||
|
|
||||||
|
```
|
||||||
|
PLAN_GATE: SEALED
|
||||||
|
Categories audited: N applicable, all answered or pointed.
|
||||||
|
<optional: 1-3 non-blocking observations>
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
PLAN_GATE: LEAKY
|
||||||
|
Missing questions (N):
|
||||||
|
1. [category] <the exact question the implementer will hit> — [BLOCKING|FRICTION] — <why they get stuck or guess wrong> — <suggested fix: the inline answer to add, or the pointer to insert (verified to exist)>
|
||||||
|
2. ...
|
||||||
|
Broken pointers (if any):
|
||||||
|
- <plan's pointer> — <what's wrong: path missing / doesn't cover topic>
|
||||||
|
```
|
||||||
|
|
||||||
|
Every missing question must be phrased as the QUESTION the implementer would actually ask ("where do I put the Terraform for the new RDS instance?"), not as an abstract complaint ("infra section is thin"). When you suggest a pointer as the fix, VERIFY it first — never recommend a pointer you haven't confirmed resolves.
|
||||||
|
|
||||||
|
## Scope discipline
|
||||||
|
|
||||||
|
- Do not redesign the approach. If the approach is coherent but under-documented, the fix is context, not redesign.
|
||||||
|
- Do not demand encyclopedic plans. The container test is "answered or pointed" — a tight plan full of verified pointers beats a bloated plan that inlines the whole wiki. Flag over-inlining only if it duplicates something that WILL drift (e.g. pasted conventions that contradict the source file).
|
||||||
|
- Three BLOCKING questions beat fifteen FRICTION nitpicks. If your list is all nitpicks, the plan is probably SEALED — say so.
|
||||||
|
|
||||||
|
## Anti-patterns
|
||||||
|
|
||||||
|
- Sealing a plan because the approach is good, without walking the manifest.
|
||||||
|
- Flagging "missing context" without phrasing the actual question the implementer would ask.
|
||||||
|
- Recommending a pointer you did not verify exists and covers the topic.
|
||||||
|
- Treating an inapplicable category as a leak (demanding a data-layer section from a docs-only plan).
|
||||||
|
- Re-reviewing executability/approach — that is `plan-review`'s lane.
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
---
|
||||||
|
description: File-based task tracking for plan-driven runs on any project. Defines the TASK-NNN directory schema (index.md + append-only log.md), the frontmatter lifecycle (pending/in-progress/blocked/complete), numbering, the completion protocol, and follow-up task creation. The tasks directory on disk is the durable run state - it survives context compression. Grants filesystem access for managing task files.
|
||||||
|
enabled_tools: fs_read, fs_grep, fs_glob, fs_ls, fs_cat, fs_write, fs_patch, fs_mkdir
|
||||||
|
---
|
||||||
|
You are tracking implementation tasks as files. The task directory is the durable source of truth for run state — anything that lives only in chat history is lost to context compression. Keep it current at every state change, not in batches.
|
||||||
|
|
||||||
|
## Layout
|
||||||
|
|
||||||
|
```
|
||||||
|
<plans_dir>/
|
||||||
|
PLAN-<slug>.md # the plan (see design-session / plan-authoring)
|
||||||
|
tasks/
|
||||||
|
TASK-001-<slug>/
|
||||||
|
index.md # current state: frontmatter + What/Steps/Acceptance criteria
|
||||||
|
log.md # append-only audit trail
|
||||||
|
TASK-002-<slug>/
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
## index.md schema
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
---
|
||||||
|
title: <short imperative title>
|
||||||
|
status: pending # pending | in-progress | blocked | complete
|
||||||
|
type: feature # feature | chore | followup
|
||||||
|
points: 1.0 # engineer-days; ~1.0 per the sizing rule
|
||||||
|
plan: PLAN-<slug>.md
|
||||||
|
blocked_by: [] # TASK ids that must be complete first
|
||||||
|
created: YYYY-MM-DD
|
||||||
|
---
|
||||||
|
|
||||||
|
## What
|
||||||
|
|
||||||
|
One paragraph: what this task produces, named concretely (files, symbols, behaviors).
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
- [ ] Concrete step — name the file, function, or migration
|
||||||
|
- [ ] ...
|
||||||
|
|
||||||
|
## Acceptance criteria
|
||||||
|
|
||||||
|
- [ ] Observable behavior, measurable ("returns 429 after 3 failed attempts")
|
||||||
|
- [ ] ...
|
||||||
|
```
|
||||||
|
|
||||||
|
Status lives in frontmatter — there are no lifecycle directories. `status: complete` plus all boxes checked IS done.
|
||||||
|
|
||||||
|
## log.md conventions
|
||||||
|
|
||||||
|
Append-only. Each entry is an H2: `## YYYY-MM-DD — <short label>` (`created`, `started`, `implemented`, `diverged`, `completed`, ...). Body is 1-3 sentences of prose; structured data lives in markdown links (branch URLs, commit SHAs, PR links). Never rewrite an old entry — add a new one.
|
||||||
|
|
||||||
|
## Numbering
|
||||||
|
|
||||||
|
Scan `tasks/TASK-*` for the highest NNN and increment (zero-padded to 3). This assumes a single writer per plans directory; if multiple agents or people share one, serialize task creation.
|
||||||
|
|
||||||
|
## Lifecycle protocol
|
||||||
|
|
||||||
|
| Transition | Do |
|
||||||
|
|---|---|
|
||||||
|
| Create | `fs_mkdir` the dir; write `index.md` (status: pending) + `log.md` with a `created` entry |
|
||||||
|
| Claim | frontmatter `status: in-progress`; log `started` (note the branch + base SHA) |
|
||||||
|
| Blocked | `status: blocked`; log why and what unblocks it |
|
||||||
|
| Complete | Check off every Step and Acceptance criterion (verified, not aspirational); log `completed` with commit SHAs AND any follow-ups reported by the implementer, VERBATIM; set `status: complete` |
|
||||||
|
|
||||||
|
Never mark a criterion checked without evidence. Never batch state changes — update at the moment of transition.
|
||||||
|
|
||||||
|
## Follow-up tasks
|
||||||
|
|
||||||
|
When implementation surfaces manual/out-of-scope actions (secrets to create, cloud roles to provision, console steps, cross-repo changes): create a task per item (group small related ones) with `type: followup`, `status: pending`, the WHAT/WHERE/WHY/WHEN in its What section, and a note of which TASK surfaced it. Follow-ups are deliverables to hand to the user — never implement them in the current run.
|
||||||
|
|
||||||
|
## Consistency checks (run at the end of a run)
|
||||||
|
|
||||||
|
- Every task dir has both `index.md` and `log.md`.
|
||||||
|
- Every `blocked_by` reference resolves to an existing task.
|
||||||
|
- No task is `complete` with unchecked Steps/Acceptance criteria.
|
||||||
|
- Every `complete` task's log has a `completed` entry with commit references.
|
||||||
|
- The PLAN's breakdown table rows all map to task dirs (and vice versa).
|
||||||
|
|
||||||
|
## Anti-patterns
|
||||||
|
|
||||||
|
- Run state that exists only in chat — session ids, decisions, and follow-ups belong in task files.
|
||||||
|
- `status: complete` with unchecked boxes, or checked boxes without evidence.
|
||||||
|
- Rewriting log history instead of appending.
|
||||||
|
- Hand-picking a task number without scanning (collisions).
|
||||||
|
- Follow-ups mentioned in a summary but never materialized as task files.
|
||||||
@@ -7,12 +7,15 @@
|
|||||||
# - <agent-name>_TOP_P
|
# - <agent-name>_TOP_P
|
||||||
# - <agent-name>_GLOBAL_TOOLS (as a JSON string array)
|
# - <agent-name>_GLOBAL_TOOLS (as a JSON string array)
|
||||||
# - <agent-name>_MCP_SERVERS (as a JSON string array)
|
# - <agent-name>_MCP_SERVERS (as a JSON string array)
|
||||||
|
# - <agent-name>_SPAWNABLE_AGENTS (as a JSON string array; see spawnable_agents below)
|
||||||
# - <agent-name>_AGENT_SESSION
|
# - <agent-name>_AGENT_SESSION
|
||||||
# - <agent-name>_VARIABLES (as JSON array of key-value pairs; e.g. '[{"name": "username", "value": "alex"}]')
|
# - <agent-name>_VARIABLES (as JSON array of key-value pairs; e.g. '[{"name": "username", "value": "alex"}]')
|
||||||
|
|
||||||
model: openai:gpt-4o # Specify the LLM to use
|
model: openai:gpt-4o # Specify the LLM to use
|
||||||
temperature: null # Set default temperature parameter, range (0, 1)
|
temperature: null # Set default temperature parameter, range (0, 1)
|
||||||
top_p: null # Set default top-p parameter, with a range of (0, 1) or (0, 2) depending on the model
|
top_p: null # Set default top-p parameter, with a range of (0, 1) or (0, 2) depending on the model
|
||||||
|
reasoning_effort: null # Reasoning effort level for models that support it (e.g. low, medium, high).
|
||||||
|
# Only valid when the agent's model declares reasoning_levels.
|
||||||
agent_session: null # Set a session to use when starting the agent. (e.g. temp, default); defaults to globally set agent_session
|
agent_session: null # Set a session to use when starting the agent. (e.g. temp, default); defaults to globally set agent_session
|
||||||
name: <agent-name> # Name of the agent, used in the UI and logs
|
name: <agent-name> # Name of the agent, used in the UI and logs
|
||||||
description: <description> # Description of the agent, used in the UI
|
description: <description> # Description of the agent, used in the UI
|
||||||
@@ -30,6 +33,12 @@ continuation_prompt: null # Custom prompt used when auto-continuing (opti
|
|||||||
# Enable this agent to spawn and manage child agents in parallel.
|
# Enable this agent to spawn and manage child agents in parallel.
|
||||||
# See https://github.com/Dark-Alex-17/coyote/wiki/Agents for detailed documentation.
|
# See https://github.com/Dark-Alex-17/coyote/wiki/Agents for detailed documentation.
|
||||||
can_spawn_agents: false # Enable the agent to spawn child agents
|
can_spawn_agents: false # Enable the agent to spawn child agents
|
||||||
|
# spawnable_agents: # Optional whitelist restricting which agents can be spawned via `agent__spawn`.
|
||||||
|
# - explore # If omitted (the default), ALL installed agents are spawnable. This is the unrestricted default.
|
||||||
|
# - coder # Provide a list to restrict. Match is exact and case-sensitive (use directory names).
|
||||||
|
# - oracle # An empty list ([]) means literally nothing spawnable.
|
||||||
|
# Also filters `agent__list_available` output so the LLM only sees what it can spawn.
|
||||||
|
# Graph agents (graph.yaml) ignore this; they declare spawn targets in agent nodes.
|
||||||
max_concurrent_agents: 4 # Maximum number of agents that can run simultaneously
|
max_concurrent_agents: 4 # Maximum number of agents that can run simultaneously
|
||||||
max_agent_depth: 3 # Maximum nesting depth for sub-agents (prevents runaway spawning)
|
max_agent_depth: 3 # Maximum nesting depth for sub-agents (prevents runaway spawning)
|
||||||
inject_spawn_instructions: true # Inject the default agent spawning instructions into the agent's system prompt
|
inject_spawn_instructions: true # Inject the default agent spawning instructions into the agent's system prompt
|
||||||
|
|||||||
+57
-5
@@ -2,6 +2,8 @@
|
|||||||
model: openai:gpt-4o # Specify the LLM to use
|
model: openai:gpt-4o # Specify the LLM to use
|
||||||
temperature: null # Set default temperature parameter (0, 1)
|
temperature: null # Set default temperature parameter (0, 1)
|
||||||
top_p: null # Set default top-p parameter, with a range of (0, 1) or (0, 2) depending on the model
|
top_p: null # Set default top-p parameter, with a range of (0, 1) or (0, 2) depending on the model
|
||||||
|
reasoning_effort: null # Reasoning effort level for models that support it (e.g. low, medium, high).
|
||||||
|
# Only valid when the active model declares reasoning_levels. See the Clients docs.
|
||||||
|
|
||||||
# ---- Behavior ----
|
# ---- Behavior ----
|
||||||
stream: true # Controls whether to use the stream-style APIs when querying for completions from LLM clients.
|
stream: true # Controls whether to use the stream-style APIs when querying for completions from LLM clients.
|
||||||
@@ -18,6 +20,7 @@ agent_session: null # Set a session to use when starting an agent (
|
|||||||
|
|
||||||
# ---- Appearance ----
|
# ---- Appearance ----
|
||||||
highlight: true # Controls syntax highlighting
|
highlight: true # Controls syntax highlighting
|
||||||
|
raw_markdown: false # When true, render markdown as raw text with syntax highlighting only. When false (default), transforms markdown syntax (headings, bold, lists, etc.) into styled terminal output
|
||||||
light_theme: false # Activates a light color theme when true. env: COYOTE_LIGHT_THEME
|
light_theme: false # Activates a light color theme when true. env: COYOTE_LIGHT_THEME
|
||||||
|
|
||||||
# ---- Miscellaneous ----
|
# ---- Miscellaneous ----
|
||||||
@@ -31,7 +34,7 @@ sync_models_url: > # URL to sync model changes from
|
|||||||
left_prompt:
|
left_prompt:
|
||||||
'{color.red}{model}){color.green}{?session {?agent {agent}>}{session}{?role /}}{!session {?agent {agent}>}}{role}{?rag @{rag}}{color.cyan}{?session )}{!session >}{color.reset} '
|
'{color.red}{model}){color.green}{?session {?agent {agent}>}{session}{?role /}}{!session {?agent {agent}>}}{role}{?rag @{rag}}{color.cyan}{?session )}{!session >}{color.reset} '
|
||||||
right_prompt:
|
right_prompt:
|
||||||
'{color.purple}{?session {?consume_tokens {consume_tokens}({consume_percent}%)}{!consume_tokens {consume_tokens}}}{color.reset}'
|
'{color.cyan}{?reasoning_effort [{reasoning_effort}] }{color.purple}{?session {?consume_tokens {consume_tokens}({consume_percent}%)}{!consume_tokens {consume_tokens}}}{color.reset}'
|
||||||
|
|
||||||
# ---- Vault ----
|
# ---- Vault ----
|
||||||
# See the [Vault documentation](https://github.com/Dark-Alex-17/coyote/wiki/Vault) for more information on the Coyote vault.
|
# See the [Vault documentation](https://github.com/Dark-Alex-17/coyote/wiki/Vault) for more information on the Coyote vault.
|
||||||
@@ -134,6 +137,14 @@ enabled_mcp_servers: null # Which MCP servers to enable by default.
|
|||||||
# - slack
|
# - slack
|
||||||
# Example (comma-separated form):
|
# Example (comma-separated form):
|
||||||
# enabled_mcp_servers: github,slack,ddg-search
|
# enabled_mcp_servers: github,slack,ddg-search
|
||||||
|
no_workspace_mcp: false # Disable loading workspace-local MCP servers (default: false).
|
||||||
|
# When false (the default), Coyote merges the first workspace MCP config it finds
|
||||||
|
# into the global MCP registry at startup, checking in order:
|
||||||
|
# 1. .coyote/mcp.json
|
||||||
|
# 2. .coyote/.mcp.json (Claude-style file name)
|
||||||
|
# 3. .mcp.json (project root; Claude Code convention)
|
||||||
|
# Workspace entries shadow global ones on name collision.
|
||||||
|
# Set to true (or pass --no-workspace-mcp) to skip this entirely.
|
||||||
|
|
||||||
# ---- Skills ----
|
# ---- Skills ----
|
||||||
# Skills are modular knowledge or capability packs the LLM can load and unload mid-conversation.
|
# Skills are modular knowledge or capability packs the LLM can load and unload mid-conversation.
|
||||||
@@ -176,11 +187,13 @@ summarization_prompt: > # The text prompt used for creating a concise s
|
|||||||
'Summarize the discussion briefly in 200 words or less to use as a prompt for future context.'
|
'Summarize the discussion briefly in 200 words or less to use as a prompt for future context.'
|
||||||
summary_context_prompt: > # The text prompt used for including the summary of the entire session as context to the model
|
summary_context_prompt: > # The text prompt used for including the summary of the entire session as context to the model
|
||||||
'This is a summary of the chat history as a recap: '
|
'This is a summary of the chat history as a recap: '
|
||||||
|
compression_keep_last: 0 # Number of most-recent messages to keep visible after compression (0 = compress all messages)
|
||||||
|
max_tool_result_chars: null # Cap on tool result characters forwarded to the model per call (null = no cap)
|
||||||
|
|
||||||
# ---- Memory ----
|
# ---- Memory ----
|
||||||
# See the [Memory documentation](https://github.com/Dark-Alex-17/coyote/wiki/Memory) for more information.
|
# See the [Memory documentation](https://github.com/Dark-Alex-17/coyote/wiki/Memory) for more information.
|
||||||
# Memory is opt-in by workspace presence (a `COYOTE.md` or `.coyote/memory/MEMORY.md`)
|
# Memory is opt-in by workspace presence (`.coyote/memory/MEMORY.md`) and global
|
||||||
# and global presence (`<config_dir>/memory/MEMORY.md`). Set `memory: false` to disable
|
# presence (`<config_dir>/memory/MEMORY.md`). Set `memory: false` to disable
|
||||||
# even when memory files exist. The cascade is: agent > session > role > app.
|
# even when memory files exist. The cascade is: agent > session > role > app.
|
||||||
# Bootstrap with `coyote --init-memory [global|workspace]` to create the marker file
|
# Bootstrap with `coyote --init-memory [global|workspace]` to create the marker file
|
||||||
# the LLM needs before it will write any memory.
|
# the LLM needs before it will write any memory.
|
||||||
@@ -190,6 +203,18 @@ memory_cap_with_tools: null # Char cap for injected memory when function ca
|
|||||||
memory_cap_without_tools: null # Char cap when function calling is unavailable (default: 12000).
|
memory_cap_without_tools: null # Char cap when function calling is unavailable (default: 12000).
|
||||||
# Indexes plus drill file bodies are injected up to this cap.
|
# Indexes plus drill file bodies are injected up to this cap.
|
||||||
|
|
||||||
|
# ---- Workspace Instructions ----
|
||||||
|
# Human-curated project instructions injected read-only into the system prompt, in full.
|
||||||
|
# Coyote walks up from the current directory and injects the first match from the file
|
||||||
|
# chain below (per directory, in order). Scaffold with `coyote --init-instructions`.
|
||||||
|
# Disable per-invocation with --no-workspace-instructions, or override the chain with
|
||||||
|
# repeatable --workspace-instructions-file flags.
|
||||||
|
workspace_instructions: null # null/true = inject when an instructions file exists; false = never inject
|
||||||
|
workspace_instructions_files: null # File name chain to search, in priority order.
|
||||||
|
# Default: [COYOTE.md, AGENTS.md, CLAUDE.md, GEMINI.md]
|
||||||
|
# Set to a custom list to reorder or drop fallbacks, e.g.:
|
||||||
|
# workspace_instructions_files: [COYOTE.md]
|
||||||
|
|
||||||
# ---- RAG ----
|
# ---- RAG ----
|
||||||
# See the [RAG Docs](https://github.com/Dark-Alex-17/coyote/wiki/RAG) for more details.
|
# See the [RAG Docs](https://github.com/Dark-Alex-17/coyote/wiki/RAG) for more details.
|
||||||
rag_embedding_model: null # Specifies the embedding model used for context retrieval
|
rag_embedding_model: null # Specifies the embedding model used for context retrieval
|
||||||
@@ -199,7 +224,7 @@ rag_chunk_size: null # Defines the size of chunks for document proce
|
|||||||
rag_chunk_overlap: null # Defines the overlap between chunks
|
rag_chunk_overlap: null # Defines the overlap between chunks
|
||||||
rag_extractor_model: null # LLM model for graph-based entity/relationship extraction; when set, enables a graph RAG signal alongside vector and BM25
|
rag_extractor_model: null # LLM model for graph-based entity/relationship extraction; when set, enables a graph RAG signal alongside vector and BM25
|
||||||
rag_extractor_prompt: null # Custom extraction prompt template; must contain __CHUNK__ placeholder; defaults to built-in prompt when null
|
rag_extractor_prompt: null # Custom extraction prompt template; must contain __CHUNK__ placeholder; defaults to built-in prompt when null
|
||||||
rag_graph_hops: 1 # Number of hops to expand from matched entities at query time (1 = direct neighbors; increase for denser graphs)
|
rag_graph_hops: 1 # Number of hops to expand from matched entities at query time (0 = seed nodes only; 1 = direct neighbors; increase for denser graphs)
|
||||||
# Defines the query structure using variables like __CONTEXT__, __SOURCES__, and __INPUT__ to tailor searches to specific needs
|
# Defines the query structure using variables like __CONTEXT__, __SOURCES__, and __INPUT__ to tailor searches to specific needs
|
||||||
rag_template: |
|
rag_template: |
|
||||||
Answer the query based on the context while respecting the rules. (user query, some textual context and rules, all inside xml tags)
|
Answer the query based on the context while respecting the rules. (user query, some textual context and rules, all inside xml tags)
|
||||||
@@ -326,11 +351,38 @@ clients:
|
|||||||
api_base: https://api.mistral.ai/v1
|
api_base: https://api.mistral.ai/v1
|
||||||
api_key: '{{MISTRAL_API_KEY}}' # You can either hard-code or inject secrets from the Coyote vault
|
api_key: '{{MISTRAL_API_KEY}}' # You can either hard-code or inject secrets from the Coyote vault
|
||||||
|
|
||||||
# See https://docs.x.ai/docs
|
# See https://docs.x.ai/docs - OAuth via SuperGrok / X Premium+ subscription
|
||||||
- type: openai-compatible
|
- type: openai-compatible
|
||||||
name: xai
|
name: xai
|
||||||
api_base: https://api.x.ai/v1
|
api_base: https://api.x.ai/v1
|
||||||
api_key: '{{XAI_API_KEY}}' # You can either hard-code or inject secrets from the Coyote vault
|
api_key: '{{XAI_API_KEY}}' # You can either hard-code or inject secrets from the Coyote vault
|
||||||
|
auth: null # When set to 'oauth', Coyote will use OAuth instead of an API key
|
||||||
|
# Authenticate with `coyote --authenticate` or `.authenticate` in the REPL
|
||||||
|
# Note: Oauth requires SuperGrok/X Premium+ subscription
|
||||||
|
|
||||||
|
# Example: private OpenAI-compatible gateway with client_credentials OAuth
|
||||||
|
# - type: openai-compatible
|
||||||
|
# name: acme-gateway
|
||||||
|
# api_base: https://gateway.acme.com/v1
|
||||||
|
# auth: oauth
|
||||||
|
# oauth:
|
||||||
|
# client_id: '{{ACME_CLIENT_ID}}'
|
||||||
|
# client_secret: '{{ACME_CLIENT_SECRET}}'
|
||||||
|
# token_url: https://auth.acme.com/oauth/token
|
||||||
|
# scopes: [openai.chat]
|
||||||
|
# flow: client_credentials
|
||||||
|
|
||||||
|
# Example: OAuth via Device Authorization Grant (RFC 8628 — for CLIs like Moonshot's kimi-code, MiniMax mmx, etc.)
|
||||||
|
# - type: openai-compatible
|
||||||
|
# name: moonshot
|
||||||
|
# api_base: https://api.kimi.com/coding/v1
|
||||||
|
# auth: oauth
|
||||||
|
# oauth:
|
||||||
|
# client_id: '{{MOONSHOT_CLIENT_ID}}'
|
||||||
|
# device_authorization_url: https://auth.kimi.com/api/oauth/device_authorization
|
||||||
|
# token_url: https://auth.kimi.com/api/oauth/token
|
||||||
|
# flow: device_code
|
||||||
|
# # use_pkce_in_device_flow: true # enable if your provider requires PKCE with device flow
|
||||||
|
|
||||||
# See https://docs.ai21.com/docs/overview
|
# See https://docs.ai21.com/docs/overview
|
||||||
- type: openai-compatible
|
- type: openai-compatible
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ name: <role-name> # The name of the role
|
|||||||
model: openai:gpt-4o # The model to use for this role
|
model: openai:gpt-4o # The model to use for this role
|
||||||
temperature: 0.2 # The temperature to use for this role when querying the model
|
temperature: 0.2 # The temperature to use for this role when querying the model
|
||||||
top_p: 0 # The top_p to use for this role when querying the model
|
top_p: 0 # The top_p to use for this role when querying the model
|
||||||
|
reasoning_effort: null # Reasoning effort level for models that support it (e.g. low, medium, high).
|
||||||
|
# Only valid when the role's model declares reasoning_levels.
|
||||||
enabled_tools: # Tools to enable for this role. Accepts a YAML list (preferred)
|
enabled_tools: # Tools to enable for this role. Accepts a YAML list (preferred)
|
||||||
- fs_ls # or a comma-separated string (e.g. `enabled_tools: fs_ls,fs_cat`).
|
- fs_ls # or a comma-separated string (e.g. `enabled_tools: fs_ls,fs_cat`).
|
||||||
- fs_cat # Use `all` to enable every visible tool.
|
- fs_cat # Use `all` to enable every visible tool.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class Coyote < Formula
|
|||||||
sha256 "$hash_linux"
|
sha256 "$hash_linux"
|
||||||
end
|
end
|
||||||
version "$version"
|
version "$version"
|
||||||
license "MIT"
|
license "AGPL-3.0-only"
|
||||||
|
|
||||||
def install
|
def install
|
||||||
bin.install "coyote"
|
bin.install "coyote"
|
||||||
|
|||||||
+4
-1
@@ -33,6 +33,8 @@ version: "1.0" # Graph schema version. Only "1.0" is accepte
|
|||||||
model: claude:claude-sonnet-4-6 # Default model for `llm` nodes that don't override it
|
model: claude:claude-sonnet-4-6 # Default model for `llm` nodes that don't override it
|
||||||
temperature: 0.0 # Default sampling temperature for `llm` nodes
|
temperature: 0.0 # Default sampling temperature for `llm` nodes
|
||||||
top_p: null # Default sampling top-p for `llm` nodes
|
top_p: null # Default sampling top-p for `llm` nodes
|
||||||
|
reasoning_effort: null # Default reasoning effort for `llm` nodes that don't override it.
|
||||||
|
# Only valid when the model declares reasoning_levels.
|
||||||
|
|
||||||
global_tools: # Tool universe an `llm` node's `tools:` whitelist draws from
|
global_tools: # Tool universe an `llm` node's `tools:` whitelist draws from
|
||||||
- web_search_coyote.sh
|
- web_search_coyote.sh
|
||||||
@@ -227,7 +229,7 @@ nodes:
|
|||||||
reranker_model: null # Optional reranker for hybrid-search results
|
reranker_model: null # Optional reranker for hybrid-search results
|
||||||
extractor_model: null # Optional chat model for graph-based entity/relationship extraction; enables graph RAG signal when set
|
extractor_model: null # Optional chat model for graph-based entity/relationship extraction; enables graph RAG signal when set
|
||||||
extractor_prompt: null # Optional custom extraction prompt; must contain __CHUNK__ placeholder; uses built-in prompt when null
|
extractor_prompt: null # Optional custom extraction prompt; must contain __CHUNK__ placeholder; uses built-in prompt when null
|
||||||
graph_hops: 1 # Graph expansion depth at query time (1 = direct neighbors; increase for denser knowledge graphs)
|
graph_hops: 1 # Graph expansion depth at query time (0 = seed nodes only; 1 = direct neighbors; increase for denser knowledge graphs)
|
||||||
batch_size: 100 # Optional embedding-request batch size
|
batch_size: 100 # Optional embedding-request batch size
|
||||||
state_updates: # {{output}} = { context: <str>, sources: [<path>, ...] }
|
state_updates: # {{output}} = { context: <str>, sources: [<path>, ...] }
|
||||||
context: "{{output.context}}" # writes `context` -> `reducers.context = concat`
|
context: "{{output.context}}" # writes `context` -> `reducers.context = concat`
|
||||||
@@ -394,6 +396,7 @@ nodes:
|
|||||||
- mcp:ddg-search # `mcp:<server>` includes that server's functions
|
- mcp:ddg-search # `mcp:<server>` includes that server's functions
|
||||||
model: claude:claude-haiku-4-5 # Optional per-node model override
|
model: claude:claude-haiku-4-5 # Optional per-node model override
|
||||||
temperature: 0.3 # Optional per-node sampling override
|
temperature: 0.3 # Optional per-node sampling override
|
||||||
|
reasoning_effort: null # Optional per-node reasoning effort override (e.g. low, medium, high)
|
||||||
max_attempts: 2 # Retry count on transient errors only. Default 1.
|
max_attempts: 2 # Retry count on transient errors only. Default 1.
|
||||||
max_iterations: 10 # Tool-call-loop turn cap. Default 10.
|
max_iterations: 10 # Tool-call-loop turn cap. Default 10.
|
||||||
fallback: review # Route here if all attempts fail
|
fallback: review # Route here if all attempts fail
|
||||||
|
|||||||
@@ -23,3 +23,16 @@ fmt:
|
|||||||
[arg('build_type', pattern="debug|release")]
|
[arg('build_type', pattern="debug|release")]
|
||||||
build build_type='debug':
|
build build_type='debug':
|
||||||
@cargo build {{ if build_type == "release" { "--release" } else { "" } }}
|
@cargo build {{ if build_type == "release" { "--release" } else { "" } }}
|
||||||
|
|
||||||
|
# Build a multi-platform Docker image (linux/amd64 + linux/arm64).
|
||||||
|
# Requires an active buildx builder with multi-platform support and a registry login.
|
||||||
|
# version: must match an existing GitHub release tag (e.g. 0.7.4)
|
||||||
|
# image: registry/image name to push to (default: darkalex17/coyote)
|
||||||
|
[group: 'build']
|
||||||
|
docker-build version image='darkalex17/coyote':
|
||||||
|
docker buildx build \
|
||||||
|
--platform linux/amd64,linux/arm64 \
|
||||||
|
--build-arg COYOTE_VERSION={{ version }} \
|
||||||
|
--tag {{ image }}:{{ version }} \
|
||||||
|
--tag {{ image }}:latest \
|
||||||
|
.
|
||||||
|
|||||||
+388
-2
@@ -3,6 +3,33 @@
|
|||||||
# - https://platform.openai.com/docs/api-reference/chat
|
# - https://platform.openai.com/docs/api-reference/chat
|
||||||
- provider: openai
|
- provider: openai
|
||||||
models:
|
models:
|
||||||
|
- name: gpt-5.6-sol
|
||||||
|
max_input_tokens: 1050000
|
||||||
|
max_output_tokens: 128000
|
||||||
|
input_price: 5
|
||||||
|
output_price: 30
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: medium
|
||||||
|
- name: gpt-5.6-terra
|
||||||
|
max_input_tokens: 1050000
|
||||||
|
max_output_tokens: 128000
|
||||||
|
input_price: 5
|
||||||
|
output_price: 30
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: medium
|
||||||
|
- name: gpt-5.6-luna
|
||||||
|
max_input_tokens: 1050000
|
||||||
|
max_output_tokens: 128000
|
||||||
|
input_price: 5
|
||||||
|
output_price: 30
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: gpt-5.5
|
- name: gpt-5.5
|
||||||
max_input_tokens: 1050000
|
max_input_tokens: 1050000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -10,6 +37,8 @@
|
|||||||
output_price: 30
|
output_price: 30
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: gpt-5.5-pro
|
- name: gpt-5.5-pro
|
||||||
max_input_tokens: 1050000
|
max_input_tokens: 1050000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -17,6 +46,8 @@
|
|||||||
output_price: 180
|
output_price: 180
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [medium, high, xhigh]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: gpt-5.4
|
- name: gpt-5.4
|
||||||
max_input_tokens: 1050000
|
max_input_tokens: 1050000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -24,6 +55,8 @@
|
|||||||
output_price: 15
|
output_price: 15
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh]
|
||||||
|
default_reasoning_effort: none
|
||||||
- name: gpt-5.4-pro
|
- name: gpt-5.4-pro
|
||||||
max_input_tokens: 1050000
|
max_input_tokens: 1050000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -31,6 +64,8 @@
|
|||||||
output_price: 180
|
output_price: 180
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [medium, high, xhigh]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: gpt-5.4-mini
|
- name: gpt-5.4-mini
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -38,6 +73,8 @@
|
|||||||
output_price: 4.5
|
output_price: 4.5
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh]
|
||||||
|
default_reasoning_effort: none
|
||||||
- name: gpt-5.4-nano
|
- name: gpt-5.4-nano
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -45,6 +82,8 @@
|
|||||||
output_price: 1.25
|
output_price: 1.25
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh]
|
||||||
|
default_reasoning_effort: none
|
||||||
- name: gpt-5.3-codex
|
- name: gpt-5.3-codex
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -52,6 +91,8 @@
|
|||||||
output_price: 14
|
output_price: 14
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: chat-latest
|
- name: chat-latest
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -66,6 +107,17 @@
|
|||||||
output_price: 14
|
output_price: 14
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh]
|
||||||
|
default_reasoning_effort: none
|
||||||
|
- name: gpt-5.2-pro
|
||||||
|
max_input_tokens: 400000
|
||||||
|
max_output_tokens: 128000
|
||||||
|
input_price: 21
|
||||||
|
output_price: 168
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [medium, high, xhigh]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: gpt-5.1
|
- name: gpt-5.1
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -73,6 +125,8 @@
|
|||||||
output_price: 10
|
output_price: 10
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high]
|
||||||
|
default_reasoning_effort: none
|
||||||
- name: gpt-5.1-chat-latest
|
- name: gpt-5.1-chat-latest
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -80,6 +134,8 @@
|
|||||||
output_price: 10
|
output_price: 10
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high]
|
||||||
|
default_reasoning_effort: none
|
||||||
- name: gpt-5
|
- name: gpt-5
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -87,6 +143,8 @@
|
|||||||
output_price: 10
|
output_price: 10
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: gpt-5-chat-latest
|
- name: gpt-5-chat-latest
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -94,6 +152,8 @@
|
|||||||
output_price: 10
|
output_price: 10
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: gpt-5-mini
|
- name: gpt-5-mini
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -151,6 +211,8 @@
|
|||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
system_prompt_prefix: Formatting re-enabled
|
system_prompt_prefix: Formatting re-enabled
|
||||||
|
reasoning_levels: [low, medium, high]
|
||||||
|
default_reasoning_effort: medium
|
||||||
patch:
|
patch:
|
||||||
body:
|
body:
|
||||||
max_tokens: null
|
max_tokens: null
|
||||||
@@ -258,24 +320,38 @@
|
|||||||
# - https://ai.google.dev/api/rest/v1beta/models/streamGenerateContent
|
# - https://ai.google.dev/api/rest/v1beta/models/streamGenerateContent
|
||||||
- provider: gemini
|
- provider: gemini
|
||||||
models:
|
models:
|
||||||
|
- name: gemini-3.6-flash
|
||||||
|
max_input_tokens: 1048576
|
||||||
|
max_output_tokens: 65536
|
||||||
|
input_price: 1.5
|
||||||
|
output_price: 7.5
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_level: medium
|
||||||
- name: gemini-3.5-flash
|
- name: gemini-3.5-flash
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
max_output_tokens: 65536
|
max_output_tokens: 65536
|
||||||
input_price: 0.2
|
input_price: 0.2
|
||||||
output_price: 1.5
|
output_price: 1.5
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: gemini-3-flash-preview
|
- name: gemini-3-flash-preview
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
max_output_tokens: 65536
|
max_output_tokens: 65536
|
||||||
input_price: 0.2
|
input_price: 0.2
|
||||||
output_price: 1.5
|
output_price: 1.5
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: gemini-3.1-flash-lite
|
- name: gemini-3.1-flash-lite
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
max_output_tokens: 65536
|
max_output_tokens: 65536
|
||||||
input_price: 0.2
|
input_price: 0.2
|
||||||
output_price: 1.5
|
output_price: 1.5
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_effort: minimal
|
||||||
- name: gemini-3.1-pro-preview
|
- name: gemini-3.1-pro-preview
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
max_output_tokens: 65535
|
max_output_tokens: 65535
|
||||||
@@ -283,6 +359,8 @@
|
|||||||
output_price: 2.5
|
output_price: 2.5
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: gemini-2.5-flash
|
- name: gemini-2.5-flash
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
max_output_tokens: 65536
|
max_output_tokens: 65536
|
||||||
@@ -297,6 +375,8 @@
|
|||||||
output_price: 0
|
output_price: 0
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: gemini-2.5-flash-lite
|
- name: gemini-2.5-flash-lite
|
||||||
max_input_tokens: 1000000
|
max_input_tokens: 1000000
|
||||||
max_output_tokens: 64000
|
max_output_tokens: 64000
|
||||||
@@ -308,10 +388,14 @@
|
|||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, high]
|
||||||
|
default_reasoning_level: high
|
||||||
- name: gemini-3-flash-preview
|
- name: gemini-3-flash-preview
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_level: high
|
||||||
- name: gemma-3-27b-it
|
- name: gemma-3-27b-it
|
||||||
max_input_tokens: 131072
|
max_input_tokens: 131072
|
||||||
max_output_tokens: 8192
|
max_output_tokens: 8192
|
||||||
@@ -329,6 +413,16 @@
|
|||||||
# - https://docs.anthropic.com/en/api/messages
|
# - https://docs.anthropic.com/en/api/messages
|
||||||
- provider: claude
|
- provider: claude
|
||||||
models:
|
models:
|
||||||
|
- name: claude-opus-5
|
||||||
|
max_input_tokens: 1000000
|
||||||
|
max_output_tokens: 128000
|
||||||
|
require_max_tokens: true
|
||||||
|
input_price: 5
|
||||||
|
output_price: 25
|
||||||
|
supports_function_calling: true
|
||||||
|
supports_vision: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: claude-fable-5
|
- name: claude-fable-5
|
||||||
max_input_tokens: 1000000
|
max_input_tokens: 1000000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -337,6 +431,8 @@
|
|||||||
output_price: 50
|
output_price: 50
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: claude-opus-4-8
|
- name: claude-opus-4-8
|
||||||
max_input_tokens: 1000000
|
max_input_tokens: 1000000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -345,6 +441,8 @@
|
|||||||
output_price: 25
|
output_price: 25
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: claude-opus-4-7
|
- name: claude-opus-4-7
|
||||||
max_input_tokens: 1000000
|
max_input_tokens: 1000000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -353,6 +451,8 @@
|
|||||||
output_price: 25
|
output_price: 25
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: claude-opus-4-6
|
- name: claude-opus-4-6
|
||||||
max_input_tokens: 200000
|
max_input_tokens: 200000
|
||||||
max_output_tokens: 8192
|
max_output_tokens: 8192
|
||||||
@@ -361,6 +461,8 @@
|
|||||||
output_price: 25
|
output_price: 25
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: claude-opus-4-6:thinking
|
- name: claude-opus-4-6:thinking
|
||||||
real_name: claude-opus-4-6
|
real_name: claude-opus-4-6
|
||||||
max_input_tokens: 200000
|
max_input_tokens: 200000
|
||||||
@@ -385,6 +487,8 @@
|
|||||||
output_price: 15
|
output_price: 15
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: claude-sonnet-4-6
|
- name: claude-sonnet-4-6
|
||||||
max_input_tokens: 200000
|
max_input_tokens: 200000
|
||||||
max_output_tokens: 8192
|
max_output_tokens: 8192
|
||||||
@@ -393,6 +497,8 @@
|
|||||||
output_price: 15
|
output_price: 15
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: claude-sonnet-4-6:thinking
|
- name: claude-sonnet-4-6:thinking
|
||||||
real_name: claude-sonnet-4-6
|
real_name: claude-sonnet-4-6
|
||||||
max_input_tokens: 200000
|
max_input_tokens: 200000
|
||||||
@@ -716,14 +822,65 @@
|
|||||||
# - https://docs.x.ai/docs/models
|
# - https://docs.x.ai/docs/models
|
||||||
# - https://docs.x.ai/docs/api-reference#chat-completions
|
# - https://docs.x.ai/docs/api-reference#chat-completions
|
||||||
- provider: xai
|
- provider: xai
|
||||||
|
oauth:
|
||||||
|
client_id: b1a00492-073a-47ea-816f-4c329264a828
|
||||||
|
authorize_url: https://auth.x.ai/oauth2/authorize
|
||||||
|
token_url: https://auth.x.ai/oauth2/token
|
||||||
|
scopes:
|
||||||
|
- openid
|
||||||
|
- profile
|
||||||
|
- email
|
||||||
|
- offline_access
|
||||||
|
- grok-cli:access
|
||||||
|
- api:access
|
||||||
|
redirect_port: 56121
|
||||||
|
flow: pkce
|
||||||
|
token_request_format: form_url_encoded
|
||||||
|
extra_authorize_params:
|
||||||
|
plan: generic
|
||||||
|
referrer: coyote
|
||||||
|
echo_pkce_in_token_exchange: true
|
||||||
models:
|
models:
|
||||||
|
- name: grok-4.5
|
||||||
|
input_price: 2
|
||||||
|
output_price: 6
|
||||||
|
max_input_tokens: 256000
|
||||||
|
supports_function_calling: true
|
||||||
|
- name: grok-build-0.1
|
||||||
|
input_price: 1
|
||||||
|
output_price: 2
|
||||||
|
max_input_tokens: 256000
|
||||||
|
supports_function_calling: true
|
||||||
|
- name: grok-4.3
|
||||||
|
input_price: 1.25
|
||||||
|
output_price: 2.5
|
||||||
|
max_input_tokens: 1000000
|
||||||
|
supports_function_calling: true
|
||||||
|
- name: grok-4.20
|
||||||
|
real_name: grok-4.20-multi-agent-0309
|
||||||
|
input_price: 1.25
|
||||||
|
output_price: 2.5
|
||||||
|
max_input_tokens: 1000000
|
||||||
|
supports_function_calling: true
|
||||||
|
- name: grok-4.20-reasoning
|
||||||
|
real_name: grok-4.20-0309-reasoning
|
||||||
|
input_price: 1.25
|
||||||
|
output_price: 2.5
|
||||||
|
max_input_tokens: 1000000
|
||||||
|
supports_function_calling: true
|
||||||
|
- name: grok-4.20-non-reasoning
|
||||||
|
real_name: grok-4.20-0309-non-reasoning
|
||||||
|
input_price: 1.25
|
||||||
|
output_price: 2.5
|
||||||
|
max_input_tokens: 1000000
|
||||||
|
supports_function_calling: true
|
||||||
- name: grok-4-1-fast-non-reasoning
|
- name: grok-4-1-fast-non-reasoning
|
||||||
max_input_tokens: 2000000
|
max_input_tokens: 1000000
|
||||||
input_price: 0.2
|
input_price: 0.2
|
||||||
output_price: 0.5
|
output_price: 0.5
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
- name: grok-4-1-fast-reasoning
|
- name: grok-4-1-fast-reasoning
|
||||||
max_input_tokens: 2000000
|
max_input_tokens: 1000000
|
||||||
input_price: 0.2
|
input_price: 0.2
|
||||||
output_price: 0.5
|
output_price: 0.5
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
@@ -835,18 +992,24 @@
|
|||||||
input_price: 0.2
|
input_price: 0.2
|
||||||
output_price: 1.5
|
output_price: 1.5
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: gemini-3-flash-preview
|
- name: gemini-3-flash-preview
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
max_output_tokens: 65536
|
max_output_tokens: 65536
|
||||||
input_price: 0.2
|
input_price: 0.2
|
||||||
output_price: 1.5
|
output_price: 1.5
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: gemini-3.1-flash-lite
|
- name: gemini-3.1-flash-lite
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
max_output_tokens: 65536
|
max_output_tokens: 65536
|
||||||
input_price: 0.2
|
input_price: 0.2
|
||||||
output_price: 1.5
|
output_price: 1.5
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, high]
|
||||||
|
default_reasoning_effort: minimal
|
||||||
- name: gemini-3.1-pro-preview
|
- name: gemini-3.1-pro-preview
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
max_output_tokens: 65536
|
max_output_tokens: 65536
|
||||||
@@ -854,6 +1017,8 @@
|
|||||||
output_price: 12
|
output_price: 12
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: gemini-2.5-flash
|
- name: gemini-2.5-flash
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
max_output_tokens: 65535
|
max_output_tokens: 65535
|
||||||
@@ -861,6 +1026,8 @@
|
|||||||
output_price: 2.5
|
output_price: 2.5
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: gemini-2.5-pro
|
- name: gemini-2.5-pro
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
max_output_tokens: 65536
|
max_output_tokens: 65536
|
||||||
@@ -868,6 +1035,8 @@
|
|||||||
output_price: 10
|
output_price: 10
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: gemini-2.5-flash-lite
|
- name: gemini-2.5-flash-lite
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
max_output_tokens: 65536
|
max_output_tokens: 65536
|
||||||
@@ -879,10 +1048,24 @@
|
|||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, high]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: gemini-3-flash-preview
|
- name: gemini-3-flash-preview
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_effort: high
|
||||||
|
- name: claude-opus-5
|
||||||
|
max_input_tokens: 1000000
|
||||||
|
max_output_tokens: 128000
|
||||||
|
require_max_tokens: true
|
||||||
|
input_price: 5
|
||||||
|
output_price: 25
|
||||||
|
supports_function_calling: true
|
||||||
|
supports_vision: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: claude-fable-5
|
- name: claude-fable-5
|
||||||
max_input_tokens: 1000000
|
max_input_tokens: 1000000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -891,6 +1074,8 @@
|
|||||||
output_price: 50
|
output_price: 50
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: claude-opus-4-8
|
- name: claude-opus-4-8
|
||||||
max_input_tokens: 1000000
|
max_input_tokens: 1000000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -899,6 +1084,8 @@
|
|||||||
output_price: 25
|
output_price: 25
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: claude-opus-4-7
|
- name: claude-opus-4-7
|
||||||
max_input_tokens: 1000000
|
max_input_tokens: 1000000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -907,6 +1094,8 @@
|
|||||||
output_price: 25
|
output_price: 25
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: claude-opus-4-6
|
- name: claude-opus-4-6
|
||||||
max_input_tokens: 200000
|
max_input_tokens: 200000
|
||||||
max_output_tokens: 8192
|
max_output_tokens: 8192
|
||||||
@@ -938,6 +1127,8 @@
|
|||||||
output_price: 15
|
output_price: 15
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: claude-sonnet-4-6
|
- name: claude-sonnet-4-6
|
||||||
max_input_tokens: 200000
|
max_input_tokens: 200000
|
||||||
max_output_tokens: 8192
|
max_output_tokens: 8192
|
||||||
@@ -946,6 +1137,8 @@
|
|||||||
output_price: 15
|
output_price: 15
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: claude-sonnet-4-6:thinking
|
- name: claude-sonnet-4-6:thinking
|
||||||
real_name: claude-sonnet-4-6
|
real_name: claude-sonnet-4-6
|
||||||
max_input_tokens: 200000
|
max_input_tokens: 200000
|
||||||
@@ -1070,6 +1263,16 @@
|
|||||||
# - https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-call.html
|
# - https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-call.html
|
||||||
- provider: bedrock
|
- provider: bedrock
|
||||||
models:
|
models:
|
||||||
|
- name: us.anthropic.claude-opus-5
|
||||||
|
max_input_tokens: 1000000
|
||||||
|
max_output_tokens: 128000
|
||||||
|
require_max_tokens: true
|
||||||
|
input_price: 5
|
||||||
|
output_price: 25
|
||||||
|
supports_function_calling: true
|
||||||
|
supports_vision: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: us.anthropic.claude-fable-5
|
- name: us.anthropic.claude-fable-5
|
||||||
max_input_tokens: 1000000
|
max_input_tokens: 1000000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1078,6 +1281,8 @@
|
|||||||
output_price: 50
|
output_price: 50
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: us.anthropic.claude-opus-4-8
|
- name: us.anthropic.claude-opus-4-8
|
||||||
max_input_tokens: 1000000
|
max_input_tokens: 1000000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1086,6 +1291,8 @@
|
|||||||
output_price: 25
|
output_price: 25
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: us.anthropic.claude-opus-4-7
|
- name: us.anthropic.claude-opus-4-7
|
||||||
max_input_tokens: 1000000
|
max_input_tokens: 1000000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1094,6 +1301,8 @@
|
|||||||
output_price: 25
|
output_price: 25
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: us.anthropic.claude-opus-4-6-v1
|
- name: us.anthropic.claude-opus-4-6-v1
|
||||||
max_input_tokens: 200000
|
max_input_tokens: 200000
|
||||||
max_output_tokens: 8192
|
max_output_tokens: 8192
|
||||||
@@ -1102,6 +1311,8 @@
|
|||||||
output_price: 25
|
output_price: 25
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: us.anthropic.claude-opus-4-6-v1:thinking
|
- name: us.anthropic.claude-opus-4-6-v1:thinking
|
||||||
real_name: us.anthropic.claude-opus-4-6-v1
|
real_name: us.anthropic.claude-opus-4-6-v1
|
||||||
max_input_tokens: 200000
|
max_input_tokens: 200000
|
||||||
@@ -1127,6 +1338,8 @@
|
|||||||
output_price: 15
|
output_price: 15
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: us.anthropic.claude-sonnet-4-6
|
- name: us.anthropic.claude-sonnet-4-6
|
||||||
max_input_tokens: 200000
|
max_input_tokens: 200000
|
||||||
max_output_tokens: 8192
|
max_output_tokens: 8192
|
||||||
@@ -1135,6 +1348,8 @@
|
|||||||
output_price: 15
|
output_price: 15
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: us.anthropic.claude-sonnet-4-6:thinking
|
- name: us.anthropic.claude-sonnet-4-6:thinking
|
||||||
real_name: us.anthropic.claude-sonnet-4-6
|
real_name: us.anthropic.claude-sonnet-4-6
|
||||||
max_input_tokens: 200000
|
max_input_tokens: 200000
|
||||||
@@ -1516,6 +1731,30 @@
|
|||||||
# - https://platform.moonshot.cn/docs/api/chat#%E5%85%AC%E5%BC%80%E7%9A%84%E6%9C%8D%E5%8A%A1%E5%9C%B0%E5%9D%80
|
# - https://platform.moonshot.cn/docs/api/chat#%E5%85%AC%E5%BC%80%E7%9A%84%E6%9C%8D%E5%8A%A1%E5%9C%B0%E5%9D%80
|
||||||
- provider: moonshot
|
- provider: moonshot
|
||||||
models:
|
models:
|
||||||
|
- name: kimi-k3
|
||||||
|
max_input_tokens: 1048576
|
||||||
|
input_price: 3
|
||||||
|
output_price: 15
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
|
- name: kimi-k2.7-code
|
||||||
|
max_input_tokens: 262144
|
||||||
|
input_price: 0.95
|
||||||
|
output_price: 4
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
|
- name: kimi-k2.7-code-highspeed
|
||||||
|
max_input_tokens: 262144
|
||||||
|
input_price: 1.9
|
||||||
|
output_price: 8
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
|
- name: kimi-k2.6
|
||||||
|
max_input_tokens: 262144
|
||||||
|
input_price: 0.95
|
||||||
|
output_price: 4
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
- name: kimi-k2.5
|
- name: kimi-k2.5
|
||||||
max_input_tokens: 262144
|
max_input_tokens: 262144
|
||||||
input_price: 0.56
|
input_price: 0.56
|
||||||
@@ -1550,6 +1789,18 @@
|
|||||||
# - https://platform.deepseek.com/api-docs/api/create-chat-completion
|
# - https://platform.deepseek.com/api-docs/api/create-chat-completion
|
||||||
- provider: deepseek
|
- provider: deepseek
|
||||||
models:
|
models:
|
||||||
|
- name: deepseek-v4-pro
|
||||||
|
max_input_tokens: 1000000
|
||||||
|
max_output_tokens: 384000
|
||||||
|
input_price: 0.435
|
||||||
|
output_price: 0.87
|
||||||
|
supports_function_calling: true
|
||||||
|
- name: deepseek-v4-flash
|
||||||
|
max_input_tokens: 1000000
|
||||||
|
max_output_tokens: 384000
|
||||||
|
input_price: 0.14
|
||||||
|
output_price: 0.28
|
||||||
|
supports_function_calling: true
|
||||||
- name: deepseek-chat
|
- name: deepseek-chat
|
||||||
max_input_tokens: 64000
|
max_input_tokens: 64000
|
||||||
max_output_tokens: 8192
|
max_output_tokens: 8192
|
||||||
@@ -1618,6 +1869,16 @@
|
|||||||
# - https://platform.minimaxi.com/document/ChatCompletion%20v2
|
# - https://platform.minimaxi.com/document/ChatCompletion%20v2
|
||||||
- provider: minimax
|
- provider: minimax
|
||||||
models:
|
models:
|
||||||
|
- name: minimax-m3
|
||||||
|
max_input_tokens: 1000000
|
||||||
|
input_price: 4.2
|
||||||
|
output_price: 16.8
|
||||||
|
supports_function_calling: true
|
||||||
|
- name: minimax-m2.7
|
||||||
|
max_input_tokens: 204800
|
||||||
|
input_price: 0.294
|
||||||
|
output_price: 1.176
|
||||||
|
supports_function_calling: true
|
||||||
- name: minimax-m2.5
|
- name: minimax-m2.5
|
||||||
max_input_tokens: 204800
|
max_input_tokens: 204800
|
||||||
input_price: 0.294
|
input_price: 0.294
|
||||||
@@ -1644,6 +1905,33 @@
|
|||||||
# - https://openrouter.ai/docs/api-reference/chat-completion
|
# - https://openrouter.ai/docs/api-reference/chat-completion
|
||||||
- provider: openrouter
|
- provider: openrouter
|
||||||
models:
|
models:
|
||||||
|
- name: openai/gpt-5.6-sol
|
||||||
|
max_input_tokens: 1050000
|
||||||
|
max_output_tokens: 128000
|
||||||
|
input_price: 5
|
||||||
|
output_price: 30
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: medium
|
||||||
|
- name: openai/gpt-5.6-terra
|
||||||
|
max_input_tokens: 1050000
|
||||||
|
max_output_tokens: 128000
|
||||||
|
input_price: 5
|
||||||
|
output_price: 30
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: medium
|
||||||
|
- name: openai/gpt-5.6-luna
|
||||||
|
max_input_tokens: 1050000
|
||||||
|
max_output_tokens: 128000
|
||||||
|
input_price: 5
|
||||||
|
output_price: 30
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: openai/gpt-5.5
|
- name: openai/gpt-5.5
|
||||||
max_input_tokens: 1050000
|
max_input_tokens: 1050000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1651,6 +1939,8 @@
|
|||||||
output_price: 30
|
output_price: 30
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: openai/gpt-5.5-pro
|
- name: openai/gpt-5.5-pro
|
||||||
max_input_tokens: 1050000
|
max_input_tokens: 1050000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1658,6 +1948,8 @@
|
|||||||
output_price: 180
|
output_price: 180
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [medium, high, xhigh]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: openai/gpt-5.4
|
- name: openai/gpt-5.4
|
||||||
max_input_tokens: 1050000
|
max_input_tokens: 1050000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1665,6 +1957,8 @@
|
|||||||
output_price: 15
|
output_price: 15
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh]
|
||||||
|
default_reasoning_effort: none
|
||||||
- name: openai/gpt-5.4-pro
|
- name: openai/gpt-5.4-pro
|
||||||
max_input_tokens: 1050000
|
max_input_tokens: 1050000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1672,6 +1966,8 @@
|
|||||||
output_price: 180
|
output_price: 180
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [medium, high, xhigh]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: openai/gpt-5.4-mini
|
- name: openai/gpt-5.4-mini
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1679,6 +1975,8 @@
|
|||||||
output_price: 4.5
|
output_price: 4.5
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh]
|
||||||
|
default_reasoning_effort: none
|
||||||
- name: openai/gpt-5.4-nano
|
- name: openai/gpt-5.4-nano
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1686,6 +1984,8 @@
|
|||||||
output_price: 1.25
|
output_price: 1.25
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh]
|
||||||
|
default_reasoning_effort: none
|
||||||
- name: openai/gpt-5.3-codex
|
- name: openai/gpt-5.3-codex
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1693,6 +1993,8 @@
|
|||||||
output_price: 14
|
output_price: 14
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: openai/gpt-5.2
|
- name: openai/gpt-5.2
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1700,6 +2002,17 @@
|
|||||||
output_price: 14
|
output_price: 14
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [none, low, medium, high, xhigh]
|
||||||
|
default_reasoning_effort: none
|
||||||
|
- name: openai/gpt-5.2-pro
|
||||||
|
max_input_tokens: 400000
|
||||||
|
max_output_tokens: 128000
|
||||||
|
input_price: 21
|
||||||
|
output_price: 168
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [medium, high, xhigh]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: openai/gpt-5
|
- name: openai/gpt-5
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1707,6 +2020,8 @@
|
|||||||
output_price: 10
|
output_price: 10
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_effort: medium
|
||||||
- name: openai/gpt-5-mini
|
- name: openai/gpt-5-mini
|
||||||
max_input_tokens: 400000
|
max_input_tokens: 400000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1744,18 +2059,67 @@
|
|||||||
input_price: 0.04
|
input_price: 0.04
|
||||||
output_price: 0.16
|
output_price: 0.16
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
- name: google/gemini-3.5-flash
|
||||||
|
max_input_tokens: 1048576
|
||||||
|
max_output_tokens: 65536
|
||||||
|
input_price: 0.2
|
||||||
|
output_price: 1.5
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_effort: medium
|
||||||
|
- name: google/gemini-3-flash-preview
|
||||||
|
max_input_tokens: 1048576
|
||||||
|
max_output_tokens: 65536
|
||||||
|
input_price: 0.2
|
||||||
|
output_price: 1.5
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_effort: high
|
||||||
|
- name: google/gemini-3.1-flash-lite
|
||||||
|
max_input_tokens: 1048576
|
||||||
|
max_output_tokens: 65536
|
||||||
|
input_price: 0.2
|
||||||
|
output_price: 1.5
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_effort: minimal
|
||||||
|
- name: google/gemini-3.1-pro-preview
|
||||||
|
max_input_tokens: 1048576
|
||||||
|
max_output_tokens: 65535
|
||||||
|
input_price: 0.3
|
||||||
|
output_price: 2.5
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high]
|
||||||
|
default_reasoning_effort: high
|
||||||
|
- name: google/gemini-3-pro-preview
|
||||||
|
max_input_tokens: 1048576
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, high]
|
||||||
|
default_reasoning_level: high
|
||||||
|
- name: google/gemini-3-flash-preview
|
||||||
|
max_input_tokens: 1048576
|
||||||
|
supports_vision: true
|
||||||
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [minimal, low, medium, high]
|
||||||
|
default_reasoning_level: high
|
||||||
- name: google/gemini-2.5-flash
|
- name: google/gemini-2.5-flash
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
input_price: 0.3
|
input_price: 0.3
|
||||||
output_price: 2.5
|
output_price: 2.5
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high]
|
||||||
|
default_reasoning_effort: low
|
||||||
- name: google/gemini-2.5-pro
|
- name: google/gemini-2.5-pro
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
input_price: 1.25
|
input_price: 1.25
|
||||||
output_price: 10
|
output_price: 10
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: google/gemini-2.5-flash-lite
|
- name: google/gemini-2.5-flash-lite
|
||||||
max_input_tokens: 1048576
|
max_input_tokens: 1048576
|
||||||
input_price: 0.3
|
input_price: 0.3
|
||||||
@@ -1777,6 +2141,16 @@
|
|||||||
max_input_tokens: 131072
|
max_input_tokens: 131072
|
||||||
input_price: 0.1
|
input_price: 0.1
|
||||||
output_price: 0.2
|
output_price: 0.2
|
||||||
|
- name: anthropic/claude-opus-5
|
||||||
|
max_input_tokens: 1000000
|
||||||
|
max_output_tokens: 128000
|
||||||
|
require_max_tokens: true
|
||||||
|
input_price: 5
|
||||||
|
output_price: 25
|
||||||
|
supports_function_calling: true
|
||||||
|
supports_vision: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: anthropic/claude-fable-5
|
- name: anthropic/claude-fable-5
|
||||||
max_input_tokens: 1000000
|
max_input_tokens: 1000000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1785,6 +2159,8 @@
|
|||||||
output_price: 50
|
output_price: 50
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: anthropic/claude-opus-4-8
|
- name: anthropic/claude-opus-4-8
|
||||||
max_input_tokens: 1000000
|
max_input_tokens: 1000000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1793,6 +2169,8 @@
|
|||||||
output_price: 25
|
output_price: 25
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: anthropic/claude-opus-4-7
|
- name: anthropic/claude-opus-4-7
|
||||||
max_input_tokens: 1000000
|
max_input_tokens: 1000000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1801,6 +2179,8 @@
|
|||||||
output_price: 25
|
output_price: 25
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: anthropic/claude-opus-4.6
|
- name: anthropic/claude-opus-4.6
|
||||||
max_input_tokens: 200000
|
max_input_tokens: 200000
|
||||||
max_output_tokens: 8192
|
max_output_tokens: 8192
|
||||||
@@ -1809,6 +2189,8 @@
|
|||||||
output_price: 25
|
output_price: 25
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: anthropic/claude-sonnet-5
|
- name: anthropic/claude-sonnet-5
|
||||||
max_input_tokens: 1000000
|
max_input_tokens: 1000000
|
||||||
max_output_tokens: 128000
|
max_output_tokens: 128000
|
||||||
@@ -1817,6 +2199,8 @@
|
|||||||
output_price: 15
|
output_price: 15
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, xhigh, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: anthropic/claude-sonnet-4.6
|
- name: anthropic/claude-sonnet-4.6
|
||||||
max_input_tokens: 200000
|
max_input_tokens: 200000
|
||||||
max_output_tokens: 8192
|
max_output_tokens: 8192
|
||||||
@@ -1825,6 +2209,8 @@
|
|||||||
output_price: 15
|
output_price: 15
|
||||||
supports_vision: true
|
supports_vision: true
|
||||||
supports_function_calling: true
|
supports_function_calling: true
|
||||||
|
reasoning_levels: [low, medium, high, max]
|
||||||
|
default_reasoning_effort: high
|
||||||
- name: anthropic/claude-opus-4.5
|
- name: anthropic/claude-opus-4.5
|
||||||
max_input_tokens: 200000
|
max_input_tokens: 200000
|
||||||
max_output_tokens: 8192
|
max_output_tokens: 8192
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
mod server;
|
||||||
|
mod types;
|
||||||
|
|
||||||
|
pub use server::run_acp_server;
|
||||||
@@ -0,0 +1,670 @@
|
|||||||
|
use super::types::{METHOD_NOT_FOUND, PARSE_ERROR, Request, Response};
|
||||||
|
use crate::client::call_chat_completions_streaming;
|
||||||
|
use crate::config::{Input, RenderMode, RequestContext};
|
||||||
|
use crate::function::supervisor::{GuardrailAction, check_pending_agents_guardrail};
|
||||||
|
use crate::utils;
|
||||||
|
use crate::utils::AbortSignal;
|
||||||
|
use anyhow::Result;
|
||||||
|
use serde_json::{Value, json};
|
||||||
|
use std::sync::Arc;
|
||||||
|
use tokio::io::{AsyncBufReadExt, AsyncRead, AsyncWrite, AsyncWriteExt, BufReader};
|
||||||
|
|
||||||
|
pub(crate) struct AcpServerState {
|
||||||
|
ctx: Option<RequestContext>,
|
||||||
|
abort: AbortSignal,
|
||||||
|
session_active: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn run_acp_server(ctx: RequestContext, abort: AbortSignal) -> Result<()> {
|
||||||
|
let state = AcpServerState {
|
||||||
|
ctx: Some(ctx),
|
||||||
|
abort,
|
||||||
|
session_active: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
run_acp_server_with_state(tokio::io::stdin(), tokio::io::stdout(), state).await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub(crate) async fn run_acp_server_on<R, W>(reader: R, writer: W) -> Result<()>
|
||||||
|
where
|
||||||
|
R: AsyncRead + Unpin,
|
||||||
|
W: AsyncWrite + Unpin,
|
||||||
|
{
|
||||||
|
use crate::utils::{create_abort_signal, drain_acp_permissions};
|
||||||
|
|
||||||
|
drain_acp_permissions();
|
||||||
|
let state = AcpServerState {
|
||||||
|
ctx: None,
|
||||||
|
abort: create_abort_signal(),
|
||||||
|
session_active: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
run_acp_server_with_state(reader, writer, state).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn run_acp_server_with_state<R, W>(
|
||||||
|
reader: R,
|
||||||
|
mut writer: W,
|
||||||
|
mut state: AcpServerState,
|
||||||
|
) -> Result<()>
|
||||||
|
where
|
||||||
|
R: AsyncRead + Unpin,
|
||||||
|
W: AsyncWrite + Unpin,
|
||||||
|
{
|
||||||
|
let reader = BufReader::new(reader);
|
||||||
|
let mut lines = reader.lines();
|
||||||
|
|
||||||
|
while let Some(line) = lines.next_line().await? {
|
||||||
|
let line = line.trim().to_string();
|
||||||
|
if line.is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(response) = dispatch(&line, &mut state).await {
|
||||||
|
for params in utils::drain_acp_permissions() {
|
||||||
|
emit_notification(&mut writer, "session/request_permission", params).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit(&mut writer, &response).await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn dispatch(raw: &str, state: &mut AcpServerState) -> Option<Response> {
|
||||||
|
let req: Request = match serde_json::from_str(raw) {
|
||||||
|
Ok(r) => r,
|
||||||
|
Err(_) => return Some(Response::err(None, PARSE_ERROR, "Parse error")),
|
||||||
|
};
|
||||||
|
|
||||||
|
// session/cancel is a notification. Handle it regardless of whether an id is present.
|
||||||
|
if req.method == "session/cancel" {
|
||||||
|
handle_session_cancel(state);
|
||||||
|
return if req.id.is_some() {
|
||||||
|
Some(Response::ok(req.id, json!({})))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
req.id.as_ref()?;
|
||||||
|
|
||||||
|
Some(match req.method.as_str() {
|
||||||
|
"initialize" => handle_initialize(req),
|
||||||
|
"session/new" => handle_session_new(req, state).await,
|
||||||
|
"session/load" => handle_session_load(req, state).await,
|
||||||
|
"session/prompt" => handle_session_prompt(req, state).await,
|
||||||
|
_ => Response::err(
|
||||||
|
req.id,
|
||||||
|
METHOD_NOT_FOUND,
|
||||||
|
format!("Method not found: {}", req.method),
|
||||||
|
),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_initialize(req: Request) -> Response {
|
||||||
|
Response::ok(
|
||||||
|
req.id,
|
||||||
|
json!({
|
||||||
|
"name": "coyote",
|
||||||
|
"version": env!("CARGO_PKG_VERSION"),
|
||||||
|
"protocolVersion": 1,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_session_new(req: Request, state: &mut AcpServerState) -> Response {
|
||||||
|
if state.session_active {
|
||||||
|
return Response::err(
|
||||||
|
req.id,
|
||||||
|
-32000,
|
||||||
|
"Session already active; this server supports one session per process",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let ctx = match state.ctx.as_mut() {
|
||||||
|
Some(c) => c,
|
||||||
|
None => {
|
||||||
|
state.session_active = true;
|
||||||
|
return Response::ok(req.id, json!({ "sessionId": "default" }));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let app = Arc::clone(&ctx.app.config);
|
||||||
|
let abort = state.abort.clone();
|
||||||
|
match ctx.use_session(app.as_ref(), None, abort).await {
|
||||||
|
Ok(_) => {
|
||||||
|
state.session_active = true;
|
||||||
|
ctx.render_mode = RenderMode::Silent;
|
||||||
|
Response::ok(req.id, json!({ "sessionId": "default" }))
|
||||||
|
}
|
||||||
|
Err(e) => Response::err(req.id, -32000, format!("Failed to create session: {e}")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_session_prompt(req: Request, state: &mut AcpServerState) -> Response {
|
||||||
|
if !state.session_active {
|
||||||
|
return Response::err(req.id, -32000, "No active session; call session/new first");
|
||||||
|
}
|
||||||
|
|
||||||
|
let params = req.params.as_ref();
|
||||||
|
let from_content_blocks: Option<String> = params
|
||||||
|
.and_then(|p| p.get("prompt"))
|
||||||
|
.and_then(Value::as_array)
|
||||||
|
.map(|blocks| {
|
||||||
|
blocks
|
||||||
|
.iter()
|
||||||
|
.filter(|b| b.get("type").and_then(Value::as_str) == Some("text"))
|
||||||
|
.filter_map(|b| b.get("text").and_then(Value::as_str))
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("\n")
|
||||||
|
})
|
||||||
|
.filter(|s| !s.is_empty());
|
||||||
|
let from_text: Option<String> = params
|
||||||
|
.and_then(|p| p.get("text"))
|
||||||
|
.and_then(Value::as_str)
|
||||||
|
.filter(|s| !s.is_empty())
|
||||||
|
.map(str::to_string);
|
||||||
|
let text = match from_content_blocks.or(from_text) {
|
||||||
|
Some(t) => t,
|
||||||
|
None => {
|
||||||
|
return Response::err(
|
||||||
|
req.id,
|
||||||
|
-32602,
|
||||||
|
"Missing params: expected prompt (ContentBlock array) or text",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let ctx = match state.ctx.as_mut() {
|
||||||
|
Some(c) => c,
|
||||||
|
None => return Response::err(req.id, -32000, "Server not configured with a context"),
|
||||||
|
};
|
||||||
|
|
||||||
|
let abort = state.abort.clone();
|
||||||
|
match run_prompt_turn(ctx, &text, abort).await {
|
||||||
|
Ok(output) => Response::ok(
|
||||||
|
req.id,
|
||||||
|
json!({ "output": output, "stopReason": "end_turn" }),
|
||||||
|
),
|
||||||
|
Err(e) => Response::err(req.id, -32000, format!("Prompt failed: {e}")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn run_prompt_turn(
|
||||||
|
ctx: &mut RequestContext,
|
||||||
|
text: &str,
|
||||||
|
abort: AbortSignal,
|
||||||
|
) -> Result<String> {
|
||||||
|
ctx.render_mode = RenderMode::Silent;
|
||||||
|
let mut input = Input::from_str(ctx, text, None)?;
|
||||||
|
loop {
|
||||||
|
ctx.before_chat_completion(&input)?;
|
||||||
|
let client = input.create_client()?;
|
||||||
|
let (output, tool_results) =
|
||||||
|
call_chat_completions_streaming(&input, client.as_ref(), ctx, abort.clone()).await?;
|
||||||
|
let app = Arc::clone(&ctx.app.config);
|
||||||
|
ctx.after_chat_completion(app.as_ref(), &input, &output, &tool_results)?;
|
||||||
|
if !tool_results.is_empty() {
|
||||||
|
input = input.merge_tool_results(output, tool_results);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
match check_pending_agents_guardrail(ctx) {
|
||||||
|
GuardrailAction::Inject(prompt) => {
|
||||||
|
input = Input::from_str(ctx, &prompt, None)?;
|
||||||
|
}
|
||||||
|
GuardrailAction::ForceTerminate(ids) => {
|
||||||
|
warn!(
|
||||||
|
"Pending-agent guardrail force-cancelled {} agent(s): {:?}",
|
||||||
|
ids.len(),
|
||||||
|
ids
|
||||||
|
);
|
||||||
|
return Ok(output);
|
||||||
|
}
|
||||||
|
GuardrailAction::NoAction => return Ok(output),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_session_cancel(state: &mut AcpServerState) {
|
||||||
|
state.abort.set_ctrlc();
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_session_load(req: Request, state: &mut AcpServerState) -> Response {
|
||||||
|
if state.session_active {
|
||||||
|
return Response::err(req.id, -32000, "Session already active");
|
||||||
|
}
|
||||||
|
|
||||||
|
let session_name = match req
|
||||||
|
.params
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|p| p.get("sessionId"))
|
||||||
|
.and_then(Value::as_str)
|
||||||
|
{
|
||||||
|
Some(n) => n.to_string(),
|
||||||
|
None => return Response::err(req.id, -32602, "Missing params.sessionId"),
|
||||||
|
};
|
||||||
|
|
||||||
|
let ctx = match state.ctx.as_mut() {
|
||||||
|
Some(c) => c,
|
||||||
|
None => return Response::err(req.id, -32000, "Server not configured with a context"),
|
||||||
|
};
|
||||||
|
|
||||||
|
let app = Arc::clone(&ctx.app.config);
|
||||||
|
let abort = state.abort.clone();
|
||||||
|
match ctx
|
||||||
|
.use_session(app.as_ref(), Some(&session_name), abort)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(_) => {
|
||||||
|
state.session_active = true;
|
||||||
|
ctx.render_mode = RenderMode::Silent;
|
||||||
|
Response::ok(req.id, json!({ "sessionId": session_name }))
|
||||||
|
}
|
||||||
|
Err(e) => Response::err(req.id, -32000, format!("Failed to load session: {e}")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn emit<W: AsyncWrite + Unpin>(writer: &mut W, response: &Response) -> Result<()> {
|
||||||
|
let mut line = serde_json::to_string(response)?;
|
||||||
|
line.push('\n');
|
||||||
|
writer.write_all(line.as_bytes()).await?;
|
||||||
|
writer.flush().await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn emit_notification<W: AsyncWrite + Unpin>(
|
||||||
|
writer: &mut W,
|
||||||
|
method: &str,
|
||||||
|
params: Value,
|
||||||
|
) -> Result<()> {
|
||||||
|
let frame = json!({
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": method,
|
||||||
|
"params": params,
|
||||||
|
});
|
||||||
|
let mut line = serde_json::to_string(&frame)?;
|
||||||
|
line.push('\n');
|
||||||
|
writer.write_all(line.as_bytes()).await?;
|
||||||
|
writer.flush().await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use std::str;
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn all_stdout_is_valid_json_rpc() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"name":"test","version":"0.1.0"}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
for line in output.split(|&b| b == b'\n').filter(|l| !l.is_empty()) {
|
||||||
|
let s = str::from_utf8(line).expect("non-UTF8 in ACP stdout");
|
||||||
|
let _: Value = serde_json::from_str(s)
|
||||||
|
.unwrap_or_else(|_| panic!("ACP stdout not valid JSON: {s}"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn unknown_method_returns_method_not_found() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":2,"method":"nonexistent","params":{}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let v: Value = serde_json::from_str(s.trim()).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(v["error"]["code"], METHOD_NOT_FOUND);
|
||||||
|
assert_eq!(v["id"], 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn invalid_json_returns_parse_error() {
|
||||||
|
let input = "not json\n";
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let v: Value = serde_json::from_str(s.trim()).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(v["error"]["code"], PARSE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn notification_without_id_produces_no_output() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","method":"session/cancel","params":{}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert!(output.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn initialize_returns_server_info() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"name":"test","version":"0.1.0"}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let v: Value = serde_json::from_str(s.trim()).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(v["id"], 1);
|
||||||
|
assert_eq!(v["result"]["name"], "coyote");
|
||||||
|
assert!(v["result"]["version"].is_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn session_new_returns_session_id() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":10,"method":"session/new","params":{}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let v: Value = serde_json::from_str(s.trim()).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(v["id"], 10);
|
||||||
|
assert_eq!(v["result"]["sessionId"], "default");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn session_new_twice_errors() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":1,"method":"session/new","params":{}}"#,
|
||||||
|
"\n",
|
||||||
|
r#"{"jsonrpc":"2.0","id":2,"method":"session/new","params":{}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let mut lines = s.lines().filter(|l| !l.is_empty());
|
||||||
|
|
||||||
|
let first: Value = serde_json::from_str(lines.next().unwrap()).unwrap();
|
||||||
|
let second: Value = serde_json::from_str(lines.next().unwrap()).unwrap();
|
||||||
|
assert!(first["result"]["sessionId"].is_string());
|
||||||
|
assert_eq!(second["error"]["code"], -32000);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn session_prompt_without_session_errors() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":3,"method":"session/prompt","params":{"text":"hello"}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let v: Value = serde_json::from_str(s.trim()).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(v["id"], 3);
|
||||||
|
assert_eq!(v["error"]["code"], -32000);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn session_prompt_with_no_context_returns_error() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":1,"method":"session/new","params":{}}"#,
|
||||||
|
"\n",
|
||||||
|
r#"{"jsonrpc":"2.0","id":2,"method":"session/prompt","params":{"text":"hello"}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let mut lines = s.lines().filter(|l| !l.is_empty());
|
||||||
|
|
||||||
|
let first: Value = serde_json::from_str(lines.next().unwrap()).unwrap();
|
||||||
|
let second: Value = serde_json::from_str(lines.next().unwrap()).unwrap();
|
||||||
|
assert_eq!(first["result"]["sessionId"], "default");
|
||||||
|
assert_eq!(second["id"], 2);
|
||||||
|
assert!(
|
||||||
|
second["error"].is_object(),
|
||||||
|
"expected error response when no ctx"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn session_cancel_notification_produces_no_output() {
|
||||||
|
let input = concat!(r#"{"jsonrpc":"2.0","method":"session/cancel"}"#, "\n",);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert!(output.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn session_cancel_request_returns_ok() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":99,"method":"session/cancel"}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let v: Value = serde_json::from_str(s.trim()).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(v["id"], 99);
|
||||||
|
assert!(v["result"].is_object());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn session_load_missing_session_id_errors() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":5,"method":"session/load","params":{}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let v: Value = serde_json::from_str(s.trim()).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(v["id"], 5);
|
||||||
|
assert_eq!(v["error"]["code"], -32602);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn session_load_after_session_new_errors() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":1,"method":"session/new","params":{}}"#,
|
||||||
|
"\n",
|
||||||
|
r#"{"jsonrpc":"2.0","id":2,"method":"session/load","params":{"sessionId":"abc"}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let mut lines = s.lines().filter(|l| !l.is_empty());
|
||||||
|
|
||||||
|
let _first: Value = serde_json::from_str(lines.next().unwrap()).unwrap();
|
||||||
|
let second: Value = serde_json::from_str(lines.next().unwrap()).unwrap();
|
||||||
|
assert_eq!(second["id"], 2);
|
||||||
|
assert_eq!(second["error"]["code"], -32000);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn session_load_with_no_context_returns_error() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":6,"method":"session/load","params":{"sessionId":"my-session"}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let v: Value = serde_json::from_str(s.trim()).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(v["id"], 6);
|
||||||
|
assert!(v["error"].is_object());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn emit_notification_produces_valid_json_rpc_frame() {
|
||||||
|
let mut output = Vec::new();
|
||||||
|
emit_notification(
|
||||||
|
&mut output,
|
||||||
|
"session/request_permission",
|
||||||
|
json!({"action": "confirm", "question": "Proceed?"}),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let v: Value = serde_json::from_str(s.trim()).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(v["jsonrpc"], "2.0");
|
||||||
|
assert_eq!(v["method"], "session/request_permission");
|
||||||
|
assert!(v["params"]["action"].is_string());
|
||||||
|
assert!(!v.as_object().unwrap().contains_key("id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn initialize_protocol_version_is_number() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let v: Value = serde_json::from_str(s.trim()).unwrap();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
v["result"]["protocolVersion"].is_number(),
|
||||||
|
"protocolVersion must be a JSON number, got: {:?}",
|
||||||
|
v["result"]["protocolVersion"]
|
||||||
|
);
|
||||||
|
assert_eq!(v["result"]["protocolVersion"], 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn session_prompt_spec_content_blocks_not_rejected() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":1,"method":"session/new","params":{}}"#,
|
||||||
|
"\n",
|
||||||
|
r#"{"jsonrpc":"2.0","id":2,"method":"session/prompt","params":{"sessionId":"default","prompt":[{"type":"text","text":"hello"}]}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let mut lines = s.lines().filter(|l| !l.is_empty());
|
||||||
|
let _first: Value = serde_json::from_str(lines.next().unwrap()).unwrap();
|
||||||
|
let second: Value = serde_json::from_str(lines.next().unwrap()).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(second["id"], 2);
|
||||||
|
let code = second["error"]["code"].as_i64().unwrap_or(0);
|
||||||
|
assert_ne!(
|
||||||
|
code, -32602,
|
||||||
|
"spec-shaped ContentBlock prompt must not get a params error"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn session_prompt_non_text_blocks_ignored() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":1,"method":"session/new","params":{}}"#,
|
||||||
|
"\n",
|
||||||
|
r#"{"jsonrpc":"2.0","id":2,"method":"session/prompt","params":{"prompt":[{"type":"image","data":"abc"},{"type":"text","text":"hello"}]}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let mut lines = s.lines().filter(|l| !l.is_empty());
|
||||||
|
let _first: Value = serde_json::from_str(lines.next().unwrap()).unwrap();
|
||||||
|
let second: Value = serde_json::from_str(lines.next().unwrap()).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(second["id"], 2);
|
||||||
|
let code = second["error"]["code"].as_i64().unwrap_or(0);
|
||||||
|
assert_ne!(code, -32602, "non-text blocks must be silently ignored");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn session_prompt_missing_both_text_and_prompt_errors() {
|
||||||
|
let input = concat!(
|
||||||
|
r#"{"jsonrpc":"2.0","id":1,"method":"session/new","params":{}}"#,
|
||||||
|
"\n",
|
||||||
|
r#"{"jsonrpc":"2.0","id":2,"method":"session/prompt","params":{"sessionId":"default"}}"#,
|
||||||
|
"\n",
|
||||||
|
);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
run_acp_server_on(input.as_bytes(), &mut output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = String::from_utf8(output).unwrap();
|
||||||
|
let mut lines = s.lines().filter(|l| !l.is_empty());
|
||||||
|
let _first: Value = serde_json::from_str(lines.next().unwrap()).unwrap();
|
||||||
|
let second: Value = serde_json::from_str(lines.next().unwrap()).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(second["id"], 2);
|
||||||
|
assert_eq!(second["error"]["code"], -32602);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
pub const METHOD_NOT_FOUND: i32 = -32601;
|
||||||
|
pub const PARSE_ERROR: i32 = -32700;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub struct Request {
|
||||||
|
pub jsonrpc: String,
|
||||||
|
pub id: Option<Value>,
|
||||||
|
pub method: String,
|
||||||
|
pub params: Option<Value>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
pub struct Response {
|
||||||
|
pub jsonrpc: &'static str,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub id: Option<Value>,
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub body: ResponseBody,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum ResponseBody {
|
||||||
|
Ok { result: Value },
|
||||||
|
Err { error: RpcError },
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
pub struct RpcError {
|
||||||
|
pub code: i32,
|
||||||
|
pub message: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
pub fn ok(id: Option<Value>, result: Value) -> Self {
|
||||||
|
Self {
|
||||||
|
jsonrpc: "2.0",
|
||||||
|
id,
|
||||||
|
body: ResponseBody::Ok { result },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn err(id: Option<Value>, code: i32, message: impl Into<String>) -> Self {
|
||||||
|
Self {
|
||||||
|
jsonrpc: "2.0",
|
||||||
|
id,
|
||||||
|
body: ResponseBody::Err {
|
||||||
|
error: RpcError {
|
||||||
|
code,
|
||||||
|
message: message.into(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
-4
@@ -1,6 +1,6 @@
|
|||||||
use crate::client::{ModelType, list_models};
|
use crate::client::{ModelType, list_models};
|
||||||
use crate::config::paths;
|
use crate::config::paths;
|
||||||
use crate::config::{AppConfig, Config, list_agents, list_sessions};
|
use crate::config::{AppConfig, Config, list_agents_with_descriptions, list_sessions};
|
||||||
use crate::utils::list_file_names;
|
use crate::utils::list_file_names;
|
||||||
use crate::vault::Vault;
|
use crate::vault::Vault;
|
||||||
use clap_complete::{CompletionCandidate, Shell, generate};
|
use clap_complete::{CompletionCandidate, Shell, generate};
|
||||||
@@ -73,10 +73,17 @@ pub(super) fn role_completer(current: &OsStr) -> Vec<CompletionCandidate> {
|
|||||||
|
|
||||||
pub(super) fn agent_completer(current: &OsStr) -> Vec<CompletionCandidate> {
|
pub(super) fn agent_completer(current: &OsStr) -> Vec<CompletionCandidate> {
|
||||||
let cur = current.to_string_lossy();
|
let cur = current.to_string_lossy();
|
||||||
list_agents()
|
list_agents_with_descriptions()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|a| a.starts_with(&*cur))
|
.filter(|(a, _)| a.starts_with(&*cur))
|
||||||
.map(CompletionCandidate::new)
|
.map(|(name, desc)| {
|
||||||
|
let help = if desc.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(desc.into())
|
||||||
|
};
|
||||||
|
CompletionCandidate::new(name).help(help)
|
||||||
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+194
-151
@@ -30,7 +30,7 @@ use std::io::{Read, stdin};
|
|||||||
",
|
",
|
||||||
group(
|
group(
|
||||||
ArgGroup::new("sbx-mode")
|
ArgGroup::new("sbx-mode")
|
||||||
.args(["sandbox", "fresh", "no_mixins"])
|
.args(["sandbox", "fresh"])
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
.conflicts_with_all([
|
.conflicts_with_all([
|
||||||
"model", "prompt", "role", "session", "agent", "rag", "rebuild_rag",
|
"model", "prompt", "role", "session", "agent", "rag", "rebuild_rag",
|
||||||
@@ -43,6 +43,10 @@ use std::io::{Read, stdin};
|
|||||||
),
|
),
|
||||||
)]
|
)]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
|
/// Input text
|
||||||
|
#[arg(trailing_var_arg = true)]
|
||||||
|
text: Vec<String>,
|
||||||
|
|
||||||
/// Select a LLM model
|
/// Select a LLM model
|
||||||
#[arg(short, long, add = ArgValueCompleter::new(model_completer))]
|
#[arg(short, long, add = ArgValueCompleter::new(model_completer))]
|
||||||
pub model: Option<String>,
|
pub model: Option<String>,
|
||||||
@@ -52,30 +56,6 @@ pub struct Cli {
|
|||||||
/// Select a role
|
/// Select a role
|
||||||
#[arg(short, long, add = ArgValueCompleter::new(role_completer))]
|
#[arg(short, long, add = ArgValueCompleter::new(role_completer))]
|
||||||
pub role: Option<String>,
|
pub role: Option<String>,
|
||||||
/// Start or join a session
|
|
||||||
#[arg(short = 's', long, add = ArgValueCompleter::new(session_completer))]
|
|
||||||
pub session: Option<Option<String>>,
|
|
||||||
/// Ensure the session is empty
|
|
||||||
#[arg(long)]
|
|
||||||
pub empty_session: bool,
|
|
||||||
/// Ensure the new conversation is saved to the session
|
|
||||||
#[arg(long)]
|
|
||||||
pub save_session: bool,
|
|
||||||
/// Start an agent
|
|
||||||
#[arg(short = 'a', long, add = ArgValueCompleter::new(agent_completer))]
|
|
||||||
pub agent: Option<String>,
|
|
||||||
/// Set agent variables
|
|
||||||
#[arg(long, value_names = ["NAME", "VALUE"], num_args = 2)]
|
|
||||||
pub agent_variable: Vec<String>,
|
|
||||||
/// Start a RAG
|
|
||||||
#[arg(long, add = ArgValueCompleter::new(rag_completer))]
|
|
||||||
pub rag: Option<String>,
|
|
||||||
/// Rebuild the RAG to sync document changes
|
|
||||||
#[arg(long)]
|
|
||||||
pub rebuild_rag: bool,
|
|
||||||
/// Execute a macro
|
|
||||||
#[arg(long = "macro", value_name = "MACRO", add = ArgValueCompleter::new(macro_completer))]
|
|
||||||
pub macro_name: Option<String>,
|
|
||||||
/// Execute commands in natural language
|
/// Execute commands in natural language
|
||||||
#[arg(short = 'e', long)]
|
#[arg(short = 'e', long)]
|
||||||
pub execute: bool,
|
pub execute: bool,
|
||||||
@@ -88,113 +68,192 @@ pub struct Cli {
|
|||||||
/// Turn off stream mode
|
/// Turn off stream mode
|
||||||
#[arg(short = 'S', long)]
|
#[arg(short = 'S', long)]
|
||||||
pub no_stream: bool,
|
pub no_stream: bool,
|
||||||
/// Disable memory for this invocation
|
/// Render markdown as raw text with syntax highlighting only (skip the rich markdown renderer)
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub no_memory: bool,
|
pub raw_markdown: bool,
|
||||||
/// Skip permission prompts by setting AUTO_CONFIRM for all tools (dangerous!)
|
|
||||||
#[arg(long)]
|
|
||||||
pub dangerously_skip_permissions: bool,
|
|
||||||
/// Bootstrap a memory marker so coyote begins loading memory next run
|
|
||||||
#[arg(long, value_name = "SCOPE", value_enum)]
|
|
||||||
pub init_memory: Option<MemoryScope>,
|
|
||||||
/// Display the message without sending it
|
/// Display the message without sending it
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub dry_run: bool,
|
pub dry_run: bool,
|
||||||
/// Display information
|
/// Disable loading workspace MCP servers from .coyote/mcp.json, .coyote/.mcp.json, or .mcp.json
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub info: bool,
|
pub no_workspace_mcp: bool,
|
||||||
/// Build all configured Bash tool scripts
|
/// Disable memory for this invocation
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub build_tools: bool,
|
pub no_memory: bool,
|
||||||
/// Reinstall bundled assets, overwriting any local changes
|
/// Disable loading workspace instructions (COYOTE.md/AGENTS.md/CLAUDE.md/etc.) for this invocation
|
||||||
#[arg(long, value_name = "CATEGORY", value_enum)]
|
|
||||||
pub install: Option<AssetCategory>,
|
|
||||||
/// Install assets from a remote git repository (URL may be suffixed with #<ref>)
|
|
||||||
#[arg(long, value_name = "GIT_URL")]
|
|
||||||
pub install_from: Option<String>,
|
|
||||||
/// Restrict --install-from to a single asset category
|
|
||||||
#[arg(long, value_name = "CATEGORY", value_enum, requires = "install_from")]
|
|
||||||
pub filter: Option<InstallFilter>,
|
|
||||||
/// Overwrite all conflicts without prompting (used with --install-from)
|
|
||||||
#[arg(long, requires = "install_from")]
|
|
||||||
pub install_force: bool,
|
|
||||||
/// Sync models updates
|
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub sync_models: bool,
|
pub no_workspace_instructions: bool,
|
||||||
/// List all available chat models
|
/// Override the workspace instructions file chain for this invocation (repeatable, priority order)
|
||||||
|
#[arg(long, value_name = "NAME")]
|
||||||
|
pub workspace_instructions_file: Vec<String>,
|
||||||
|
/// Skip permission prompts by setting AUTO_CONFIRM for all tools (dangerous!)
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub list_models: bool,
|
pub dangerously_skip_permissions: bool,
|
||||||
/// List all roles
|
|
||||||
#[arg(long)]
|
/// Start or join a session
|
||||||
pub list_roles: bool,
|
#[arg(short = 's', long, help_heading = "Session & Memory", add = ArgValueCompleter::new(session_completer))]
|
||||||
/// List all sessions
|
pub session: Option<Option<String>>,
|
||||||
#[arg(long)]
|
/// Ensure the session is empty
|
||||||
pub list_sessions: bool,
|
#[arg(long, help_heading = "Session & Memory")]
|
||||||
/// List all agents
|
pub empty_session: bool,
|
||||||
#[arg(long)]
|
/// Ensure the new conversation is saved to the session
|
||||||
pub list_agents: bool,
|
#[arg(long, help_heading = "Session & Memory")]
|
||||||
/// List all RAGs
|
pub save_session: bool,
|
||||||
#[arg(long)]
|
/// Bootstrap a memory marker so coyote begins loading memory next run
|
||||||
pub list_rags: bool,
|
#[arg(
|
||||||
/// List all macros
|
long,
|
||||||
#[arg(long)]
|
value_name = "SCOPE",
|
||||||
pub list_macros: bool,
|
value_enum,
|
||||||
/// List all installed skills
|
help_heading = "Session & Memory"
|
||||||
#[arg(long)]
|
)]
|
||||||
pub list_skills: bool,
|
pub init_memory: Option<MemoryScope>,
|
||||||
|
/// Scaffold a COYOTE.md workspace instructions file in the current directory
|
||||||
|
#[arg(long, help_heading = "Session & Memory")]
|
||||||
|
pub init_instructions: bool,
|
||||||
/// Pre-load an existing skill into the session (repeatable). If a single
|
/// Pre-load an existing skill into the session (repeatable). If a single
|
||||||
/// `--skill <NAME>` is given and the skill doesn't exist, opens $EDITOR
|
/// `--skill <NAME>` is given and the skill doesn't exist, opens $EDITOR
|
||||||
/// with a scaffold to create it.
|
/// with a scaffold to create it.
|
||||||
#[arg(long, value_name = "NAME")]
|
#[arg(long, value_name = "NAME", help_heading = "Session & Memory")]
|
||||||
pub skill: Vec<String>,
|
pub skill: Vec<String>,
|
||||||
/// Input text
|
|
||||||
#[arg(trailing_var_arg = true)]
|
/// Start an agent
|
||||||
text: Vec<String>,
|
#[arg(short = 'a', long, help_heading = "Agents, RAG & Macros", add = ArgValueCompleter::new(agent_completer))]
|
||||||
/// Tail logs
|
pub agent: Option<String>,
|
||||||
#[arg(long)]
|
/// Set agent variables
|
||||||
pub tail_logs: bool,
|
#[arg(long, value_names = ["NAME", "VALUE"], num_args = 2, help_heading = "Agents, RAG & Macros")]
|
||||||
/// Disable colored log output
|
pub agent_variable: Vec<String>,
|
||||||
#[arg(long, requires = "tail_logs")]
|
/// Start a RAG
|
||||||
pub disable_log_colors: bool,
|
#[arg(long, help_heading = "Agents, RAG & Macros", add = ArgValueCompleter::new(rag_completer))]
|
||||||
/// Add a secret to the Coyote vault
|
pub rag: Option<String>,
|
||||||
#[arg(long, value_name = "SECRET_NAME", exclusive = true)]
|
/// Rebuild the RAG to sync document changes
|
||||||
pub add_secret: Option<String>,
|
#[arg(long, help_heading = "Agents, RAG & Macros")]
|
||||||
/// Decrypt a secret from the Coyote vault and print the plaintext
|
pub rebuild_rag: bool,
|
||||||
#[arg(long, value_name = "SECRET_NAME", exclusive = true, add = ArgValueCompleter::new(secrets_completer))]
|
/// Execute a macro
|
||||||
pub get_secret: Option<String>,
|
#[arg(long = "macro", value_name = "MACRO", help_heading = "Agents, RAG & Macros", add = ArgValueCompleter::new(macro_completer))]
|
||||||
/// Update an existing secret in the Coyote vault
|
pub macro_name: Option<String>,
|
||||||
#[arg(long, value_name = "SECRET_NAME", exclusive = true, add = ArgValueCompleter::new(secrets_completer))]
|
|
||||||
pub update_secret: Option<String>,
|
/// List all available chat models
|
||||||
/// Delete a secret from the Coyote vault
|
#[arg(long, help_heading = "List & Discovery")]
|
||||||
#[arg(long, value_name = "SECRET_NAME", exclusive = true, add = ArgValueCompleter::new(secrets_completer))]
|
pub list_models: bool,
|
||||||
pub delete_secret: Option<String>,
|
/// List all roles
|
||||||
/// List all secrets stored in the Coyote vault
|
#[arg(long, help_heading = "List & Discovery")]
|
||||||
#[arg(long, exclusive = true)]
|
pub list_roles: bool,
|
||||||
pub list_secrets: bool,
|
/// List all sessions
|
||||||
/// Authenticate with an LLM provider using OAuth (e.g., --authenticate client_name)
|
#[arg(long, help_heading = "List & Discovery")]
|
||||||
#[arg(long, exclusive = true, value_name = "CLIENT_NAME")]
|
pub list_sessions: bool,
|
||||||
pub authenticate: Option<Option<String>>,
|
/// List all agents
|
||||||
/// Authenticate with an OAuth-protected remote MCP server (e.g., --auth-mcp server_name)
|
#[arg(long, help_heading = "List & Discovery")]
|
||||||
#[arg(long, exclusive = true, value_name = "SERVER_NAME", add = ArgValueCompleter::new(mcp_server_completer))]
|
pub list_agents: bool,
|
||||||
pub auth_mcp: Option<String>,
|
/// List all RAGs
|
||||||
/// Generate static shell completion scripts
|
#[arg(long, help_heading = "List & Discovery")]
|
||||||
#[arg(long, value_name = "SHELL", value_enum)]
|
pub list_rags: bool,
|
||||||
pub completions: Option<ShellCompletion>,
|
/// List all macros
|
||||||
|
#[arg(long, help_heading = "List & Discovery")]
|
||||||
|
pub list_macros: bool,
|
||||||
|
/// List all installed skills
|
||||||
|
#[arg(long, help_heading = "List & Discovery")]
|
||||||
|
pub list_skills: bool,
|
||||||
|
|
||||||
|
/// Reinstall bundled assets, overwriting any local changes
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
value_name = "CATEGORY",
|
||||||
|
value_enum,
|
||||||
|
help_heading = "Installation & Updates"
|
||||||
|
)]
|
||||||
|
pub install: Option<AssetCategory>,
|
||||||
|
/// Install assets from a remote git repository (URL may be suffixed with #<ref>)
|
||||||
|
#[arg(long, value_name = "GIT_URL", help_heading = "Installation & Updates")]
|
||||||
|
pub install_from: Option<String>,
|
||||||
|
/// Restrict --install-from to a single asset category
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
value_name = "CATEGORY",
|
||||||
|
value_enum,
|
||||||
|
requires = "install_from",
|
||||||
|
help_heading = "Installation & Updates"
|
||||||
|
)]
|
||||||
|
pub filter: Option<InstallFilter>,
|
||||||
|
/// Overwrite all conflicts without prompting (used with --install-from)
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
requires = "install_from",
|
||||||
|
help_heading = "Installation & Updates"
|
||||||
|
)]
|
||||||
|
pub install_force: bool,
|
||||||
|
/// Sync models updates
|
||||||
|
#[arg(long, help_heading = "Installation & Updates")]
|
||||||
|
pub sync_models: bool,
|
||||||
/// Update Coyote to the latest release, or to a specific version
|
/// Update Coyote to the latest release, or to a specific version
|
||||||
#[arg(long, value_name = "VERSION")]
|
#[arg(long, value_name = "VERSION", help_heading = "Installation & Updates")]
|
||||||
pub update: Option<Option<String>>,
|
pub update: Option<Option<String>>,
|
||||||
/// With --update, update even if Coyote was installed via a package manager
|
/// With --update, update even if Coyote was installed via a package manager
|
||||||
#[arg(long, requires = "update")]
|
#[arg(long, requires = "update", help_heading = "Installation & Updates")]
|
||||||
pub force: bool,
|
pub force: bool,
|
||||||
|
|
||||||
|
/// Add a secret to the Coyote vault
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
value_name = "SECRET_NAME",
|
||||||
|
exclusive = true,
|
||||||
|
help_heading = "Vault & Secrets"
|
||||||
|
)]
|
||||||
|
pub add_secret: Option<String>,
|
||||||
|
/// Decrypt a secret from the Coyote vault and print the plaintext
|
||||||
|
#[arg(long, value_name = "SECRET_NAME", exclusive = true, help_heading = "Vault & Secrets", add = ArgValueCompleter::new(secrets_completer))]
|
||||||
|
pub get_secret: Option<String>,
|
||||||
|
/// Update an existing secret in the Coyote vault
|
||||||
|
#[arg(long, value_name = "SECRET_NAME", exclusive = true, help_heading = "Vault & Secrets", add = ArgValueCompleter::new(secrets_completer))]
|
||||||
|
pub update_secret: Option<String>,
|
||||||
|
/// Delete a secret from the Coyote vault
|
||||||
|
#[arg(long, value_name = "SECRET_NAME", exclusive = true, help_heading = "Vault & Secrets", add = ArgValueCompleter::new(secrets_completer))]
|
||||||
|
pub delete_secret: Option<String>,
|
||||||
|
/// List all secrets stored in the Coyote vault
|
||||||
|
#[arg(long, exclusive = true, help_heading = "Vault & Secrets")]
|
||||||
|
pub list_secrets: bool,
|
||||||
|
|
||||||
|
/// Authenticate with an LLM provider using OAuth (e.g., --authenticate client_name)
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
exclusive = true,
|
||||||
|
value_name = "CLIENT_NAME",
|
||||||
|
help_heading = "Authentication"
|
||||||
|
)]
|
||||||
|
pub authenticate: Option<Option<String>>,
|
||||||
|
/// Authenticate with an OAuth-protected remote MCP server (e.g., --auth-mcp server_name)
|
||||||
|
#[arg(long, exclusive = true, value_name = "SERVER_NAME", help_heading = "Authentication", add = ArgValueCompleter::new(mcp_server_completer))]
|
||||||
|
pub auth_mcp: Option<String>,
|
||||||
|
|
||||||
/// Launch Coyote inside a Docker sandbox (via `sbx`); name defaults to current directory basename
|
/// Launch Coyote inside a Docker sandbox (via `sbx`); name defaults to current directory basename
|
||||||
#[arg(long, value_name = "NAME")]
|
#[arg(long, value_name = "NAME", help_heading = "Sandbox")]
|
||||||
pub sandbox: Option<Option<String>>,
|
pub sandbox: Option<Option<String>>,
|
||||||
/// Create the sandbox without bootstrapping the host config or vault password file
|
/// Start the sandbox with a clean slate. No copied config or tokens; LLM credentials injected via sbx proxy
|
||||||
#[arg(long, requires = "sandbox")]
|
#[arg(long, requires = "sandbox", help_heading = "Sandbox")]
|
||||||
pub fresh: bool,
|
pub fresh: bool,
|
||||||
/// Skip discovery and application of all sbx mixins (user and built-in)
|
/// Declare that no human is present. All user-interaction tools return structured JSON instead of
|
||||||
#[arg(long, requires = "sandbox")]
|
/// prompting. Implies --dangerously-skip-permissions. Incompatible with REPL mode (requires a prompt).
|
||||||
pub no_mixins: bool,
|
#[arg(long, help_heading = "Sandbox")]
|
||||||
|
pub headless: bool,
|
||||||
|
/// Run as an ACP agent server over stdio (JSON-RPC 2.0). Every stdout byte must be valid JSON-RPC.
|
||||||
|
/// Implies --headless. Single session per process.
|
||||||
|
#[arg(long, help_heading = "Sandbox")]
|
||||||
|
pub acp_server: bool,
|
||||||
|
/// Display information
|
||||||
|
#[arg(long, help_heading = "Diagnostics & Tools")]
|
||||||
|
pub info: bool,
|
||||||
|
/// Build all configured Bash tool scripts
|
||||||
|
#[arg(long, help_heading = "Diagnostics & Tools")]
|
||||||
|
pub build_tools: bool,
|
||||||
|
/// Tail logs
|
||||||
|
#[arg(long, help_heading = "Diagnostics & Tools")]
|
||||||
|
pub tail_logs: bool,
|
||||||
|
/// Disable colored log output
|
||||||
|
#[arg(long, requires = "tail_logs", help_heading = "Diagnostics & Tools")]
|
||||||
|
pub disable_log_colors: bool,
|
||||||
|
|
||||||
|
/// Generate static shell completion scripts
|
||||||
|
#[arg(long, value_name = "SHELL", value_enum, help_heading = "Shell")]
|
||||||
|
pub completions: Option<ShellCompletion>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cli {
|
impl Cli {
|
||||||
@@ -439,6 +498,28 @@ mod tests {
|
|||||||
assert!(!cli.dangerously_skip_permissions);
|
assert!(!cli.dangerously_skip_permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_headless_flag() {
|
||||||
|
let cli = parse(&["--headless", "do something"]);
|
||||||
|
assert!(cli.headless);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_headless_default_off() {
|
||||||
|
assert!(!parse(&[]).headless);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_acp_server_flag() {
|
||||||
|
let cli = parse(&["--acp-server"]);
|
||||||
|
assert!(cli.acp_server);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_acp_server_default_off() {
|
||||||
|
assert!(!parse(&[]).acp_server);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_sync_models_flag() {
|
fn parse_sync_models_flag() {
|
||||||
let cli = parse(&["--sync-models"]);
|
let cli = parse(&["--sync-models"]);
|
||||||
@@ -552,42 +633,4 @@ mod tests {
|
|||||||
fn parse_sandbox_is_exclusive() {
|
fn parse_sandbox_is_exclusive() {
|
||||||
assert!(Cli::try_parse_from(["coyote", "--sandbox", "--agent", "foo"]).is_err());
|
assert!(Cli::try_parse_from(["coyote", "--sandbox", "--agent", "foo"]).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn parse_fresh_flag_requires_sandbox() {
|
|
||||||
assert!(Cli::try_parse_from(["coyote", "--fresh"]).is_err());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn parse_fresh_flag_with_sandbox() {
|
|
||||||
let cli = parse(&["--sandbox", "--fresh"]);
|
|
||||||
assert_eq!(cli.sandbox, Some(None));
|
|
||||||
assert!(cli.fresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn parse_fresh_flag_with_named_sandbox() {
|
|
||||||
let cli = parse(&["--sandbox", "foo", "--fresh"]);
|
|
||||||
assert_eq!(cli.sandbox, Some(Some("foo".to_string())));
|
|
||||||
assert!(cli.fresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn parse_no_mixins_requires_sandbox() {
|
|
||||||
assert!(Cli::try_parse_from(["coyote", "--no-mixins"]).is_err());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn parse_no_mixins_with_sandbox() {
|
|
||||||
let cli = parse(&["--sandbox", "--no-mixins"]);
|
|
||||||
assert!(cli.no_mixins);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn parse_sandbox_with_fresh_and_no_mixins() {
|
|
||||||
let cli = parse(&["--sandbox", "foo", "--fresh", "--no-mixins"]);
|
|
||||||
assert_eq!(cli.sandbox, Some(Some("foo".to_string())));
|
|
||||||
assert!(cli.fresh);
|
|
||||||
assert!(cli.no_mixins);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ fn prepare_chat_completions(
|
|||||||
|
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"{}/openai/deployments/{}/chat/completions?api-version=2024-12-01-preview",
|
"{}/openai/deployments/{}/chat/completions?api-version=2024-12-01-preview",
|
||||||
&api_base,
|
api_base,
|
||||||
self_.model.real_name()
|
self_.model.real_name()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ fn prepare_embeddings(self_: &AzureOpenAIClient, data: &EmbeddingsData) -> Resul
|
|||||||
|
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"{}/openai/deployments/{}/embeddings?api-version=2024-10-21",
|
"{}/openai/deployments/{}/embeddings?api-version=2024-10-21",
|
||||||
&api_base,
|
api_base,
|
||||||
self_.model.real_name()
|
self_.model.real_name()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -325,6 +325,7 @@ fn build_chat_completions_body(data: ChatCompletionsData, model: &Model) -> Resu
|
|||||||
mut messages,
|
mut messages,
|
||||||
temperature,
|
temperature,
|
||||||
top_p,
|
top_p,
|
||||||
|
reasoning_effort,
|
||||||
functions,
|
functions,
|
||||||
stream: _,
|
stream: _,
|
||||||
} = data;
|
} = data;
|
||||||
@@ -396,6 +397,11 @@ fn build_chat_completions_body(data: ChatCompletionsData, model: &Model) -> Resu
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
for tool_result in tool_results {
|
for tool_result in tool_results {
|
||||||
|
if let Some(round_text) = &tool_result.text {
|
||||||
|
assistant_parts.push(json!({
|
||||||
|
"text": round_text,
|
||||||
|
}))
|
||||||
|
}
|
||||||
assistant_parts.push(json!({
|
assistant_parts.push(json!({
|
||||||
"toolUse": {
|
"toolUse": {
|
||||||
"toolUseId": tool_result.call.id,
|
"toolUseId": tool_result.call.id,
|
||||||
@@ -457,6 +463,9 @@ fn build_chat_completions_body(data: ChatCompletionsData, model: &Model) -> Resu
|
|||||||
if let Some(v) = top_p {
|
if let Some(v) = top_p {
|
||||||
body["inferenceConfig"]["topP"] = v.into();
|
body["inferenceConfig"]["topP"] = v.into();
|
||||||
}
|
}
|
||||||
|
if let Some(v) = reasoning_effort {
|
||||||
|
body["additionalModelRequestFields"] = json!({ "output_config": { "effort": v } });
|
||||||
|
}
|
||||||
if let Some(functions) = functions {
|
if let Some(functions) = functions {
|
||||||
let tools: Vec<_> = functions
|
let tools: Vec<_> = functions
|
||||||
.iter()
|
.iter()
|
||||||
@@ -520,7 +529,7 @@ fn extract_chat_completions(data: &Value) -> Result<ChatCompletionsOutput> {
|
|||||||
bail!("Invalid response data: {data}");
|
bail!("Invalid response data: {data}");
|
||||||
}
|
}
|
||||||
|
|
||||||
let output = ChatCompletionsOutput { text, tool_calls };
|
let output = ChatCompletionsOutput { text, tool_calls, ..Default::default() };
|
||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+53
-7
@@ -168,12 +168,22 @@ pub async fn claude_chat_completions_streaming(
|
|||||||
let mut function_arguments = String::new();
|
let mut function_arguments = String::new();
|
||||||
let mut function_id = String::new();
|
let mut function_id = String::new();
|
||||||
let mut reasoning_state = 0;
|
let mut reasoning_state = 0;
|
||||||
|
let mut thinking_text = String::new();
|
||||||
|
let mut thinking_signature = String::new();
|
||||||
let handle = |message: SseMessage| -> Result<bool> {
|
let handle = |message: SseMessage| -> Result<bool> {
|
||||||
let data: Value = serde_json::from_str(&message.data)?;
|
let data: Value = serde_json::from_str(&message.data)?;
|
||||||
debug!("stream-data: {data}");
|
debug!("stream-data: {data}");
|
||||||
if let Some(typ) = data["type"].as_str() {
|
if let Some(typ) = data["type"].as_str() {
|
||||||
match typ {
|
match typ {
|
||||||
"content_block_start" => {
|
"content_block_start" => {
|
||||||
|
if let (Some("redacted_thinking"), Some(redacted_data)) = (
|
||||||
|
data["content_block"]["type"].as_str(),
|
||||||
|
data["content_block"]["data"].as_str(),
|
||||||
|
) {
|
||||||
|
handler.thinking_block(ThinkingBlock::RedactedThinking {
|
||||||
|
data: redacted_data.to_string(),
|
||||||
|
});
|
||||||
|
}
|
||||||
if let (Some("tool_use"), Some(name), Some(id)) = (
|
if let (Some("tool_use"), Some(name), Some(id)) = (
|
||||||
data["content_block"]["type"].as_str(),
|
data["content_block"]["type"].as_str(),
|
||||||
data["content_block"]["name"].as_str(),
|
data["content_block"]["name"].as_str(),
|
||||||
@@ -206,7 +216,10 @@ pub async fn claude_chat_completions_streaming(
|
|||||||
handler.text("<think>\n")?;
|
handler.text("<think>\n")?;
|
||||||
reasoning_state = 1;
|
reasoning_state = 1;
|
||||||
}
|
}
|
||||||
|
thinking_text.push_str(text);
|
||||||
handler.text(text)?;
|
handler.text(text)?;
|
||||||
|
} else if let Some(signature) = data["delta"]["signature"].as_str() {
|
||||||
|
thinking_signature.push_str(signature);
|
||||||
} else if let (true, Some(partial_json)) = (
|
} else if let (true, Some(partial_json)) = (
|
||||||
!function_name.is_empty(),
|
!function_name.is_empty(),
|
||||||
data["delta"]["partial_json"].as_str(),
|
data["delta"]["partial_json"].as_str(),
|
||||||
@@ -218,6 +231,10 @@ pub async fn claude_chat_completions_streaming(
|
|||||||
if reasoning_state == 1 {
|
if reasoning_state == 1 {
|
||||||
handler.text("\n</think>\n\n")?;
|
handler.text("\n</think>\n\n")?;
|
||||||
reasoning_state = 0;
|
reasoning_state = 0;
|
||||||
|
handler.thinking_block(ThinkingBlock::Thinking {
|
||||||
|
thinking: std::mem::take(&mut thinking_text),
|
||||||
|
signature: std::mem::take(&mut thinking_signature),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if !function_name.is_empty() {
|
if !function_name.is_empty() {
|
||||||
let arguments: Value = if function_arguments.is_empty() {
|
let arguments: Value = if function_arguments.is_empty() {
|
||||||
@@ -251,6 +268,7 @@ pub fn claude_build_chat_completions_body(
|
|||||||
mut messages,
|
mut messages,
|
||||||
temperature,
|
temperature,
|
||||||
top_p,
|
top_p,
|
||||||
|
reasoning_effort,
|
||||||
functions,
|
functions,
|
||||||
stream,
|
stream,
|
||||||
} = data;
|
} = data;
|
||||||
@@ -312,13 +330,25 @@ pub fn claude_build_chat_completions_body(
|
|||||||
}) => {
|
}) => {
|
||||||
let mut assistant_parts = vec![];
|
let mut assistant_parts = vec![];
|
||||||
let mut user_parts = vec![];
|
let mut user_parts = vec![];
|
||||||
if !text.is_empty() {
|
for (index, tool_result) in tool_results.iter().enumerate() {
|
||||||
assistant_parts.push(json!({
|
for block in &tool_result.thinking {
|
||||||
"type": "text",
|
assistant_parts.push(json!(block));
|
||||||
"text": text,
|
}
|
||||||
}))
|
let round_text = if index == 0 && !text.is_empty() {
|
||||||
}
|
Some(text.as_str())
|
||||||
for tool_result in tool_results {
|
} else {
|
||||||
|
tool_result.text.as_deref()
|
||||||
|
};
|
||||||
|
if let Some(round_text) = round_text {
|
||||||
|
let round_text = strip_think_tag(round_text);
|
||||||
|
let round_text = round_text.trim();
|
||||||
|
if !round_text.is_empty() {
|
||||||
|
assistant_parts.push(json!({
|
||||||
|
"type": "text",
|
||||||
|
"text": round_text,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
assistant_parts.push(json!({
|
assistant_parts.push(json!({
|
||||||
"type": "tool_use",
|
"type": "tool_use",
|
||||||
"id": tool_result.call.id,
|
"id": tool_result.call.id,
|
||||||
@@ -369,6 +399,9 @@ pub fn claude_build_chat_completions_body(
|
|||||||
if let Some(v) = top_p {
|
if let Some(v) = top_p {
|
||||||
body["top_p"] = v.into();
|
body["top_p"] = v.into();
|
||||||
}
|
}
|
||||||
|
if let Some(v) = reasoning_effort {
|
||||||
|
body["output_config"] = json!({ "effort": v });
|
||||||
|
}
|
||||||
if stream {
|
if stream {
|
||||||
body["stream"] = true.into();
|
body["stream"] = true.into();
|
||||||
}
|
}
|
||||||
@@ -399,12 +432,24 @@ pub fn claude_extract_chat_completions(data: &Value) -> Result<ChatCompletionsOu
|
|||||||
let mut text = String::new();
|
let mut text = String::new();
|
||||||
let mut reasoning = None;
|
let mut reasoning = None;
|
||||||
let mut tool_calls = vec![];
|
let mut tool_calls = vec![];
|
||||||
|
let mut thinking = vec![];
|
||||||
if let Some(list) = data["content"].as_array() {
|
if let Some(list) = data["content"].as_array() {
|
||||||
for item in list {
|
for item in list {
|
||||||
match item["type"].as_str() {
|
match item["type"].as_str() {
|
||||||
Some("thinking") => {
|
Some("thinking") => {
|
||||||
if let Some(v) = item["thinking"].as_str() {
|
if let Some(v) = item["thinking"].as_str() {
|
||||||
reasoning = Some(v.to_string());
|
reasoning = Some(v.to_string());
|
||||||
|
thinking.push(ThinkingBlock::Thinking {
|
||||||
|
thinking: v.to_string(),
|
||||||
|
signature: item["signature"].as_str().unwrap_or_default().to_string(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Some("redacted_thinking") => {
|
||||||
|
if let Some(v) = item["data"].as_str() {
|
||||||
|
thinking.push(ThinkingBlock::RedactedThinking {
|
||||||
|
data: v.to_string(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some("text") => {
|
Some("text") => {
|
||||||
@@ -443,6 +488,7 @@ pub fn claude_extract_chat_completions(data: &Value) -> Result<ChatCompletionsOu
|
|||||||
let output = ChatCompletionsOutput {
|
let output = ChatCompletionsOutput {
|
||||||
text: text.to_string(),
|
text: text.to_string(),
|
||||||
tool_calls,
|
tool_calls,
|
||||||
|
thinking,
|
||||||
};
|
};
|
||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ impl OAuthProvider for ClaudeOAuthProvider {
|
|||||||
"https://console.anthropic.com/oauth/code/callback"
|
"https://console.anthropic.com/oauth/code/callback"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scopes(&self) -> &str {
|
fn scopes(&self) -> String {
|
||||||
"org:create_api_key user:profile user:inference"
|
"org:create_api_key user:profile user:inference".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extra_authorize_params(&self) -> Vec<(&str, &str)> {
|
fn extra_authorize_params(&self) -> Vec<(&str, &str)> {
|
||||||
|
|||||||
@@ -244,6 +244,6 @@ fn extract_chat_completions(data: &Value) -> Result<ChatCompletionsOutput> {
|
|||||||
if text.is_empty() && tool_calls.is_empty() {
|
if text.is_empty() && tool_calls.is_empty() {
|
||||||
bail!("Invalid response data: {data}");
|
bail!("Invalid response data: {data}");
|
||||||
}
|
}
|
||||||
let output = ChatCompletionsOutput { text, tool_calls };
|
let output = ChatCompletionsOutput { text, tool_calls, ..Default::default() };
|
||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|||||||
+59
-9
@@ -286,6 +286,7 @@ pub struct ChatCompletionsData {
|
|||||||
pub messages: Vec<Message>,
|
pub messages: Vec<Message>,
|
||||||
pub temperature: Option<f64>,
|
pub temperature: Option<f64>,
|
||||||
pub top_p: Option<f64>,
|
pub top_p: Option<f64>,
|
||||||
|
pub reasoning_effort: Option<String>,
|
||||||
pub functions: Option<Vec<FunctionDeclaration>>,
|
pub functions: Option<Vec<FunctionDeclaration>>,
|
||||||
pub stream: bool,
|
pub stream: bool,
|
||||||
}
|
}
|
||||||
@@ -294,6 +295,7 @@ pub struct ChatCompletionsData {
|
|||||||
pub struct ChatCompletionsOutput {
|
pub struct ChatCompletionsOutput {
|
||||||
pub text: String,
|
pub text: String,
|
||||||
pub tool_calls: Vec<ToolCall>,
|
pub tool_calls: Vec<ToolCall>,
|
||||||
|
pub thinking: Vec<ThinkingBlock>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChatCompletionsOutput {
|
impl ChatCompletionsOutput {
|
||||||
@@ -401,9 +403,24 @@ pub async fn create_openai_compatible_client_config(
|
|||||||
};
|
};
|
||||||
config["api_base"] = api_base.into();
|
config["api_base"] = api_base.into();
|
||||||
|
|
||||||
let api_key = prompt_input_string("API Key", false, None)?;
|
let has_bundled_oauth = ALL_PROVIDER_MODELS
|
||||||
if !api_key.is_empty() {
|
.iter()
|
||||||
config["api_key"] = api_key.into();
|
.any(|p| p.provider == client && p.oauth.is_some());
|
||||||
|
|
||||||
|
let use_oauth = if has_bundled_oauth {
|
||||||
|
let choice = Select::new("Authentication method:", vec!["API Key", "OAuth"]).prompt()?;
|
||||||
|
choice == "OAuth"
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
|
||||||
|
if use_oauth {
|
||||||
|
config["auth"] = "oauth".into();
|
||||||
|
} else {
|
||||||
|
let api_key = prompt_input_string("API Key", false, None)?;
|
||||||
|
if !api_key.is_empty() {
|
||||||
|
config["api_key"] = api_key.into();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let model = set_client_models_config(&mut config, &name).await?;
|
let model = set_client_models_config(&mut config, &name).await?;
|
||||||
@@ -434,6 +451,7 @@ pub async fn call_chat_completions(
|
|||||||
let ChatCompletionsOutput {
|
let ChatCompletionsOutput {
|
||||||
mut text,
|
mut text,
|
||||||
tool_calls,
|
tool_calls,
|
||||||
|
thinking,
|
||||||
..
|
..
|
||||||
} = ret;
|
} = ret;
|
||||||
if !text.is_empty() {
|
if !text.is_empty() {
|
||||||
@@ -444,7 +462,10 @@ pub async fn call_chat_completions(
|
|||||||
ctx.app.config.print_markdown(&text)?;
|
ctx.app.config.print_markdown(&text)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let tool_results = eval_tool_calls(ctx, tool_calls).await?;
|
let mut tool_results = eval_tool_calls(ctx, tool_calls).await?;
|
||||||
|
if let Some(first) = tool_results.first_mut() {
|
||||||
|
first.thinking = thinking;
|
||||||
|
}
|
||||||
tool_results
|
tool_results
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|res| ctx.tool_scope.tool_tracker.record_call(res.call.clone()));
|
.for_each(|res| ctx.tool_scope.tool_tracker.record_call(res.call.clone()));
|
||||||
@@ -472,26 +493,55 @@ pub async fn call_chat_completions_streaming(
|
|||||||
render_stream(rx, client.app_config(), abort_signal.clone(), silent),
|
render_stream(rx, client.app_config(), abort_signal.clone(), silent),
|
||||||
);
|
);
|
||||||
|
|
||||||
if handler.abort().aborted() {
|
let aborted_ctrlc = handler.abort().aborted_ctrlc();
|
||||||
|
let aborted_ctrld = handler.abort().aborted_ctrld();
|
||||||
|
|
||||||
|
if aborted_ctrld {
|
||||||
bail!("Aborted.");
|
bail!("Aborted.");
|
||||||
}
|
}
|
||||||
|
|
||||||
render_ret?;
|
render_ret?;
|
||||||
|
|
||||||
let (text, tool_calls) = handler.take();
|
let (text, tool_calls, thinking) = handler.take();
|
||||||
|
|
||||||
|
if aborted_ctrlc {
|
||||||
|
if !ctx.working_mode.is_repl() || ctx.session.is_none() {
|
||||||
|
bail!("Aborted.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if text.is_empty() {
|
||||||
|
if !silent && *IS_STDOUT_TERMINAL {
|
||||||
|
println!();
|
||||||
|
eprintln!("{}", error_text("Response interrupted"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(("".to_string(), vec![]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if !silent && *IS_STDOUT_TERMINAL {
|
||||||
|
println!();
|
||||||
|
eprintln!("{}", error_text("Response interrupted"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok((text, vec![]));
|
||||||
|
}
|
||||||
|
|
||||||
match send_ret {
|
match send_ret {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
if !text.is_empty() && !text.ends_with('\n') {
|
if !silent && !text.is_empty() && !text.ends_with('\n') {
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
let tool_results = eval_tool_calls(ctx, tool_calls).await?;
|
let mut tool_results = eval_tool_calls(ctx, tool_calls).await?;
|
||||||
|
if let Some(first) = tool_results.first_mut() {
|
||||||
|
first.thinking = thinking;
|
||||||
|
}
|
||||||
tool_results
|
tool_results
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|res| ctx.tool_scope.tool_tracker.record_call(res.call.clone()));
|
.for_each(|res| ctx.tool_scope.tool_tracker.record_call(res.call.clone()));
|
||||||
Ok((text, tool_results))
|
Ok((text, tool_results))
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if !text.is_empty() {
|
if !silent && !text.is_empty() {
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
Err(err)
|
Err(err)
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ impl OAuthProvider for GeminiOAuthProvider {
|
|||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scopes(&self) -> &str {
|
fn scopes(&self) -> String {
|
||||||
"https://www.googleapis.com/auth/generative-language.peruserquota https://www.googleapis.com/auth/generative-language.retriever https://www.googleapis.com/auth/userinfo.email"
|
"https://www.googleapis.com/auth/generative-language.peruserquota https://www.googleapis.com/auth/generative-language.retriever https://www.googleapis.com/auth/userinfo.email".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn client_secret(&self) -> Option<&str> {
|
fn client_secret(&self) -> Option<&str> {
|
||||||
|
|||||||
+20
-2
@@ -118,6 +118,9 @@ impl MessageContent {
|
|||||||
lines.push(text.clone())
|
lines.push(text.clone())
|
||||||
}
|
}
|
||||||
for tool_result in tool_results {
|
for tool_result in tool_results {
|
||||||
|
if let Some(round_text) = &tool_result.text {
|
||||||
|
lines.push(round_text.clone())
|
||||||
|
}
|
||||||
let mut parts = vec!["Call".to_string()];
|
let mut parts = vec!["Call".to_string()];
|
||||||
if let Some((agent_name, functions)) = agent_info
|
if let Some((agent_name, functions)) = agent_info
|
||||||
&& functions.contains(&tool_result.call.name)
|
&& functions.contains(&tool_result.call.name)
|
||||||
@@ -185,6 +188,17 @@ pub struct ImageUrl {
|
|||||||
pub url: String,
|
pub url: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An extended-thinking block returned by Anthropic-protocol models.
|
||||||
|
/// Serialized to match the API wire format (`type: thinking` / `type: redacted_thinking`)
|
||||||
|
/// so blocks can be replayed verbatim, signature intact, in subsequent
|
||||||
|
/// tool-loop rounds as the API requires.
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
#[serde(tag = "type", rename_all = "snake_case")]
|
||||||
|
pub enum ThinkingBlock {
|
||||||
|
Thinking { thinking: String, signature: String },
|
||||||
|
RedactedThinking { data: String },
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct MessageContentToolCalls {
|
pub struct MessageContentToolCalls {
|
||||||
pub tool_results: Vec<ToolResult>,
|
pub tool_results: Vec<ToolResult>,
|
||||||
@@ -201,9 +215,13 @@ impl MessageContentToolCalls {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn merge(&mut self, tool_results: Vec<ToolResult>, _text: String) {
|
pub fn merge(&mut self, mut tool_results: Vec<ToolResult>, text: String) {
|
||||||
|
if !text.is_empty()
|
||||||
|
&& let Some(first) = tool_results.first_mut()
|
||||||
|
{
|
||||||
|
first.text = Some(text);
|
||||||
|
}
|
||||||
self.tool_results.extend(tool_results);
|
self.tool_results.extend(tool_results);
|
||||||
self.text.clear();
|
|
||||||
self.sequence = true;
|
self.sequence = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ mod common;
|
|||||||
mod gemini_oauth;
|
mod gemini_oauth;
|
||||||
mod message;
|
mod message;
|
||||||
pub mod oauth;
|
pub mod oauth;
|
||||||
|
mod openai_compatible_oauth;
|
||||||
mod openai_oauth;
|
mod openai_oauth;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
mod macros;
|
||||||
@@ -37,6 +38,15 @@ register_client!(
|
|||||||
(bedrock, "bedrock", BedrockConfig, BedrockClient),
|
(bedrock, "bedrock", BedrockConfig, BedrockClient),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
pub fn client_type_supports_oauth(type_str: &str) -> bool {
|
||||||
|
matches!(
|
||||||
|
type_str,
|
||||||
|
ClaudeClient::NAME | OpenAIClient::NAME | GeminiClient::NAME
|
||||||
|
) || ALL_PROVIDER_MODELS
|
||||||
|
.iter()
|
||||||
|
.any(|pm| pm.provider == type_str && pm.oauth.is_some())
|
||||||
|
}
|
||||||
|
|
||||||
pub const OPENAI_COMPATIBLE_PROVIDERS: [(&str, &str); 18] = [
|
pub const OPENAI_COMPATIBLE_PROVIDERS: [(&str, &str); 18] = [
|
||||||
("ai21", "https://api.ai21.com/studio/v1"),
|
("ai21", "https://api.ai21.com/studio/v1"),
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use super::{
|
|||||||
use crate::config::AppConfig;
|
use crate::config::AppConfig;
|
||||||
use crate::utils::{estimate_token_length, strip_think_tag};
|
use crate::utils::{estimate_token_length, strip_think_tag};
|
||||||
|
|
||||||
|
use super::oauth::OAuthConfig;
|
||||||
use anyhow::{Result, bail};
|
use anyhow::{Result, bail};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
@@ -289,6 +290,14 @@ impl Model {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn reasoning_levels(&self) -> &[String] {
|
||||||
|
&self.data.reasoning_levels
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn default_reasoning_effort(&self) -> Option<&str> {
|
||||||
|
self.data.default_reasoning_effort.as_deref()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||||
@@ -316,6 +325,10 @@ pub struct ModelData {
|
|||||||
pub supports_vision: bool,
|
pub supports_vision: bool,
|
||||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||||
pub supports_function_calling: bool,
|
pub supports_function_calling: bool,
|
||||||
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
|
pub reasoning_levels: Vec<String>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub default_reasoning_effort: Option<String>,
|
||||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||||
no_stream: bool,
|
no_stream: bool,
|
||||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||||
@@ -345,6 +358,8 @@ impl ModelData {
|
|||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct ProviderModels {
|
pub struct ProviderModels {
|
||||||
pub provider: String,
|
pub provider: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub oauth: Option<OAuthConfig>,
|
||||||
pub models: Vec<ModelData>,
|
pub models: Vec<ModelData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+993
-75
File diff suppressed because it is too large
Load Diff
+67
-35
@@ -356,6 +356,7 @@ pub fn openai_build_chat_completions_body(data: ChatCompletionsData, model: &Mod
|
|||||||
messages,
|
messages,
|
||||||
temperature,
|
temperature,
|
||||||
top_p,
|
top_p,
|
||||||
|
reasoning_effort,
|
||||||
functions,
|
functions,
|
||||||
stream,
|
stream,
|
||||||
} = data;
|
} = data;
|
||||||
@@ -369,7 +370,7 @@ pub fn openai_build_chat_completions_body(data: ChatCompletionsData, model: &Mod
|
|||||||
match content {
|
match content {
|
||||||
MessageContent::ToolCalls(MessageContentToolCalls {
|
MessageContent::ToolCalls(MessageContentToolCalls {
|
||||||
tool_results,
|
tool_results,
|
||||||
text: _,
|
text,
|
||||||
sequence,
|
sequence,
|
||||||
}) => {
|
}) => {
|
||||||
if !sequence {
|
if !sequence {
|
||||||
@@ -386,9 +387,12 @@ pub fn openai_build_chat_completions_body(data: ChatCompletionsData, model: &Mod
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let mut messages = vec![
|
let mut assistant_message =
|
||||||
json!({ "role": MessageRole::Assistant, "tool_calls": tool_calls }),
|
json!({ "role": MessageRole::Assistant, "tool_calls": tool_calls });
|
||||||
];
|
if !text.is_empty() {
|
||||||
|
assistant_message["content"] = strip_think_tag(&text).into();
|
||||||
|
}
|
||||||
|
let mut messages = vec![assistant_message];
|
||||||
for tool_result in tool_results {
|
for tool_result in tool_results {
|
||||||
messages.push(json!({
|
messages.push(json!({
|
||||||
"role": "tool",
|
"role": "tool",
|
||||||
@@ -398,21 +402,30 @@ pub fn openai_build_chat_completions_body(data: ChatCompletionsData, model: &Mod
|
|||||||
}
|
}
|
||||||
messages
|
messages
|
||||||
} else {
|
} else {
|
||||||
tool_results.into_iter().flat_map(|tool_result| {
|
tool_results.into_iter().enumerate().flat_map(|(index, tool_result)| {
|
||||||
|
let round_text = if index == 0 && !text.is_empty() {
|
||||||
|
Some(text.clone())
|
||||||
|
} else {
|
||||||
|
tool_result.text.clone()
|
||||||
|
};
|
||||||
|
let mut assistant_message = json!({
|
||||||
|
"role": MessageRole::Assistant,
|
||||||
|
"tool_calls": [
|
||||||
|
{
|
||||||
|
"id": tool_result.call.id,
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
|
"name": tool_result.call.name,
|
||||||
|
"arguments": tool_result.call.arguments.to_string(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
if let Some(round_text) = round_text {
|
||||||
|
assistant_message["content"] = strip_think_tag(&round_text).into();
|
||||||
|
}
|
||||||
vec![
|
vec![
|
||||||
json!({
|
assistant_message,
|
||||||
"role": MessageRole::Assistant,
|
|
||||||
"tool_calls": [
|
|
||||||
{
|
|
||||||
"id": tool_result.call.id,
|
|
||||||
"type": "function",
|
|
||||||
"function": {
|
|
||||||
"name": tool_result.call.name,
|
|
||||||
"arguments": tool_result.call.arguments.to_string(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}),
|
|
||||||
json!({
|
json!({
|
||||||
"role": "tool",
|
"role": "tool",
|
||||||
"content": tool_result.output.to_string(),
|
"content": tool_result.output.to_string(),
|
||||||
@@ -454,6 +467,9 @@ pub fn openai_build_chat_completions_body(data: ChatCompletionsData, model: &Mod
|
|||||||
if let Some(v) = top_p {
|
if let Some(v) = top_p {
|
||||||
body["top_p"] = v.into();
|
body["top_p"] = v.into();
|
||||||
}
|
}
|
||||||
|
if let Some(v) = reasoning_effort {
|
||||||
|
body["reasoning_effort"] = v.into();
|
||||||
|
}
|
||||||
if stream {
|
if stream {
|
||||||
body["stream"] = true.into();
|
body["stream"] = true.into();
|
||||||
}
|
}
|
||||||
@@ -517,7 +533,7 @@ pub fn openai_extract_chat_completions(data: &Value) -> Result<ChatCompletionsOu
|
|||||||
} else {
|
} else {
|
||||||
text.to_string()
|
text.to_string()
|
||||||
};
|
};
|
||||||
let output = ChatCompletionsOutput { text, tool_calls };
|
let output = ChatCompletionsOutput { text, tool_calls, ..Default::default() };
|
||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -534,6 +550,7 @@ pub fn openai_build_responses_body(data: ChatCompletionsData, model: &Model) ->
|
|||||||
messages,
|
messages,
|
||||||
temperature,
|
temperature,
|
||||||
top_p,
|
top_p,
|
||||||
|
reasoning_effort,
|
||||||
functions,
|
functions,
|
||||||
stream,
|
stream,
|
||||||
} = data;
|
} = data;
|
||||||
@@ -547,24 +564,36 @@ pub fn openai_build_responses_body(data: ChatCompletionsData, model: &Model) ->
|
|||||||
match content {
|
match content {
|
||||||
MessageContent::ToolCalls(MessageContentToolCalls {
|
MessageContent::ToolCalls(MessageContentToolCalls {
|
||||||
tool_results,
|
tool_results,
|
||||||
text: _,
|
text,
|
||||||
sequence: _,
|
sequence: _,
|
||||||
}) => tool_results
|
}) => tool_results
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flat_map(|tool_result| {
|
.enumerate()
|
||||||
vec![
|
.flat_map(|(index, tool_result)| {
|
||||||
json!({
|
let round_text = if index == 0 && !text.is_empty() {
|
||||||
"type": "function_call",
|
Some(text.clone())
|
||||||
"call_id": tool_result.call.id,
|
} else {
|
||||||
"name": tool_result.call.name,
|
tool_result.text.clone()
|
||||||
"arguments": tool_result.call.arguments.to_string(),
|
};
|
||||||
}),
|
let mut items = vec![];
|
||||||
json!({
|
if let Some(round_text) = round_text {
|
||||||
"type": "function_call_output",
|
items.push(json!({
|
||||||
"call_id": tool_result.call.id,
|
"role": MessageRole::Assistant,
|
||||||
"output": tool_result.output.to_string(),
|
"content": strip_think_tag(&round_text),
|
||||||
}),
|
}));
|
||||||
]
|
}
|
||||||
|
items.push(json!({
|
||||||
|
"type": "function_call",
|
||||||
|
"call_id": tool_result.call.id,
|
||||||
|
"name": tool_result.call.name,
|
||||||
|
"arguments": tool_result.call.arguments.to_string(),
|
||||||
|
}));
|
||||||
|
items.push(json!({
|
||||||
|
"type": "function_call_output",
|
||||||
|
"call_id": tool_result.call.id,
|
||||||
|
"output": tool_result.output.to_string(),
|
||||||
|
}));
|
||||||
|
items
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
MessageContent::Text(text) if role.is_assistant() && i != messages_len - 1 => {
|
MessageContent::Text(text) if role.is_assistant() && i != messages_len - 1 => {
|
||||||
@@ -590,6 +619,9 @@ pub fn openai_build_responses_body(data: ChatCompletionsData, model: &Model) ->
|
|||||||
if let Some(v) = top_p {
|
if let Some(v) = top_p {
|
||||||
body["top_p"] = v.into();
|
body["top_p"] = v.into();
|
||||||
}
|
}
|
||||||
|
if let Some(v) = reasoning_effort {
|
||||||
|
body["reasoning"] = json!({ "effort": v });
|
||||||
|
}
|
||||||
if stream {
|
if stream {
|
||||||
body["stream"] = true.into();
|
body["stream"] = true.into();
|
||||||
}
|
}
|
||||||
@@ -664,7 +696,7 @@ pub fn openai_extract_responses(data: &Value) -> Result<ChatCompletionsOutput> {
|
|||||||
if text.is_empty() && tool_calls.is_empty() {
|
if text.is_empty() && tool_calls.is_empty() {
|
||||||
bail!("Invalid response data: {data}");
|
bail!("Invalid response data: {data}");
|
||||||
}
|
}
|
||||||
Ok(ChatCompletionsOutput { text, tool_calls })
|
Ok(ChatCompletionsOutput { text, tool_calls, ..Default::default() })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn openai_responses_streaming(
|
pub async fn openai_responses_streaming(
|
||||||
|
|||||||
+126
-40
@@ -1,16 +1,21 @@
|
|||||||
|
use super::access_token::get_access_token;
|
||||||
|
use super::oauth;
|
||||||
use super::openai::*;
|
use super::openai::*;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result, anyhow, bail};
|
||||||
use reqwest::RequestBuilder;
|
use reqwest::{Client as ReqwestClient, RequestBuilder};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::{Value, json};
|
use serde_json::{Value, json};
|
||||||
|
use oauth::OAuthConfig;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct OpenAICompatibleConfig {
|
pub struct OpenAICompatibleConfig {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub api_base: Option<String>,
|
pub api_base: Option<String>,
|
||||||
pub api_key: Option<String>,
|
pub api_key: Option<String>,
|
||||||
|
pub auth: Option<String>,
|
||||||
|
pub oauth: Option<Box<OAuthConfig>>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub models: Vec<ModelData>,
|
pub models: Vec<ModelData>,
|
||||||
pub patch: Option<RequestPatch>,
|
pub patch: Option<RequestPatch>,
|
||||||
@@ -24,76 +29,157 @@ impl OpenAICompatibleClient {
|
|||||||
create_client_config!([]);
|
create_client_config!([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_client_trait!(
|
#[async_trait::async_trait]
|
||||||
OpenAICompatibleClient,
|
impl Client for OpenAICompatibleClient {
|
||||||
(
|
client_common_fns!();
|
||||||
prepare_chat_completions,
|
|
||||||
openai_chat_completions,
|
|
||||||
openai_chat_completions_streaming
|
|
||||||
),
|
|
||||||
(prepare_embeddings, openai_embeddings),
|
|
||||||
(prepare_rerank, generic_rerank),
|
|
||||||
);
|
|
||||||
|
|
||||||
fn prepare_chat_completions(
|
fn supports_oauth(&self) -> bool {
|
||||||
|
self.config.auth.as_deref() == Some("oauth")
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn chat_completions_inner(
|
||||||
|
&self,
|
||||||
|
client: &ReqwestClient,
|
||||||
|
data: ChatCompletionsData,
|
||||||
|
) -> Result<ChatCompletionsOutput> {
|
||||||
|
let request_data = prepare_chat_completions(self, client, data).await?;
|
||||||
|
let builder = self.request_builder(client, request_data);
|
||||||
|
|
||||||
|
openai_chat_completions(builder, self.model()).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn chat_completions_streaming_inner(
|
||||||
|
&self,
|
||||||
|
client: &ReqwestClient,
|
||||||
|
handler: &mut SseHandler,
|
||||||
|
data: ChatCompletionsData,
|
||||||
|
) -> Result<()> {
|
||||||
|
let request_data = prepare_chat_completions(self, client, data).await?;
|
||||||
|
let builder = self.request_builder(client, request_data);
|
||||||
|
|
||||||
|
openai_chat_completions_streaming(builder, handler, self.model()).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn embeddings_inner(
|
||||||
|
&self,
|
||||||
|
client: &ReqwestClient,
|
||||||
|
data: &EmbeddingsData,
|
||||||
|
) -> Result<EmbeddingsOutput> {
|
||||||
|
let request_data = prepare_embeddings(self, client, data).await?;
|
||||||
|
let builder = self.request_builder(client, request_data);
|
||||||
|
|
||||||
|
openai_embeddings(builder, self.model()).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn rerank_inner(
|
||||||
|
&self,
|
||||||
|
client: &ReqwestClient,
|
||||||
|
data: &RerankData,
|
||||||
|
) -> Result<RerankOutput> {
|
||||||
|
let request_data = prepare_rerank(self, client, data).await?;
|
||||||
|
let builder = self.request_builder(client, request_data);
|
||||||
|
|
||||||
|
generic_rerank(builder, self.model()).await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn prepare_chat_completions(
|
||||||
self_: &OpenAICompatibleClient,
|
self_: &OpenAICompatibleClient,
|
||||||
|
client: &ReqwestClient,
|
||||||
data: ChatCompletionsData,
|
data: ChatCompletionsData,
|
||||||
) -> Result<RequestData> {
|
) -> Result<RequestData> {
|
||||||
let api_key = self_.get_api_key().ok();
|
|
||||||
let api_base = get_api_base_ext(self_)?;
|
let api_base = get_api_base_ext(self_)?;
|
||||||
|
|
||||||
let url = format!("{api_base}/chat/completions");
|
let url = format!("{api_base}/chat/completions");
|
||||||
|
|
||||||
let body = openai_build_chat_completions_body(data, &self_.model);
|
let body = openai_build_chat_completions_body(data, &self_.model);
|
||||||
|
|
||||||
let mut request_data = RequestData::new(url, body);
|
let mut request_data = RequestData::new(url, body);
|
||||||
|
|
||||||
if let Some(api_key) = api_key {
|
apply_auth(self_, client, &mut request_data).await?;
|
||||||
request_data.bearer_auth(api_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(request_data)
|
Ok(request_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_embeddings(
|
async fn prepare_embeddings(
|
||||||
self_: &OpenAICompatibleClient,
|
self_: &OpenAICompatibleClient,
|
||||||
|
client: &ReqwestClient,
|
||||||
data: &EmbeddingsData,
|
data: &EmbeddingsData,
|
||||||
) -> Result<RequestData> {
|
) -> Result<RequestData> {
|
||||||
let api_key = self_.get_api_key().ok();
|
|
||||||
let api_base = get_api_base_ext(self_)?;
|
let api_base = get_api_base_ext(self_)?;
|
||||||
|
|
||||||
let url = format!("{api_base}/embeddings");
|
let url = format!("{api_base}/embeddings");
|
||||||
|
|
||||||
let body = openai_build_embeddings_body(data, &self_.model);
|
let body = openai_build_embeddings_body(data, &self_.model);
|
||||||
|
|
||||||
let mut request_data = RequestData::new(url, body);
|
let mut request_data = RequestData::new(url, body);
|
||||||
|
|
||||||
if let Some(api_key) = api_key {
|
apply_auth(self_, client, &mut request_data).await?;
|
||||||
request_data.bearer_auth(api_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(request_data)
|
Ok(request_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_rerank(self_: &OpenAICompatibleClient, data: &RerankData) -> Result<RequestData> {
|
async fn prepare_rerank(
|
||||||
let api_key = self_.get_api_key().ok();
|
self_: &OpenAICompatibleClient,
|
||||||
|
client: &ReqwestClient,
|
||||||
|
data: &RerankData,
|
||||||
|
) -> Result<RequestData> {
|
||||||
let api_base = get_api_base_ext(self_)?;
|
let api_base = get_api_base_ext(self_)?;
|
||||||
|
|
||||||
let url = if self_.name().starts_with("ernie") {
|
let url = if self_.name().starts_with("ernie") {
|
||||||
format!("{api_base}/rerankers")
|
format!("{api_base}/rerankers")
|
||||||
} else {
|
} else {
|
||||||
format!("{api_base}/rerank")
|
format!("{api_base}/rerank")
|
||||||
};
|
};
|
||||||
|
|
||||||
let body = generic_build_rerank_body(data, &self_.model);
|
let body = generic_build_rerank_body(data, &self_.model);
|
||||||
|
|
||||||
let mut request_data = RequestData::new(url, body);
|
let mut request_data = RequestData::new(url, body);
|
||||||
|
|
||||||
|
apply_auth(self_, client, &mut request_data).await?;
|
||||||
|
|
||||||
|
Ok(request_data)
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(api_key) = api_key {
|
async fn apply_auth(
|
||||||
|
self_: &OpenAICompatibleClient,
|
||||||
|
client: &ReqwestClient,
|
||||||
|
request_data: &mut RequestData,
|
||||||
|
) -> Result<()> {
|
||||||
|
if self_.config.auth.as_deref() == Some("oauth") {
|
||||||
|
let client_name = self_.name();
|
||||||
|
let app_config = self_.app_config();
|
||||||
|
let cc = app_config
|
||||||
|
.clients
|
||||||
|
.iter()
|
||||||
|
.find(|cc| {
|
||||||
|
matches!(
|
||||||
|
cc,
|
||||||
|
ClientConfig::OpenAICompatibleConfig(c)
|
||||||
|
if c.name.as_deref().unwrap_or("openai-compatible") == client_name
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.ok_or_else(|| {
|
||||||
|
anyhow!("Could not locate ClientConfig entry for '{}'", client_name)
|
||||||
|
})?;
|
||||||
|
let provider = oauth::get_oauth_provider_for_client(cc, &ALL_PROVIDER_MODELS)
|
||||||
|
.ok_or_else(|| {
|
||||||
|
anyhow!(
|
||||||
|
"OAuth configured for '{}' but no oauth block resolved (missing from both models.yaml and user config)",
|
||||||
|
client_name
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ready = oauth::prepare_oauth_access_token(client, &*provider, client_name).await?;
|
||||||
|
if !ready {
|
||||||
|
bail!(
|
||||||
|
"OAuth configured for '{}' but no tokens found. Run: 'coyote --authenticate {}' or '.authenticate' in the REPL",
|
||||||
|
client_name,
|
||||||
|
client_name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let token = get_access_token(client_name)?;
|
||||||
|
request_data.bearer_auth(token);
|
||||||
|
|
||||||
|
for (key, value) in provider.extra_request_headers() {
|
||||||
|
request_data.header(key, value);
|
||||||
|
}
|
||||||
|
} else if let Ok(api_key) = self_.get_api_key() {
|
||||||
request_data.bearer_auth(api_key);
|
request_data.bearer_auth(api_key);
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
Ok(request_data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_api_base_ext(self_: &OpenAICompatibleClient) -> Result<String> {
|
fn get_api_base_ext(self_: &OpenAICompatibleClient) -> Result<String> {
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
use url::Url;
|
||||||
|
|
||||||
|
use super::oauth::{OAuthConfig, OAuthFlow, OAuthProvider, TokenRequestFormat};
|
||||||
|
|
||||||
|
pub struct OpenAICompatibleOAuthProvider {
|
||||||
|
pub config: OAuthConfig,
|
||||||
|
pub client_name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_loopback_uri(uri: &str) -> bool {
|
||||||
|
Url::parse(uri)
|
||||||
|
.ok()
|
||||||
|
.and_then(|u| u.host_str().map(str::to_string))
|
||||||
|
.is_some_and(|host| matches!(host.as_str(), "127.0.0.1" | "localhost" | "[::1]" | "::1"))
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OAuthProvider for OpenAICompatibleOAuthProvider {
|
||||||
|
fn provider_name(&self) -> &str {
|
||||||
|
&self.client_name
|
||||||
|
}
|
||||||
|
|
||||||
|
fn client_id(&self) -> &str {
|
||||||
|
&self.config.client_id
|
||||||
|
}
|
||||||
|
|
||||||
|
fn authorize_url(&self) -> &str {
|
||||||
|
self.config.authorize_url.as_deref().unwrap_or("")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn token_url(&self) -> &str {
|
||||||
|
&self.config.token_url
|
||||||
|
}
|
||||||
|
|
||||||
|
fn redirect_uri(&self) -> &str {
|
||||||
|
self.config.redirect_uri.as_deref().unwrap_or("")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn scopes(&self) -> String {
|
||||||
|
self.config.scopes.join(" ")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn client_secret(&self) -> Option<&str> {
|
||||||
|
self.config.client_secret.as_deref()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extra_authorize_params(&self) -> Vec<(&str, &str)> {
|
||||||
|
self.config
|
||||||
|
.extra_authorize_params
|
||||||
|
.iter()
|
||||||
|
.map(|(k, v)| (k.as_str(), v.as_str()))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn token_request_format(&self) -> TokenRequestFormat {
|
||||||
|
self.config
|
||||||
|
.token_request_format
|
||||||
|
.unwrap_or(TokenRequestFormat::FormUrlEncoded)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn uses_localhost_redirect(&self) -> bool {
|
||||||
|
self.config.redirect_uri.is_none() && self.config.redirect_port.is_none()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extra_token_headers(&self) -> Vec<(&str, &str)> {
|
||||||
|
self.config
|
||||||
|
.extra_token_headers
|
||||||
|
.iter()
|
||||||
|
.map(|(k, v)| (k.as_str(), v.as_str()))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extra_request_headers(&self) -> Vec<(&str, &str)> {
|
||||||
|
self.config
|
||||||
|
.extra_request_headers
|
||||||
|
.iter()
|
||||||
|
.map(|(k, v)| (k.as_str(), v.as_str()))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fixed_redirect_uri(&self) -> Option<String> {
|
||||||
|
if let Some(uri) = &self.config.redirect_uri {
|
||||||
|
return if is_loopback_uri(uri) {
|
||||||
|
Some(uri.clone())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if let Some(port) = self.config.redirect_port {
|
||||||
|
return Some(format!("http://127.0.0.1:{port}/callback"));
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn include_state_in_token_exchange(&self) -> bool {
|
||||||
|
self.config.include_state_in_token_exchange
|
||||||
|
}
|
||||||
|
|
||||||
|
fn flow(&self) -> OAuthFlow {
|
||||||
|
self.config.flow
|
||||||
|
}
|
||||||
|
|
||||||
|
fn echo_pkce_in_token_exchange(&self) -> bool {
|
||||||
|
self.config.echo_pkce_in_token_exchange
|
||||||
|
}
|
||||||
|
|
||||||
|
fn device_authorization_url(&self) -> Option<&str> {
|
||||||
|
self.config.device_authorization_url.as_deref()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn use_pkce_in_device_flow(&self) -> bool {
|
||||||
|
self.config.use_pkce_in_device_flow
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,8 +26,8 @@ impl OAuthProvider for OpenAIOAuthProvider {
|
|||||||
"http://localhost:1455/auth/callback"
|
"http://localhost:1455/auth/callback"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scopes(&self) -> &str {
|
fn scopes(&self) -> String {
|
||||||
"openid profile email offline_access"
|
"openid profile email offline_access".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn token_request_format(&self) -> TokenRequestFormat {
|
fn token_request_format(&self) -> TokenRequestFormat {
|
||||||
|
|||||||
+13
-4
@@ -1,4 +1,4 @@
|
|||||||
use super::{ToolCall, catch_error};
|
use super::{ThinkingBlock, ToolCall, catch_error};
|
||||||
use crate::utils::AbortSignal;
|
use crate::utils::AbortSignal;
|
||||||
|
|
||||||
use anyhow::{Context, Result, anyhow, bail};
|
use anyhow::{Context, Result, anyhow, bail};
|
||||||
@@ -13,6 +13,7 @@ pub struct SseHandler {
|
|||||||
abort_signal: AbortSignal,
|
abort_signal: AbortSignal,
|
||||||
buffer: String,
|
buffer: String,
|
||||||
tool_calls: Vec<ToolCall>,
|
tool_calls: Vec<ToolCall>,
|
||||||
|
thinking: Vec<ThinkingBlock>,
|
||||||
last_tool_calls: Vec<ToolCall>,
|
last_tool_calls: Vec<ToolCall>,
|
||||||
max_call_repeats: usize,
|
max_call_repeats: usize,
|
||||||
call_repeat_chain_len: usize,
|
call_repeat_chain_len: usize,
|
||||||
@@ -26,6 +27,7 @@ impl SseHandler {
|
|||||||
abort_signal,
|
abort_signal,
|
||||||
buffer: String::new(),
|
buffer: String::new(),
|
||||||
tool_calls: Vec::new(),
|
tool_calls: Vec::new(),
|
||||||
|
thinking: Vec::new(),
|
||||||
last_tool_calls: Vec::new(),
|
last_tool_calls: Vec::new(),
|
||||||
max_call_repeats: 2,
|
max_call_repeats: 2,
|
||||||
call_repeat_chain_len: 3,
|
call_repeat_chain_len: 3,
|
||||||
@@ -170,6 +172,10 @@ impl SseHandler {
|
|||||||
message
|
message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn thinking_block(&mut self, block: ThinkingBlock) {
|
||||||
|
self.thinking.push(block);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn abort(&self) -> AbortSignal {
|
pub fn abort(&self) -> AbortSignal {
|
||||||
self.abort_signal.clone()
|
self.abort_signal.clone()
|
||||||
}
|
}
|
||||||
@@ -179,11 +185,14 @@ impl SseHandler {
|
|||||||
&self.last_tool_calls
|
&self.last_tool_calls
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take(self) -> (String, Vec<ToolCall>) {
|
pub fn take(self) -> (String, Vec<ToolCall>, Vec<ThinkingBlock>) {
|
||||||
let Self {
|
let Self {
|
||||||
buffer, tool_calls, ..
|
buffer,
|
||||||
|
tool_calls,
|
||||||
|
thinking,
|
||||||
|
..
|
||||||
} = self;
|
} = self;
|
||||||
(buffer, tool_calls)
|
(buffer, tool_calls, thinking)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-5
@@ -322,7 +322,11 @@ fn gemini_extract_chat_completions_text(data: &Value) -> Result<ChatCompletionsO
|
|||||||
bail!("Invalid response data: {data}");
|
bail!("Invalid response data: {data}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let output = ChatCompletionsOutput { text, tool_calls };
|
let output = ChatCompletionsOutput {
|
||||||
|
text,
|
||||||
|
tool_calls,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,6 +338,7 @@ pub fn gemini_build_chat_completions_body(
|
|||||||
mut messages,
|
mut messages,
|
||||||
temperature,
|
temperature,
|
||||||
top_p,
|
top_p,
|
||||||
|
reasoning_effort,
|
||||||
functions,
|
functions,
|
||||||
stream: _,
|
stream: _,
|
||||||
} = data;
|
} = data;
|
||||||
@@ -371,8 +376,15 @@ pub fn gemini_build_chat_completions_body(
|
|||||||
.collect();
|
.collect();
|
||||||
vec![json!({ "role": role, "parts": parts })]
|
vec![json!({ "role": role, "parts": parts })]
|
||||||
},
|
},
|
||||||
MessageContent::ToolCalls(MessageContentToolCalls { tool_results, .. }) => {
|
MessageContent::ToolCalls(MessageContentToolCalls { tool_results, text, .. }) => {
|
||||||
let model_parts: Vec<Value> = tool_results.iter().map(|tool_result| {
|
let mut model_parts: Vec<Value> = vec![];
|
||||||
|
if !text.is_empty() {
|
||||||
|
model_parts.push(json!({ "text": text }));
|
||||||
|
}
|
||||||
|
for tool_result in tool_results.iter() {
|
||||||
|
if let Some(round_text) = &tool_result.text {
|
||||||
|
model_parts.push(json!({ "text": round_text }));
|
||||||
|
}
|
||||||
let mut part = json!({
|
let mut part = json!({
|
||||||
"functionCall": {
|
"functionCall": {
|
||||||
"name": tool_result.call.name,
|
"name": tool_result.call.name,
|
||||||
@@ -382,8 +394,8 @@ pub fn gemini_build_chat_completions_body(
|
|||||||
if let Some(sig) = &tool_result.call.thought_signature {
|
if let Some(sig) = &tool_result.call.thought_signature {
|
||||||
part["thoughtSignature"] = json!(sig);
|
part["thoughtSignature"] = json!(sig);
|
||||||
}
|
}
|
||||||
part
|
model_parts.push(part);
|
||||||
}).collect();
|
}
|
||||||
let function_parts: Vec<Value> = tool_results.into_iter().map(|tool_result| {
|
let function_parts: Vec<Value> = tool_results.into_iter().map(|tool_result| {
|
||||||
json!({
|
json!({
|
||||||
"functionResponse": {
|
"functionResponse": {
|
||||||
@@ -426,6 +438,9 @@ pub fn gemini_build_chat_completions_body(
|
|||||||
if let Some(v) = top_p {
|
if let Some(v) = top_p {
|
||||||
body["generationConfig"]["topP"] = v.into();
|
body["generationConfig"]["topP"] = v.into();
|
||||||
}
|
}
|
||||||
|
if let Some(v) = reasoning_effort {
|
||||||
|
body["generationConfig"]["thinking_config"] = json!({"thinking_level": v});
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(functions) = functions {
|
if let Some(functions) = functions {
|
||||||
// Gemini doesn't support functions with parameters that have empty properties, so we need to patch it.
|
// Gemini doesn't support functions with parameters that have empty properties, so we need to patch it.
|
||||||
|
|||||||
+143
-14
@@ -43,6 +43,8 @@ pub struct Agent {
|
|||||||
graph_rags: HashMap<String, Arc<Rag>>,
|
graph_rags: HashMap<String, Arc<Rag>>,
|
||||||
model: Model,
|
model: Model,
|
||||||
vault: GlobalVault,
|
vault: GlobalVault,
|
||||||
|
is_graph: bool,
|
||||||
|
enabled_tools: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Agent {
|
impl Agent {
|
||||||
@@ -219,7 +221,7 @@ impl Agent {
|
|||||||
&& !matches!(agent_config.memory, Some(false))
|
&& !matches!(agent_config.memory, Some(false))
|
||||||
&& !matches!(app.memory, Some(false))
|
&& !matches!(app.memory, Some(false))
|
||||||
{
|
{
|
||||||
let memory_exists = paths::global_memory_index_path().exists()
|
let memory_exists = paths::global_memory_index_file().exists()
|
||||||
|| env::current_dir()
|
|| env::current_dir()
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|cwd| memory::discover_workspace_memory(&cwd))
|
.and_then(|cwd| memory::discover_workspace_memory(&cwd))
|
||||||
@@ -243,6 +245,8 @@ impl Agent {
|
|||||||
graph_rags,
|
graph_rags,
|
||||||
model,
|
model,
|
||||||
vault: app_state.vault.clone(),
|
vault: app_state.vault.clone(),
|
||||||
|
is_graph: graph_for_rag.is_some(),
|
||||||
|
enabled_tools: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,6 +343,10 @@ impl Agent {
|
|||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_graph(&self) -> bool {
|
||||||
|
self.is_graph
|
||||||
|
}
|
||||||
|
|
||||||
pub fn functions(&self) -> &Functions {
|
pub fn functions(&self) -> &Functions {
|
||||||
&self.functions
|
&self.functions
|
||||||
}
|
}
|
||||||
@@ -359,6 +367,10 @@ impl Agent {
|
|||||||
&self.config.mcp_servers
|
&self.config.mcp_servers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn spawnable_agents(&self) -> Option<&[String]> {
|
||||||
|
self.config.spawnable_agents.as_deref()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn skills_enabled(&self) -> Option<bool> {
|
pub fn skills_enabled(&self) -> Option<bool> {
|
||||||
self.config.skills_enabled
|
self.config.skills_enabled
|
||||||
}
|
}
|
||||||
@@ -519,6 +531,14 @@ impl Agent {
|
|||||||
self.config.compression_threshold
|
self.config.compression_threshold
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn max_tool_result_chars(&self) -> Option<usize> {
|
||||||
|
self.config.max_tool_result_chars
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn compression_keep_last(&self) -> Option<usize> {
|
||||||
|
self.config.compression_keep_last
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_dynamic_instructions(&self) -> bool {
|
pub fn is_dynamic_instructions(&self) -> bool {
|
||||||
self.config.dynamic_instructions
|
self.config.dynamic_instructions
|
||||||
}
|
}
|
||||||
@@ -553,6 +573,25 @@ impl Agent {
|
|||||||
_ => bail!("No return value from '_instructions' function"),
|
_ => bail!("No return value from '_instructions' function"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub fn test_new(config: AgentConfig) -> Self {
|
||||||
|
Self {
|
||||||
|
name: config.name.clone(),
|
||||||
|
config,
|
||||||
|
shared_variables: Default::default(),
|
||||||
|
session_variables: None,
|
||||||
|
shared_dynamic_instructions: None,
|
||||||
|
session_dynamic_instructions: None,
|
||||||
|
functions: Functions::default(),
|
||||||
|
rag: None,
|
||||||
|
graph_rags: Default::default(),
|
||||||
|
model: Model::default(),
|
||||||
|
vault: std::sync::Arc::new(Vault::default()),
|
||||||
|
is_graph: false,
|
||||||
|
enabled_tools: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RoleLike for Agent {
|
impl RoleLike for Agent {
|
||||||
@@ -575,8 +614,12 @@ impl RoleLike for Agent {
|
|||||||
self.config.top_p
|
self.config.top_p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reasoning_effort(&self) -> Option<String> {
|
||||||
|
self.config.reasoning_effort.clone()
|
||||||
|
}
|
||||||
|
|
||||||
fn enabled_tools(&self) -> Option<Vec<String>> {
|
fn enabled_tools(&self) -> Option<Vec<String>> {
|
||||||
None
|
self.enabled_tools.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enabled_mcp_servers(&self) -> Option<Vec<String>> {
|
fn enabled_mcp_servers(&self) -> Option<Vec<String>> {
|
||||||
@@ -596,19 +639,18 @@ impl RoleLike for Agent {
|
|||||||
self.config.top_p = value;
|
self.config.top_p = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_reasoning_effort(&mut self, value: Option<String>) {
|
||||||
|
self.config.reasoning_effort = value;
|
||||||
|
}
|
||||||
|
|
||||||
fn set_enabled_tools(&mut self, value: Option<Vec<String>>) {
|
fn set_enabled_tools(&mut self, value: Option<Vec<String>>) {
|
||||||
match value {
|
self.enabled_tools = value.map(|tools| {
|
||||||
Some(tools) => {
|
tools
|
||||||
self.config.global_tools = tools
|
.into_iter()
|
||||||
.into_iter()
|
.map(|v| v.trim().to_string())
|
||||||
.map(|v| v.trim().to_string())
|
.filter(|v| !v.is_empty())
|
||||||
.filter(|v| !v.is_empty())
|
.collect::<Vec<_>>()
|
||||||
.collect::<Vec<_>>();
|
});
|
||||||
}
|
|
||||||
None => {
|
|
||||||
self.config.global_tools.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_enabled_mcp_servers(&mut self, value: Option<Vec<String>>) {
|
fn set_enabled_mcp_servers(&mut self, value: Option<Vec<String>>) {
|
||||||
@@ -637,11 +679,15 @@ pub struct AgentConfig {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub top_p: Option<f64>,
|
pub top_p: Option<f64>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub reasoning_effort: Option<String>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub agent_session: Option<String>,
|
pub agent_session: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub auto_continue: bool,
|
pub auto_continue: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub can_spawn_agents: bool,
|
pub can_spawn_agents: bool,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub spawnable_agents: Option<Vec<String>>,
|
||||||
#[serde(default = "default_max_concurrent_agents")]
|
#[serde(default = "default_max_concurrent_agents")]
|
||||||
pub max_concurrent_agents: usize,
|
pub max_concurrent_agents: usize,
|
||||||
#[serde(default = "default_max_agent_depth")]
|
#[serde(default = "default_max_agent_depth")]
|
||||||
@@ -660,6 +706,10 @@ pub struct AgentConfig {
|
|||||||
pub memory: Option<bool>,
|
pub memory: Option<bool>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub compression_threshold: Option<usize>,
|
pub compression_threshold: Option<usize>,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub max_tool_result_chars: Option<usize>,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub compression_keep_last: Option<usize>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub description: String,
|
pub description: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@@ -732,6 +782,7 @@ impl AgentConfig {
|
|||||||
model_id: graph.model.clone(),
|
model_id: graph.model.clone(),
|
||||||
temperature: graph.temperature,
|
temperature: graph.temperature,
|
||||||
top_p: graph.top_p,
|
top_p: graph.top_p,
|
||||||
|
reasoning_effort: graph.reasoning_effort.clone(),
|
||||||
description: graph.description.clone(),
|
description: graph.description.clone(),
|
||||||
global_tools: graph.global_tools.clone(),
|
global_tools: graph.global_tools.clone(),
|
||||||
mcp_servers: graph.mcp_servers.clone(),
|
mcp_servers: graph.mcp_servers.clone(),
|
||||||
@@ -766,6 +817,9 @@ impl AgentConfig {
|
|||||||
if let Some(v) = read_env_value::<f64>(&with_prefix("top_p")) {
|
if let Some(v) = read_env_value::<f64>(&with_prefix("top_p")) {
|
||||||
self.top_p = v;
|
self.top_p = v;
|
||||||
}
|
}
|
||||||
|
if let Some(v) = read_env_value::<String>(&with_prefix("reasoning_effort")) {
|
||||||
|
self.reasoning_effort = v;
|
||||||
|
}
|
||||||
if let Ok(v) = env::var(with_prefix("global_tools"))
|
if let Ok(v) = env::var(with_prefix("global_tools"))
|
||||||
&& let Ok(v) = serde_json::from_str(&v)
|
&& let Ok(v) = serde_json::from_str(&v)
|
||||||
{
|
{
|
||||||
@@ -776,6 +830,11 @@ impl AgentConfig {
|
|||||||
{
|
{
|
||||||
self.mcp_servers = v;
|
self.mcp_servers = v;
|
||||||
}
|
}
|
||||||
|
if let Ok(v) = env::var(with_prefix("spawnable_agents"))
|
||||||
|
&& let Ok(v) = serde_json::from_str(&v)
|
||||||
|
{
|
||||||
|
self.spawnable_agents = Some(v);
|
||||||
|
}
|
||||||
if let Some(v) = read_env_value::<String>(&with_prefix("agent_session")) {
|
if let Some(v) = read_env_value::<String>(&with_prefix("agent_session")) {
|
||||||
self.agent_session = v;
|
self.agent_session = v;
|
||||||
}
|
}
|
||||||
@@ -999,6 +1058,36 @@ pub fn list_agents() -> Vec<String> {
|
|||||||
agents
|
agents
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn list_agents_with_descriptions() -> Vec<(String, String)> {
|
||||||
|
list_agents()
|
||||||
|
.into_iter()
|
||||||
|
.map(|name| {
|
||||||
|
let description = load_agent_description(&name);
|
||||||
|
(name, description)
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct AgentMetadataStub {
|
||||||
|
#[serde(default)]
|
||||||
|
description: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn load_agent_description(name: &str) -> String {
|
||||||
|
if let Ok(config) = AgentConfig::load(&paths::agent_config_file(name)) {
|
||||||
|
return config.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Ok(contents) = read_to_string(paths::agent_graph_file(name))
|
||||||
|
&& let Ok(meta) = serde_yaml::from_str::<AgentMetadataStub>(&contents)
|
||||||
|
{
|
||||||
|
return meta.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
String::new()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn complete_agent_variables(agent_name: &str) -> Vec<(String, Option<String>)> {
|
pub fn complete_agent_variables(agent_name: &str) -> Vec<(String, Option<String>)> {
|
||||||
let config_path = paths::agent_config_file(agent_name);
|
let config_path = paths::agent_config_file(agent_name);
|
||||||
if !config_path.exists() {
|
if !config_path.exists() {
|
||||||
@@ -1188,4 +1277,44 @@ variables:
|
|||||||
assert_eq!(config.max_agent_depth, default_max_agent_depth());
|
assert_eq!(config.max_agent_depth, default_max_agent_depth());
|
||||||
assert_eq!(config.escalation_timeout, default_escalation_timeout());
|
assert_eq!(config.escalation_timeout, default_escalation_timeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn agent_metadata_stub_extracts_description_from_graph_yaml() {
|
||||||
|
let yaml = r#"
|
||||||
|
name: librarian
|
||||||
|
description: External-reference research agent.
|
||||||
|
version: "1.0"
|
||||||
|
start: triage
|
||||||
|
nodes: {}
|
||||||
|
"#;
|
||||||
|
|
||||||
|
let meta: AgentMetadataStub = serde_yaml::from_str(yaml).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(meta.description, "External-reference research agent.");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn agent_metadata_stub_extracts_multiline_description() {
|
||||||
|
let yaml = r#"
|
||||||
|
name: coder
|
||||||
|
description: |
|
||||||
|
Implementation agent. Plans, implements, and runs build + tests in a
|
||||||
|
bounded fix-loop until verified.
|
||||||
|
version: "1.0"
|
||||||
|
"#;
|
||||||
|
|
||||||
|
let meta: AgentMetadataStub = serde_yaml::from_str(yaml).unwrap();
|
||||||
|
|
||||||
|
assert!(meta.description.starts_with("Implementation agent."));
|
||||||
|
assert!(meta.description.contains("bounded fix-loop"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn agent_metadata_stub_defaults_when_description_missing() {
|
||||||
|
let yaml = "name: nameless\nversion: \"1.0\"\n";
|
||||||
|
|
||||||
|
let meta: AgentMetadataStub = serde_yaml::from_str(yaml).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(meta.description, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+84
-14
@@ -1,4 +1,4 @@
|
|||||||
use crate::client::{ClientConfig, list_models};
|
use crate::client::{ClientConfig, Model, ModelType, list_models};
|
||||||
use crate::render::{MarkdownRender, RenderOptions};
|
use crate::render::{MarkdownRender, RenderOptions};
|
||||||
use crate::utils::{IS_STDOUT_TERMINAL, NO_COLOR, decode_bin, get_env_name};
|
use crate::utils::{IS_STDOUT_TERMINAL, NO_COLOR, decode_bin, get_env_name};
|
||||||
|
|
||||||
@@ -21,6 +21,7 @@ pub struct AppConfig {
|
|||||||
pub model_id: String,
|
pub model_id: String,
|
||||||
pub temperature: Option<f64>,
|
pub temperature: Option<f64>,
|
||||||
pub top_p: Option<f64>,
|
pub top_p: Option<f64>,
|
||||||
|
pub reasoning_effort: Option<String>,
|
||||||
|
|
||||||
pub dry_run: bool,
|
pub dry_run: bool,
|
||||||
pub stream: bool,
|
pub stream: bool,
|
||||||
@@ -61,13 +62,18 @@ pub struct AppConfig {
|
|||||||
|
|
||||||
pub save_session: Option<bool>,
|
pub save_session: Option<bool>,
|
||||||
pub compression_threshold: usize,
|
pub compression_threshold: usize,
|
||||||
|
pub compression_keep_last: usize,
|
||||||
pub summarization_prompt: Option<String>,
|
pub summarization_prompt: Option<String>,
|
||||||
pub summary_context_prompt: Option<String>,
|
pub summary_context_prompt: Option<String>,
|
||||||
|
pub max_tool_result_chars: Option<usize>,
|
||||||
|
|
||||||
pub memory: Option<bool>,
|
pub memory: Option<bool>,
|
||||||
pub memory_cap_with_tools: Option<usize>,
|
pub memory_cap_with_tools: Option<usize>,
|
||||||
pub memory_cap_without_tools: Option<usize>,
|
pub memory_cap_without_tools: Option<usize>,
|
||||||
|
|
||||||
|
pub workspace_instructions: Option<bool>,
|
||||||
|
pub workspace_instructions_files: Option<Vec<String>>,
|
||||||
|
|
||||||
pub rag_embedding_model: Option<String>,
|
pub rag_embedding_model: Option<String>,
|
||||||
pub rag_reranker_model: Option<String>,
|
pub rag_reranker_model: Option<String>,
|
||||||
pub rag_top_k: usize,
|
pub rag_top_k: usize,
|
||||||
@@ -82,12 +88,14 @@ pub struct AppConfig {
|
|||||||
pub document_loaders: HashMap<String, String>,
|
pub document_loaders: HashMap<String, String>,
|
||||||
|
|
||||||
pub highlight: bool,
|
pub highlight: bool,
|
||||||
|
pub raw_markdown: bool,
|
||||||
pub theme: Option<String>,
|
pub theme: Option<String>,
|
||||||
pub left_prompt: Option<String>,
|
pub left_prompt: Option<String>,
|
||||||
pub right_prompt: Option<String>,
|
pub right_prompt: Option<String>,
|
||||||
|
|
||||||
pub user_agent: Option<String>,
|
pub user_agent: Option<String>,
|
||||||
pub save_shell_history: bool,
|
pub save_shell_history: bool,
|
||||||
|
pub no_workspace_mcp: bool,
|
||||||
pub sync_models_url: Option<String>,
|
pub sync_models_url: Option<String>,
|
||||||
|
|
||||||
pub clients: Vec<ClientConfig>,
|
pub clients: Vec<ClientConfig>,
|
||||||
@@ -99,6 +107,7 @@ impl Default for AppConfig {
|
|||||||
model_id: Default::default(),
|
model_id: Default::default(),
|
||||||
temperature: None,
|
temperature: None,
|
||||||
top_p: None,
|
top_p: None,
|
||||||
|
reasoning_effort: None,
|
||||||
|
|
||||||
dry_run: false,
|
dry_run: false,
|
||||||
stream: true,
|
stream: true,
|
||||||
@@ -136,13 +145,18 @@ impl Default for AppConfig {
|
|||||||
|
|
||||||
save_session: None,
|
save_session: None,
|
||||||
compression_threshold: 4000,
|
compression_threshold: 4000,
|
||||||
|
compression_keep_last: 0,
|
||||||
summarization_prompt: None,
|
summarization_prompt: None,
|
||||||
summary_context_prompt: None,
|
summary_context_prompt: None,
|
||||||
|
max_tool_result_chars: None,
|
||||||
|
|
||||||
memory: None,
|
memory: None,
|
||||||
memory_cap_with_tools: None,
|
memory_cap_with_tools: None,
|
||||||
memory_cap_without_tools: None,
|
memory_cap_without_tools: None,
|
||||||
|
|
||||||
|
workspace_instructions: None,
|
||||||
|
workspace_instructions_files: None,
|
||||||
|
|
||||||
rag_embedding_model: None,
|
rag_embedding_model: None,
|
||||||
rag_reranker_model: None,
|
rag_reranker_model: None,
|
||||||
rag_top_k: 5,
|
rag_top_k: 5,
|
||||||
@@ -156,12 +170,14 @@ impl Default for AppConfig {
|
|||||||
document_loaders: Default::default(),
|
document_loaders: Default::default(),
|
||||||
|
|
||||||
highlight: true,
|
highlight: true,
|
||||||
|
raw_markdown: false,
|
||||||
theme: None,
|
theme: None,
|
||||||
left_prompt: None,
|
left_prompt: None,
|
||||||
right_prompt: None,
|
right_prompt: None,
|
||||||
|
|
||||||
user_agent: None,
|
user_agent: None,
|
||||||
save_shell_history: true,
|
save_shell_history: true,
|
||||||
|
no_workspace_mcp: false,
|
||||||
sync_models_url: None,
|
sync_models_url: None,
|
||||||
|
|
||||||
clients: vec![],
|
clients: vec![],
|
||||||
@@ -175,6 +191,7 @@ impl AppConfig {
|
|||||||
model_id: config.model_id,
|
model_id: config.model_id,
|
||||||
temperature: config.temperature,
|
temperature: config.temperature,
|
||||||
top_p: config.top_p,
|
top_p: config.top_p,
|
||||||
|
reasoning_effort: None,
|
||||||
|
|
||||||
dry_run: config.dry_run,
|
dry_run: config.dry_run,
|
||||||
stream: config.stream,
|
stream: config.stream,
|
||||||
@@ -212,13 +229,18 @@ impl AppConfig {
|
|||||||
|
|
||||||
save_session: config.save_session,
|
save_session: config.save_session,
|
||||||
compression_threshold: config.compression_threshold,
|
compression_threshold: config.compression_threshold,
|
||||||
|
compression_keep_last: config.compression_keep_last,
|
||||||
summarization_prompt: config.summarization_prompt,
|
summarization_prompt: config.summarization_prompt,
|
||||||
summary_context_prompt: config.summary_context_prompt,
|
summary_context_prompt: config.summary_context_prompt,
|
||||||
|
max_tool_result_chars: config.max_tool_result_chars,
|
||||||
|
|
||||||
memory: config.memory,
|
memory: config.memory,
|
||||||
memory_cap_with_tools: config.memory_cap_with_tools,
|
memory_cap_with_tools: config.memory_cap_with_tools,
|
||||||
memory_cap_without_tools: config.memory_cap_without_tools,
|
memory_cap_without_tools: config.memory_cap_without_tools,
|
||||||
|
|
||||||
|
workspace_instructions: config.workspace_instructions,
|
||||||
|
workspace_instructions_files: config.workspace_instructions_files,
|
||||||
|
|
||||||
rag_embedding_model: config.rag_embedding_model,
|
rag_embedding_model: config.rag_embedding_model,
|
||||||
rag_reranker_model: config.rag_reranker_model,
|
rag_reranker_model: config.rag_reranker_model,
|
||||||
rag_top_k: config.rag_top_k,
|
rag_top_k: config.rag_top_k,
|
||||||
@@ -232,12 +254,14 @@ impl AppConfig {
|
|||||||
document_loaders: config.document_loaders,
|
document_loaders: config.document_loaders,
|
||||||
|
|
||||||
highlight: config.highlight,
|
highlight: config.highlight,
|
||||||
|
raw_markdown: config.raw_markdown,
|
||||||
theme: config.theme,
|
theme: config.theme,
|
||||||
left_prompt: config.left_prompt,
|
left_prompt: config.left_prompt,
|
||||||
right_prompt: config.right_prompt,
|
right_prompt: config.right_prompt,
|
||||||
|
|
||||||
user_agent: config.user_agent,
|
user_agent: config.user_agent,
|
||||||
save_shell_history: config.save_shell_history,
|
save_shell_history: config.save_shell_history,
|
||||||
|
no_workspace_mcp: false,
|
||||||
sync_models_url: config.sync_models_url,
|
sync_models_url: config.sync_models_url,
|
||||||
|
|
||||||
clients: config.clients,
|
clients: config.clients,
|
||||||
@@ -250,6 +274,7 @@ impl AppConfig {
|
|||||||
app_config.setup_document_loaders();
|
app_config.setup_document_loaders();
|
||||||
app_config.setup_user_agent();
|
app_config.setup_user_agent();
|
||||||
app_config.resolve_model()?;
|
app_config.resolve_model()?;
|
||||||
|
app_config.validate_reasoning_effort()?;
|
||||||
Ok(app_config)
|
Ok(app_config)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,6 +295,31 @@ impl AppConfig {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn validate_reasoning_effort(&self) -> Result<()> {
|
||||||
|
let Some(ref effort) = self.reasoning_effort else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
let model = Model::retrieve_model(self, &self.model_id, ModelType::Chat)?;
|
||||||
|
let levels = model.reasoning_levels();
|
||||||
|
|
||||||
|
if levels.is_empty() {
|
||||||
|
bail!(
|
||||||
|
"reasoning_effort '{}' is configured but the model does not support reasoning effort",
|
||||||
|
effort
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if !levels.iter().any(|l| l == effort) {
|
||||||
|
bail!(
|
||||||
|
"reasoning_effort '{}' is not valid for the model. Supported levels: {}",
|
||||||
|
effort,
|
||||||
|
levels.join(", ")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn resolve_model(&mut self) -> Result<()> {
|
pub fn resolve_model(&mut self) -> Result<()> {
|
||||||
if self.model_id.is_empty() {
|
if self.model_id.is_empty() {
|
||||||
let models = list_models(self, crate::client::ModelType::Chat);
|
let models = list_models(self, crate::client::ModelType::Chat);
|
||||||
@@ -288,7 +338,7 @@ impl AppConfig {
|
|||||||
return path.clone();
|
return path.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(translated) = paths::translate_sandboxed_home_path(path)
|
if let Some(translated) = paths::translate_sandboxed_home_dir(path)
|
||||||
&& translated.exists()
|
&& translated.exists()
|
||||||
{
|
{
|
||||||
info!(
|
info!(
|
||||||
@@ -308,16 +358,18 @@ impl AppConfig {
|
|||||||
|
|
||||||
pub fn editor(&self) -> Result<String> {
|
pub fn editor(&self) -> Result<String> {
|
||||||
super::EDITOR.get_or_init(move || {
|
super::EDITOR.get_or_init(move || {
|
||||||
let editor = self.editor.clone()
|
if let Some(editor) = self.editor.clone()
|
||||||
.or_else(|| env::var("VISUAL").ok().or_else(|| env::var("EDITOR").ok()))
|
.or_else(|| env::var("VISUAL").ok().or_else(|| env::var("EDITOR").ok()))
|
||||||
.unwrap_or_else(|| {
|
&& which::which(&editor).is_ok()
|
||||||
if cfg!(windows) {
|
{
|
||||||
"notepad".to_string()
|
return Some(editor);
|
||||||
} else {
|
}
|
||||||
"nano".to_string()
|
let default = if cfg!(windows) {
|
||||||
}
|
"notepad".to_string()
|
||||||
});
|
} else {
|
||||||
which::which(&editor).ok().map(|_| editor)
|
"nano".to_string()
|
||||||
|
};
|
||||||
|
which::which(&default).ok().map(|_| default)
|
||||||
})
|
})
|
||||||
.clone()
|
.clone()
|
||||||
.ok_or_else(|| anyhow!("Editor not found. Please add the `editor` configuration or set the $EDITOR or $VISUAL environment variable."))
|
.ok_or_else(|| anyhow!("Editor not found. Please add the `editor` configuration or set the $EDITOR or $VISUAL environment variable."))
|
||||||
@@ -337,7 +389,7 @@ impl AppConfig {
|
|||||||
let theme = if self.highlight {
|
let theme = if self.highlight {
|
||||||
let theme_mode = if self.light_theme() { "light" } else { "dark" };
|
let theme_mode = if self.light_theme() { "light" } else { "dark" };
|
||||||
let theme_filename = format!("{theme_mode}.tmTheme");
|
let theme_filename = format!("{theme_mode}.tmTheme");
|
||||||
let theme_path = paths::local_path(&theme_filename);
|
let theme_path = paths::local_dir(&theme_filename);
|
||||||
if theme_path.exists() {
|
if theme_path.exists() {
|
||||||
let theme = ThemeSet::get_theme(&theme_path)
|
let theme = ThemeSet::get_theme(&theme_path)
|
||||||
.with_context(|| format!("Invalid theme at '{}'", theme_path.display()))?;
|
.with_context(|| format!("Invalid theme at '{}'", theme_path.display()))?;
|
||||||
@@ -362,14 +414,26 @@ impl AppConfig {
|
|||||||
env::var("COLORTERM").as_ref().map(|v| v.as_str()),
|
env::var("COLORTERM").as_ref().map(|v| v.as_str()),
|
||||||
Ok("truecolor")
|
Ok("truecolor")
|
||||||
);
|
);
|
||||||
Ok(RenderOptions::new(theme, wrap, self.wrap_code, truecolor))
|
Ok(RenderOptions::new(
|
||||||
|
theme,
|
||||||
|
wrap,
|
||||||
|
self.wrap_code,
|
||||||
|
self.raw_markdown,
|
||||||
|
truecolor,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_markdown(&self, text: &str) -> Result<()> {
|
pub fn print_markdown(&self, text: &str) -> Result<()> {
|
||||||
if *IS_STDOUT_TERMINAL {
|
if *IS_STDOUT_TERMINAL {
|
||||||
let render_options = self.render_options()?;
|
let render_options = self.render_options()?;
|
||||||
let mut markdown_render = MarkdownRender::init(render_options)?;
|
let mut markdown_render = MarkdownRender::init(render_options)?;
|
||||||
println!("{}", markdown_render.render(text));
|
let body = markdown_render.render(text);
|
||||||
|
let tail = markdown_render.finalize();
|
||||||
|
if tail.is_empty() {
|
||||||
|
println!("{body}");
|
||||||
|
} else {
|
||||||
|
println!("{body}\n{tail}");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("{text}");
|
println!("{text}");
|
||||||
}
|
}
|
||||||
@@ -421,6 +485,9 @@ impl AppConfig {
|
|||||||
if let Some(v) = super::read_env_value::<f64>(&get_env_name("top_p")) {
|
if let Some(v) = super::read_env_value::<f64>(&get_env_name("top_p")) {
|
||||||
self.top_p = v;
|
self.top_p = v;
|
||||||
}
|
}
|
||||||
|
if let Some(v) = super::read_env_value::<String>(&get_env_name("reasoning_effort")) {
|
||||||
|
self.reasoning_effort = v;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(Some(v)) = super::read_env_bool(&get_env_name("dry_run")) {
|
if let Some(Some(v)) = super::read_env_bool(&get_env_name("dry_run")) {
|
||||||
self.dry_run = v;
|
self.dry_run = v;
|
||||||
@@ -543,6 +610,9 @@ impl AppConfig {
|
|||||||
if *NO_COLOR {
|
if *NO_COLOR {
|
||||||
self.highlight = false;
|
self.highlight = false;
|
||||||
}
|
}
|
||||||
|
if let Some(Some(v)) = super::read_env_bool(&get_env_name("raw_markdown")) {
|
||||||
|
self.raw_markdown = v;
|
||||||
|
}
|
||||||
if self.highlight && self.theme.is_none() {
|
if self.highlight && self.theme.is_none() {
|
||||||
if let Some(v) = super::read_env_value::<String>(&get_env_name("theme")) {
|
if let Some(v) = super::read_env_value::<String>(&get_env_name("theme")) {
|
||||||
self.theme = v;
|
self.theme = v;
|
||||||
|
|||||||
@@ -253,6 +253,10 @@ impl Input {
|
|||||||
patch_messages(&mut messages, model);
|
patch_messages(&mut messages, model);
|
||||||
model.guard_max_input_tokens(&messages)?;
|
model.guard_max_input_tokens(&messages)?;
|
||||||
let (temperature, top_p) = (self.role().temperature(), self.role().top_p());
|
let (temperature, top_p) = (self.role().temperature(), self.role().top_p());
|
||||||
|
let reasoning_effort = self
|
||||||
|
.role()
|
||||||
|
.reasoning_effort()
|
||||||
|
.or_else(|| model.default_reasoning_effort().map(|s| s.to_string()));
|
||||||
let functions = if model.supports_function_calling() {
|
let functions = if model.supports_function_calling() {
|
||||||
let fns = self.functions.clone();
|
let fns = self.functions.clone();
|
||||||
if let Some(vec) = &fns {
|
if let Some(vec) = &fns {
|
||||||
@@ -268,6 +272,7 @@ impl Input {
|
|||||||
messages,
|
messages,
|
||||||
temperature,
|
temperature,
|
||||||
top_p,
|
top_p,
|
||||||
|
reasoning_effort,
|
||||||
functions,
|
functions,
|
||||||
stream,
|
stream,
|
||||||
})
|
})
|
||||||
@@ -316,6 +321,10 @@ impl Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn with_session(&self) -> bool {
|
||||||
|
self.with_session
|
||||||
|
}
|
||||||
|
|
||||||
pub fn with_agent(&self) -> bool {
|
pub fn with_agent(&self) -> bool {
|
||||||
self.with_agent
|
self.with_agent
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,211 @@
|
|||||||
|
use std::fs;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
use log::warn;
|
||||||
|
|
||||||
|
pub const WORKSPACE_INSTRUCTIONS_FILE_NAME: &str = "COYOTE.md";
|
||||||
|
pub const DEFAULT_WORKSPACE_INSTRUCTIONS_FILES: [&str; 4] = [
|
||||||
|
WORKSPACE_INSTRUCTIONS_FILE_NAME,
|
||||||
|
"AGENTS.md",
|
||||||
|
"CLAUDE.md",
|
||||||
|
"GEMINI.md",
|
||||||
|
];
|
||||||
|
const INSTRUCTIONS_SIZE_WARN_THRESHOLD: usize = 24_000;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct WorkspaceInstructions {
|
||||||
|
pub path: PathBuf,
|
||||||
|
pub content: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn default_workspace_instructions_files() -> Vec<String> {
|
||||||
|
DEFAULT_WORKSPACE_INSTRUCTIONS_FILES
|
||||||
|
.iter()
|
||||||
|
.map(|s| s.to_string())
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn discover_workspace_instructions(
|
||||||
|
start: &Path,
|
||||||
|
file_names: &[String],
|
||||||
|
) -> Option<WorkspaceInstructions> {
|
||||||
|
for dir in start.ancestors() {
|
||||||
|
for name in file_names {
|
||||||
|
let candidate = dir.join(name);
|
||||||
|
if !candidate.is_file() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
match fs::read_to_string(&candidate) {
|
||||||
|
Ok(content) if !content.trim().is_empty() => {
|
||||||
|
return Some(WorkspaceInstructions {
|
||||||
|
path: candidate,
|
||||||
|
content,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(e) => warn!(
|
||||||
|
"failed to read workspace instructions at {}: {e}",
|
||||||
|
candidate.display()
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn build_instructions_section(instructions: &WorkspaceInstructions) -> String {
|
||||||
|
let char_count = instructions.content.chars().count();
|
||||||
|
if char_count > INSTRUCTIONS_SIZE_WARN_THRESHOLD {
|
||||||
|
warn!(
|
||||||
|
"workspace instructions at {} are large ({char_count} chars); \
|
||||||
|
consider moving detail into workspace memory drill files",
|
||||||
|
instructions.path.display()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
format!(
|
||||||
|
"<workspace_instructions source=\"{}\">\n{}\n</workspace_instructions>",
|
||||||
|
instructions.path.display(),
|
||||||
|
instructions.content.trim_end()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use std::{env, time};
|
||||||
|
use time::SystemTime;
|
||||||
|
|
||||||
|
fn temp_root(label: &str) -> PathBuf {
|
||||||
|
let unique = SystemTime::now()
|
||||||
|
.duration_since(time::UNIX_EPOCH)
|
||||||
|
.unwrap()
|
||||||
|
.as_nanos();
|
||||||
|
let root = env::temp_dir().join(format!("coyote-instructions-{label}-{unique}"));
|
||||||
|
fs::create_dir_all(&root).unwrap();
|
||||||
|
root
|
||||||
|
}
|
||||||
|
|
||||||
|
fn defaults() -> Vec<String> {
|
||||||
|
default_workspace_instructions_files()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn discovery_returns_none_when_no_file_exists() {
|
||||||
|
let root = temp_root("none");
|
||||||
|
|
||||||
|
assert!(discover_workspace_instructions(&root, &defaults()).is_none());
|
||||||
|
|
||||||
|
let _ = fs::remove_dir_all(&root);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn discovery_finds_coyote_md() {
|
||||||
|
let root = temp_root("coyote");
|
||||||
|
fs::write(root.join("COYOTE.md"), "coyote instructions").unwrap();
|
||||||
|
|
||||||
|
let found = discover_workspace_instructions(&root, &defaults()).unwrap();
|
||||||
|
assert_eq!(found.path, root.join("COYOTE.md"));
|
||||||
|
assert_eq!(found.content, "coyote instructions");
|
||||||
|
|
||||||
|
let _ = fs::remove_dir_all(&root);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn discovery_falls_back_through_chain_in_order() {
|
||||||
|
let root = temp_root("fallback");
|
||||||
|
fs::write(root.join("GEMINI.md"), "gemini instructions").unwrap();
|
||||||
|
|
||||||
|
let found = discover_workspace_instructions(&root, &defaults()).unwrap();
|
||||||
|
assert_eq!(found.path, root.join("GEMINI.md"));
|
||||||
|
|
||||||
|
fs::write(root.join("CLAUDE.md"), "claude instructions").unwrap();
|
||||||
|
let found = discover_workspace_instructions(&root, &defaults()).unwrap();
|
||||||
|
assert_eq!(found.path, root.join("CLAUDE.md"));
|
||||||
|
|
||||||
|
fs::write(root.join("AGENTS.md"), "agents instructions").unwrap();
|
||||||
|
let found = discover_workspace_instructions(&root, &defaults()).unwrap();
|
||||||
|
assert_eq!(found.path, root.join("AGENTS.md"));
|
||||||
|
|
||||||
|
let _ = fs::remove_dir_all(&root);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn discovery_prefers_coyote_md_over_fallbacks() {
|
||||||
|
let root = temp_root("precedence");
|
||||||
|
fs::write(root.join("COYOTE.md"), "coyote").unwrap();
|
||||||
|
fs::write(root.join("AGENTS.md"), "agents").unwrap();
|
||||||
|
fs::write(root.join("CLAUDE.md"), "claude").unwrap();
|
||||||
|
|
||||||
|
let found = discover_workspace_instructions(&root, &defaults()).unwrap();
|
||||||
|
assert_eq!(found.path, root.join("COYOTE.md"));
|
||||||
|
|
||||||
|
let _ = fs::remove_dir_all(&root);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn discovery_walks_up_from_nested_dir() {
|
||||||
|
let root = temp_root("walk_up");
|
||||||
|
fs::write(root.join("AGENTS.md"), "root instructions").unwrap();
|
||||||
|
let nested = root.join("src").join("deep");
|
||||||
|
fs::create_dir_all(&nested).unwrap();
|
||||||
|
|
||||||
|
let found = discover_workspace_instructions(&nested, &defaults()).unwrap();
|
||||||
|
assert_eq!(found.path, root.join("AGENTS.md"));
|
||||||
|
|
||||||
|
let _ = fs::remove_dir_all(&root);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn discovery_prefers_closer_file_over_higher_priority_name_above() {
|
||||||
|
let root = temp_root("depth_first");
|
||||||
|
fs::write(root.join("COYOTE.md"), "root coyote").unwrap();
|
||||||
|
let nested = root.join("packages").join("app");
|
||||||
|
fs::create_dir_all(&nested).unwrap();
|
||||||
|
fs::write(nested.join("CLAUDE.md"), "nested claude").unwrap();
|
||||||
|
|
||||||
|
let found = discover_workspace_instructions(&nested, &defaults()).unwrap();
|
||||||
|
assert_eq!(found.path, nested.join("CLAUDE.md"));
|
||||||
|
|
||||||
|
let _ = fs::remove_dir_all(&root);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn discovery_skips_empty_files() {
|
||||||
|
let root = temp_root("empty");
|
||||||
|
fs::write(root.join("COYOTE.md"), " \n").unwrap();
|
||||||
|
fs::write(root.join("AGENTS.md"), "real content").unwrap();
|
||||||
|
|
||||||
|
let found = discover_workspace_instructions(&root, &defaults()).unwrap();
|
||||||
|
assert_eq!(found.path, root.join("AGENTS.md"));
|
||||||
|
|
||||||
|
let _ = fs::remove_dir_all(&root);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn discovery_honors_custom_file_chain() {
|
||||||
|
let root = temp_root("custom");
|
||||||
|
fs::write(root.join("CLAUDE.md"), "claude").unwrap();
|
||||||
|
|
||||||
|
let only_agents = vec!["AGENTS.md".to_string()];
|
||||||
|
assert!(discover_workspace_instructions(&root, &only_agents).is_none());
|
||||||
|
|
||||||
|
let empty: Vec<String> = vec![];
|
||||||
|
assert!(discover_workspace_instructions(&root, &empty).is_none());
|
||||||
|
|
||||||
|
let _ = fs::remove_dir_all(&root);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn build_section_wraps_content_with_source_path() {
|
||||||
|
let instructions = WorkspaceInstructions {
|
||||||
|
path: PathBuf::from("/ws/COYOTE.md"),
|
||||||
|
content: "Do the thing.\n".into(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let section = build_instructions_section(&instructions);
|
||||||
|
assert!(section.starts_with("<workspace_instructions source=\"/ws/COYOTE.md\">"));
|
||||||
|
assert!(section.contains("Do the thing."));
|
||||||
|
assert!(section.ends_with("</workspace_instructions>"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ use crate::mcp::{
|
|||||||
spawn_mcp_server,
|
spawn_mcp_server,
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{Result, anyhow};
|
use anyhow::Result;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@@ -111,10 +111,10 @@ impl McpFactory {
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
if is_auth_required_error(&e) {
|
if is_auth_required_error(&e) {
|
||||||
anyhow!(
|
e.context(format!(
|
||||||
"MCP server '{name}' requires OAuth authentication. \
|
"MCP server '{name}' requires OAuth authentication. \
|
||||||
Run `coyote --auth-mcp {name}` or `.mcp auth {name}` in the REPL to authenticate."
|
Run `coyote --auth-mcp {name}` or `.mcp auth {name}` in the REPL to authenticate."
|
||||||
)
|
))
|
||||||
} else {
|
} else {
|
||||||
e
|
e
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-45
@@ -7,41 +7,27 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::config::{
|
use crate::config::{
|
||||||
GIT_DIR_NAME, GITIGNORE_FILE_NAME, MEMORY_DIR_NAME, MEMORY_INDEX_FILE_NAME,
|
GIT_DIR_NAME, GITIGNORE_FILE_NAME, MEMORY_DIR_NAME, MEMORY_INDEX_FILE_NAME,
|
||||||
WORKSPACE_MEMORY_DIR_NAME, WORKSPACE_MEMORY_FILE_NAME, paths,
|
WORKSPACE_COYOTE_DIR_NAME, paths,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const DEFAULT_MEMORY_CAP_WITH_TOOLS: usize = 6_000;
|
pub const DEFAULT_MEMORY_CAP_WITH_TOOLS: usize = 6_000;
|
||||||
pub const DEFAULT_MEMORY_CAP_WITHOUT_TOOLS: usize = 12_000;
|
pub const DEFAULT_MEMORY_CAP_WITHOUT_TOOLS: usize = 12_000;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum WorkspaceMemory {
|
pub struct WorkspaceMemory {
|
||||||
Structured {
|
pub workspace_root: PathBuf,
|
||||||
workspace_root: PathBuf,
|
pub dir: PathBuf,
|
||||||
dir: PathBuf,
|
|
||||||
},
|
|
||||||
Lite {
|
|
||||||
workspace_root: PathBuf,
|
|
||||||
file: PathBuf,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn discover_workspace_memory(start: &Path) -> Option<WorkspaceMemory> {
|
pub fn discover_workspace_memory(start: &Path) -> Option<WorkspaceMemory> {
|
||||||
for dir in start.ancestors() {
|
for dir in start.ancestors() {
|
||||||
let structured = dir.join(WORKSPACE_MEMORY_DIR_NAME).join(MEMORY_DIR_NAME);
|
let structured = dir.join(WORKSPACE_COYOTE_DIR_NAME).join(MEMORY_DIR_NAME);
|
||||||
if structured.join(MEMORY_INDEX_FILE_NAME).exists() {
|
if structured.join(MEMORY_INDEX_FILE_NAME).exists() {
|
||||||
return Some(WorkspaceMemory::Structured {
|
return Some(WorkspaceMemory {
|
||||||
workspace_root: dir.to_path_buf(),
|
workspace_root: dir.to_path_buf(),
|
||||||
dir: structured,
|
dir: structured,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let lite = dir.join(WORKSPACE_MEMORY_FILE_NAME);
|
|
||||||
if lite.exists() {
|
|
||||||
return Some(WorkspaceMemory::Lite {
|
|
||||||
workspace_root: dir.to_path_buf(),
|
|
||||||
file: lite,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@@ -82,10 +68,10 @@ pub fn bootstrap_workspace_memory(git_root: &Path) -> Result<PathBuf> {
|
|||||||
Ok(mem_dir)
|
Ok(mem_dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn append_gitignore_entry(git_root: &Path) -> Result<bool> {
|
pub fn append_gitignore_entry(git_root: &Path) -> Result<bool> {
|
||||||
let gitignore = git_root.join(GITIGNORE_FILE_NAME);
|
let gitignore = git_root.join(GITIGNORE_FILE_NAME);
|
||||||
let entry = format!("{WORKSPACE_MEMORY_DIR_NAME}/{MEMORY_DIR_NAME}/");
|
let entry = format!("{WORKSPACE_COYOTE_DIR_NAME}/{MEMORY_DIR_NAME}/");
|
||||||
let entry_no_slash = format!("{WORKSPACE_MEMORY_DIR_NAME}/{MEMORY_DIR_NAME}");
|
let entry_no_slash = format!("{WORKSPACE_COYOTE_DIR_NAME}/{MEMORY_DIR_NAME}");
|
||||||
|
|
||||||
let existing = fs::read_to_string(&gitignore).unwrap_or_default();
|
let existing = fs::read_to_string(&gitignore).unwrap_or_default();
|
||||||
let already_present = existing.lines().any(|line| {
|
let already_present = existing.lines().any(|line| {
|
||||||
@@ -212,9 +198,8 @@ impl MemoryStore {
|
|||||||
pub fn load_workspace_index(&self) -> Result<Option<String>> {
|
pub fn load_workspace_index(&self) -> Result<Option<String>> {
|
||||||
match &self.workspace {
|
match &self.workspace {
|
||||||
None => Ok(None),
|
None => Ok(None),
|
||||||
Some(WorkspaceMemory::Lite { file, .. }) => Ok(Some(fs::read_to_string(file)?)),
|
Some(ws) => {
|
||||||
Some(WorkspaceMemory::Structured { dir, .. }) => {
|
let index = ws.dir.join(MEMORY_INDEX_FILE_NAME);
|
||||||
let index = dir.join(MEMORY_INDEX_FILE_NAME);
|
|
||||||
if index.exists() {
|
if index.exists() {
|
||||||
Ok(Some(fs::read_to_string(index)?))
|
Ok(Some(fs::read_to_string(index)?))
|
||||||
} else {
|
} else {
|
||||||
@@ -231,8 +216,8 @@ impl MemoryStore {
|
|||||||
collect_md_files(&self.global_dir, &mut out)?;
|
collect_md_files(&self.global_dir, &mut out)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(WorkspaceMemory::Structured { dir, .. }) = &self.workspace {
|
if let Some(ws) = &self.workspace {
|
||||||
collect_md_files(dir, &mut out)?;
|
collect_md_files(&ws.dir, &mut out)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(out)
|
Ok(out)
|
||||||
@@ -347,7 +332,7 @@ mod tests {
|
|||||||
let root = temp_root("phase1");
|
let root = temp_root("phase1");
|
||||||
let workspace = root.join("workspace");
|
let workspace = root.join("workspace");
|
||||||
let workspace_memory_dir = workspace
|
let workspace_memory_dir = workspace
|
||||||
.join(WORKSPACE_MEMORY_DIR_NAME)
|
.join(WORKSPACE_COYOTE_DIR_NAME)
|
||||||
.join(MEMORY_DIR_NAME);
|
.join(MEMORY_DIR_NAME);
|
||||||
fs::create_dir_all(&workspace_memory_dir).unwrap();
|
fs::create_dir_all(&workspace_memory_dir).unwrap();
|
||||||
fs::write(
|
fs::write(
|
||||||
@@ -378,18 +363,13 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn workspace_discovery_prefers_structured_over_lite() {
|
fn workspace_discovery_ignores_root_instructions_file() {
|
||||||
let root = temp_root("prefer");
|
let root = temp_root("no_lite");
|
||||||
let workspace = root.join("ws");
|
let workspace = root.join("ws");
|
||||||
let structured = workspace
|
fs::create_dir_all(&workspace).unwrap();
|
||||||
.join(WORKSPACE_MEMORY_DIR_NAME)
|
fs::write(workspace.join("COYOTE.md"), "instructions, not memory").unwrap();
|
||||||
.join(MEMORY_DIR_NAME);
|
|
||||||
fs::create_dir_all(&structured).unwrap();
|
|
||||||
fs::write(structured.join(MEMORY_INDEX_FILE_NAME), "s").unwrap();
|
|
||||||
fs::write(workspace.join(WORKSPACE_MEMORY_FILE_NAME), "l").unwrap();
|
|
||||||
|
|
||||||
let found = discover_workspace_memory(&workspace);
|
assert!(discover_workspace_memory(&workspace).is_none());
|
||||||
assert!(matches!(found, Some(WorkspaceMemory::Structured { .. })));
|
|
||||||
|
|
||||||
let _ = fs::remove_dir_all(&root);
|
let _ = fs::remove_dir_all(&root);
|
||||||
}
|
}
|
||||||
@@ -415,7 +395,7 @@ mod tests {
|
|||||||
let root = temp_root("indexes_only");
|
let root = temp_root("indexes_only");
|
||||||
let workspace = root.join("ws");
|
let workspace = root.join("ws");
|
||||||
let structured = workspace
|
let structured = workspace
|
||||||
.join(WORKSPACE_MEMORY_DIR_NAME)
|
.join(WORKSPACE_COYOTE_DIR_NAME)
|
||||||
.join(MEMORY_DIR_NAME);
|
.join(MEMORY_DIR_NAME);
|
||||||
fs::create_dir_all(&structured).unwrap();
|
fs::create_dir_all(&structured).unwrap();
|
||||||
fs::write(
|
fs::write(
|
||||||
@@ -450,7 +430,7 @@ mod tests {
|
|||||||
let root = temp_root("drill_bodies");
|
let root = temp_root("drill_bodies");
|
||||||
let workspace = root.join("ws");
|
let workspace = root.join("ws");
|
||||||
let structured = workspace
|
let structured = workspace
|
||||||
.join(WORKSPACE_MEMORY_DIR_NAME)
|
.join(WORKSPACE_COYOTE_DIR_NAME)
|
||||||
.join(MEMORY_DIR_NAME);
|
.join(MEMORY_DIR_NAME);
|
||||||
fs::create_dir_all(&structured).unwrap();
|
fs::create_dir_all(&structured).unwrap();
|
||||||
fs::write(structured.join(MEMORY_INDEX_FILE_NAME), "idx").unwrap();
|
fs::write(structured.join(MEMORY_INDEX_FILE_NAME), "idx").unwrap();
|
||||||
@@ -485,7 +465,7 @@ mod tests {
|
|||||||
let root = temp_root("cap");
|
let root = temp_root("cap");
|
||||||
let workspace = root.join("ws");
|
let workspace = root.join("ws");
|
||||||
let structured = workspace
|
let structured = workspace
|
||||||
.join(WORKSPACE_MEMORY_DIR_NAME)
|
.join(WORKSPACE_COYOTE_DIR_NAME)
|
||||||
.join(MEMORY_DIR_NAME);
|
.join(MEMORY_DIR_NAME);
|
||||||
fs::create_dir_all(&structured).unwrap();
|
fs::create_dir_all(&structured).unwrap();
|
||||||
fs::write(structured.join(MEMORY_INDEX_FILE_NAME), "idx").unwrap();
|
fs::write(structured.join(MEMORY_INDEX_FILE_NAME), "idx").unwrap();
|
||||||
@@ -575,15 +555,15 @@ mod tests {
|
|||||||
let root = temp_root("walk_up");
|
let root = temp_root("walk_up");
|
||||||
let workspace = root.join("ws");
|
let workspace = root.join("ws");
|
||||||
let mem_dir = workspace
|
let mem_dir = workspace
|
||||||
.join(WORKSPACE_MEMORY_DIR_NAME)
|
.join(WORKSPACE_COYOTE_DIR_NAME)
|
||||||
.join(MEMORY_DIR_NAME);
|
.join(MEMORY_DIR_NAME);
|
||||||
fs::create_dir_all(&mem_dir).unwrap();
|
fs::create_dir_all(&mem_dir).unwrap();
|
||||||
fs::write(mem_dir.join(MEMORY_INDEX_FILE_NAME), "idx").unwrap();
|
fs::write(mem_dir.join(MEMORY_INDEX_FILE_NAME), "idx").unwrap();
|
||||||
let nested = workspace.join("src").join("deep").join("path");
|
let nested = workspace.join("src").join("deep").join("path");
|
||||||
fs::create_dir_all(&nested).unwrap();
|
fs::create_dir_all(&nested).unwrap();
|
||||||
|
|
||||||
let found = discover_workspace_memory(&nested);
|
let found = discover_workspace_memory(&nested).expect("workspace memory should be found");
|
||||||
assert!(matches!(found, Some(WorkspaceMemory::Structured { .. })));
|
assert_eq!(found.dir, mem_dir);
|
||||||
|
|
||||||
let _ = fs::remove_dir_all(&root);
|
let _ = fs::remove_dir_all(&root);
|
||||||
}
|
}
|
||||||
|
|||||||
+181
-13
@@ -3,6 +3,7 @@ mod app_config;
|
|||||||
mod app_state;
|
mod app_state;
|
||||||
mod input;
|
mod input;
|
||||||
mod install_remote;
|
mod install_remote;
|
||||||
|
pub(crate) mod instructions;
|
||||||
mod macros;
|
mod macros;
|
||||||
mod mcp_factory;
|
mod mcp_factory;
|
||||||
pub(crate) mod memory;
|
pub(crate) mod memory;
|
||||||
@@ -21,6 +22,7 @@ mod update;
|
|||||||
|
|
||||||
pub use self::agent::{
|
pub use self::agent::{
|
||||||
Agent, AgentVariable, AgentVariables, complete_agent_variables, list_agents,
|
Agent, AgentVariable, AgentVariables, complete_agent_variables, list_agents,
|
||||||
|
list_agents_with_descriptions,
|
||||||
};
|
};
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
pub use self::app_config::AppConfig;
|
pub use self::app_config::AppConfig;
|
||||||
@@ -33,7 +35,7 @@ pub use self::request_context::{RenderMode, RequestContext, should_inject_skill_
|
|||||||
pub use self::role::{
|
pub use self::role::{
|
||||||
CODE_ROLE, CREATE_TITLE_ROLE, EXPLAIN_SHELL_ROLE, Role, RoleLike, SHELL_ROLE,
|
CODE_ROLE, CREATE_TITLE_ROLE, EXPLAIN_SHELL_ROLE, Role, RoleLike, SHELL_ROLE,
|
||||||
};
|
};
|
||||||
use self::session::Session;
|
pub use self::session::Session;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
pub use self::skill::Skill;
|
pub use self::skill::Skill;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
@@ -42,11 +44,12 @@ pub use self::skill_policy::SkillPolicy;
|
|||||||
pub use self::skill_registry::SkillRegistry;
|
pub use self::skill_registry::SkillRegistry;
|
||||||
pub use self::update::run_self_update;
|
pub use self::update::run_self_update;
|
||||||
use crate::client::{
|
use crate::client::{
|
||||||
ClientConfig, MessageContentToolCalls, Model, ModelType, OPENAI_COMPATIBLE_PROVIDERS,
|
self, ClientConfig, MessageContentToolCalls, Model, ModelType, OPENAI_COMPATIBLE_PROVIDERS,
|
||||||
ProviderModels, create_client_config, list_client_types,
|
ProviderModels, create_client_config, list_client_types, oauth, set_client_models_config,
|
||||||
};
|
};
|
||||||
use crate::function::{FunctionDeclaration, Functions};
|
use crate::function::{FunctionDeclaration, Functions};
|
||||||
use crate::rag::Rag;
|
use crate::rag::Rag;
|
||||||
|
use crate::sandbox::SANDBOX_ENV_FLAG;
|
||||||
use crate::utils::*;
|
use crate::utils::*;
|
||||||
pub use macros::macro_execute;
|
pub use macros::macro_execute;
|
||||||
|
|
||||||
@@ -59,10 +62,10 @@ use fancy_regex::Regex;
|
|||||||
use gman::providers::SupportedProvider;
|
use gman::providers::SupportedProvider;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use indoc::formatdoc;
|
use indoc::formatdoc;
|
||||||
use inquire::{Confirm, Select};
|
use inquire::{Confirm, Select, Text};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use std::collections::HashMap;
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
use std::{
|
use std::{
|
||||||
env,
|
env,
|
||||||
@@ -140,14 +143,14 @@ const GLOBAL_TOOLS_DIR_NAME: &str = "tools";
|
|||||||
const GLOBAL_TOOLS_UTILS_DIR_NAME: &str = "utils";
|
const GLOBAL_TOOLS_UTILS_DIR_NAME: &str = "utils";
|
||||||
const BASH_PROMPT_UTILS_FILE_NAME: &str = "prompt-utils.sh";
|
const BASH_PROMPT_UTILS_FILE_NAME: &str = "prompt-utils.sh";
|
||||||
const MCP_FILE_NAME: &str = "mcp.json";
|
const MCP_FILE_NAME: &str = "mcp.json";
|
||||||
|
const HIDDEN_MCP_FILE_NAME: &str = ".mcp.json";
|
||||||
const MEMORY_DIR_NAME: &str = "memory";
|
const MEMORY_DIR_NAME: &str = "memory";
|
||||||
const MEMORY_INDEX_FILE_NAME: &str = "MEMORY.md";
|
const MEMORY_INDEX_FILE_NAME: &str = "MEMORY.md";
|
||||||
const WORKSPACE_MEMORY_FILE_NAME: &str = "COYOTE.md";
|
const WORKSPACE_COYOTE_DIR_NAME: &str = ".coyote";
|
||||||
const WORKSPACE_MEMORY_DIR_NAME: &str = ".coyote";
|
|
||||||
const SBX_KIT_DIR_NAME: &str = "sbx-kit";
|
const SBX_KIT_DIR_NAME: &str = "sbx-kit";
|
||||||
const SBX_KIT_HASH_FILE: &str = "kit.sha256";
|
const SBX_KIT_HASH_FILE: &str = "kit.sha256";
|
||||||
const SBX_MIXIN_FILE_NAME: &str = "sbx-mixin.yaml";
|
const SBX_MIXIN_FILE_NAME: &str = "sbx-mixin.yaml";
|
||||||
const SBX_VAULT_MIXINS_DIR_NAME: &str = "sbx-vault-mixins";
|
pub(crate) const VAULT_DATA_FILE_NAME: &str = "vault.yml";
|
||||||
const SBX_MIXIN_KITS_DIR_NAME: &str = "sbx-mixin-kits";
|
const SBX_MIXIN_KITS_DIR_NAME: &str = "sbx-mixin-kits";
|
||||||
const GIT_DIR_NAME: &str = ".git";
|
const GIT_DIR_NAME: &str = ".git";
|
||||||
const GITIGNORE_FILE_NAME: &str = ".gitignore";
|
const GITIGNORE_FILE_NAME: &str = ".gitignore";
|
||||||
@@ -183,7 +186,7 @@ const SUMMARIZATION_PROMPT: &str =
|
|||||||
const SUMMARY_CONTEXT_PROMPT: &str = "This is a summary of the chat history as a recap: ";
|
const SUMMARY_CONTEXT_PROMPT: &str = "This is a summary of the chat history as a recap: ";
|
||||||
|
|
||||||
const LEFT_PROMPT: &str = "{color.red}{model}){color.green}{?session {?agent {agent}>}{session}{?role /}}{!session {?agent {agent}>}}{role}{?rag @{rag}}{color.cyan}{?session )}{!session >}{color.reset} ";
|
const LEFT_PROMPT: &str = "{color.red}{model}){color.green}{?session {?agent {agent}>}{session}{?role /}}{!session {?agent {agent}>}}{role}{?rag @{rag}}{color.cyan}{?session )}{!session >}{color.reset} ";
|
||||||
const RIGHT_PROMPT: &str = "{color.purple}{?session {?consume_tokens {consume_tokens}({consume_percent}%)}{!consume_tokens {consume_tokens}}}{color.reset}";
|
const RIGHT_PROMPT: &str = "{color.cyan}{?reasoning_effort [{reasoning_effort}] }{color.purple}{?session {?consume_tokens {consume_tokens}({consume_percent}%)}{!consume_tokens {consume_tokens}}}{color.reset}";
|
||||||
|
|
||||||
static EDITOR: OnceLock<Option<String>> = OnceLock::new();
|
static EDITOR: OnceLock<Option<String>> = OnceLock::new();
|
||||||
|
|
||||||
@@ -237,13 +240,18 @@ pub struct Config {
|
|||||||
|
|
||||||
pub save_session: Option<bool>,
|
pub save_session: Option<bool>,
|
||||||
pub compression_threshold: usize,
|
pub compression_threshold: usize,
|
||||||
|
pub compression_keep_last: usize,
|
||||||
pub summarization_prompt: Option<String>,
|
pub summarization_prompt: Option<String>,
|
||||||
pub summary_context_prompt: Option<String>,
|
pub summary_context_prompt: Option<String>,
|
||||||
|
pub max_tool_result_chars: Option<usize>,
|
||||||
|
|
||||||
pub memory: Option<bool>,
|
pub memory: Option<bool>,
|
||||||
pub memory_cap_with_tools: Option<usize>,
|
pub memory_cap_with_tools: Option<usize>,
|
||||||
pub memory_cap_without_tools: Option<usize>,
|
pub memory_cap_without_tools: Option<usize>,
|
||||||
|
|
||||||
|
pub workspace_instructions: Option<bool>,
|
||||||
|
pub workspace_instructions_files: Option<Vec<String>>,
|
||||||
|
|
||||||
pub rag_embedding_model: Option<String>,
|
pub rag_embedding_model: Option<String>,
|
||||||
pub rag_reranker_model: Option<String>,
|
pub rag_reranker_model: Option<String>,
|
||||||
pub rag_top_k: usize,
|
pub rag_top_k: usize,
|
||||||
@@ -258,6 +266,7 @@ pub struct Config {
|
|||||||
pub document_loaders: HashMap<String, String>,
|
pub document_loaders: HashMap<String, String>,
|
||||||
|
|
||||||
pub highlight: bool,
|
pub highlight: bool,
|
||||||
|
pub raw_markdown: bool,
|
||||||
pub theme: Option<String>,
|
pub theme: Option<String>,
|
||||||
pub left_prompt: Option<String>,
|
pub left_prompt: Option<String>,
|
||||||
pub right_prompt: Option<String>,
|
pub right_prompt: Option<String>,
|
||||||
@@ -312,13 +321,18 @@ impl Default for Config {
|
|||||||
|
|
||||||
save_session: None,
|
save_session: None,
|
||||||
compression_threshold: 4000,
|
compression_threshold: 4000,
|
||||||
|
compression_keep_last: 0,
|
||||||
summarization_prompt: None,
|
summarization_prompt: None,
|
||||||
summary_context_prompt: None,
|
summary_context_prompt: None,
|
||||||
|
max_tool_result_chars: None,
|
||||||
|
|
||||||
memory: None,
|
memory: None,
|
||||||
memory_cap_with_tools: None,
|
memory_cap_with_tools: None,
|
||||||
memory_cap_without_tools: None,
|
memory_cap_without_tools: None,
|
||||||
|
|
||||||
|
workspace_instructions: None,
|
||||||
|
workspace_instructions_files: None,
|
||||||
|
|
||||||
rag_embedding_model: None,
|
rag_embedding_model: None,
|
||||||
rag_reranker_model: None,
|
rag_reranker_model: None,
|
||||||
rag_top_k: 5,
|
rag_top_k: 5,
|
||||||
@@ -332,6 +346,7 @@ impl Default for Config {
|
|||||||
document_loaders: Default::default(),
|
document_loaders: Default::default(),
|
||||||
|
|
||||||
highlight: true,
|
highlight: true,
|
||||||
|
raw_markdown: false,
|
||||||
theme: None,
|
theme: None,
|
||||||
left_prompt: None,
|
left_prompt: None,
|
||||||
right_prompt: None,
|
right_prompt: None,
|
||||||
@@ -474,7 +489,7 @@ fn confirm_asset_overwrite(category: AssetCategory, label: &str, target: &Path)
|
|||||||
pub fn default_sessions_dir() -> PathBuf {
|
pub fn default_sessions_dir() -> PathBuf {
|
||||||
match env::var(get_env_name("sessions_dir")) {
|
match env::var(get_env_name("sessions_dir")) {
|
||||||
Ok(value) => PathBuf::from(value),
|
Ok(value) => PathBuf::from(value),
|
||||||
Err(_) => paths::local_path(SESSIONS_DIR_NAME),
|
Err(_) => paths::local_dir(SESSIONS_DIR_NAME),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,6 +522,16 @@ pub async fn sync_models(url: &str, abort_signal: AbortSignal) -> Result<()> {
|
|||||||
impl Config {
|
impl Config {
|
||||||
pub async fn load_with_interpolation(info_flag: bool) -> Result<Self> {
|
pub async fn load_with_interpolation(info_flag: bool) -> Result<Self> {
|
||||||
let config_path = paths::config_file();
|
let config_path = paths::config_file();
|
||||||
|
|
||||||
|
if env::var_os(SANDBOX_ENV_FLAG).is_some() {
|
||||||
|
if !config_path.exists() {
|
||||||
|
create_config_file(&config_path).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let (config, _) = Self::load_from_file(&config_path)?;
|
||||||
|
return Ok(config);
|
||||||
|
}
|
||||||
|
|
||||||
let (mut config, content) = if !config_path.exists() {
|
let (mut config, content) = if !config_path.exists() {
|
||||||
match env::var(get_env_name("provider"))
|
match env::var(get_env_name("provider"))
|
||||||
.ok()
|
.ok()
|
||||||
@@ -589,6 +614,18 @@ impl Config {
|
|||||||
})
|
})
|
||||||
.with_context(|| "Failed to load config from str")?;
|
.with_context(|| "Failed to load config from str")?;
|
||||||
|
|
||||||
|
let mut seen = HashSet::new();
|
||||||
|
for cc in &config.clients {
|
||||||
|
let (name, _, _) = oauth::client_config_info(cc);
|
||||||
|
if !seen.insert(name.to_string()) {
|
||||||
|
bail!(
|
||||||
|
"Duplicate client name '{name}' in config.yaml. \
|
||||||
|
Client names must be unique across all `clients[]` entries \
|
||||||
|
to avoid OAuth token collisions."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(config)
|
Ok(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -725,12 +762,14 @@ pub async fn create_config_file(config_path: &Path) -> Result<()> {
|
|||||||
process::exit(0);
|
process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if env::var_os(SANDBOX_ENV_FLAG).is_some() {
|
||||||
|
return create_config_file_sandbox(config_path).await;
|
||||||
|
}
|
||||||
|
|
||||||
let provider_choice = prompt_provider_choice()?;
|
let provider_choice = prompt_provider_choice()?;
|
||||||
let mut vault = match &provider_choice {
|
let mut vault = match &provider_choice {
|
||||||
None => Vault::default_local(),
|
None => Vault::default_local(),
|
||||||
Some(provider) => Vault {
|
Some(provider) => Vault::from_provider(provider.clone()),
|
||||||
provider: provider.clone(),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
create_vault_password_file(&mut vault)?;
|
create_vault_password_file(&mut vault)?;
|
||||||
if provider_choice.is_some() {
|
if provider_choice.is_some() {
|
||||||
@@ -786,6 +825,82 @@ pub async fn create_config_file(config_path: &Path) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn create_config_file_sandbox(config_path: &Path) -> Result<()> {
|
||||||
|
let client = Select::new("API Provider (required):", list_client_types()).prompt()?;
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"Running in sandbox mode — your API provider credentials are managed by your host Coyote configuration if configured."
|
||||||
|
);
|
||||||
|
|
||||||
|
let oai_api_base = client::OPENAI_COMPATIBLE_PROVIDERS
|
||||||
|
.iter()
|
||||||
|
.find(|(name, _)| *name == client)
|
||||||
|
.map(|(_, url)| *url);
|
||||||
|
|
||||||
|
let mut client_config = if let Some(api_base) = oai_api_base {
|
||||||
|
let api_base_str = if api_base.contains('{') {
|
||||||
|
Text::new("API Base:")
|
||||||
|
.with_placeholder(&format!("e.g. {api_base}"))
|
||||||
|
.prompt()?
|
||||||
|
} else {
|
||||||
|
api_base.to_string()
|
||||||
|
};
|
||||||
|
serde_json::json!({
|
||||||
|
"type": "openai-compatible",
|
||||||
|
"name": client,
|
||||||
|
"api_base": api_base_str,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
serde_json::json!({ "type": client })
|
||||||
|
};
|
||||||
|
|
||||||
|
if client::client_type_supports_oauth(client) {
|
||||||
|
let use_oauth = Confirm::new("Use OAuth authentication instead?")
|
||||||
|
.with_default(false)
|
||||||
|
.prompt()?;
|
||||||
|
if use_oauth {
|
||||||
|
client_config["auth"] = "oauth".into();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let model = set_client_models_config(&mut client_config, client).await?;
|
||||||
|
|
||||||
|
let mut config = serde_json::json!({});
|
||||||
|
config["model"] = model.into();
|
||||||
|
config["stream"] = serde_json::json!(true);
|
||||||
|
config["save"] = serde_json::json!(true);
|
||||||
|
config["keybindings"] = serde_json::json!("vi");
|
||||||
|
config["wrap"] = serde_json::json!("auto");
|
||||||
|
config["wrap_code"] = serde_json::json!(false);
|
||||||
|
config["function_calling_support"] = serde_json::json!(true);
|
||||||
|
config["enabled_tools"] = serde_json::json!(null);
|
||||||
|
config["visible_tools"] = serde_json::json!(DEFAULT_VISIBLE_TOOLS);
|
||||||
|
config["mcp_server_support"] = serde_json::json!(true);
|
||||||
|
config["enabled_mcp_servers"] = serde_json::json!(null);
|
||||||
|
config["highlight"] = serde_json::json!(true);
|
||||||
|
config["light_theme"] = serde_json::json!(false);
|
||||||
|
config[CLIENTS_FIELD] = serde_json::json!(vec![client_config]);
|
||||||
|
|
||||||
|
let config_data = serde_yaml::to_string(&config).with_context(|| "Failed to create config")?;
|
||||||
|
let config_data = format!(
|
||||||
|
"# see https://github.com/Dark-Alex-17/coyote/blob/main/config.example.yaml\n\n{config_data}"
|
||||||
|
);
|
||||||
|
|
||||||
|
ensure_parent_exists(config_path)?;
|
||||||
|
std::fs::write(config_path, config_data)
|
||||||
|
.with_context(|| format!("Failed to write to '{}'", config_path.display()))?;
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
use std::os::unix::prelude::PermissionsExt;
|
||||||
|
let perms = std::fs::Permissions::from_mode(0o600);
|
||||||
|
std::fs::set_permissions(config_path, perms)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("✓ Saved the config file to '{}'.\n", config_path.display());
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn ensure_parent_exists(path: &Path) -> Result<()> {
|
pub(crate) fn ensure_parent_exists(path: &Path) -> Result<()> {
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -1082,4 +1197,57 @@ clients:
|
|||||||
assert!(!state.assert(StateFlags::SESSION));
|
assert!(!state.assert(StateFlags::SESSION));
|
||||||
assert!(!state.assert(StateFlags::empty()));
|
assert!(!state.assert(StateFlags::empty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
#[serial_test::serial]
|
||||||
|
async fn sandbox_config_load_no_interpolation() {
|
||||||
|
use std::fs;
|
||||||
|
use std::time;
|
||||||
|
|
||||||
|
let unique = time::SystemTime::now()
|
||||||
|
.duration_since(time::UNIX_EPOCH)
|
||||||
|
.unwrap()
|
||||||
|
.as_nanos();
|
||||||
|
let tmp_dir = std::env::temp_dir().join(format!("coyote-sandbox-cfg-{unique}"));
|
||||||
|
fs::create_dir_all(&tmp_dir).unwrap();
|
||||||
|
let config_path = tmp_dir.join("config.yaml");
|
||||||
|
|
||||||
|
fs::write(
|
||||||
|
&config_path,
|
||||||
|
"model: claude:claude-3-5-haiku\nclients:\n - type: claude\n api_key: '{{ANTHROPIC_API_KEY}}'\n",
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let config_env = get_env_name("config_file");
|
||||||
|
let prev_config = std::env::var_os(&config_env);
|
||||||
|
let prev_sandbox = std::env::var_os(crate::sandbox::SANDBOX_ENV_FLAG);
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
std::env::set_var(&config_env, &config_path);
|
||||||
|
std::env::set_var(crate::sandbox::SANDBOX_ENV_FLAG, "1");
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = Config::load_with_interpolation(false).await;
|
||||||
|
let (_, raw) = Config::load_from_file(&config_path).unwrap();
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
match prev_config {
|
||||||
|
Some(v) => std::env::set_var(&config_env, v),
|
||||||
|
None => std::env::remove_var(&config_env),
|
||||||
|
}
|
||||||
|
match prev_sandbox {
|
||||||
|
Some(v) => std::env::set_var(crate::sandbox::SANDBOX_ENV_FLAG, v),
|
||||||
|
None => std::env::remove_var(crate::sandbox::SANDBOX_ENV_FLAG),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let _ = fs::remove_dir_all(&tmp_dir);
|
||||||
|
|
||||||
|
result.expect(
|
||||||
|
"load_with_interpolation should succeed in sandbox mode with placeholder values",
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
raw.contains("{{ANTHROPIC_API_KEY}}"),
|
||||||
|
"placeholder should be preserved as a literal string in sandbox mode"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+199
-65
@@ -2,10 +2,10 @@ use super::role::Role;
|
|||||||
use super::{
|
use super::{
|
||||||
AGENT_GRAPH_FILE_NAME, AGENTS_DIR_NAME, BASH_PROMPT_UTILS_FILE_NAME, CONFIG_FILE_NAME,
|
AGENT_GRAPH_FILE_NAME, AGENTS_DIR_NAME, BASH_PROMPT_UTILS_FILE_NAME, CONFIG_FILE_NAME,
|
||||||
ENV_FILE_NAME, FUNCTIONS_BIN_DIR_NAME, FUNCTIONS_DIR_NAME, GLOBAL_TOOLS_DIR_NAME,
|
ENV_FILE_NAME, FUNCTIONS_BIN_DIR_NAME, FUNCTIONS_DIR_NAME, GLOBAL_TOOLS_DIR_NAME,
|
||||||
GLOBAL_TOOLS_UTILS_DIR_NAME, MACROS_DIR_NAME, MCP_FILE_NAME, MEMORY_DIR_NAME,
|
GLOBAL_TOOLS_UTILS_DIR_NAME, HIDDEN_MCP_FILE_NAME, MACROS_DIR_NAME, MCP_FILE_NAME,
|
||||||
MEMORY_INDEX_FILE_NAME, ModelsOverride, RAGS_DIR_NAME, ROLES_DIR_NAME, SBX_KIT_DIR_NAME,
|
MEMORY_DIR_NAME, MEMORY_INDEX_FILE_NAME, ModelsOverride, RAGS_DIR_NAME, ROLES_DIR_NAME,
|
||||||
SBX_KIT_HASH_FILE, SBX_MIXIN_FILE_NAME, SBX_MIXIN_KITS_DIR_NAME, SBX_VAULT_MIXINS_DIR_NAME,
|
SBX_KIT_DIR_NAME, SBX_KIT_HASH_FILE, SBX_MIXIN_FILE_NAME, SBX_MIXIN_KITS_DIR_NAME,
|
||||||
SKILLS_DIR_NAME, WORKSPACE_MEMORY_DIR_NAME,
|
SKILLS_DIR_NAME, WORKSPACE_COYOTE_DIR_NAME,
|
||||||
};
|
};
|
||||||
use crate::client::ProviderModels;
|
use crate::client::ProviderModels;
|
||||||
use crate::config::REPL_HISTORY_DIR_NAME;
|
use crate::config::REPL_HISTORY_DIR_NAME;
|
||||||
@@ -30,11 +30,11 @@ pub fn config_dir() -> PathBuf {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn local_path(name: &str) -> PathBuf {
|
pub fn local_dir(name: &str) -> PathBuf {
|
||||||
config_dir().join(name)
|
config_dir().join(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cache_path() -> PathBuf {
|
pub fn cache_dir() -> PathBuf {
|
||||||
if let Ok(v) = env::var(get_env_name("cache_dir")) {
|
if let Ok(v) = env::var(get_env_name("cache_dir")) {
|
||||||
PathBuf::from(v)
|
PathBuf::from(v)
|
||||||
} else if let Ok(v) = env::var("XDG_CACHE_HOME") {
|
} else if let Ok(v) = env::var("XDG_CACHE_HOME") {
|
||||||
@@ -49,7 +49,7 @@ pub fn sandbox_kit_override() -> Option<PathBuf> {
|
|||||||
env::var_os(get_env_name("sandbox_kit")).map(PathBuf::from)
|
env::var_os(get_env_name("sandbox_kit")).map(PathBuf::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn translate_sandboxed_home_path(path: &Path) -> Option<PathBuf> {
|
pub fn translate_sandboxed_home_dir(path: &Path) -> Option<PathBuf> {
|
||||||
env::var_os("IS_SANDBOX")?;
|
env::var_os("IS_SANDBOX")?;
|
||||||
|
|
||||||
let s = path.to_str()?;
|
let s = path.to_str()?;
|
||||||
@@ -62,7 +62,7 @@ pub fn translate_sandboxed_home_path(path: &Path) -> Option<PathBuf> {
|
|||||||
return Some(translated);
|
return Some(translated);
|
||||||
}
|
}
|
||||||
|
|
||||||
translate_windows_users_path(s)
|
translate_windows_users_dir(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn translate_unix_home_style(s: &str, prefix: &str) -> Option<PathBuf> {
|
fn translate_unix_home_style(s: &str, prefix: &str) -> Option<PathBuf> {
|
||||||
@@ -83,7 +83,7 @@ fn translate_unix_home_style(s: &str, prefix: &str) -> Option<PathBuf> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn translate_windows_users_path(s: &str) -> Option<PathBuf> {
|
fn translate_windows_users_dir(s: &str) -> Option<PathBuf> {
|
||||||
let bytes = s.as_bytes();
|
let bytes = s.as_bytes();
|
||||||
if bytes.len() < 4 || !bytes[0].is_ascii_alphabetic() || bytes[1] != b':' || bytes[2] != b'\\' {
|
if bytes.len() < 4 || !bytes[0].is_ascii_alphabetic() || bytes[1] != b':' || bytes[2] != b'\\' {
|
||||||
return None;
|
return None;
|
||||||
@@ -118,7 +118,7 @@ pub fn global_tools_sbx_mixin_file() -> PathBuf {
|
|||||||
pub fn find_workspace_sbx_mixin(start: &Path) -> Option<PathBuf> {
|
pub fn find_workspace_sbx_mixin(start: &Path) -> Option<PathBuf> {
|
||||||
for dir in start.ancestors() {
|
for dir in start.ancestors() {
|
||||||
let candidate = dir
|
let candidate = dir
|
||||||
.join(WORKSPACE_MEMORY_DIR_NAME)
|
.join(WORKSPACE_COYOTE_DIR_NAME)
|
||||||
.join(SBX_MIXIN_FILE_NAME);
|
.join(SBX_MIXIN_FILE_NAME);
|
||||||
if candidate.exists() {
|
if candidate.exists() {
|
||||||
return Some(candidate);
|
return Some(candidate);
|
||||||
@@ -128,49 +128,41 @@ pub fn find_workspace_sbx_mixin(start: &Path) -> Option<PathBuf> {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn oauth_tokens_path() -> PathBuf {
|
pub fn oauth_tokens_dir() -> PathBuf {
|
||||||
cache_path().join("oauth")
|
cache_dir().join("oauth")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn token_file(client_name: &str) -> PathBuf {
|
pub fn token_file(client_name: &str) -> PathBuf {
|
||||||
oauth_tokens_path().join(format!("{client_name}_oauth_tokens.json"))
|
oauth_tokens_dir().join(format!("{client_name}_oauth_tokens.json"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn log_path() -> PathBuf {
|
pub fn log_file() -> PathBuf {
|
||||||
cache_path().join(format!("{}.log", env!("CARGO_CRATE_NAME")))
|
cache_dir().join(format!("{}.log", env!("CARGO_CRATE_NAME")))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sbx_kit_dir() -> PathBuf {
|
pub fn sbx_kit_dir() -> PathBuf {
|
||||||
cache_path().join(SBX_KIT_DIR_NAME)
|
cache_dir().join(SBX_KIT_DIR_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sbx_kit_hash_file() -> PathBuf {
|
pub fn sbx_kit_hash_file() -> PathBuf {
|
||||||
sbx_kit_dir().join(SBX_KIT_HASH_FILE)
|
sbx_kit_dir().join(SBX_KIT_HASH_FILE)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sbx_vault_mixins_dir() -> PathBuf {
|
|
||||||
cache_path().join(SBX_VAULT_MIXINS_DIR_NAME)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn sbx_vault_mixins_hash_file() -> PathBuf {
|
|
||||||
sbx_vault_mixins_dir().join(SBX_KIT_HASH_FILE)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn sbx_mixin_kits_dir() -> PathBuf {
|
pub fn sbx_mixin_kits_dir() -> PathBuf {
|
||||||
cache_path().join(SBX_MIXIN_KITS_DIR_NAME)
|
cache_dir().join(SBX_MIXIN_KITS_DIR_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn config_file() -> PathBuf {
|
pub fn config_file() -> PathBuf {
|
||||||
match env::var(get_env_name("config_file")) {
|
match env::var(get_env_name("config_file")) {
|
||||||
Ok(value) => PathBuf::from(value),
|
Ok(value) => PathBuf::from(value),
|
||||||
Err(_) => local_path(CONFIG_FILE_NAME),
|
Err(_) => local_dir(CONFIG_FILE_NAME),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn roles_dir() -> PathBuf {
|
pub fn roles_dir() -> PathBuf {
|
||||||
match env::var(get_env_name("roles_dir")) {
|
match env::var(get_env_name("roles_dir")) {
|
||||||
Ok(value) => PathBuf::from(value),
|
Ok(value) => PathBuf::from(value),
|
||||||
Err(_) => local_path(ROLES_DIR_NAME),
|
Err(_) => local_dir(ROLES_DIR_NAME),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +173,7 @@ pub fn role_file(name: &str) -> PathBuf {
|
|||||||
pub fn skills_dir() -> PathBuf {
|
pub fn skills_dir() -> PathBuf {
|
||||||
match env::var(get_env_name("skills_dir")) {
|
match env::var(get_env_name("skills_dir")) {
|
||||||
Ok(value) => PathBuf::from(value),
|
Ok(value) => PathBuf::from(value),
|
||||||
Err(_) => local_path(SKILLS_DIR_NAME),
|
Err(_) => local_dir(SKILLS_DIR_NAME),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +185,40 @@ pub fn skill_file(name: &str) -> PathBuf {
|
|||||||
skill_dir(name).join("SKILL.md")
|
skill_dir(name).join("SKILL.md")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn workspace_config_dir() -> PathBuf {
|
||||||
|
let workspace_dir_name = match env::var(get_env_name("workspace_config_dir")) {
|
||||||
|
Ok(value) => value,
|
||||||
|
Err(_) => WORKSPACE_COYOTE_DIR_NAME.to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
|
env::current_dir()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.join(workspace_dir_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn workspace_skills_dir() -> PathBuf {
|
||||||
|
workspace_config_dir().join(SKILLS_DIR_NAME)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn workspace_skill_file(name: &str) -> PathBuf {
|
||||||
|
workspace_skills_dir().join(name).join("SKILL.md")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn workspace_mcp_config_file() -> Option<PathBuf> {
|
||||||
|
workspace_mcp_config_file_in(&env::current_dir().unwrap_or_default())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn workspace_mcp_config_file_in(workspace_root: &Path) -> Option<PathBuf> {
|
||||||
|
let dir = workspace_config_dir();
|
||||||
|
[
|
||||||
|
dir.join(MCP_FILE_NAME),
|
||||||
|
dir.join(HIDDEN_MCP_FILE_NAME),
|
||||||
|
workspace_root.join(HIDDEN_MCP_FILE_NAME),
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.find(|candidate| candidate.is_file())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn validate_skill_name(name: &str) -> Result<()> {
|
pub fn validate_skill_name(name: &str) -> Result<()> {
|
||||||
if name.is_empty() {
|
if name.is_empty() {
|
||||||
bail!("Skill name cannot be empty");
|
bail!("Skill name cannot be empty");
|
||||||
@@ -209,7 +235,7 @@ pub fn validate_skill_name(name: &str) -> Result<()> {
|
|||||||
pub fn macros_dir() -> PathBuf {
|
pub fn macros_dir() -> PathBuf {
|
||||||
match env::var(get_env_name("macros_dir")) {
|
match env::var(get_env_name("macros_dir")) {
|
||||||
Ok(value) => PathBuf::from(value),
|
Ok(value) => PathBuf::from(value),
|
||||||
Err(_) => local_path(MACROS_DIR_NAME),
|
Err(_) => local_dir(MACROS_DIR_NAME),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,21 +246,21 @@ pub fn macro_file(name: &str) -> PathBuf {
|
|||||||
pub fn env_file() -> PathBuf {
|
pub fn env_file() -> PathBuf {
|
||||||
match env::var(get_env_name("env_file")) {
|
match env::var(get_env_name("env_file")) {
|
||||||
Ok(value) => PathBuf::from(value),
|
Ok(value) => PathBuf::from(value),
|
||||||
Err(_) => local_path(ENV_FILE_NAME),
|
Err(_) => local_dir(ENV_FILE_NAME),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rags_dir() -> PathBuf {
|
pub fn rags_dir() -> PathBuf {
|
||||||
match env::var(get_env_name("rags_dir")) {
|
match env::var(get_env_name("rags_dir")) {
|
||||||
Ok(value) => PathBuf::from(value),
|
Ok(value) => PathBuf::from(value),
|
||||||
Err(_) => local_path(RAGS_DIR_NAME),
|
Err(_) => local_dir(RAGS_DIR_NAME),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn functions_dir() -> PathBuf {
|
pub fn functions_dir() -> PathBuf {
|
||||||
match env::var(get_env_name("functions_dir")) {
|
match env::var(get_env_name("functions_dir")) {
|
||||||
Ok(value) => PathBuf::from(value),
|
Ok(value) => PathBuf::from(value),
|
||||||
Err(_) => local_path(FUNCTIONS_DIR_NAME),
|
Err(_) => local_dir(FUNCTIONS_DIR_NAME),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,7 +285,7 @@ pub fn bash_prompt_utils_file() -> PathBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn agents_data_dir() -> PathBuf {
|
pub fn agents_data_dir() -> PathBuf {
|
||||||
local_path(AGENTS_DIR_NAME)
|
local_dir(AGENTS_DIR_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn agent_data_dir(name: &str) -> PathBuf {
|
pub fn agent_data_dir(name: &str) -> PathBuf {
|
||||||
@@ -305,25 +331,29 @@ pub fn agent_functions_file(name: &str) -> Result<PathBuf> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn models_override_file() -> PathBuf {
|
pub fn models_override_file() -> PathBuf {
|
||||||
local_path("models-override.yaml")
|
local_dir("models-override.yaml")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn global_memory_dir() -> PathBuf {
|
pub fn global_memory_dir() -> PathBuf {
|
||||||
config_dir().join(MEMORY_DIR_NAME)
|
config_dir().join(MEMORY_DIR_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn global_memory_index_path() -> PathBuf {
|
pub fn global_memory_index_file() -> PathBuf {
|
||||||
global_memory_dir().join(MEMORY_INDEX_FILE_NAME)
|
global_memory_dir().join(MEMORY_INDEX_FILE_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn workspace_memory_dir_for(workspace_root: &Path) -> PathBuf {
|
pub fn workspace_memory_dir_for(workspace_root: &Path) -> PathBuf {
|
||||||
workspace_root
|
workspace_root
|
||||||
.join(WORKSPACE_MEMORY_DIR_NAME)
|
.join(WORKSPACE_COYOTE_DIR_NAME)
|
||||||
.join(MEMORY_DIR_NAME)
|
.join(MEMORY_DIR_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn workspace_memory_index_file_for(workspace_root: &Path) -> PathBuf {
|
||||||
|
workspace_memory_dir_for(workspace_root).join(MEMORY_INDEX_FILE_NAME)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn repl_history_dir() -> PathBuf {
|
pub fn repl_history_dir() -> PathBuf {
|
||||||
cache_path().join(REPL_HISTORY_DIR_NAME)
|
cache_dir().join(REPL_HISTORY_DIR_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn repl_history_file(session: &Option<Session>) -> PathBuf {
|
pub fn repl_history_file(session: &Option<Session>) -> PathBuf {
|
||||||
@@ -346,7 +376,7 @@ pub fn log_config() -> Result<(LevelFilter, Option<PathBuf>)> {
|
|||||||
});
|
});
|
||||||
let resolved_log_path = match env::var(get_env_name("log_path")) {
|
let resolved_log_path = match env::var(get_env_name("log_path")) {
|
||||||
Ok(v) => Some(PathBuf::from(v)),
|
Ok(v) => Some(PathBuf::from(v)),
|
||||||
Err(_) => Some(log_path()),
|
Err(_) => Some(log_file()),
|
||||||
};
|
};
|
||||||
Ok((log_level, resolved_log_path))
|
Ok((log_level, resolved_log_path))
|
||||||
}
|
}
|
||||||
@@ -405,15 +435,21 @@ pub fn has_macro(name: &str) -> bool {
|
|||||||
|
|
||||||
pub fn list_skills() -> Vec<String> {
|
pub fn list_skills() -> Vec<String> {
|
||||||
let mut names = Vec::new();
|
let mut names = Vec::new();
|
||||||
if let Ok(rd) = read_dir(skills_dir()) {
|
let mut seen = HashSet::new();
|
||||||
for entry in rd.flatten() {
|
|
||||||
if let Ok(file_type) = entry.file_type()
|
for dir in [workspace_skills_dir(), skills_dir()] {
|
||||||
&& file_type.is_dir()
|
if let Ok(rd) = read_dir(dir) {
|
||||||
&& let Some(name) = entry.file_name().to_str()
|
for entry in rd.flatten() {
|
||||||
&& entry.path().join("SKILL.md").is_file()
|
if let Ok(file_type) = entry.file_type()
|
||||||
&& validate_skill_name(name).is_ok()
|
&& file_type.is_dir()
|
||||||
{
|
&& let Some(name) = entry.file_name().to_str()
|
||||||
names.push(name.to_string());
|
&& !seen.contains(name)
|
||||||
|
&& entry.path().join("SKILL.md").is_file()
|
||||||
|
&& validate_skill_name(name).is_ok()
|
||||||
|
{
|
||||||
|
seen.insert(name.to_string());
|
||||||
|
names.push(name.to_string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -423,7 +459,7 @@ pub fn list_skills() -> Vec<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_skill(name: &str) -> bool {
|
pub fn has_skill(name: &str) -> bool {
|
||||||
skill_file(name).is_file()
|
workspace_skill_file(name).is_file() || skill_file(name).is_file()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn local_models_override() -> Result<Vec<ProviderModels>> {
|
pub fn local_models_override() -> Result<Vec<ProviderModels>> {
|
||||||
@@ -527,7 +563,7 @@ mod tests {
|
|||||||
fn returns_none_when_not_in_sandbox() {
|
fn returns_none_when_not_in_sandbox() {
|
||||||
without_sandbox(|| {
|
without_sandbox(|| {
|
||||||
let p = Path::new("/home/atusa/.coyote_password");
|
let p = Path::new("/home/atusa/.coyote_password");
|
||||||
assert_eq!(translate_sandboxed_home_path(p), None);
|
assert_eq!(translate_sandboxed_home_dir(p), None);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,7 +573,7 @@ mod tests {
|
|||||||
with_sandbox(|| {
|
with_sandbox(|| {
|
||||||
let p = Path::new("/home/atusa/.coyote_password");
|
let p = Path::new("/home/atusa/.coyote_password");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
translate_sandboxed_home_path(p),
|
translate_sandboxed_home_dir(p),
|
||||||
Some(PathBuf::from("/home/agent/.coyote_password"))
|
Some(PathBuf::from("/home/agent/.coyote_password"))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -545,11 +581,11 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[serial]
|
#[serial]
|
||||||
fn translates_nested_host_home_path() {
|
fn translates_nested_host_home_dir() {
|
||||||
with_sandbox(|| {
|
with_sandbox(|| {
|
||||||
let p = Path::new("/home/atusa/.config/coyote/.password");
|
let p = Path::new("/home/atusa/.config/coyote/.password");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
translate_sandboxed_home_path(p),
|
translate_sandboxed_home_dir(p),
|
||||||
Some(PathBuf::from("/home/agent/.config/coyote/.password"))
|
Some(PathBuf::from("/home/agent/.config/coyote/.password"))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -560,7 +596,7 @@ mod tests {
|
|||||||
fn returns_none_when_path_already_targets_agent_home() {
|
fn returns_none_when_path_already_targets_agent_home() {
|
||||||
with_sandbox(|| {
|
with_sandbox(|| {
|
||||||
let p = Path::new("/home/agent/.coyote_password");
|
let p = Path::new("/home/agent/.coyote_password");
|
||||||
assert_eq!(translate_sandboxed_home_path(p), None);
|
assert_eq!(translate_sandboxed_home_dir(p), None);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,7 +605,7 @@ mod tests {
|
|||||||
fn returns_none_when_path_is_outside_home() {
|
fn returns_none_when_path_is_outside_home() {
|
||||||
with_sandbox(|| {
|
with_sandbox(|| {
|
||||||
let p = Path::new("/etc/coyote/.coyote_password");
|
let p = Path::new("/etc/coyote/.coyote_password");
|
||||||
assert_eq!(translate_sandboxed_home_path(p), None);
|
assert_eq!(translate_sandboxed_home_dir(p), None);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,7 +614,7 @@ mod tests {
|
|||||||
fn returns_none_for_relative_path() {
|
fn returns_none_for_relative_path() {
|
||||||
with_sandbox(|| {
|
with_sandbox(|| {
|
||||||
let p = Path::new(".coyote_password");
|
let p = Path::new(".coyote_password");
|
||||||
assert_eq!(translate_sandboxed_home_path(p), None);
|
assert_eq!(translate_sandboxed_home_dir(p), None);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,17 +623,17 @@ mod tests {
|
|||||||
fn returns_none_for_first_segment_not_home() {
|
fn returns_none_for_first_segment_not_home() {
|
||||||
with_sandbox(|| {
|
with_sandbox(|| {
|
||||||
let p = Path::new("/opt/atusa/.coyote_password");
|
let p = Path::new("/opt/atusa/.coyote_password");
|
||||||
assert_eq!(translate_sandboxed_home_path(p), None);
|
assert_eq!(translate_sandboxed_home_dir(p), None);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[serial]
|
#[serial]
|
||||||
fn translates_macos_users_path() {
|
fn translates_macos_users_dir() {
|
||||||
with_sandbox(|| {
|
with_sandbox(|| {
|
||||||
let p = Path::new("/Users/atusa/.coyote_password");
|
let p = Path::new("/Users/atusa/.coyote_password");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
translate_sandboxed_home_path(p),
|
translate_sandboxed_home_dir(p),
|
||||||
Some(PathBuf::from("/home/agent/.coyote_password"))
|
Some(PathBuf::from("/home/agent/.coyote_password"))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -605,11 +641,11 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[serial]
|
#[serial]
|
||||||
fn translates_macos_nested_path() {
|
fn translates_macos_nested_dir() {
|
||||||
with_sandbox(|| {
|
with_sandbox(|| {
|
||||||
let p = Path::new("/Users/atusa/.config/coyote/.password");
|
let p = Path::new("/Users/atusa/.config/coyote/.password");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
translate_sandboxed_home_path(p),
|
translate_sandboxed_home_dir(p),
|
||||||
Some(PathBuf::from("/home/agent/.config/coyote/.password"))
|
Some(PathBuf::from("/home/agent/.config/coyote/.password"))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -617,10 +653,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[serial]
|
#[serial]
|
||||||
fn returns_none_when_macos_path_already_targets_agent() {
|
fn returns_none_when_macos_dir_already_targets_agent() {
|
||||||
with_sandbox(|| {
|
with_sandbox(|| {
|
||||||
let p = Path::new("/Users/agent/.coyote_password");
|
let p = Path::new("/Users/agent/.coyote_password");
|
||||||
assert_eq!(translate_sandboxed_home_path(p), None);
|
assert_eq!(translate_sandboxed_home_dir(p), None);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,7 +666,7 @@ mod tests {
|
|||||||
with_sandbox(|| {
|
with_sandbox(|| {
|
||||||
let p = Path::new("C:\\Users\\atusa\\.coyote_password");
|
let p = Path::new("C:\\Users\\atusa\\.coyote_password");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
translate_sandboxed_home_path(p),
|
translate_sandboxed_home_dir(p),
|
||||||
Some(PathBuf::from("/home/agent/.coyote_password"))
|
Some(PathBuf::from("/home/agent/.coyote_password"))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -642,7 +678,7 @@ mod tests {
|
|||||||
with_sandbox(|| {
|
with_sandbox(|| {
|
||||||
let p = Path::new("D:\\Users\\atusa\\.config\\coyote\\.password");
|
let p = Path::new("D:\\Users\\atusa\\.config\\coyote\\.password");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
translate_sandboxed_home_path(p),
|
translate_sandboxed_home_dir(p),
|
||||||
Some(PathBuf::from("/home/agent/.config/coyote/.password"))
|
Some(PathBuf::from("/home/agent/.config/coyote/.password"))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -653,7 +689,105 @@ mod tests {
|
|||||||
fn returns_none_when_windows_path_already_targets_agent() {
|
fn returns_none_when_windows_path_already_targets_agent() {
|
||||||
with_sandbox(|| {
|
with_sandbox(|| {
|
||||||
let p = Path::new("C:\\Users\\agent\\.coyote_password");
|
let p = Path::new("C:\\Users\\agent\\.coyote_password");
|
||||||
assert_eq!(translate_sandboxed_home_path(p), None);
|
assert_eq!(translate_sandboxed_home_dir(p), None);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod workspace_mcp_resolution {
|
||||||
|
use super::*;
|
||||||
|
use serial_test::serial;
|
||||||
|
|
||||||
|
fn with_workspace_dir<F: FnOnce(&Path, &Path)>(f: F) {
|
||||||
|
let unique = time::SystemTime::now()
|
||||||
|
.duration_since(time::UNIX_EPOCH)
|
||||||
|
.unwrap()
|
||||||
|
.as_nanos();
|
||||||
|
let root = env::temp_dir().join(format!("coyote-workspace-mcp-test-{unique}"));
|
||||||
|
let ws_dir = root.join(WORKSPACE_COYOTE_DIR_NAME);
|
||||||
|
fs::create_dir_all(&ws_dir).unwrap();
|
||||||
|
let env_name = get_env_name("workspace_config_dir");
|
||||||
|
let prev = env::var_os(&env_name);
|
||||||
|
unsafe {
|
||||||
|
env::set_var(&env_name, &ws_dir);
|
||||||
|
}
|
||||||
|
f(&root, &ws_dir);
|
||||||
|
unsafe {
|
||||||
|
match prev {
|
||||||
|
Some(v) => env::set_var(&env_name, v),
|
||||||
|
None => env::remove_var(&env_name),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let _ = fs::remove_dir_all(&root);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial]
|
||||||
|
fn returns_none_when_no_config_exists() {
|
||||||
|
with_workspace_dir(|root, _| {
|
||||||
|
assert_eq!(workspace_mcp_config_file_in(root), None);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial]
|
||||||
|
fn finds_mcp_json() {
|
||||||
|
with_workspace_dir(|root, ws_dir| {
|
||||||
|
fs::write(ws_dir.join("mcp.json"), "{}").unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
workspace_mcp_config_file_in(root),
|
||||||
|
Some(ws_dir.join("mcp.json"))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial]
|
||||||
|
fn falls_back_to_claude_style_hidden_mcp_json() {
|
||||||
|
with_workspace_dir(|root, ws_dir| {
|
||||||
|
fs::write(ws_dir.join(".mcp.json"), "{}").unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
workspace_mcp_config_file_in(root),
|
||||||
|
Some(ws_dir.join(".mcp.json"))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial]
|
||||||
|
fn prefers_mcp_json_when_both_exist() {
|
||||||
|
with_workspace_dir(|root, ws_dir| {
|
||||||
|
fs::write(ws_dir.join("mcp.json"), "{}").unwrap();
|
||||||
|
fs::write(ws_dir.join(".mcp.json"), "{}").unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
workspace_mcp_config_file_in(root),
|
||||||
|
Some(ws_dir.join("mcp.json"))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial]
|
||||||
|
fn falls_back_to_project_root_hidden_mcp_json() {
|
||||||
|
with_workspace_dir(|root, _| {
|
||||||
|
fs::write(root.join(".mcp.json"), "{}").unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
workspace_mcp_config_file_in(root),
|
||||||
|
Some(root.join(".mcp.json"))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial]
|
||||||
|
fn prefers_workspace_dir_config_over_project_root() {
|
||||||
|
with_workspace_dir(|root, ws_dir| {
|
||||||
|
fs::write(ws_dir.join(".mcp.json"), "{}").unwrap();
|
||||||
|
fs::write(root.join(".mcp.json"), "{}").unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
workspace_mcp_config_file_in(root),
|
||||||
|
Some(ws_dir.join(".mcp.json"))
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ pub(in crate::config) const DEFAULT_SPAWN_INSTRUCTIONS: &str = indoc! {"
|
|||||||
| `agent__spawn` | Spawn a subagent in the background. Returns an `id` immediately. |
|
| `agent__spawn` | Spawn a subagent in the background. Returns an `id` immediately. |
|
||||||
| `agent__check` | Non-blocking check: is the agent done yet? Returns PENDING or result. |
|
| `agent__check` | Non-blocking check: is the agent done yet? Returns PENDING or result. |
|
||||||
| `agent__collect` | Blocking wait: wait for an agent to finish, return its output. |
|
| `agent__collect` | Blocking wait: wait for an agent to finish, return its output. |
|
||||||
| `agent__list` | List all spawned agents and their status. |
|
| `agent__list_available` | List all agent types you can spawn (name + description). Use this to discover specialists before calling `agent__spawn`. |
|
||||||
|
| `agent__list_running` | List all subagents YOU have spawned, with their status. |
|
||||||
| `agent__cancel` | Cancel a running agent by ID. |
|
| `agent__cancel` | Cancel a running agent by ID. |
|
||||||
| `agent__task_create` | Create a task in the dependency-aware task queue. |
|
| `agent__task_create` | Create a task in the dependency-aware task queue. |
|
||||||
| `agent__task_list` | List all tasks and their status/dependencies. |
|
| `agent__task_list` | List all tasks and their status/dependencies. |
|
||||||
@@ -206,7 +207,7 @@ pub(in crate::config) const DEFAULT_USER_INTERACTION_INSTRUCTIONS: &str = indoc!
|
|||||||
## User Interaction
|
## User Interaction
|
||||||
|
|
||||||
You have built-in tools to interact with the user directly:
|
You have built-in tools to interact with the user directly:
|
||||||
- `user__ask --question \"...\" --options [\"A\", \"B\", \"C\"]`: Present a selection prompt. Returns the chosen option.
|
- `user__select --question \"...\" --options [\"A\", \"B\", \"C\"]`: Present a single-select list of named options. Use this — not `user__confirm` — whenever there are 2+ named options. Returns the chosen option.
|
||||||
- `user__confirm --question \"...\"`: Ask a yes/no question. Returns \"yes\" or \"no\".
|
- `user__confirm --question \"...\"`: Ask a yes/no question. Returns \"yes\" or \"no\".
|
||||||
- `user__input --question \"...\"`: Request free-form text input from the user.
|
- `user__input --question \"...\"`: Request free-form text input from the user.
|
||||||
- `user__checkbox --question \"...\" --options [\"A\", \"B\", \"C\"]`: Multi-select prompt. Returns an array of selected options.
|
- `user__checkbox --question \"...\" --options [\"A\", \"B\", \"C\"]`: Multi-select prompt. Returns an array of selected options.
|
||||||
|
|||||||
+1060
-26
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,9 @@ pub trait RoleLike {
|
|||||||
fn enabled_mcp_servers(&self) -> Option<Vec<String>>;
|
fn enabled_mcp_servers(&self) -> Option<Vec<String>>;
|
||||||
fn set_model(&mut self, model: Model);
|
fn set_model(&mut self, model: Model);
|
||||||
fn set_temperature(&mut self, value: Option<f64>);
|
fn set_temperature(&mut self, value: Option<f64>);
|
||||||
|
fn reasoning_effort(&self) -> Option<String>;
|
||||||
fn set_top_p(&mut self, value: Option<f64>);
|
fn set_top_p(&mut self, value: Option<f64>);
|
||||||
|
fn set_reasoning_effort(&mut self, value: Option<String>);
|
||||||
fn set_enabled_tools(&mut self, value: Option<Vec<String>>);
|
fn set_enabled_tools(&mut self, value: Option<Vec<String>>);
|
||||||
fn set_enabled_mcp_servers(&mut self, value: Option<Vec<String>>);
|
fn set_enabled_mcp_servers(&mut self, value: Option<Vec<String>>);
|
||||||
}
|
}
|
||||||
@@ -51,6 +53,8 @@ pub struct Role {
|
|||||||
temperature: Option<f64>,
|
temperature: Option<f64>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
top_p: Option<f64>,
|
top_p: Option<f64>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
reasoning_effort: Option<String>,
|
||||||
#[serde(
|
#[serde(
|
||||||
default,
|
default,
|
||||||
skip_serializing_if = "Option::is_none",
|
skip_serializing_if = "Option::is_none",
|
||||||
@@ -116,6 +120,9 @@ impl Role {
|
|||||||
"model" => role.model_id = value.as_str().map(|v| v.to_string()),
|
"model" => role.model_id = value.as_str().map(|v| v.to_string()),
|
||||||
"temperature" => role.temperature = value.as_f64(),
|
"temperature" => role.temperature = value.as_f64(),
|
||||||
"top_p" => role.top_p = value.as_f64(),
|
"top_p" => role.top_p = value.as_f64(),
|
||||||
|
"reasoning_effort" => {
|
||||||
|
role.reasoning_effort = value.as_str().map(|v| v.to_string())
|
||||||
|
}
|
||||||
"enabled_tools" => role.enabled_tools = parse_string_or_array(value),
|
"enabled_tools" => role.enabled_tools = parse_string_or_array(value),
|
||||||
"enabled_mcp_servers" => {
|
"enabled_mcp_servers" => {
|
||||||
role.enabled_mcp_servers = parse_string_or_array(value)
|
role.enabled_mcp_servers = parse_string_or_array(value)
|
||||||
@@ -170,6 +177,9 @@ impl Role {
|
|||||||
if let Some(top_p) = self.top_p() {
|
if let Some(top_p) = self.top_p() {
|
||||||
metadata.push(format!("top_p: {top_p}"));
|
metadata.push(format!("top_p: {top_p}"));
|
||||||
}
|
}
|
||||||
|
if let Some(reasoning_effort) = self.reasoning_effort() {
|
||||||
|
metadata.push(format!("reasoning_effort: {reasoning_effort}"));
|
||||||
|
}
|
||||||
if let Some(enabled_tools) = &self.enabled_tools {
|
if let Some(enabled_tools) = &self.enabled_tools {
|
||||||
let inline = serde_json::to_string(enabled_tools).unwrap_or_else(|_| "[]".to_string());
|
let inline = serde_json::to_string(enabled_tools).unwrap_or_else(|_| "[]".to_string());
|
||||||
metadata.push(format!("enabled_tools: {inline}"));
|
metadata.push(format!("enabled_tools: {inline}"));
|
||||||
@@ -245,12 +255,14 @@ impl Role {
|
|||||||
|
|
||||||
pub fn sync<T: RoleLike>(&mut self, role_like: &T) {
|
pub fn sync<T: RoleLike>(&mut self, role_like: &T) {
|
||||||
let model = role_like.model();
|
let model = role_like.model();
|
||||||
|
let reasoning_effort = role_like.reasoning_effort();
|
||||||
let temperature = role_like.temperature();
|
let temperature = role_like.temperature();
|
||||||
let top_p = role_like.top_p();
|
let top_p = role_like.top_p();
|
||||||
let enabled_tools = role_like.enabled_tools();
|
let enabled_tools = role_like.enabled_tools();
|
||||||
let enabled_mcp_servers = role_like.enabled_mcp_servers();
|
let enabled_mcp_servers = role_like.enabled_mcp_servers();
|
||||||
self.batch_set(
|
self.batch_set(
|
||||||
model,
|
model,
|
||||||
|
reasoning_effort,
|
||||||
temperature,
|
temperature,
|
||||||
top_p,
|
top_p,
|
||||||
enabled_tools,
|
enabled_tools,
|
||||||
@@ -261,12 +273,16 @@ impl Role {
|
|||||||
pub fn batch_set(
|
pub fn batch_set(
|
||||||
&mut self,
|
&mut self,
|
||||||
model: &Model,
|
model: &Model,
|
||||||
|
reasoning_effort: Option<String>,
|
||||||
temperature: Option<f64>,
|
temperature: Option<f64>,
|
||||||
top_p: Option<f64>,
|
top_p: Option<f64>,
|
||||||
enabled_tools: Option<Vec<String>>,
|
enabled_tools: Option<Vec<String>>,
|
||||||
enabled_mcp_servers: Option<Vec<String>>,
|
enabled_mcp_servers: Option<Vec<String>>,
|
||||||
) {
|
) {
|
||||||
self.set_model(model.clone());
|
self.set_model(model.clone());
|
||||||
|
if reasoning_effort.is_some() {
|
||||||
|
self.set_reasoning_effort(reasoning_effort.clone());
|
||||||
|
}
|
||||||
if temperature.is_some() {
|
if temperature.is_some() {
|
||||||
self.set_temperature(temperature);
|
self.set_temperature(temperature);
|
||||||
}
|
}
|
||||||
@@ -410,6 +426,10 @@ impl RoleLike for Role {
|
|||||||
self.top_p
|
self.top_p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reasoning_effort(&self) -> Option<String> {
|
||||||
|
self.reasoning_effort.clone()
|
||||||
|
}
|
||||||
|
|
||||||
fn enabled_tools(&self) -> Option<Vec<String>> {
|
fn enabled_tools(&self) -> Option<Vec<String>> {
|
||||||
self.enabled_tools.clone()
|
self.enabled_tools.clone()
|
||||||
}
|
}
|
||||||
@@ -433,6 +453,10 @@ impl RoleLike for Role {
|
|||||||
self.top_p = value;
|
self.top_p = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_reasoning_effort(&mut self, value: Option<String>) {
|
||||||
|
self.reasoning_effort = value;
|
||||||
|
}
|
||||||
|
|
||||||
fn set_enabled_tools(&mut self, value: Option<Vec<String>>) {
|
fn set_enabled_tools(&mut self, value: Option<Vec<String>>) {
|
||||||
self.enabled_tools = value;
|
self.enabled_tools = value;
|
||||||
}
|
}
|
||||||
|
|||||||
+78
-9
@@ -24,6 +24,8 @@ pub struct Session {
|
|||||||
temperature: Option<f64>,
|
temperature: Option<f64>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
top_p: Option<f64>,
|
top_p: Option<f64>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
reasoning_effort: Option<String>,
|
||||||
#[serde(
|
#[serde(
|
||||||
default,
|
default,
|
||||||
skip_serializing_if = "Option::is_none",
|
skip_serializing_if = "Option::is_none",
|
||||||
@@ -175,6 +177,14 @@ impl Session {
|
|||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_name(&mut self, name: String) {
|
||||||
|
self.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn clear_autoname(&mut self) {
|
||||||
|
self.autoname = None;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn role_name(&self) -> Option<&str> {
|
pub fn role_name(&self) -> Option<&str> {
|
||||||
self.role_name.as_deref()
|
self.role_name.as_deref()
|
||||||
}
|
}
|
||||||
@@ -261,7 +271,7 @@ impl Session {
|
|||||||
data["messages"] = json!(self.messages);
|
data["messages"] = json!(self.messages);
|
||||||
|
|
||||||
let output = serde_yaml::to_string(&data)
|
let output = serde_yaml::to_string(&data)
|
||||||
.with_context(|| format!("Unable to show info about session '{}'", &self.name))?;
|
.with_context(|| format!("Unable to show info about session '{}'", self.name))?;
|
||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,14 +368,24 @@ impl Session {
|
|||||||
for message in &self.messages {
|
for message in &self.messages {
|
||||||
match message.role {
|
match message.role {
|
||||||
MessageRole::System => {
|
MessageRole::System => {
|
||||||
lines.push(
|
let body = render
|
||||||
render
|
.render(&message.content.render_input(resolve_url_fn, agent_info));
|
||||||
.render(&message.content.render_input(resolve_url_fn, agent_info)),
|
let tail = render.finalize();
|
||||||
);
|
if tail.is_empty() {
|
||||||
|
lines.push(body);
|
||||||
|
} else {
|
||||||
|
lines.push(format!("{body}\n{tail}"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MessageRole::Assistant => {
|
MessageRole::Assistant => {
|
||||||
if let MessageContent::Text(text) = &message.content {
|
if let MessageContent::Text(text) = &message.content {
|
||||||
lines.push(render.render(text));
|
let body = render.render(text);
|
||||||
|
let tail = render.finalize();
|
||||||
|
if tail.is_empty() {
|
||||||
|
lines.push(body);
|
||||||
|
} else {
|
||||||
|
lines.push(format!("{body}\n{tail}"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lines.push("".into());
|
lines.push("".into());
|
||||||
}
|
}
|
||||||
@@ -401,6 +421,7 @@ impl Session {
|
|||||||
self.model_id = role.model().id();
|
self.model_id = role.model().id();
|
||||||
self.temperature = role.temperature();
|
self.temperature = role.temperature();
|
||||||
self.top_p = role.top_p();
|
self.top_p = role.top_p();
|
||||||
|
self.reasoning_effort = role.reasoning_effort();
|
||||||
self.enabled_tools = role.enabled_tools();
|
self.enabled_tools = role.enabled_tools();
|
||||||
self.enabled_mcp_servers = role.enabled_mcp_servers();
|
self.enabled_mcp_servers = role.enabled_mcp_servers();
|
||||||
self.model = role.model().clone();
|
self.model = role.model().clone();
|
||||||
@@ -549,7 +570,7 @@ impl Session {
|
|||||||
self.compressing = compressing;
|
self.compressing = compressing;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compress(&mut self, mut prompt: String) {
|
pub fn compress(&mut self, mut prompt: String, keep_last: usize) {
|
||||||
if let Some(system_prompt) = self.messages.first().and_then(|v| {
|
if let Some(system_prompt) = self.messages.first().and_then(|v| {
|
||||||
if MessageRole::System == v.role {
|
if MessageRole::System == v.role {
|
||||||
let content = v.content.to_text();
|
let content = v.content.to_text();
|
||||||
@@ -561,11 +582,17 @@ impl Session {
|
|||||||
}) {
|
}) {
|
||||||
prompt = format!("{system_prompt}\n\n{prompt}",);
|
prompt = format!("{system_prompt}\n\n{prompt}",);
|
||||||
}
|
}
|
||||||
|
let messages_to_keep = if keep_last > 0 && keep_last < self.messages.len() {
|
||||||
|
self.messages.split_off(self.messages.len() - keep_last)
|
||||||
|
} else {
|
||||||
|
vec![]
|
||||||
|
};
|
||||||
self.compressed_messages.append(&mut self.messages);
|
self.compressed_messages.append(&mut self.messages);
|
||||||
self.messages.push(Message::new(
|
self.messages.push(Message::new(
|
||||||
MessageRole::System,
|
MessageRole::System,
|
||||||
MessageContent::Text(prompt),
|
MessageContent::Text(prompt),
|
||||||
));
|
));
|
||||||
|
self.messages.extend(messages_to_keep);
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
self.update_tokens();
|
self.update_tokens();
|
||||||
}
|
}
|
||||||
@@ -672,6 +699,19 @@ impl Session {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn flush(&mut self) -> Result<()> {
|
||||||
|
if !self.dirty {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(path) = self.path.clone() {
|
||||||
|
let name = self.name.clone();
|
||||||
|
self.save(&name, Path::new(&path), false)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn guard_empty(&self) -> Result<()> {
|
pub fn guard_empty(&self) -> Result<()> {
|
||||||
if !self.is_empty() {
|
if !self.is_empty() {
|
||||||
bail!(
|
bail!(
|
||||||
@@ -732,6 +772,15 @@ impl Session {
|
|||||||
self.update_tokens();
|
self.update_tokens();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn pop_last_exchange(&mut self) -> Option<String> {
|
||||||
|
let user_idx = self.messages.iter().rposition(|m| m.role.is_user())?;
|
||||||
|
let user_text = self.messages[user_idx].content.as_text()?.to_string();
|
||||||
|
self.messages.truncate(user_idx);
|
||||||
|
self.dirty = true;
|
||||||
|
self.update_tokens();
|
||||||
|
Some(user_text)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn echo_messages(&self, input: &Input) -> String {
|
pub fn echo_messages(&self, input: &Input) -> String {
|
||||||
let messages = self.build_messages(input);
|
let messages = self.build_messages(input);
|
||||||
serde_yaml::to_string(&messages).unwrap_or_else(|_| "Unable to echo message".into())
|
serde_yaml::to_string(&messages).unwrap_or_else(|_| "Unable to echo message".into())
|
||||||
@@ -783,6 +832,10 @@ impl RoleLike for Session {
|
|||||||
self.top_p
|
self.top_p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reasoning_effort(&self) -> Option<String> {
|
||||||
|
self.reasoning_effort.clone()
|
||||||
|
}
|
||||||
|
|
||||||
fn enabled_tools(&self) -> Option<Vec<String>> {
|
fn enabled_tools(&self) -> Option<Vec<String>> {
|
||||||
self.enabled_tools.clone()
|
self.enabled_tools.clone()
|
||||||
}
|
}
|
||||||
@@ -814,6 +867,13 @@ impl RoleLike for Session {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_reasoning_effort(&mut self, value: Option<String>) {
|
||||||
|
if self.reasoning_effort != value {
|
||||||
|
self.reasoning_effort = value;
|
||||||
|
self.dirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn set_enabled_tools(&mut self, value: Option<Vec<String>>) {
|
fn set_enabled_tools(&mut self, value: Option<Vec<String>>) {
|
||||||
if self.enabled_tools != value {
|
if self.enabled_tools != value {
|
||||||
self.enabled_tools = value;
|
self.enabled_tools = value;
|
||||||
@@ -991,7 +1051,7 @@ mod tests {
|
|||||||
assert_eq!(session.messages.len(), 2);
|
assert_eq!(session.messages.len(), 2);
|
||||||
assert!(session.compressed_messages.is_empty());
|
assert!(session.compressed_messages.is_empty());
|
||||||
|
|
||||||
session.compress("Summary of conversation".to_string());
|
session.compress("Summary of conversation".to_string(), 0);
|
||||||
|
|
||||||
assert!(!session.compressed_messages.is_empty());
|
assert!(!session.compressed_messages.is_empty());
|
||||||
assert_eq!(session.messages.len(), 1);
|
assert_eq!(session.messages.len(), 1);
|
||||||
@@ -1006,7 +1066,7 @@ mod tests {
|
|||||||
MessageContent::Text("hello".to_string()),
|
MessageContent::Text("hello".to_string()),
|
||||||
));
|
));
|
||||||
|
|
||||||
session.compress("Summary".to_string());
|
session.compress("Summary".to_string(), 0);
|
||||||
|
|
||||||
assert!(!session.is_empty());
|
assert!(!session.is_empty());
|
||||||
}
|
}
|
||||||
@@ -1023,4 +1083,13 @@ mod tests {
|
|||||||
session.set_autonaming(true);
|
session.set_autonaming(true);
|
||||||
assert!(!session.need_autoname());
|
assert!(!session.need_autoname());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn session_set_name_updates_name() {
|
||||||
|
let mut session = Session::default();
|
||||||
|
|
||||||
|
session.set_name("my-fork".to_string());
|
||||||
|
|
||||||
|
assert_eq!(session.name(), "my-fork");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -117,7 +117,11 @@ impl Skill {
|
|||||||
|
|
||||||
pub fn load(name: &str) -> Result<Self> {
|
pub fn load(name: &str) -> Result<Self> {
|
||||||
paths::validate_skill_name(name)?;
|
paths::validate_skill_name(name)?;
|
||||||
let path = paths::skill_file(name);
|
let path = if paths::workspace_skill_file(name).is_file() {
|
||||||
|
paths::workspace_skill_file(name)
|
||||||
|
} else {
|
||||||
|
paths::skill_file(name)
|
||||||
|
};
|
||||||
let content = read_to_string(&path)
|
let content = read_to_string(&path)
|
||||||
.with_context(|| format!("Failed to read skill '{name}' at {}", path.display()))?;
|
.with_context(|| format!("Failed to read skill '{name}' at {}", path.display()))?;
|
||||||
Ok(Skill::new(name, &content))
|
Ok(Skill::new(name, &content))
|
||||||
|
|||||||
+20
-34
@@ -321,7 +321,7 @@ pub fn handle_memory_tool(ctx: &mut RequestContext, cmd_name: &str, args: &Value
|
|||||||
|
|
||||||
Ok(json!({
|
Ok(json!({
|
||||||
"files": entries,
|
"files": entries,
|
||||||
"global_index_exists": paths::global_memory_index_path().exists(),
|
"global_index_exists": paths::global_memory_index_file().exists(),
|
||||||
"workspace": store.workspace.as_ref().map(workspace_label),
|
"workspace": store.workspace.as_ref().map(workspace_label),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@@ -474,7 +474,7 @@ fn rename_memory(store: &MemoryStore, cwd: &Path, args: &Value) -> Result<Value>
|
|||||||
let description = renamed.frontmatter.description.clone().unwrap_or_default();
|
let description = renamed.frontmatter.description.clone().unwrap_or_default();
|
||||||
ensure_index_entry(&index_path, &new_name, &description)?;
|
ensure_index_entry(&index_path, &new_name, &description)?;
|
||||||
|
|
||||||
// Other indexes (other scope's MEMORY.md, lite COYOTE.md): rewrite wikilinks only.
|
// Other indexes (other scope's MEMORY.md): rewrite wikilinks only.
|
||||||
for other_index in other_index_paths(store, &target_dir) {
|
for other_index in other_index_paths(store, &target_dir) {
|
||||||
if let Ok(existing) = fs::read_to_string(&other_index)
|
if let Ok(existing) = fs::read_to_string(&other_index)
|
||||||
&& existing.contains(&needle)
|
&& existing.contains(&needle)
|
||||||
@@ -539,17 +539,11 @@ fn other_index_paths(store: &MemoryStore, own_dir: &Path) -> Vec<PathBuf> {
|
|||||||
out.push(global_index);
|
out.push(global_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
match &store.workspace {
|
if let Some(ws) = &store.workspace {
|
||||||
Some(WorkspaceMemory::Structured { dir, .. }) => {
|
let index = ws.dir.join("MEMORY.md");
|
||||||
let index = dir.join("MEMORY.md");
|
if ws.dir.as_path() != own_dir && index.exists() {
|
||||||
if dir.as_path() != own_dir && index.exists() {
|
out.push(index);
|
||||||
out.push(index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Some(WorkspaceMemory::Lite { file, .. }) if file.exists() => {
|
|
||||||
out.push(file.clone());
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out
|
out
|
||||||
@@ -637,10 +631,7 @@ fn find_file(store: &MemoryStore, name: &str) -> Result<Option<MemoryFile>> {
|
|||||||
|
|
||||||
fn workspace_write_dir(store: &MemoryStore, cwd: &Path) -> Result<PathBuf> {
|
fn workspace_write_dir(store: &MemoryStore, cwd: &Path) -> Result<PathBuf> {
|
||||||
match &store.workspace {
|
match &store.workspace {
|
||||||
Some(WorkspaceMemory::Structured { dir, .. }) => Ok(dir.clone()),
|
Some(ws) => Ok(ws.dir.clone()),
|
||||||
Some(WorkspaceMemory::Lite { workspace_root, .. }) => {
|
|
||||||
Ok(paths::workspace_memory_dir_for(workspace_root))
|
|
||||||
}
|
|
||||||
None => match find_git_root(cwd) {
|
None => match find_git_root(cwd) {
|
||||||
Some(git_root) => bootstrap_workspace_memory(&git_root),
|
Some(git_root) => bootstrap_workspace_memory(&git_root),
|
||||||
None => bail!(
|
None => bail!(
|
||||||
@@ -652,20 +643,10 @@ fn workspace_write_dir(store: &MemoryStore, cwd: &Path) -> Result<PathBuf> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn workspace_label(w: &WorkspaceMemory) -> Value {
|
fn workspace_label(w: &WorkspaceMemory) -> Value {
|
||||||
match w {
|
json!({
|
||||||
WorkspaceMemory::Structured { workspace_root, .. } => json!({
|
"root": w.workspace_root.display().to_string(),
|
||||||
"mode": "structured",
|
"dir": w.dir.display().to_string(),
|
||||||
"root": workspace_root.display().to_string(),
|
})
|
||||||
}),
|
|
||||||
WorkspaceMemory::Lite {
|
|
||||||
workspace_root,
|
|
||||||
file,
|
|
||||||
} => json!({
|
|
||||||
"mode": "lite",
|
|
||||||
"root": workspace_root.display().to_string(),
|
|
||||||
"file": file.display().to_string(),
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lint_memory(store: &MemoryStore) -> Result<Value> {
|
fn lint_memory(store: &MemoryStore) -> Result<Value> {
|
||||||
@@ -872,19 +853,24 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn workspace_write_dir_promotes_lite_to_structured_subdir() {
|
fn workspace_write_dir_treats_root_instructions_file_as_no_memory() {
|
||||||
let root = temp_root("ws_lite_promote");
|
let root = temp_root("ws_instructions_only");
|
||||||
let workspace = root.join("ws");
|
let workspace = root.join("ws");
|
||||||
fs::create_dir_all(&workspace).unwrap();
|
fs::create_dir_all(workspace.join(".git")).unwrap();
|
||||||
fs::write(workspace.join("COYOTE.md"), "lite").unwrap();
|
fs::write(workspace.join("COYOTE.md"), "instructions, not memory").unwrap();
|
||||||
|
|
||||||
let store = MemoryStore {
|
let store = MemoryStore {
|
||||||
global_dir: root.join("g"),
|
global_dir: root.join("g"),
|
||||||
workspace: discover_workspace_memory(&workspace),
|
workspace: discover_workspace_memory(&workspace),
|
||||||
};
|
};
|
||||||
|
assert!(store.workspace.is_none(), "COYOTE.md must not be memory");
|
||||||
|
|
||||||
let dir = workspace_write_dir(&store, &workspace).unwrap();
|
let dir = workspace_write_dir(&store, &workspace).unwrap();
|
||||||
assert_eq!(dir, workspace.join(".coyote").join("memory"));
|
assert_eq!(dir, workspace.join(".coyote").join("memory"));
|
||||||
|
assert!(
|
||||||
|
dir.join("MEMORY.md").exists(),
|
||||||
|
"bootstrap must create index"
|
||||||
|
);
|
||||||
|
|
||||||
let _ = fs::remove_dir_all(&root);
|
let _ = fs::remove_dir_all(&root);
|
||||||
}
|
}
|
||||||
|
|||||||
+276
-36
@@ -5,6 +5,7 @@ pub(crate) mod todo;
|
|||||||
pub(crate) mod user_interaction;
|
pub(crate) mod user_interaction;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
client::ThinkingBlock,
|
||||||
config::{Agent, RequestContext},
|
config::{Agent, RequestContext},
|
||||||
graph,
|
graph,
|
||||||
utils::*,
|
utils::*,
|
||||||
@@ -18,6 +19,7 @@ use crate::mcp::{
|
|||||||
};
|
};
|
||||||
use crate::parsers::{bash, python, typescript};
|
use crate::parsers::{bash, python, typescript};
|
||||||
use anyhow::{Context, Result, anyhow, bail};
|
use anyhow::{Context, Result, anyhow, bail};
|
||||||
|
use futures_util::future;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use indoc::formatdoc;
|
use indoc::formatdoc;
|
||||||
use memory::MEMORY_FUNCTION_PREFIX;
|
use memory::MEMORY_FUNCTION_PREFIX;
|
||||||
@@ -29,6 +31,7 @@ use std::collections::VecDeque;
|
|||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
use std::sync::atomic::Ordering;
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
env, fs, io,
|
env, fs, io,
|
||||||
@@ -144,31 +147,54 @@ pub async fn eval_tool_calls(
|
|||||||
if calls.is_empty() {
|
if calls.is_empty() {
|
||||||
bail!("The request was aborted because an infinite loop of function calls was detected.")
|
bail!("The request was aborted because an infinite loop of function calls was detected.")
|
||||||
}
|
}
|
||||||
let mut is_all_null = true;
|
let mut to_execute: Vec<(usize, ToolCall)> = Vec::with_capacity(calls.len());
|
||||||
for call in calls {
|
let mut indexed_results: Vec<(usize, ToolResult)> = vec![];
|
||||||
|
for (idx, call) in calls.into_iter().enumerate() {
|
||||||
if let Some(msg) = ctx.tool_scope.tool_tracker.check_loop(&call.clone()) {
|
if let Some(msg) = ctx.tool_scope.tool_tracker.check_loop(&call.clone()) {
|
||||||
let dup_msg = format!("{{\"tool_call_loop_alert\":{}}}", &msg.trim());
|
let dup_msg = format!("{{\"tool_call_loop_alert\":{}}}", msg.trim());
|
||||||
println!(
|
println!(
|
||||||
"{}",
|
"{}",
|
||||||
warning_text(format!("{}: ⚠️ Tool-call loop detected! ⚠️", &call.name).as_str())
|
muted_warning_text(
|
||||||
|
format!("{}: ⚠️ Tool-call loop detected! ⚠️", call.name).as_str()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
let val = json!(dup_msg);
|
indexed_results.push((idx, ToolResult::new(call, json!(dup_msg))));
|
||||||
output.push(ToolResult::new(call, val));
|
|
||||||
is_all_null = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
let mut result = call.eval(ctx).await?;
|
|
||||||
if result.is_null() {
|
|
||||||
result = json!("DONE");
|
|
||||||
} else {
|
} else {
|
||||||
is_all_null = false;
|
to_execute.push((idx, call));
|
||||||
}
|
}
|
||||||
output.push(ToolResult::new(call, result));
|
|
||||||
}
|
}
|
||||||
if is_all_null {
|
|
||||||
output = vec![];
|
let (mcp_calls, sequential_calls): (Vec<_>, Vec<_>) =
|
||||||
|
to_execute.into_iter().partition(|(_, call)| {
|
||||||
|
call.name.starts_with(MCP_INVOKE_META_FUNCTION_NAME_PREFIX)
|
||||||
|
|| call.name.starts_with(MCP_SEARCH_META_FUNCTION_NAME_PREFIX)
|
||||||
|
|| call
|
||||||
|
.name
|
||||||
|
.starts_with(MCP_DESCRIBE_META_FUNCTION_NAME_PREFIX)
|
||||||
|
});
|
||||||
|
|
||||||
|
if !mcp_calls.is_empty() {
|
||||||
|
let ctx_ref: &RequestContext = ctx;
|
||||||
|
let futs: Vec<_> = mcp_calls
|
||||||
|
.into_iter()
|
||||||
|
.map(|(idx, call)| async move {
|
||||||
|
let result = call.eval_mcp(ctx_ref).await;
|
||||||
|
(idx, call, result)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
for (idx, call, result) in future::join_all(futs).await {
|
||||||
|
indexed_results.push((idx, ToolResult::new(call, normalize_tool_result(result?))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (idx, call) in sequential_calls {
|
||||||
|
let result = call.eval(ctx).await?;
|
||||||
|
indexed_results.push((idx, ToolResult::new(call, normalize_tool_result(result))));
|
||||||
|
}
|
||||||
|
|
||||||
|
indexed_results.sort_unstable_by_key(|(idx, _)| *idx);
|
||||||
|
output = indexed_results.into_iter().map(|(_, r)| r).collect();
|
||||||
|
|
||||||
if !output.is_empty() {
|
if !output.is_empty() {
|
||||||
let (has_escalations, summary) = if ctx.current_depth == 0
|
let (has_escalations, summary) = if ctx.current_depth == 0
|
||||||
&& let Some(queue) = ctx.root_escalation_queue()
|
&& let Some(queue) = ctx.root_escalation_queue()
|
||||||
@@ -193,18 +219,65 @@ pub async fn eval_tool_calls(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let max_chars = ctx
|
||||||
|
.agent
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|a| a.max_tool_result_chars())
|
||||||
|
.or_else(|| ctx.app.config.max_tool_result_chars);
|
||||||
|
if let Some(max_chars) = max_chars.filter(|&n| n > 0) {
|
||||||
|
output = output
|
||||||
|
.into_iter()
|
||||||
|
.map(|r| r.truncate_if_needed(max_chars))
|
||||||
|
.collect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Tools that succeed silently (e.g. `mkdir -p` via execute_command) evaluate to
|
||||||
|
/// `Null`. Substitute a concrete `"DONE"` marker so every call produces a
|
||||||
|
/// `ToolResult`: agentic loops (graph llm nodes, spawned agents, the REPL) treat
|
||||||
|
/// an empty `tool_results` as "the LLM concluded", so dropping silent results
|
||||||
|
/// would prematurely terminate a turn that called only silent tools.
|
||||||
|
fn normalize_tool_result(result: Value) -> Value {
|
||||||
|
if result.is_null() {
|
||||||
|
json!("DONE")
|
||||||
|
} else {
|
||||||
|
result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct ToolResult {
|
pub struct ToolResult {
|
||||||
pub call: ToolCall,
|
pub call: ToolCall,
|
||||||
pub output: Value,
|
pub output: Value,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub text: Option<String>,
|
||||||
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
|
pub thinking: Vec<ThinkingBlock>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToolResult {
|
impl ToolResult {
|
||||||
pub fn new(call: ToolCall, output: Value) -> Self {
|
pub fn new(call: ToolCall, output: Value) -> Self {
|
||||||
Self { call, output }
|
Self {
|
||||||
|
call,
|
||||||
|
output,
|
||||||
|
text: None,
|
||||||
|
thinking: vec![],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn truncate_if_needed(mut self, max_chars: usize) -> Self {
|
||||||
|
let s = self.output.to_string();
|
||||||
|
if s.len() > max_chars {
|
||||||
|
let prefix = s.get(..max_chars).unwrap_or(s.as_str());
|
||||||
|
self.output = json!(format!(
|
||||||
|
"[truncated: tool output exceeded {max_chars} chars]\n{prefix}"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -730,7 +803,7 @@ impl Functions {
|
|||||||
let root_dir = paths::functions_dir();
|
let root_dir = paths::functions_dir();
|
||||||
let tool_path = format!(
|
let tool_path = format!(
|
||||||
"{}/{binary_name}",
|
"{}/{binary_name}",
|
||||||
&paths::global_tools_dir().to_string_lossy()
|
paths::global_tools_dir().to_string_lossy()
|
||||||
);
|
);
|
||||||
content_template
|
content_template
|
||||||
.replace("{function_name}", binary_name)
|
.replace("{function_name}", binary_name)
|
||||||
@@ -741,7 +814,7 @@ impl Functions {
|
|||||||
let root_dir = paths::agent_data_dir(agent_name);
|
let root_dir = paths::agent_data_dir(agent_name);
|
||||||
let tool_path = format!(
|
let tool_path = format!(
|
||||||
"{}/{binary_name}",
|
"{}/{binary_name}",
|
||||||
&paths::global_tools_dir().to_string_lossy()
|
paths::global_tools_dir().to_string_lossy()
|
||||||
);
|
);
|
||||||
content_template
|
content_template
|
||||||
.replace("{function_name}", binary_name)
|
.replace("{function_name}", binary_name)
|
||||||
@@ -870,7 +943,7 @@ impl Functions {
|
|||||||
let root_dir = paths::functions_dir();
|
let root_dir = paths::functions_dir();
|
||||||
let tool_path = format!(
|
let tool_path = format!(
|
||||||
"{}/{binary_name}",
|
"{}/{binary_name}",
|
||||||
&paths::global_tools_dir().to_string_lossy()
|
paths::global_tools_dir().to_string_lossy()
|
||||||
);
|
);
|
||||||
content_template
|
content_template
|
||||||
.replace("{function_name}", binary_name)
|
.replace("{function_name}", binary_name)
|
||||||
@@ -881,7 +954,7 @@ impl Functions {
|
|||||||
let root_dir = paths::agent_data_dir(agent_name);
|
let root_dir = paths::agent_data_dir(agent_name);
|
||||||
let tool_path = format!(
|
let tool_path = format!(
|
||||||
"{}/{binary_name}",
|
"{}/{binary_name}",
|
||||||
&paths::global_tools_dir().to_string_lossy()
|
paths::global_tools_dir().to_string_lossy()
|
||||||
);
|
);
|
||||||
content_template
|
content_template
|
||||||
.replace("{function_name}", binary_name)
|
.replace("{function_name}", binary_name)
|
||||||
@@ -1024,6 +1097,62 @@ impl ToolCall {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_arguments(&self) -> Result<Value> {
|
||||||
|
if self.arguments.is_object() {
|
||||||
|
Ok(self.arguments.clone())
|
||||||
|
} else if let Some(arguments) = self.arguments.as_str() {
|
||||||
|
serde_json::from_str(arguments).map_err(|_| {
|
||||||
|
anyhow!(
|
||||||
|
"The call '{}' has invalid arguments: {arguments}",
|
||||||
|
self.name
|
||||||
|
)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
bail!(
|
||||||
|
"The call '{}' has invalid arguments: {}",
|
||||||
|
self.name,
|
||||||
|
self.arguments
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn eval_mcp(&self, ctx: &RequestContext) -> Result<Value> {
|
||||||
|
let json_data = self.parse_arguments()?;
|
||||||
|
let cmd_name = self.name.as_str();
|
||||||
|
if *IS_STDOUT_TERMINAL && ctx.current_depth == 0 && !HEADLESS.load(Ordering::SeqCst) {
|
||||||
|
println!(
|
||||||
|
"{}",
|
||||||
|
format_call_log(cmd_name, &[json_data.to_string()], &json_data)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
let result = if cmd_name.starts_with(MCP_SEARCH_META_FUNCTION_NAME_PREFIX) {
|
||||||
|
Self::search_mcp_tools(ctx, cmd_name, &json_data)
|
||||||
|
.await
|
||||||
|
.unwrap_or_else(|e| {
|
||||||
|
let error_msg = format!("MCP search failed: {e}");
|
||||||
|
eprintln!("{}", muted_warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
||||||
|
json!({"tool_call_error": error_msg})
|
||||||
|
})
|
||||||
|
} else if cmd_name.starts_with(MCP_DESCRIBE_META_FUNCTION_NAME_PREFIX) {
|
||||||
|
Self::describe_mcp_tool(ctx, cmd_name, json_data.clone())
|
||||||
|
.await
|
||||||
|
.unwrap_or_else(|e| {
|
||||||
|
let error_msg = format!("MCP describe failed: {e}");
|
||||||
|
eprintln!("{}", muted_warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
||||||
|
json!({"tool_call_error": error_msg})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Self::invoke_mcp_tool(ctx, cmd_name, &json_data)
|
||||||
|
.await
|
||||||
|
.unwrap_or_else(|e| {
|
||||||
|
let error_msg = format!("MCP tool invocation failed: {e}");
|
||||||
|
eprintln!("{}", muted_warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
||||||
|
json!({"tool_call_error": error_msg})
|
||||||
|
})
|
||||||
|
};
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn eval(&self, ctx: &mut RequestContext) -> Result<Value> {
|
pub async fn eval(&self, ctx: &mut RequestContext) -> Result<Value> {
|
||||||
let agent = ctx.agent.clone();
|
let agent = ctx.agent.clone();
|
||||||
let functions = ctx.tool_scope.functions.clone();
|
let functions = ctx.tool_scope.functions.clone();
|
||||||
@@ -1050,10 +1179,8 @@ impl ToolCall {
|
|||||||
|
|
||||||
cmd_args.push(json_data.to_string());
|
cmd_args.push(json_data.to_string());
|
||||||
|
|
||||||
let prompt = format!("Call {cmd_name} {}", cmd_args.join(" "));
|
if *IS_STDOUT_TERMINAL && current_depth == 0 && !HEADLESS.load(Ordering::SeqCst) {
|
||||||
|
println!("{}", format_call_log(&cmd_name, &cmd_args, &json_data));
|
||||||
if *IS_STDOUT_TERMINAL && current_depth == 0 {
|
|
||||||
println!("{}", dimmed_text(&prompt));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let output = match cmd_name.as_str() {
|
let output = match cmd_name.as_str() {
|
||||||
@@ -1062,7 +1189,7 @@ impl ToolCall {
|
|||||||
.await
|
.await
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
let error_msg = format!("MCP search failed: {e}");
|
let error_msg = format!("MCP search failed: {e}");
|
||||||
eprintln!("{}", warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
eprintln!("{}", muted_warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
||||||
json!({"tool_call_error": error_msg})
|
json!({"tool_call_error": error_msg})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1071,7 +1198,7 @@ impl ToolCall {
|
|||||||
.await
|
.await
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
let error_msg = format!("MCP describe failed: {e}");
|
let error_msg = format!("MCP describe failed: {e}");
|
||||||
eprintln!("{}", warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
eprintln!("{}", muted_warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
||||||
json!({"tool_call_error": error_msg})
|
json!({"tool_call_error": error_msg})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1080,21 +1207,21 @@ impl ToolCall {
|
|||||||
.await
|
.await
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
let error_msg = format!("MCP tool invocation failed: {e}");
|
let error_msg = format!("MCP tool invocation failed: {e}");
|
||||||
eprintln!("{}", warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
eprintln!("{}", muted_warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
||||||
json!({"tool_call_error": error_msg})
|
json!({"tool_call_error": error_msg})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_ if cmd_name.starts_with(TODO_FUNCTION_PREFIX) => {
|
_ if cmd_name.starts_with(TODO_FUNCTION_PREFIX) => {
|
||||||
todo::handle_todo_tool(ctx, &cmd_name, &json_data).unwrap_or_else(|e| {
|
todo::handle_todo_tool(ctx, &cmd_name, &json_data).unwrap_or_else(|e| {
|
||||||
let error_msg = format!("Todo tool failed: {e}");
|
let error_msg = format!("Todo tool failed: {e}");
|
||||||
eprintln!("{}", warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
eprintln!("{}", muted_warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
||||||
json!({"tool_call_error": error_msg})
|
json!({"tool_call_error": error_msg})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_ if cmd_name.starts_with(MEMORY_FUNCTION_PREFIX) => {
|
_ if cmd_name.starts_with(MEMORY_FUNCTION_PREFIX) => {
|
||||||
memory::handle_memory_tool(ctx, &cmd_name, &json_data).unwrap_or_else(|e| {
|
memory::handle_memory_tool(ctx, &cmd_name, &json_data).unwrap_or_else(|e| {
|
||||||
let error_msg = format!("Memory tool failed: {e}");
|
let error_msg = format!("Memory tool failed: {e}");
|
||||||
eprintln!("{}", warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
eprintln!("{}", muted_warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
||||||
json!({"tool_call_error": error_msg})
|
json!({"tool_call_error": error_msg})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1103,7 +1230,7 @@ impl ToolCall {
|
|||||||
.await
|
.await
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
let error_msg = format!("Skill tool failed: {e}");
|
let error_msg = format!("Skill tool failed: {e}");
|
||||||
eprintln!("{}", warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
eprintln!("{}", muted_warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
||||||
json!({"tool_call_error": error_msg})
|
json!({"tool_call_error": error_msg})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1112,7 +1239,7 @@ impl ToolCall {
|
|||||||
.await
|
.await
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
let error_msg = format!("Supervisor tool failed: {e}");
|
let error_msg = format!("Supervisor tool failed: {e}");
|
||||||
eprintln!("{}", warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
eprintln!("{}", muted_warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
||||||
json!({"tool_call_error": error_msg})
|
json!({"tool_call_error": error_msg})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1121,7 +1248,7 @@ impl ToolCall {
|
|||||||
.await
|
.await
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
let error_msg = format!("User interaction failed: {e}");
|
let error_msg = format!("User interaction failed: {e}");
|
||||||
eprintln!("{}", warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
eprintln!("{}", muted_warning_text(&format!("⚠️ {error_msg} ⚠️")));
|
||||||
json!({"tool_call_error": error_msg})
|
json!({"tool_call_error": error_msg})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1381,7 +1508,10 @@ pub fn run_llm_function(
|
|||||||
let stderr = String::from_utf8_lossy(&stderr_bytes).trim().to_string();
|
let stderr = String::from_utf8_lossy(&stderr_bytes).trim().to_string();
|
||||||
let stdout = String::from_utf8_lossy(&stdout_bytes).trim().to_string();
|
let stdout = String::from_utf8_lossy(&stdout_bytes).trim().to_string();
|
||||||
let tool_error_message = format!("Tool call '{command_name}' exited with code {exit_code}");
|
let tool_error_message = format!("Tool call '{command_name}' exited with code {exit_code}");
|
||||||
eprintln!("{}", warning_text(&format!("⚠️ {tool_error_message} ⚠️")));
|
eprintln!(
|
||||||
|
"{}",
|
||||||
|
muted_warning_text(&format!("⚠️ {tool_error_message} ⚠️"))
|
||||||
|
);
|
||||||
let mut error_json = json!({"tool_call_error": tool_error_message});
|
let mut error_json = json!({"tool_call_error": tool_error_message});
|
||||||
if !stderr.is_empty() {
|
if !stderr.is_empty() {
|
||||||
error_json["stderr"] = json!(stderr);
|
error_json["stderr"] = json!(stderr);
|
||||||
@@ -1514,6 +1644,47 @@ impl ToolCallTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn format_call_log(cmd_name: &str, cmd_args: &[String], json_data: &serde_json::Value) -> String {
|
||||||
|
if *NO_COLOR {
|
||||||
|
return format!("Call {cmd_name} {}", cmd_args.join(" "));
|
||||||
|
}
|
||||||
|
let prefix_args = &cmd_args[..cmd_args.len().saturating_sub(1)];
|
||||||
|
let prefix = if prefix_args.is_empty() {
|
||||||
|
String::new()
|
||||||
|
} else {
|
||||||
|
format!("{} ", dimmed_text(&prefix_args.join(" ")))
|
||||||
|
};
|
||||||
|
format!(
|
||||||
|
"{}{} {}{}",
|
||||||
|
dimmed_text("Call "),
|
||||||
|
cyan_bold_text(cmd_name),
|
||||||
|
prefix,
|
||||||
|
format_json_colored_keys(json_data),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn format_json_colored_keys(value: &serde_json::Value) -> String {
|
||||||
|
let serde_json::Value::Object(map) = value else {
|
||||||
|
return dimmed_text(&value.to_string());
|
||||||
|
};
|
||||||
|
if map.is_empty() {
|
||||||
|
return dimmed_text("{}");
|
||||||
|
}
|
||||||
|
let pairs: Vec<String> = map
|
||||||
|
.iter()
|
||||||
|
.map(|(k, v)| {
|
||||||
|
let key = magenta_text(&format!("\"{k}\""));
|
||||||
|
format!("{}{}", key, dimmed_text(&format!(": {v}")))
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
format!(
|
||||||
|
"{}{}{}",
|
||||||
|
dimmed_text("{"),
|
||||||
|
pairs.join(&dimmed_text(", ")),
|
||||||
|
dimmed_text("}")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -1527,6 +1698,21 @@ mod tests {
|
|||||||
ToolCall::new(name.to_string(), args, Some("id1".to_string()))
|
ToolCall::new(name.to_string(), args, Some("id1".to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn normalize_tool_result_substitutes_done_for_null() {
|
||||||
|
assert_eq!(normalize_tool_result(Value::Null), json!("DONE"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn normalize_tool_result_preserves_non_null_values() {
|
||||||
|
assert_eq!(
|
||||||
|
normalize_tool_result(json!({"output": "hi"})),
|
||||||
|
json!({"output": "hi"})
|
||||||
|
);
|
||||||
|
assert_eq!(normalize_tool_result(json!("")), json!(""));
|
||||||
|
assert_eq!(normalize_tool_result(json!(false)), json!(false));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn toolcall_new_sets_fields() {
|
fn toolcall_new_sets_fields() {
|
||||||
let tc = ToolCall::new("my_tool".into(), json!({"x": 1}), Some("call-1".into()));
|
let tc = ToolCall::new("my_tool".into(), json!({"x": 1}), Some("call-1".into()));
|
||||||
@@ -1765,7 +1951,8 @@ mod tests {
|
|||||||
assert!(f.contains("agent__spawn"));
|
assert!(f.contains("agent__spawn"));
|
||||||
assert!(f.contains("agent__check"));
|
assert!(f.contains("agent__check"));
|
||||||
assert!(f.contains("agent__collect"));
|
assert!(f.contains("agent__collect"));
|
||||||
assert!(f.contains("agent__list"));
|
assert!(f.contains("agent__list_running"));
|
||||||
|
assert!(f.contains("agent__list_available"));
|
||||||
assert!(f.contains("agent__cancel"));
|
assert!(f.contains("agent__cancel"));
|
||||||
assert!(f.contains("agent__reply_escalation"));
|
assert!(f.contains("agent__reply_escalation"));
|
||||||
}
|
}
|
||||||
@@ -1782,7 +1969,7 @@ mod tests {
|
|||||||
fn functions_append_user_interaction_adds_declarations() {
|
fn functions_append_user_interaction_adds_declarations() {
|
||||||
let mut f = Functions::default();
|
let mut f = Functions::default();
|
||||||
f.append_user_interaction_functions();
|
f.append_user_interaction_functions();
|
||||||
assert!(f.contains("user__ask"));
|
assert!(f.contains("user__select"));
|
||||||
assert!(f.contains("user__confirm"));
|
assert!(f.contains("user__confirm"));
|
||||||
assert!(f.contains("user__input"));
|
assert!(f.contains("user__input"));
|
||||||
assert!(f.contains("user__checkbox"));
|
assert!(f.contains("user__checkbox"));
|
||||||
@@ -1890,4 +2077,57 @@ mod tests {
|
|||||||
assert_eq!(result.call.name, "my_tool");
|
assert_eq!(result.call.name, "my_tool");
|
||||||
assert_eq!(result.output, json!({"result": "ok"}));
|
assert_eq!(result.output, json!({"result": "ok"}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn thinking_block_matches_anthropic_wire_format() {
|
||||||
|
let block = ThinkingBlock::Thinking {
|
||||||
|
thinking: "chain of thought".to_string(),
|
||||||
|
signature: "sig123".to_string(),
|
||||||
|
};
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::to_value(&block).unwrap(),
|
||||||
|
json!({"type": "thinking", "thinking": "chain of thought", "signature": "sig123"})
|
||||||
|
);
|
||||||
|
|
||||||
|
let redacted = ThinkingBlock::RedactedThinking {
|
||||||
|
data: "opaque".to_string(),
|
||||||
|
};
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::to_value(&redacted).unwrap(),
|
||||||
|
json!({"type": "redacted_thinking", "data": "opaque"})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tool_result_deserializes_without_text_and_thinking() {
|
||||||
|
let yaml = "call:\n name: my_tool\n arguments: {}\noutput: ok\n";
|
||||||
|
let result: ToolResult = serde_yaml::from_str(yaml).unwrap();
|
||||||
|
assert_eq!(result.call.name, "my_tool");
|
||||||
|
assert!(result.text.is_none());
|
||||||
|
assert!(result.thinking.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_arguments_passes_through_object() {
|
||||||
|
let tc = call_with_args("t", json!({"x": 1, "y": "hello"}));
|
||||||
|
assert_eq!(tc.parse_arguments().unwrap(), json!({"x": 1, "y": "hello"}));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_arguments_deserializes_json_string() {
|
||||||
|
let tc = call_with_args("t", json!(r#"{"a": true}"#));
|
||||||
|
assert_eq!(tc.parse_arguments().unwrap(), json!({"a": true}));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_arguments_returns_err_for_invalid_json_string() {
|
||||||
|
let tc = call_with_args("t", json!("not json {"));
|
||||||
|
assert!(tc.parse_arguments().is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_arguments_returns_err_for_non_object_non_string() {
|
||||||
|
let tc = call_with_args("t", json!(42));
|
||||||
|
assert!(tc.parse_arguments().is_err());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user