Skip to content

Commit 4c7de89

Browse files
authored
feat: cloud integration (auth, protocol, pull) (#77)
1 parent 957204f commit 4c7de89

50 files changed

Lines changed: 3196 additions & 322 deletions

Some content is hidden

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

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
- run: pnpm i
3131

32-
- run: pnpm build
32+
- run: pnpm -r build
3333

3434
- run: pnpm publish -r --access public --no-git-checks
3535
env:

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
node-version: lts/*
2626
cache: pnpm
2727
- run: pnpm i
28+
- run: pnpm --filter skilld-protocol build
2829
- run: pnpm lint
2930
- run: pnpm typecheck
3031
- run: pnpm build

build.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ export default defineBuildConfig({
55
{
66
type: 'bundle',
77
input: [
8-
'./src/index.ts',
98
'./src/cli-entry.ts',
109
'./src/cli.ts',
1110
'./src/prepare.ts',
1211
'./src/retriv/worker.ts',
1312
],
13+
rolldown: {
14+
external: ['@napi-rs/keyring', /@napi-rs\/keyring-/],
15+
},
1416
},
1517
],
1618
})

package.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@
3131
"cursor",
3232
"codex"
3333
],
34-
"exports": {
35-
".": {
36-
"types": "./dist/index.d.mts",
37-
"import": "./dist/index.mjs"
38-
}
39-
},
40-
"main": "./dist/index.mjs",
41-
"types": "./dist/index.d.mts",
4234
"bin": {
4335
"skilld": "./dist/cli-entry.mjs"
4436
},
@@ -57,7 +49,7 @@
5749
"typecheck": "tsc --noEmit",
5850
"test": "vitest",
5951
"test:run": "vitest run",
60-
"release": "pnpm build && bumpp -x \"npx changelogen --output=CHANGELOG.md\"",
52+
"release": "pnpm -r build && bumpp -r -x \"npx changelogen --output=CHANGELOG.md\"",
6153
"prepack": "pnpm run build",
6254
"prepare": "test -z \"$CI\" && skilld prepare || true"
6355
},
@@ -79,18 +71,23 @@
7971
"pathe": "catalog:",
8072
"retriv": "catalog:",
8173
"semver": "catalog:",
74+
"skilld-protocol": "workspace:*",
8275
"sqlite-vec": "catalog:deps",
8376
"std-env": "catalog:",
8477
"typebox": "catalog:",
8578
"typescript": "catalog:",
8679
"unagent": "catalog:"
8780
},
81+
"optionalDependencies": {
82+
"@napi-rs/keyring": "^1.1.6"
83+
},
8884
"devDependencies": {
8985
"@antfu/eslint-config": "catalog:dev-lint",
9086
"@types/node": "catalog:dev-build",
9187
"@types/semver": "catalog:",
9288
"@vitest/coverage-v8": "catalog:dev-test",
9389
"bumpp": "catalog:",
90+
"eslint": "catalog:dev-lint",
9491
"obuild": "catalog:dev-build",
9592
"tsx": "catalog:",
9693
"vitest": "catalog:dev-test"

packages/protocol/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# skilld-protocol
2+
3+
Wire shapes and constants shared between the [skilld CLI](https://github.com/skilld-dev/skilld) and [skilld.dev](https://skilld.dev). The single source of truth for everything that crosses that boundary: telemetry, audit, auth, device flow, collection manifests.
4+
5+
## Install
6+
7+
```sh
8+
pnpm add skilld-protocol
9+
```
10+
11+
ESM-only. Node ≥18. One peer-free dep: `zod` v4.
12+
13+
## Subpaths
14+
15+
- `skilld-protocol/wire` — every endpoint shape as a zod schema (suffix `Schema`) and the matching inferred TS type (no suffix). Use `import { FooSchema }` for runtime validation; `import type { Foo }` for the type.
16+
- `skilld-protocol/constants` — readonly tuples backing the closed enums plus their inferred unions.
17+
- `skilld-protocol/test-fixtures` — canonical payloads each consumer round-trips through their schema on CI.
18+
19+
## Repo
20+
21+
This package lives inside the [skilld CLI](https://github.com/skilld-dev/skilld) monorepo at `packages/protocol`. The CLI consumes it as a workspace dep; skilld.dev consumes the published npm version.

packages/protocol/build.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineBuildConfig } from 'obuild/config'
2+
3+
export default defineBuildConfig({
4+
entries: [
5+
{
6+
type: 'bundle',
7+
input: [
8+
'./src/wire.ts',
9+
'./src/constants.ts',
10+
'./src/test-fixtures.ts',
11+
],
12+
outDir: './dist',
13+
},
14+
],
15+
})
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import antfu from '@antfu/eslint-config'
2+
3+
export default antfu({
4+
type: 'lib',
5+
typescript: true,
6+
stylistic: true,
7+
ignores: ['dist', 'node_modules'],
8+
})

packages/protocol/package.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "skilld-protocol",
3+
"type": "module",
4+
"version": "0.2.2",
5+
"description": "Wire shapes and constants shared between the skilld CLI and skilld.dev",
6+
"author": {
7+
"name": "Harlan Wilton",
8+
"email": "harlan@harlanzw.com",
9+
"url": "https://harlanzw.com/"
10+
},
11+
"license": "MIT",
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/skilld-dev/skilld.git",
15+
"directory": "packages/protocol"
16+
},
17+
"keywords": ["skilld", "protocol", "zod", "schema"],
18+
"sideEffects": false,
19+
"exports": {
20+
"./wire": {
21+
"types": "./dist/wire.d.mts",
22+
"import": "./dist/wire.mjs"
23+
},
24+
"./constants": {
25+
"types": "./dist/constants.d.mts",
26+
"import": "./dist/constants.mjs"
27+
},
28+
"./test-fixtures": {
29+
"types": "./dist/test-fixtures.d.mts",
30+
"import": "./dist/test-fixtures.mjs"
31+
}
32+
},
33+
"files": ["dist"],
34+
"engines": {
35+
"node": ">=18"
36+
},
37+
"scripts": {
38+
"build": "obuild",
39+
"lint": "eslint .",
40+
"lint:fix": "eslint . --fix",
41+
"typecheck": "tsc --noEmit",
42+
"test": "vitest",
43+
"test:run": "vitest run",
44+
"publint": "publint",
45+
"attw": "pnpm pack && attw skilld-protocol-*.tgz --ignore-rules no-resolution cjs-resolves-to-esm && rm skilld-protocol-*.tgz",
46+
"prepack": "pnpm build"
47+
},
48+
"dependencies": {
49+
"zod": "catalog:"
50+
},
51+
"devDependencies": {
52+
"@antfu/eslint-config": "catalog:dev-lint",
53+
"@arethetypeswrong/cli": "catalog:",
54+
"@types/node": "catalog:dev-build",
55+
"eslint": "catalog:dev-lint",
56+
"obuild": "catalog:dev-build",
57+
"publint": "catalog:",
58+
"typescript": "catalog:",
59+
"vitest": "catalog:dev-test"
60+
}
61+
}

packages/protocol/src/constants.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* Canonical readonly tuples for closed enums and their inferred TS unions.
3+
*
4+
* The wire schemas import these tuples for `z.enum(...)`. The TS unions are
5+
* exported for tooling (autocomplete, exhaustive switches). Telemetry surface
6+
* is intentionally open on the wire (`z.string().min(1).max(32)` in
7+
* `wire/telemetry.ts`) so the CLI can ship new surfaces without a coordinated
8+
* protocol bump; the closed tuple here is the *currently canonical* list.
9+
*/
10+
11+
export const TELEMETRY_EVENTS = [
12+
'install',
13+
'install-failed',
14+
'update',
15+
'audit-warn',
16+
'audit-fail',
17+
'audit-blocked',
18+
'auth-flow',
19+
'pull-checklist',
20+
] as const
21+
22+
export const TELEMETRY_SURFACES = [
23+
'cli:add',
24+
'cli:pull',
25+
'cli:prepare',
26+
'cli:update',
27+
'cli:wizard',
28+
'cli:auth',
29+
] as const
30+
31+
export const SOURCE_KINDS = [
32+
'npm',
33+
'gh',
34+
'crate',
35+
'collection',
36+
'curator',
37+
] as const
38+
39+
export const AUDIT_STATUSES = [
40+
'pass',
41+
'warn',
42+
'fail',
43+
'unaudited',
44+
] as const
45+
46+
export const AUDIT_ENTRY_STATUSES = [
47+
'pass',
48+
'warn',
49+
'fail',
50+
] as const
51+
52+
export const AUTH_FLOWS = [
53+
'pkce',
54+
'device',
55+
'oidc',
56+
] as const
57+
58+
export type TelemetryEvent = typeof TELEMETRY_EVENTS[number]
59+
export type TelemetrySurface = typeof TELEMETRY_SURFACES[number]
60+
export type SourceKind = typeof SOURCE_KINDS[number]
61+
export type AuditStatus = typeof AUDIT_STATUSES[number]
62+
export type AuditEntryStatus = typeof AUDIT_ENTRY_STATUSES[number]
63+
export type AuthFlow = typeof AUTH_FLOWS[number]

0 commit comments

Comments
 (0)