@repome/sdk 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # @repome/sdk
2
+
3
+ Use repome as a git SDK — write files, commit, and push from any JavaScript
4
+ runtime with no clone required.
5
+
6
+ ## Porcelain API
7
+
8
+ ```ts
9
+ import { repome } from '@repome/sdk'
10
+
11
+ const git = await repome('acme/my-repo', {
12
+ token: process.env.REPOME_TOKEN!,
13
+ })
14
+
15
+ await git.add('src/main.ts', sourceCode)
16
+ await git.add('README.md', readmeText)
17
+
18
+ const commit = await git.commit('feat: generated output')
19
+ console.log(commit.sha) // a1b2c3d4...
20
+ console.log(commit.url) // https://api.repome.sh/acme/my-repo/commit/a1b2c3d
21
+ ```
22
+
23
+ `repome(slug, options)` returns a `GitRepo` bound to one repo. The repo is
24
+ created automatically if it does not exist. Files staged with `add()` are
25
+ held in memory and pushed as a single atomic commit when you call
26
+ `commit()`.
27
+
28
+ ```ts
29
+ interface GitRepo {
30
+ add(path: string, content: string | Uint8Array): Promise<void>
31
+ remove(path: string): Promise<void>
32
+ commit(message: string, options?: CommitOptions): Promise<Commit>
33
+ read(path: string, ref?: string): Promise<Blob>
34
+ ls(ref?: string, options?: LsOptions): Promise<TreeEntry[]>
35
+ log(options?: LogOptions): Promise<Commit[]>
36
+ }
37
+ ```
38
+
39
+ `add()` and `remove()` accumulate in memory; the next `commit()` packages
40
+ both into one atomic request. `read()` returns
41
+ `{ content: string, bytes: Uint8Array, sha }` — use `bytes` for binary
42
+ content. `ls()` returns a flat, recursive listing by default; pass
43
+ `{ recursive: false }` for a one-level directory walk.
44
+
45
+ Use `repome.ephemeral()` when you need a no-account repo for SDK writes:
46
+
47
+ ```ts
48
+ const git = await repome.ephemeral({ ttl: '24h' })
49
+ await git.add('README.md', '# hello')
50
+ await git.commit('initial')
51
+
52
+ console.log(git.remote)
53
+ console.log(git.expiresAt)
54
+ ```
55
+
56
+ Anonymous repos currently support the SDK control-plane path. Plain `git push`
57
+ to an anonymous magic endpoint is not part of this SDK slice.
58
+
59
+ ## Low-level oRPC client
60
+
61
+ `createClient({ baseUrl, apiKey })` returns the typed oRPC client over the
62
+ raw contract. Use it when you need a procedure that isn't on `GitRepo`
63
+ (e.g. `keys.*`, `repos.list`, `orgs.*`).
64
+
65
+ ```ts
66
+ import { createClient } from '@repome/sdk'
67
+
68
+ const client = createClient({
69
+ baseUrl: 'https://api.repome.sh',
70
+ apiKey: process.env.REPOME_API_KEY!,
71
+ })
72
+
73
+ const { items } = await client.repos.list({ orgSlug: 'acme' })
74
+ ```
75
+
76
+ API keys must use the `rpme_` prefix and are sent as
77
+ `Authorization: Bearer <key>`. Create keys with
78
+ `repome keys create <name> --scope repos:write`; repeat `--scope` for
79
+ additional access.
80
+
81
+ ## Smoke test
82
+
83
+ `scripts/smoke.ts` drives the full porcelain surface (ensure, add, commit,
84
+ read, ls, remove, log, commit-view URL) against a live Worker and cleans up
85
+ the test repo on the way out.
86
+
87
+ ```bash
88
+ # Local dev (portless)
89
+ export REPOME_SERVER_URL=https://api.repome.test
90
+ export REPOME_API_KEY=$(repome auth token)
91
+ vp run @repome/sdk#smoke
92
+
93
+ # Skip cleanup to inspect the resulting repo
94
+ REPOME_SMOKE_KEEP=1 vp run @repome/sdk#smoke
95
+
96
+ # Pin the repo name (otherwise sdk-smoke-<random>)
97
+ REPOME_SMOKE_NAME=sdk-smoke vp run @repome/sdk#smoke
98
+ ```
99
+
100
+ Inputs: `REPOME_API_KEY` (required; needs `repos:read` + `repos:write`),
101
+ `REPOME_SERVER_URL` (default `https://api.repome.sh`),
102
+ `REPOME_SMOKE_ORG` (default: active org from `me.get`),
103
+ `REPOME_SMOKE_NAME`, `REPOME_SMOKE_KEEP=1`.