@timefly/opencode-plugin 0.2.0 → 0.2.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 +2 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +65 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -10
- package/dist/install.d.ts +1 -1
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +2 -7
- package/dist/login.d.ts +2 -1
- package/dist/login.d.ts.map +1 -1
- package/dist/login.js +1 -5
- package/dist/read-chat-params.d.ts +31 -0
- package/dist/read-chat-params.d.ts.map +1 -0
- package/dist/read-chat-params.js +10 -0
- package/package.json +4 -9
package/README.md
CHANGED
|
@@ -14,6 +14,8 @@ bunx @timefly/opencode-plugin login
|
|
|
14
14
|
# 3. Restart OpenCode
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
> **Note:** `login` and `setup-opencode` are subcommands. If `login` runs the installer again, update to v0.2.1+ or use `bunx timefly-opencode-login`.
|
|
18
|
+
|
|
17
19
|
You need a **TimeFly Supporter** plan for sync. Free accounts can install the plugin but `POST /ai/sync` returns 403.
|
|
18
20
|
|
|
19
21
|
## Installation (step by step)
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { runInstall } from './install.js';
|
|
3
|
+
import { runLogin } from './login.js';
|
|
4
|
+
const printHelp = () => {
|
|
5
|
+
console.log(`TimeFly OpenCode plugin
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
bunx @timefly/opencode-plugin <command> [options]
|
|
9
|
+
|
|
10
|
+
Commands:
|
|
11
|
+
setup-opencode Add plugin to opencode.json
|
|
12
|
+
login Sign in with TimeFly (Google OAuth)
|
|
13
|
+
|
|
14
|
+
Setup options:
|
|
15
|
+
--target user|project Config scope (default: user)
|
|
16
|
+
--project /path Required when --target project
|
|
17
|
+
--local Use local build path instead of npm package
|
|
18
|
+
|
|
19
|
+
Examples:
|
|
20
|
+
bunx @timefly/opencode-plugin setup-opencode -- --target user
|
|
21
|
+
bunx @timefly/opencode-plugin login
|
|
22
|
+
`);
|
|
23
|
+
};
|
|
24
|
+
const readCommand = (argumentsList) => {
|
|
25
|
+
const firstArgument = argumentsList[0];
|
|
26
|
+
if (!firstArgument || firstArgument.startsWith('-')) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return firstArgument;
|
|
30
|
+
};
|
|
31
|
+
const readCommandArguments = (argumentsList) => {
|
|
32
|
+
const separatorIndex = argumentsList.indexOf('--');
|
|
33
|
+
if (separatorIndex >= 0) {
|
|
34
|
+
return argumentsList.slice(separatorIndex + 1);
|
|
35
|
+
}
|
|
36
|
+
const command = readCommand(argumentsList);
|
|
37
|
+
if (!command) {
|
|
38
|
+
return argumentsList;
|
|
39
|
+
}
|
|
40
|
+
return argumentsList.slice(1);
|
|
41
|
+
};
|
|
42
|
+
const run = () => {
|
|
43
|
+
const argumentsList = process.argv.slice(2);
|
|
44
|
+
const command = readCommand(argumentsList);
|
|
45
|
+
const commandArguments = readCommandArguments(argumentsList);
|
|
46
|
+
if (command === 'setup-opencode' || command === 'install') {
|
|
47
|
+
return runInstall(commandArguments);
|
|
48
|
+
}
|
|
49
|
+
if (command === 'login') {
|
|
50
|
+
return runLogin();
|
|
51
|
+
}
|
|
52
|
+
if (!command) {
|
|
53
|
+
printHelp();
|
|
54
|
+
return Promise.resolve();
|
|
55
|
+
}
|
|
56
|
+
console.error(`Unknown command: ${command}`);
|
|
57
|
+
printHelp();
|
|
58
|
+
process.exitCode = 1;
|
|
59
|
+
return Promise.resolve();
|
|
60
|
+
};
|
|
61
|
+
run().catch((error) => {
|
|
62
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
63
|
+
console.error(`[timefly-opencode] ${message}`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
});
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAWjD,eAAO,MAAM,qBAAqB,EAAE,MAyDnC,CAAA;AAED,eAAe,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -2,25 +2,38 @@ import { createEventTracker } from './event-tracker.js';
|
|
|
2
2
|
import { handleBusEvent } from './event-handlers.js';
|
|
3
3
|
import { mapCompactionInput, mapLlmRequestInput, mapToolCallInput, mapToolResultInput } from './map-opencode-event.js';
|
|
4
4
|
import { createEventPublisher } from './publish-events.js';
|
|
5
|
+
import { resolveChatParams } from './read-chat-params.js';
|
|
5
6
|
import packageJson from '../package.json' with { type: 'json' };
|
|
6
7
|
const PLUGIN_VERSION = packageJson.version;
|
|
7
8
|
export const timeflyOpenCodePlugin = ({ client }) => {
|
|
8
9
|
const tracker = createEventTracker();
|
|
9
10
|
const publisher = createEventPublisher(client, PLUGIN_VERSION);
|
|
10
|
-
return
|
|
11
|
+
return client.app
|
|
12
|
+
.log({
|
|
13
|
+
body: {
|
|
14
|
+
service: 'timefly-opencode-plugin',
|
|
15
|
+
level: 'info',
|
|
16
|
+
message: `TimeFly telemetry active (v${PLUGIN_VERSION})`,
|
|
17
|
+
extra: { source: 'opencode' }
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
.then(() => undefined)
|
|
21
|
+
.catch(() => undefined)
|
|
22
|
+
.then(() => Promise.resolve({
|
|
11
23
|
event: (input) => handleBusEvent(input.event, tracker, publisher.publish),
|
|
12
24
|
'chat.params': (input, output) => {
|
|
13
25
|
tracker.recordSessionStats(input.sessionID, { requestCount: 1 });
|
|
26
|
+
const resolvedParams = resolveChatParams(input, output);
|
|
14
27
|
return publisher.publish([
|
|
15
28
|
mapLlmRequestInput({
|
|
16
|
-
sessionID:
|
|
17
|
-
agent:
|
|
18
|
-
providerId:
|
|
19
|
-
modelId:
|
|
20
|
-
providerSource:
|
|
21
|
-
temperature:
|
|
22
|
-
topP:
|
|
23
|
-
maxOutputTokens:
|
|
29
|
+
sessionID: resolvedParams.sessionID,
|
|
30
|
+
agent: resolvedParams.agent,
|
|
31
|
+
providerId: resolvedParams.providerId,
|
|
32
|
+
modelId: resolvedParams.modelId,
|
|
33
|
+
providerSource: resolvedParams.providerSource,
|
|
34
|
+
temperature: resolvedParams.temperature,
|
|
35
|
+
topP: resolvedParams.topP,
|
|
36
|
+
maxOutputTokens: resolvedParams.maxOutputTokens
|
|
24
37
|
})
|
|
25
38
|
]);
|
|
26
39
|
},
|
|
@@ -38,6 +51,6 @@ export const timeflyOpenCodePlugin = ({ client }) => {
|
|
|
38
51
|
})
|
|
39
52
|
]),
|
|
40
53
|
'experimental.session.compacting': (input) => publisher.publish([mapCompactionInput(input.sessionID)])
|
|
41
|
-
});
|
|
54
|
+
}));
|
|
42
55
|
};
|
|
43
56
|
export default timeflyOpenCodePlugin;
|
package/dist/install.d.ts
CHANGED
package/dist/install.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":";AA8HA,eAAO,MAAM,UAAU,GAAI,eAAe,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAGhE,CAAA"}
|
package/dist/install.js
CHANGED
|
@@ -87,12 +87,7 @@ const installPlugin = (options) => {
|
|
|
87
87
|
printPostInstallInstructions(configPath);
|
|
88
88
|
});
|
|
89
89
|
};
|
|
90
|
-
const
|
|
91
|
-
const options = parseArguments(
|
|
90
|
+
export const runInstall = (argumentsList) => {
|
|
91
|
+
const options = parseArguments(argumentsList);
|
|
92
92
|
return installPlugin(options);
|
|
93
93
|
};
|
|
94
|
-
run().catch((error) => {
|
|
95
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
96
|
-
console.error(`[timefly-opencode-install] ${message}`);
|
|
97
|
-
process.exit(1);
|
|
98
|
-
});
|
package/dist/login.d.ts
CHANGED
package/dist/login.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":";AA8IA,QAAA,MAAM,QAAQ,QAAO,OAAO,CAAC,IAAI,CAkDhC,CAAA;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
package/dist/login.js
CHANGED
|
@@ -150,8 +150,4 @@ const runLogin = () => {
|
|
|
150
150
|
console.log('Restart OpenCode to start syncing telemetry.');
|
|
151
151
|
});
|
|
152
152
|
};
|
|
153
|
-
runLogin
|
|
154
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
155
|
-
console.error(`[timefly-opencode-login] ${message}`);
|
|
156
|
-
process.exit(1);
|
|
157
|
-
});
|
|
153
|
+
export { runLogin };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type ChatParamsInput = {
|
|
2
|
+
sessionID: string;
|
|
3
|
+
agent: string;
|
|
4
|
+
model?: {
|
|
5
|
+
id?: string;
|
|
6
|
+
providerID?: string;
|
|
7
|
+
};
|
|
8
|
+
provider?: {
|
|
9
|
+
source?: string;
|
|
10
|
+
info?: {
|
|
11
|
+
id?: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export type ChatParamsOutput = {
|
|
16
|
+
temperature: number;
|
|
17
|
+
topP: number;
|
|
18
|
+
maxOutputTokens?: number;
|
|
19
|
+
};
|
|
20
|
+
export type ResolvedChatParams = {
|
|
21
|
+
sessionID: string;
|
|
22
|
+
agent: string;
|
|
23
|
+
providerId: string;
|
|
24
|
+
modelId: string;
|
|
25
|
+
providerSource: string;
|
|
26
|
+
temperature: number;
|
|
27
|
+
topP: number;
|
|
28
|
+
maxOutputTokens?: number;
|
|
29
|
+
};
|
|
30
|
+
export declare const resolveChatParams: (input: ChatParamsInput, output: ChatParamsOutput) => ResolvedChatParams;
|
|
31
|
+
//# sourceMappingURL=read-chat-params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-chat-params.d.ts","sourceRoot":"","sources":["../src/read-chat-params.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE;QACP,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,UAAU,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,QAAQ,CAAC,EAAE;QACV,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,IAAI,CAAC,EAAE;YACN,EAAE,CAAC,EAAE,MAAM,CAAA;SACX,CAAA;KACD,CAAA;CACD,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,eAAe,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,eAAe,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,OAAO,eAAe,EAAE,QAAQ,gBAAgB,KAAG,kBASnF,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const resolveChatParams = (input, output) => ({
|
|
2
|
+
sessionID: input.sessionID,
|
|
3
|
+
agent: input.agent,
|
|
4
|
+
providerId: input.provider?.info?.id ?? input.model?.providerID ?? 'unknown',
|
|
5
|
+
modelId: input.model?.id ?? 'unknown',
|
|
6
|
+
providerSource: input.provider?.source ?? 'unknown',
|
|
7
|
+
temperature: output.temperature,
|
|
8
|
+
topP: output.topP,
|
|
9
|
+
maxOutputTokens: output.maxOutputTokens
|
|
10
|
+
});
|
package/package.json
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timefly/opencode-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "TimeFly telemetry plugin for OpenCode — sessions, tokens, models, and tools",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"bin":
|
|
7
|
-
"timefly-opencode-install": "./dist/install.js",
|
|
8
|
-
"timefly-opencode-login": "./dist/login.js",
|
|
9
|
-
"setup-opencode": "./dist/install.js",
|
|
10
|
-
"login": "./dist/login.js"
|
|
11
|
-
},
|
|
6
|
+
"bin": "./dist/cli.js",
|
|
12
7
|
"main": "./dist/index.js",
|
|
13
8
|
"types": "./dist/index.d.ts",
|
|
14
9
|
"exports": {
|
|
@@ -27,8 +22,8 @@
|
|
|
27
22
|
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p test/tsconfig.json --noEmit",
|
|
28
23
|
"test": "bun test",
|
|
29
24
|
"prepublishOnly": "bun run build && bun run typecheck && bun test",
|
|
30
|
-
"setup-opencode": "bun run dist/
|
|
31
|
-
"login": "bun run dist/
|
|
25
|
+
"setup-opencode": "bun run dist/cli.js setup-opencode",
|
|
26
|
+
"login": "bun run dist/cli.js login",
|
|
32
27
|
"link": "bun link"
|
|
33
28
|
},
|
|
34
29
|
"repository": {
|