Skip to content

Commit abcb0dc

Browse files
committed
Deep refactor of schema for 2.0.0
1 parent 912e997 commit abcb0dc

File tree

587 files changed

+20535
-13637
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

587 files changed

+20535
-13637
lines changed

.beads/issues.jsonl

Lines changed: 88 additions & 20 deletions
Large diffs are not rendered by default.

.github/workflows/php.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ permissions:
1111

1212
jobs:
1313
build:
14-
name: 'PHP ${{ matrix.php }} (Composer Flags: ${{ matrix.composer }})'
14+
name: 'PHP ${{ matrix.php }} (Symfony ${{ matrix.symfony }}, Composer Flags: ${{ matrix.composer }})'
1515

1616
runs-on: ubuntu-24.04
1717

1818
strategy:
1919
fail-fast: true
2020
matrix:
2121
php: ['8.3', '8.4', '8.5']
22+
symfony: ['^7.0', '^8.0']
2223
composer: ['--prefer-stable', '--prefer-lowest']
24+
exclude:
25+
- php: '8.3'
26+
symfony: '^8.0'
2327

2428
steps:
2529
- uses: actions/checkout@v3
@@ -37,14 +41,30 @@ jobs:
3741
# ${{ runner.os }}-php-
3842

3943
- name: Install dependencies
40-
run: composer update --no-interaction ${{ matrix.composer }}
44+
run: >
45+
composer update --no-interaction ${{ matrix.composer }} -W
46+
--with symfony/console:${{ matrix.symfony }}
47+
--with symfony/filesystem:${{ matrix.symfony }}
48+
--with symfony/process:${{ matrix.symfony }}
49+
--with symfony/property-access:${{ matrix.symfony }}
50+
--with symfony/property-info:${{ matrix.symfony }}
51+
--with symfony/serializer:${{ matrix.symfony }}
52+
--with symfony/validator:${{ matrix.symfony }}
53+
--with symfony/var-dumper:${{ matrix.symfony }}
54+
--with symfony/yaml:${{ matrix.symfony }}
55+
--with symfony/css-selector:${{ matrix.symfony }}
56+
--with symfony/dom-crawler:${{ matrix.symfony }}
57+
--with symfony/http-client:${{ matrix.symfony }}
4158
4259
- name: Regenerate Autoloader
4360
run: composer dump-autoload
4461

4562
- name: Run test suite (all code local)
4663
run: composer test
4764

65+
- name: Run Instructor docs QA
66+
run: composer --working-dir=packages/instructor docs:qa
67+
4868
# - name: Install dependencies in all packages
4969
# run: |
5070
# for dir in packages/*; do

bin/instructor-docs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env php
22
<?php
33

4-
use Cognesy\Doctor\Docs;
4+
use Cognesy\Doctools\Docs;
55

66
ini_set('display_errors', 1);
77
ini_set('display_startup_errors', 1);
@@ -28,4 +28,4 @@ require findAutoload();
2828

2929
// run the app
3030
$app = new Docs();
31-
$app->run();
31+
$app->run();

composer.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,21 @@
4747
"psr/http-client": "^1.0",
4848
"psr/http-message": "^2.0",
4949
"psr/log": "^3.0",
50-
"symfony/console": "^7.1",
51-
"symfony/filesystem": "^7.1",
52-
"symfony/process": "^7.0",
53-
"symfony/property-access": "^7.0",
54-
"symfony/property-info": "^7.0",
55-
"symfony/serializer": "^7.0",
56-
"symfony/validator": "^7.0",
57-
"symfony/var-dumper": "^7.0",
58-
"symfony/yaml": "^7.0",
50+
"symfony/console": "^7.1 || ^8.0",
51+
"symfony/filesystem": "^7.1 || ^8.0",
52+
"symfony/process": "^7.0 || ^8.0",
53+
"symfony/property-access": "^7.0 || ^8.0",
54+
"symfony/property-info": "^7.0 || ^8.0",
55+
"symfony/serializer": "^7.0 || ^8.0",
56+
"symfony/validator": "^7.0 || ^8.0",
57+
"symfony/var-dumper": "^7.0 || ^8.0",
58+
"symfony/yaml": "^7.0 || ^8.0",
5959
"vlucas/phpdotenv": "^5.6"
6060
},
6161
"scripts": {
6262
"bench": "@php ./vendor/bin/phpbench run",
6363
"docs": "@php ./bin/instructor-docs",
64+
"docs:qa": "bash ./scripts/docs-qa-all.sh",
6465
"hub": "php ./bin/instructor-hub",
6566
"phpstan": "@php ./vendor/bin/phpstan analyse -c phpstan.neon",
6667
"psalm": "@php ./vendor/bin/psalm -c packages/instructor/psalm.xml",
@@ -120,7 +121,7 @@
120121
"Cognesy\\Pipeline\\": "packages/pipeline/src/",
121122
"Cognesy\\Polyglot\\": "packages/polyglot/src/",
122123
"Cognesy\\Sandbox\\": "packages/sandbox/src/",
123-
"Cognesy\\Schema\\": "packages/schema/src/",
124+
"Cognesy\\Schema\\": "packages/schema2/src/",
124125
"Cognesy\\Setup\\": "packages/setup/src/",
125126
"Cognesy\\Stream\\": "packages/stream/src/",
126127
"Cognesy\\Template\\": "packages/templates/src/",
@@ -150,7 +151,7 @@
150151
"Cognesy\\Pipeline\\Tests\\": "packages/pipeline/tests/",
151152
"Cognesy\\Polyglot\\Tests\\": "packages/polyglot/tests/",
152153
"Cognesy\\Sandbox\\Tests\\": "packages/sandbox/tests/",
153-
"Cognesy\\Schema\\Tests\\": "packages/schema/tests/",
154+
"Cognesy\\Schema\\Tests\\": "packages/schema2/tests/",
154155
"Cognesy\\Setup\\Tests\\": "packages/setup/tests/",
155156
"Cognesy\\Stream\\Tests\\": "packages/stream/tests/",
156157
"Cognesy\\Templates\\Tests\\": "packages/templates/tests/",
@@ -203,9 +204,9 @@
203204
"psr/http-factory-implementation": "*",
204205
"shipmonk/dead-code-detector": "^0.5.1",
205206
"spatie/browsershot": "^5.1",
206-
"symfony/css-selector": "^7.0",
207-
"symfony/dom-crawler": "^7.0",
208-
"symfony/http-client": "^7.0",
207+
"symfony/css-selector": "^7.0 || ^8.0",
208+
"symfony/dom-crawler": "^7.0 || ^8.0",
209+
"symfony/http-client": "^7.0 || ^8.0",
209210
"toolkit/cli-utils": "^2.0",
210211
"twig/twig": "^3.0",
211212
"vimeo/psalm": "^6.0"

config/http.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
'streamChunkSize' => 256,
1313
'maxConcurrent' => 5,
1414
'poolTimeout' => 60,
15-
'failOnError' => true,
15+
'failOnError' => false,
1616
],
1717
'guzzle' => [
1818
'driver' => 'guzzle',
@@ -22,7 +22,7 @@
2222
'streamChunkSize' => 256,
2323
'maxConcurrent' => 5,
2424
'poolTimeout' => 60,
25-
'failOnError' => true,
25+
'failOnError' => false,
2626
],
2727
'symfony' => [
2828
'driver' => 'symfony',
@@ -32,7 +32,7 @@
3232
'streamChunkSize' => 0,
3333
'maxConcurrent' => 5,
3434
'poolTimeout' => 60,
35-
'failOnError' => true,
35+
'failOnError' => false,
3636
],
3737
'laravel' => [
3838
'driver' => 'laravel',
@@ -42,7 +42,7 @@
4242
'streamChunkSize' => 256,
4343
'maxConcurrent' => 5,
4444
'poolTimeout' => 60,
45-
'failOnError' => true,
45+
'failOnError' => false,
4646
],
4747
'exthttp' => [
4848
'driver' => 'exthttp',
@@ -52,7 +52,7 @@
5252
'streamChunkSize' => 256,
5353
'maxConcurrent' => 10,
5454
'poolTimeout' => 60,
55-
'failOnError' => true,
55+
'failOnError' => false,
5656
],
5757
'http-ollama' => [
5858
'driver' => 'guzzle',
@@ -62,7 +62,7 @@
6262
'idleTimeout' => -1,
6363
'maxConcurrent' => 5,
6464
'poolTimeout' => 60,
65-
'failOnError' => true,
65+
'failOnError' => false,
6666
],
6767
],
6868
];
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: Overview
3+
description: 'Unified API for Claude Code, Codex, and OpenCode CLIs.'
4+
---
5+
6+
`agent-ctrl` gives you one fluent API (`AgentCtrl`) to run different code-agent CLIs.
7+
8+
Supported bridges:
9+
10+
- Claude Code
11+
- OpenAI Codex
12+
- OpenCode
13+
14+
All of them return the same response type: `AgentResponse`.
15+
16+
## Docs
17+
18+
- [Getting Started](2-getting-started.md)
19+
- [Streaming](3-streaming.md)
20+
- [Session Management](4-session-management.md)
21+
- [Agent Options](5-agent-options.md)
22+
- [Response Object](6-response-object.md)
23+
- [Troubleshooting](7-troubleshooting.md)
24+
- [Claude Code Bridge (Internals)](8-claude-code-bridge.md)
25+
- [Codex Bridge (Internals)](9-codex-bridge.md)
26+
- [OpenCode Bridge (Internals)](10-opencode-bridge.md)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: 'OpenCode Bridge (Internals)'
3+
description: 'Low-level OpenCode CLI bridge flow for advanced use cases.'
4+
---
5+
6+
> Most users should use `AgentCtrl::openCode()` from the high-level API.
7+
> Use this page when you need direct request/command/parser control.
8+
9+
## Core Flow
10+
11+
```php
12+
use Cognesy\AgentCtrl\Common\Execution\SandboxCommandExecutor;
13+
use Cognesy\AgentCtrl\OpenCode\Application\Builder\OpenCodeCommandBuilder;
14+
use Cognesy\AgentCtrl\OpenCode\Application\Dto\OpenCodeRequest;
15+
use Cognesy\AgentCtrl\OpenCode\Application\Parser\ResponseParser;
16+
use Cognesy\AgentCtrl\OpenCode\Domain\Enum\OutputFormat;
17+
18+
$request = new OpenCodeRequest(
19+
prompt: 'Summarize the architecture in short bullets.',
20+
outputFormat: OutputFormat::Json,
21+
);
22+
23+
$spec = (new OpenCodeCommandBuilder())->buildRun($request);
24+
$result = SandboxCommandExecutor::forOpenCode()->execute($spec);
25+
$response = (new ResponseParser())->parse($result, OutputFormat::Json);
26+
27+
echo $response->messageText();
28+
// @doctest id="d364"
29+
```
30+
31+
## Session Handling
32+
33+
`OpenCodeRequest` supports:
34+
35+
- `continueSession: true` (resume most recent)
36+
- `sessionId: '...'` (resume a specific session)
37+
38+
## Key Types
39+
40+
- Request DTO: `OpenCodeRequest`
41+
- Command builder: `OpenCodeCommandBuilder`
42+
- Parser: `ResponseParser`
43+
- Stream events: `TextEvent`, `ToolUseEvent`, `StepFinishEvent`, `ErrorEvent`
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: 'Getting Started'
3+
description: 'Run your first prompt with AgentCtrl.'
4+
---
5+
6+
## Install
7+
8+
```bash
9+
composer require cognesy/agent-ctrl
10+
# @doctest id="09bd"
11+
```
12+
13+
You need at least one CLI binary installed and authenticated (`claude`, `codex`, or `opencode`).
14+
15+
## Minimal Execution
16+
17+
```php
18+
use Cognesy\AgentCtrl\AgentCtrl;
19+
20+
$response = AgentCtrl::codex()->execute('Summarize this repository.');
21+
22+
echo $response->text();
23+
// @doctest id="f6ab"
24+
```
25+
26+
## Runtime Agent Selection
27+
28+
```php
29+
use Cognesy\AgentCtrl\AgentCtrl;
30+
use Cognesy\AgentCtrl\Enum\AgentType;
31+
32+
$agent = AgentType::from('codex');
33+
$response = AgentCtrl::make($agent)->execute('List top risks in this code.');
34+
// @doctest id="849a"
35+
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: Streaming
3+
description: 'Handle text, tool, completion, and error events in real time.'
4+
---
5+
6+
Use `executeStreaming()` when you want incremental output.
7+
8+
```php
9+
use Cognesy\AgentCtrl\AgentCtrl;
10+
use Cognesy\AgentCtrl\Dto\AgentResponse;
11+
12+
$response = AgentCtrl::openCode()
13+
->onText(fn(string $text) => print($text))
14+
->onToolUse(fn(string $tool, array $input, ?string $output) => print("\n[tool:$tool]\n"))
15+
->onComplete(fn(AgentResponse $response) => print("\n[done]\n"))
16+
->onError(fn(string $message, ?string $code) => print("\n[error:$message]\n"))
17+
->executeStreaming('Explain this package architecture.');
18+
// @doctest id="ae97"
19+
```
20+
21+
`execute()` is a non-streaming convenience method.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: 'Session Management'
3+
description: 'Continue the latest session or resume a specific session ID.'
4+
---
5+
6+
All bridges support continuing and resuming sessions.
7+
8+
## Continue Latest Session
9+
10+
```php
11+
use Cognesy\AgentCtrl\AgentCtrl;
12+
13+
$response = AgentCtrl::codex()
14+
->continueSession()
15+
->execute('Continue from the previous plan and apply step 2.');
16+
// @doctest id="9993"
17+
```
18+
19+
## Resume Specific Session
20+
21+
```php
22+
use Cognesy\AgentCtrl\AgentCtrl;
23+
24+
$first = AgentCtrl::codex()->execute('Create a migration plan.');
25+
$sessionId = $first->sessionId();
26+
27+
if ($sessionId !== null) {
28+
$next = AgentCtrl::codex()
29+
->resumeSession((string) $sessionId)
30+
->execute('Now implement the first migration.');
31+
}
32+
// @doctest id="da0c"
33+
```
34+
35+
`sessionId()` returns `AgentSessionId|null`.

0 commit comments

Comments
 (0)