opencode-synced 0.4.0 → 0.4.1
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/dist/index.js +171 -13877
- package/dist/sync/apply.d.ts +1 -1
- package/dist/sync/apply.js +195 -0
- package/dist/sync/commit.js +74 -0
- package/dist/sync/config.d.ts +1 -1
- package/dist/sync/config.js +176 -0
- package/dist/sync/errors.js +32 -0
- package/dist/sync/paths.d.ts +1 -1
- package/dist/sync/paths.js +178 -0
- package/dist/sync/repo.d.ts +1 -1
- package/dist/sync/repo.js +248 -0
- package/dist/sync/service.js +453 -0
- package/dist/sync/utils.js +70 -0
- package/package.json +2 -2
- package/dist/sync/config.test.d.ts +0 -1
- package/dist/sync/paths.test.d.ts +0 -1
- package/dist/sync/repo.test.d.ts +0 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const SERVICE_NAME = 'opencode-synced';
|
|
2
|
+
export function createLogger(client) {
|
|
3
|
+
return {
|
|
4
|
+
debug: (message, extra) => log(client, 'debug', message, extra),
|
|
5
|
+
info: (message, extra) => log(client, 'info', message, extra),
|
|
6
|
+
warn: (message, extra) => log(client, 'warn', message, extra),
|
|
7
|
+
error: (message, extra) => log(client, 'error', message, extra),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function log(client, level, message, extra) {
|
|
11
|
+
client.app
|
|
12
|
+
.log({
|
|
13
|
+
body: {
|
|
14
|
+
service: SERVICE_NAME,
|
|
15
|
+
level,
|
|
16
|
+
message,
|
|
17
|
+
extra,
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
.catch((err) => {
|
|
21
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
22
|
+
showToast(client, `Logging failed: ${errorMsg}`, 'error');
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export async function showToast(client, message, variant) {
|
|
26
|
+
await client.tui.showToast({
|
|
27
|
+
body: { title: 'opencode-synced plugin', message, variant },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function unwrapData(response) {
|
|
31
|
+
if (!response || typeof response !== 'object')
|
|
32
|
+
return null;
|
|
33
|
+
const maybeError = response.error;
|
|
34
|
+
if (maybeError)
|
|
35
|
+
return null;
|
|
36
|
+
if ('data' in response) {
|
|
37
|
+
const data = response.data;
|
|
38
|
+
if (data !== undefined)
|
|
39
|
+
return data;
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return response;
|
|
43
|
+
}
|
|
44
|
+
export function extractTextFromResponse(response) {
|
|
45
|
+
if (!response || typeof response !== 'object')
|
|
46
|
+
return null;
|
|
47
|
+
const parts = response.parts ??
|
|
48
|
+
response.info?.parts ??
|
|
49
|
+
[];
|
|
50
|
+
const textPart = parts.find((part) => part.type === 'text' && part.text);
|
|
51
|
+
return textPart?.text?.trim() ?? null;
|
|
52
|
+
}
|
|
53
|
+
export async function resolveSmallModel(client) {
|
|
54
|
+
try {
|
|
55
|
+
const response = await client.config.get();
|
|
56
|
+
const config = unwrapData(response);
|
|
57
|
+
if (!config)
|
|
58
|
+
return null;
|
|
59
|
+
const modelValue = config.small_model ?? config.model;
|
|
60
|
+
if (!modelValue)
|
|
61
|
+
return null;
|
|
62
|
+
const [providerID, modelID] = modelValue.split('/', 2);
|
|
63
|
+
if (!providerID || !modelID)
|
|
64
|
+
return null;
|
|
65
|
+
return { providerID, modelID };
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-synced",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Sync global OpenCode config across machines via GitHub.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ian Hildebrand"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"vitest": "^3.2.4"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
|
-
"build": "rm -rf dist &&
|
|
40
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && cp -r src/command dist/command",
|
|
41
41
|
"test": "vitest run",
|
|
42
42
|
"test:watch": "vitest",
|
|
43
43
|
"lint": "biome lint .",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/sync/repo.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|