Skip to content

Commit 820253b

Browse files
committed
Cleanup before 2.0.0 release
1 parent 61bc0e2 commit 820253b

File tree

830 files changed

+10835
-15676
lines changed

Some content is hidden

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

830 files changed

+10835
-15676
lines changed

.beads/issues.jsonl

Lines changed: 21 additions & 3 deletions
Large diffs are not rendered by default.

.github/workflows/split.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ jobs:
3333
- local: 'packages/config'
3434
repo: 'cognesy/instructor-config'
3535
name: 'instructor-config'
36-
- local: 'packages/doctor'
37-
repo: 'cognesy/instructor-doctor'
38-
name: 'instructor-doctor'
36+
- local: 'packages/doctools'
37+
repo: 'cognesy/instructor-doctools'
38+
name: 'instructor-doctools'
3939
- local: 'packages/dynamic'
4040
repo: 'cognesy/instructor-dynamic'
4141
name: 'instructor-dynamic'

.github/workflows/split.yml.bak

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ jobs:
3333
- local: 'packages/config'
3434
repo: 'cognesy/instructor-config'
3535
name: 'instructor-config'
36-
- local: 'packages/doctor'
37-
repo: 'cognesy/instructor-doctor'
38-
name: 'instructor-doctor'
36+
- local: 'packages/doctools'
37+
repo: 'cognesy/instructor-doctools'
38+
name: 'instructor-doctools'
3939
- local: 'packages/dynamic'
4040
repo: 'cognesy/instructor-dynamic'
4141
name: 'instructor-dynamic'

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"Cognesy\\AgentCtrl\\": "packages/agent-ctrl/src/",
108108
"Cognesy\\Auxiliary\\": "packages/auxiliary/src/",
109109
"Cognesy\\Config\\": "packages/config/src/",
110-
"Cognesy\\Doctor\\": "packages/doctor/src/",
110+
"Cognesy\\Doctools\\": "packages/doctools/src/",
111111
"Cognesy\\Dynamic\\": "packages/dynamic/src/",
112112
"Cognesy\\Events\\": "packages/events/src/",
113113
"Cognesy\\Http\\": "packages/http-client/src/",
@@ -156,7 +156,7 @@
156156
"Cognesy\\Templates\\Tests\\": "packages/templates/tests/",
157157
"Cognesy\\Utils\\Tests\\": "packages/utils/tests/",
158158
"Cognesy\\Auxiliary\\Tests\\": "packages/auxiliary/tests/",
159-
"Cognesy\\Doctor\\Tests\\": "packages/doctor/tests/",
159+
"Cognesy\\Doctools\\Tests\\": "packages/doctools/tests/",
160160
"Cognesy\\Evals\\Tests\\": "packages/evals/tests/",
161161
"Cognesy\\Experimental\\Tests\\": "packages/experimental/tests/",
162162
"Cognesy\\InstructorHub\\Tests\\": "packages/hub/tests/",

docs-build/cookbook/structured_outputs/troubleshooting/cost_calculation.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function printCostBreakdown(Usage $usage, Pricing $pricing): void {
3838
echo " Input: \${$pricing->inputPerMToken}\n";
3939
echo " Output: \${$pricing->outputPerMToken}\n";
4040
echo " Cache read: \${$pricing->cacheReadPerMToken}\n";
41-
echo "\nTotal cost: \$" . number_format($usage->calculateCost($pricing), 6) . "\n";
41+
echo "\nTotal cost: \$" . number_format($usage->cost($pricing), 6) . "\n";
4242
}
4343

4444
// OPTION 1: Configure pricing in LLM config preset
@@ -86,7 +86,7 @@ printCostBreakdown($response->usage(), $pricing);
8686

8787
// You can also attach pricing to usage for later calculation
8888
$usageWithPricing = $response->usage()->withPricing($pricing);
89-
echo "\nCost via stored pricing: \$" . number_format($usageWithPricing->calculateCost(), 6) . "\n";
89+
echo "\nCost via stored pricing: \$" . number_format($usageWithPricing->cost(), 6) . "\n";
9090

9191

9292
// OPTION 3: Compare costs across different models
@@ -107,7 +107,7 @@ $models = [
107107
echo "For {$usage->inputTokens} input + {$usage->outputTokens} output tokens:\n\n";
108108
foreach ($models as $model => $prices) {
109109
$pricing = Pricing::fromArray($prices);
110-
$cost = $usage->calculateCost($pricing);
110+
$cost = $usage->cost($pricing);
111111
printf(" %-20s \$%.6f\n", $model, $cost);
112112
}
113113
?>

docs-build/packages/agents/01-introduction.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ $agent = AgentBuilder::base()
3535
->withCapability(new UseBash())
3636
->withCapability(new UseGuards(maxSteps: 10))
3737
->build();
38-
// @doctest id="893f"
38+
// @doctest id="ca41"
3939
```
4040

4141
## Package Structure
@@ -49,7 +49,7 @@ Capability/ # Use* capabilities (Core, Bash, File, Subagent, etc.)
4949
Collections/ # Tools, AgentSteps, StepExecutions, ErrorList, etc.
5050
Context/ # AgentContext, message compilers (CanCompileMessages)
5151
Continuation/ # StopSignal, StopReason, ExecutionContinuation
52-
Data/ # AgentState, ExecutionState, AgentStep, AgentBudget
52+
Data/ # AgentState, ExecutionState, AgentStep, ExecutionBudget
5353
Drivers/ # ToolCallingDriver, ReActDriver, FakeAgentDriver
5454
Enums/ # AgentStepType, ExecutionStatus
5555
Events/ # Agent event system
@@ -59,7 +59,7 @@ Interception/ # CanInterceptAgentLifecycle, PassThroughInterceptor
5959
Template/ # Agent definitions, parsers, registry
6060
Session/ # AgentSession, SessionRuntime, actions, repositories, stores
6161
Tool/ # ToolInterface, BaseTool, FunctionTool, ToolExecutor
62-
// @doctest id="95b2"
62+
// @doctest id="3a51"
6363
```
6464

6565
## Minimal Example
@@ -72,7 +72,7 @@ $state = AgentState::empty()->withUserMessage('Hello!');
7272
$result = $loop->execute($state);
7373

7474
echo $result->finalResponse()->toString();
75-
// @doctest id="d635"
75+
// @doctest id="891e"
7676
```
7777

7878
## Recommended Path

docs-build/packages/agents/02-basic-agent.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $result = $loop->execute($state);
1919

2020
echo $result->finalResponse()->toString();
2121
// "2 + 2 equals 4."
22-
// @doctest id="cbfd"
22+
// @doctest id="f0dd"
2323
```
2424

2525
## What Happens
@@ -51,7 +51,7 @@ $result = $loop->execute($state);
5151

5252
echo $result->finalResponse()->toString();
5353
// "The weather in Paris is 72°F and sunny."
54-
// @doctest id="f26d"
54+
// @doctest id="2f2f"
5555
```
5656

5757
## Customizing the Loop
@@ -60,7 +60,7 @@ Add a tool to a default loop:
6060

6161
```php
6262
$loop = AgentLoop::default()->withTool($myTool);
63-
// @doctest id="8af7"
63+
// @doctest id="9c4d"
6464
```
6565

6666
Swap the driver to use ReAct reasoning:
@@ -85,7 +85,7 @@ $loop = AgentLoop::default()->withDriver(new ReActDriver(
8585
structuredOutput: $structuredOutput,
8686
model: 'gpt-4o',
8787
));
88-
// @doctest id="baad"
88+
// @doctest id="1a5f"
8989
```
9090

9191
## System Prompt
@@ -94,7 +94,7 @@ $loop = AgentLoop::default()->withDriver(new ReActDriver(
9494
$state = AgentState::empty()
9595
->withSystemPrompt('You are a helpful assistant.')
9696
->withUserMessage('Hello!');
97-
// @doctest id="8355"
97+
// @doctest id="13bf"
9898
```
9999

100100
## Using AgentBuilder
@@ -114,7 +114,7 @@ $agent = AgentBuilder::base()
114114
->build();
115115

116116
$result = $agent->execute($state);
117-
// @doctest id="55b8"
117+
// @doctest id="0fb0"
118118
```
119119

120120
See [AgentBuilder & Capabilities](13-agent-builder.md) for details.

docs-build/packages/agents/03-basic-concepts.mdx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The orchestrator. Runs a step-based loop: call LLM, execute tools, check stop co
1111

1212
```
1313
BeforeExecution -> [ BeforeStep -> UseTools -> AfterStep -> ShouldStop? ] -> AfterExecution
14-
// @doctest id="a1d9"
14+
// @doctest id="d4d4"
1515
```
1616

1717
## AgentState
@@ -31,9 +31,8 @@ Immutable value object holding everything about an agent's session and execution
3131
```php
3232
$state = AgentState::empty()
3333
->withSystemPrompt('You are helpful.')
34-
->withUserMessage('Hello')
35-
->withBudget(new AgentBudget(maxSteps: 10));
36-
// @doctest id="831f"
34+
->withUserMessage('Hello');
35+
// @doctest id="4541"
3736
```
3837

3938
## AgentContext
@@ -44,7 +43,7 @@ Holds the conversation data: messages, system prompt, metadata, and response for
4443
$state = AgentState::empty()
4544
->withSystemPrompt('You are helpful.')
4645
->withMetadata('user_id', 123);
47-
// @doctest id="8acd"
46+
// @doctest id="d39d"
4847
```
4948

5049
## AgentStep
@@ -69,5 +68,5 @@ Tracks the current execution's transient state: status, completed steps, current
6968
$state->execution()->status(); // ExecutionStatus::InProgress
7069
$state->execution()->stepCount(); // 3
7170
$state->execution()->shouldStop(); // false
72-
// @doctest id="44de"
71+
// @doctest id="84e5"
7372
```

docs-build/packages/agents/04-controlling-the-loop.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ description: 'Run agents to completion with execute() or step through with itera
1111

1212
```php
1313
$finalState = $loop->execute($state);
14-
// @doctest id="1089"
14+
// @doctest id="c390"
1515
```
1616

1717
`iterate()` yields state after each step, giving you full control:
@@ -26,7 +26,7 @@ foreach ($loop->iterate($state) as $stepState) {
2626
echo " Tool: {$exec->name()} -> {$exec->value()}\n";
2727
}
2828
}
29-
// @doctest id="e0a9"
29+
// @doctest id="516a"
3030
```
3131

3232
## Inspecting State
@@ -51,7 +51,7 @@ $toolExec = $state->lastToolExecution();
5151
$toolExec?->name(); // 'weather'
5252
$toolExec?->value(); // '72F, sunny'
5353
$toolExec?->hasError(); // false
54-
// @doctest id="14a4"
54+
// @doctest id="58e7"
5555
```
5656

5757
## Reading the Agent's Response
@@ -68,7 +68,7 @@ all other cases: forced stops, errors, budget exhaustion, etc.
6868
```php
6969
$state->hasFinalResponse(); // true only on natural completion
7070
$state->finalResponse()->toString(); // strict: empty when interrupted
71-
// @doctest id="c43e"
71+
// @doctest id="8619"
7272
```
7373

7474
Use `finalResponse()` when you need to distinguish between a genuine
@@ -82,7 +82,7 @@ otherwise the last step's output messages regardless of step type.
8282

8383
```php
8484
$state->currentResponse()->toString(); // pragmatic: last output text
85-
// @doctest id="cacf"
85+
// @doctest id="d3d5"
8686
```
8787

8888
Use `currentResponse()` when you want to show *something* to the user
@@ -111,7 +111,7 @@ if ($state->hasFinalResponse()) {
111111
echo "Agent stopped: {$reason->value}\n";
112112
echo $state->currentResponse()->toString();
113113
}
114-
// @doctest id="6c09"
114+
// @doctest id="daf7"
115115
```
116116

117117
## Listening to Events
@@ -129,5 +129,5 @@ $loop->onEvent(AgentStepCompleted::class, function (AgentStepCompleted $event) {
129129
$loop->wiretap(function ($event) {
130130
echo get_class($event) . "\n";
131131
});
132-
// @doctest id="5d90"
132+
// @doctest id="4e00"
133133
```

docs-build/packages/agents/05-tools.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use Cognesy\Agents\Tool\Tools\MockTool;
1717

1818
$calculator = MockTool::returning('calculator', 'Performs math', '42');
1919
$tools = new Tools($calculator);
20-
// @doctest id="6e0b"
20+
// @doctest id="eaf2"
2121
```
2222

2323
## Using FunctionTool
@@ -34,7 +34,7 @@ function get_weather(string $city): string {
3434
$tool = FunctionTool::fromCallable(get_weather(...));
3535

3636
$tools = new Tools($tool);
37-
// @doctest id="8c57"
37+
// @doctest id="f4fe"
3838
```
3939

4040
## Multiple Tools
@@ -57,7 +57,7 @@ $tools = new Tools(
5757
FunctionTool::fromCallable(get_weather(...)),
5858
FunctionTool::fromCallable(calculate(...)),
5959
);
60-
// @doctest id="85df"
60+
// @doctest id="d862"
6161
```
6262

6363
## Agent with Tools
@@ -71,7 +71,7 @@ $loop = AgentLoop::default()->withTools($tools);
7171
$state = AgentState::empty()->withUserMessage('What is the weather in Paris?');
7272
$result = $loop->execute($state);
7373
// LLM calls the weather tool, gets result, then responds
74-
// @doctest id="15a1"
74+
// @doctest id="9d47"
7575
```
7676

7777
## Tool Contracts
@@ -88,7 +88,7 @@ interface ToolInterface {
8888
public function toToolSchema(): array; // JSON schema sent to LLM
8989
public function descriptor(): CanDescribeTool; // metadata accessor
9090
}
91-
// @doctest id="f5ff"
91+
// @doctest id="e79f"
9292
```
9393

9494
### CanDescribeTool
@@ -102,7 +102,7 @@ interface CanDescribeTool {
102102
public function metadata(): array; // summary for browsing/discovery
103103
public function instructions(): array; // full specification with parameters
104104
}
105-
// @doctest id="6776"
105+
// @doctest id="7cbf"
106106
```
107107

108108
`metadata()` returns lightweight info (name, summary, namespace) for tool listings. `instructions()` returns the complete specification including parameters and return type.
@@ -127,7 +127,7 @@ class WeatherTool extends BaseTool
127127
return "Weather in {$city}: 72F, sunny";
128128
}
129129
}
130-
// @doctest id="64f8"
130+
// @doctest id="0b1b"
131131
```
132132

133133
See [Building Tools](06-building-tools.md) for the full guide on creating custom tools.

0 commit comments

Comments
 (0)