@uselemma/opencode 0.1.2 → 0.2.0
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 +1 -1
- package/package.json +2 -2
- package/runtime/lemma.mjs +3310 -1187
- package/scripts/setup.mjs +73 -3
package/scripts/setup.mjs
CHANGED
|
@@ -28,7 +28,8 @@ import {
|
|
|
28
28
|
} from "node:fs/promises";
|
|
29
29
|
import { homedir } from "node:os";
|
|
30
30
|
import { dirname, join, resolve } from "node:path";
|
|
31
|
-
var
|
|
31
|
+
var LEMMA_OPENCODE_SETUP_COMMAND = "pnpm dlx @uselemma/opencode setup";
|
|
32
|
+
var LEMMA_OPENCODE_CREDENTIALS_HELP = `Lemma OpenCode credentials are missing or invalid. Run \`${LEMMA_OPENCODE_SETUP_COMMAND}\` to connect or rotate the scoped credential.`;
|
|
32
33
|
function isRecord(value) {
|
|
33
34
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34
35
|
}
|
|
@@ -107,6 +108,69 @@ async function writeDataDirLocation(dataDir, options = {}) {
|
|
|
107
108
|
await writeSecureJson(locationPath, { version: 1, dataDir: absolute });
|
|
108
109
|
}
|
|
109
110
|
|
|
111
|
+
// package.json
|
|
112
|
+
var package_default = {
|
|
113
|
+
name: "@uselemma/opencode",
|
|
114
|
+
version: "0.2.0",
|
|
115
|
+
description: "Lemma SDK tracing for OpenCode coding-agent sessions",
|
|
116
|
+
license: "MIT",
|
|
117
|
+
author: "Lemma",
|
|
118
|
+
repository: {
|
|
119
|
+
type: "git",
|
|
120
|
+
url: "https://github.com/uselemma/lemma",
|
|
121
|
+
directory: "plugins/lemma-opencode"
|
|
122
|
+
},
|
|
123
|
+
homepage: "https://github.com/uselemma/lemma/tree/main/plugins/lemma-opencode#readme",
|
|
124
|
+
bugs: {
|
|
125
|
+
url: "https://github.com/uselemma/lemma/issues"
|
|
126
|
+
},
|
|
127
|
+
type: "module",
|
|
128
|
+
main: "./runtime/lemma.mjs",
|
|
129
|
+
types: "./runtime/lemma.d.ts",
|
|
130
|
+
exports: {
|
|
131
|
+
".": {
|
|
132
|
+
types: "./runtime/lemma.d.ts",
|
|
133
|
+
import: "./runtime/lemma.mjs",
|
|
134
|
+
default: "./runtime/lemma.mjs"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
bin: {
|
|
138
|
+
"lemma-opencode": "./scripts/setup.mjs"
|
|
139
|
+
},
|
|
140
|
+
files: [
|
|
141
|
+
"runtime/lemma.mjs",
|
|
142
|
+
"runtime/lemma.d.ts",
|
|
143
|
+
"scripts/setup.mjs",
|
|
144
|
+
"README.md"
|
|
145
|
+
],
|
|
146
|
+
keywords: [
|
|
147
|
+
"opencode",
|
|
148
|
+
"observability",
|
|
149
|
+
"tracing"
|
|
150
|
+
],
|
|
151
|
+
scripts: {
|
|
152
|
+
build: "node build.mjs",
|
|
153
|
+
"type-check": "tsc --noEmit",
|
|
154
|
+
test: "vitest run",
|
|
155
|
+
"verify:local": "pnpm run build && node verify-local.mjs",
|
|
156
|
+
prepublishOnly: "pnpm run type-check && pnpm run build"
|
|
157
|
+
},
|
|
158
|
+
dependencies: {
|
|
159
|
+
"@opencode-ai/plugin": "1.18.19",
|
|
160
|
+
"@uselemma/tracing": "workspace:^"
|
|
161
|
+
},
|
|
162
|
+
devDependencies: {
|
|
163
|
+
"@opencode-ai/sdk": "1.18.19",
|
|
164
|
+
"@types/node": "^22.18.8",
|
|
165
|
+
esbuild: "^0.25.11",
|
|
166
|
+
typescript: "^5.9.3",
|
|
167
|
+
vitest: "^3.2.4"
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// src/user-agent.ts
|
|
172
|
+
var PLUGIN_USER_AGENT = `${package_default.name}/${package_default.version}`;
|
|
173
|
+
|
|
110
174
|
// src/setup.ts
|
|
111
175
|
var DEFAULT_API_URL = "https://api.uselemma.ai";
|
|
112
176
|
var MANAGED_PLUGIN_MARKER = "// @uselemma/opencode managed plugin";
|
|
@@ -137,7 +201,10 @@ async function startDeviceAuthorization(apiUrl, fetchImplementation) {
|
|
|
137
201
|
`${apiUrl}/coding-harness/device-authorizations`,
|
|
138
202
|
{
|
|
139
203
|
method: "POST",
|
|
140
|
-
headers: {
|
|
204
|
+
headers: {
|
|
205
|
+
"content-type": "application/json",
|
|
206
|
+
"user-agent": PLUGIN_USER_AGENT
|
|
207
|
+
},
|
|
141
208
|
body: JSON.stringify({ harness: "opencode" })
|
|
142
209
|
}
|
|
143
210
|
)
|
|
@@ -161,7 +228,10 @@ async function pollDeviceAuthorization(apiUrl, deviceCode, fetchImplementation)
|
|
|
161
228
|
`${apiUrl}/coding-harness/device-authorizations/token`,
|
|
162
229
|
{
|
|
163
230
|
method: "POST",
|
|
164
|
-
headers: {
|
|
231
|
+
headers: {
|
|
232
|
+
"content-type": "application/json",
|
|
233
|
+
"user-agent": PLUGIN_USER_AGENT
|
|
234
|
+
},
|
|
165
235
|
body: JSON.stringify({ device_code: deviceCode })
|
|
166
236
|
}
|
|
167
237
|
);
|