|
2 | 2 |
|
3 | 3 | A TypeScript/JavaScript SDK for the Polyscope API. |
4 | 4 |
|
5 | | -## Installation |
| 5 | +## Official Documentation |
6 | 6 |
|
7 | | -```bash |
8 | | -npm install @polyscope/sdk |
9 | | -``` |
| 7 | +Documentation for the Polyscope Laravel SDK can be found on the [Polyscope website](https://getpolyscope.com/docs/integrations/javascript-sdk). |
10 | 8 |
|
11 | | -## Quick Start |
| 9 | +## License |
12 | 10 |
|
13 | | -```typescript |
14 | | -import { Polyscope } from "@polyscope/sdk"; |
15 | | - |
16 | | -const polyscope = new Polyscope({ apiToken: "your-api-token" }); |
17 | | - |
18 | | -const servers = await polyscope.servers(); |
19 | | -const repositories = await polyscope.repositories(); |
20 | | -const workspaces = await polyscope.workspaces(); |
21 | | - |
22 | | -// Create a workspace directly from a repository resource. |
23 | | -const workspace = await repositories[0].createWorkspace({ |
24 | | - prompt: "Fix the login flow", |
25 | | - serverId: "srv-1", // optional |
26 | | -}); |
27 | | - |
28 | | -// Or use a prompt string shorthand. |
29 | | -const workspace = await repositories[0].createWorkspace("Fix the login flow"); |
30 | | -``` |
31 | | - |
32 | | -If no token is passed, the SDK automatically falls back to Polyscope's local settings file and reads `authToken`. |
33 | | -By default it checks: |
34 | | - |
35 | | -- `~/.polyscope/settings.json` |
36 | | -- `~/Library/Application Support/com.getpolyscope.app/settings.json` |
37 | | -- `~/.config/com.getpolyscope.app/settings.json` |
38 | | -- `%APPDATA%/com.getpolyscope.app/settings.json` |
39 | | - |
40 | | -You can override this with: |
41 | | - |
42 | | -```bash |
43 | | -POLYSCOPE_SETTINGS_PATH=/custom/path/settings.json |
44 | | -``` |
45 | | - |
46 | | -If you need a custom base URL: |
47 | | - |
48 | | -```typescript |
49 | | -const polyscope = new Polyscope(); |
50 | | -polyscope.setBaseUrl("https://your-polyscope-instance.com"); |
51 | | -polyscope.setApiToken("your-api-token"); |
52 | | -``` |
53 | | - |
54 | | -## Supported API Areas (v1 only) |
55 | | - |
56 | | -- Servers: `servers()` |
57 | | -- Repositories: `repositories()` |
58 | | -- Workspaces: `workspaces()`, `createWorkspace()`, `workspace()`, `deleteWorkspace()` |
59 | | -- Workspace messages: `workspace.messages()`, `workspace.prompt()` |
60 | | -- Workspace actions: `workspace.diff()`, `workspace.commit()`, `workspace.pullRequest()`, `workspace.stop()` |
61 | | - |
62 | | -## Error Handling |
63 | | - |
64 | | -The SDK maps common HTTP/API failures to typed errors: |
65 | | - |
66 | | -- `ValidationError` |
67 | | -- `AuthenticationError` |
68 | | -- `ForbiddenError` |
69 | | -- `NotFoundError` |
70 | | -- `RateLimitError` |
71 | | -- `ServerOfflineError` |
72 | | -- `ServerTimeoutError` |
73 | | -- `ApiError` |
74 | | - |
75 | | -Example: |
76 | | - |
77 | | -```typescript |
78 | | -import { Polyscope, ValidationError } from "@polyscope/sdk"; |
79 | | - |
80 | | -try { |
81 | | - await polyscope.createWorkspace({ repositoryId: "" }); |
82 | | -} catch (error) { |
83 | | - if (error instanceof ValidationError) { |
84 | | - console.log(error.errors); |
85 | | - } |
86 | | -} |
87 | | -``` |
88 | | - |
89 | | -## Development |
90 | | - |
91 | | -```bash |
92 | | -npm run build |
93 | | -npm run typecheck |
94 | | -``` |
| 11 | +Polyscope JS SDK is open-sourced software licensed under the [MIT license](LICENSE.md). |
0 commit comments