Skip to content

Commit 9e56fbf

Browse files
mpociotclaude
andcommitted
Add PHP 8.5 to CI matrix and support prompt string shorthand in createWorkspace
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 689364b commit 9e56fbf

4 files changed

Lines changed: 45 additions & 3 deletions

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
php: ['8.2', '8.3', '8.4']
14+
php: ['8.4', '8.5']
1515

1616
steps:
1717
- name: Checkout

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ $workspace = $repositories[0]->createWorkspace([
2424
'prompt' => 'Fix the login flow',
2525
'server_id' => 'srv-1', // optional
2626
]);
27+
28+
// Or use a prompt string shorthand.
29+
$workspace = $repositories[0]->createWorkspace('Fix the login flow');
2730
```
2831

2932
If no token is passed, the SDK automatically falls back to Polyscope's local settings file and reads `authToken`.

src/Resources/Repository.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ class Repository extends Resource
4242
public ?string $serverId = null;
4343

4444
/**
45-
* @param array<string, mixed> $data
45+
* @param array<string, mixed>|string $data
4646
*/
47-
public function createWorkspace(array $data = []): Workspace
47+
public function createWorkspace(array|string $data = []): Workspace
4848
{
49+
if (is_string($data)) {
50+
$data = ['prompt' => $data];
51+
}
52+
4953
$repositoryId = $this->id();
5054

5155
if (

tests/PolyscopeSDKTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,41 @@ public function test_repository_resource_can_create_workspace_without_manual_rep
245245
$this->assertSame('repo-1', $workspace->repoId);
246246
}
247247

248+
public function test_repository_resource_can_create_workspace_from_prompt_string(): void
249+
{
250+
$sdk = new Polyscope('token', $http = Mockery::mock(Client::class));
251+
252+
$http->shouldReceive('request')
253+
->once()
254+
->with('POST', 'v1/workspaces', [
255+
'timeout' => 30,
256+
'json' => [
257+
'prompt' => 'Fix bug',
258+
'repository_id' => 'repo-1',
259+
],
260+
])
261+
->andReturn(new Response(201, [], json_encode([
262+
'data' => [
263+
'id' => 'wt-1',
264+
'repo_id' => 'repo-1',
265+
'branch' => 'fix-bug',
266+
'status' => 'active',
267+
],
268+
], JSON_THROW_ON_ERROR)));
269+
270+
$repository = new \Polyscope\Laravel\Resources\Repository([
271+
'id' => 'repo-1',
272+
'name' => 'polyscope',
273+
'path' => '/code/polyscope',
274+
], $sdk);
275+
276+
$workspace = $repository->createWorkspace('Fix bug');
277+
278+
$this->assertInstanceOf(Workspace::class, $workspace);
279+
$this->assertSame('wt-1', $workspace->id);
280+
$this->assertSame('repo-1', $workspace->repoId);
281+
}
282+
248283
public function test_repository_resource_rejects_mismatched_repository_id_when_creating_workspace(): void
249284
{
250285
$this->expectException(RuntimeException::class);

0 commit comments

Comments
 (0)