opencode-discord-presence 0.1.2 → 0.1.3

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/config.js ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @fileoverview Configuration management for Discord Presence plugin
3
+ * @module opencode-discord-presence/config
4
+ *
5
+ * Handles plugin configuration with sensible defaults and user overrides.
6
+ * Configuration is typically passed from opencode.json.
7
+ */
8
+ /**
9
+ * Default Discord Application ID
10
+ * Users can override this with their own Application ID if needed.
11
+ * This ID should be replaced with the actual shared Application ID
12
+ * created in Discord Developer Portal.
13
+ */
14
+ export const DEFAULT_APPLICATION_ID = "1466770544748662819";
15
+ /**
16
+ * Default configuration for the Discord Presence plugin
17
+ *
18
+ * All options are enabled by default for the best out-of-box experience.
19
+ */
20
+ export const defaultConfig = {
21
+ enabled: true,
22
+ applicationId: DEFAULT_APPLICATION_ID,
23
+ showSessionTime: true,
24
+ showTokenUsage: true,
25
+ showProjectName: true,
26
+ language: "auto",
27
+ };
28
+ /**
29
+ * Merge user configuration with defaults
30
+ *
31
+ * @param userConfig - Partial user configuration from opencode.json
32
+ * @returns Complete configuration with defaults applied
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * // User wants to disable token usage display
37
+ * const config = getConfig({ showTokenUsage: false })
38
+ * // config.enabled === true (default)
39
+ * // config.showTokenUsage === false (user override)
40
+ * // config.showSessionTime === true (default)
41
+ * ```
42
+ */
43
+ export function getConfig(userConfig) {
44
+ return {
45
+ ...defaultConfig,
46
+ ...userConfig,
47
+ };
48
+ }
49
+ /**
50
+ * Validate configuration and return warnings for invalid values
51
+ *
52
+ * @param config - Configuration to validate
53
+ * @returns Array of warning messages
54
+ */
55
+ export function validateConfig(config) {
56
+ const warnings = [];
57
+ if (config.applicationId === DEFAULT_APPLICATION_ID) {
58
+ warnings.push("Using default Discord Application ID. For custom branding, create your own app at https://discord.com/developers/applications");
59
+ }
60
+ if (!config.applicationId) {
61
+ warnings.push("Discord Application ID is required for Rich Presence to work");
62
+ }
63
+ return warnings;
64
+ }
65
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,qBAAqB,CAAA;AAE3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAA0B;IAClD,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,sBAAsB;IACrC,eAAe,EAAE,IAAI;IACrB,cAAc,EAAE,IAAI;IACpB,eAAe,EAAE,IAAI;IACrB,QAAQ,EAAE,MAAM;CACjB,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,SAAS,CAAC,UAA0C;IAClE,OAAO;QACL,GAAG,aAAa;QAChB,GAAG,UAAU;KACd,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAA6B;IAC1D,MAAM,QAAQ,GAAa,EAAE,CAAA;IAE7B,IAAI,MAAM,CAAC,aAAa,KAAK,sBAAsB,EAAE,CAAC;QACpD,QAAQ,CAAC,IAAI,CACX,+HAA+H,CAChI,CAAA;IACH,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;QAC1B,QAAQ,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAA;IAC/E,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { en } from "./locales/en";
2
+ import { ja } from "./locales/ja";
3
+ import { ko } from "./locales/ko";
4
+ import { zh } from "./locales/zh";
5
+ const locales = {
6
+ ko,
7
+ en,
8
+ ja,
9
+ zh,
10
+ };
11
+ export const supportedLanguages = Object.keys(locales);
12
+ function detectSystemLanguage() {
13
+ const env = process.env.LANG || process.env.LANGUAGE || process.env.LC_ALL || "";
14
+ const langCode = env.split("_")[0]?.toLowerCase();
15
+ if (langCode && langCode in locales) {
16
+ return langCode;
17
+ }
18
+ return "en";
19
+ }
20
+ export function getLocale(language = "auto") {
21
+ if (language === "auto") {
22
+ return locales[detectSystemLanguage()];
23
+ }
24
+ return locales[language] || locales.en;
25
+ }
26
+ export function getAvailableLanguages() {
27
+ return Object.values(locales).map((locale) => ({
28
+ code: locale.code,
29
+ name: locale.name,
30
+ }));
31
+ }
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AACjC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AACjC,OAAO,EAAE,EAAE,EAAe,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AAIjC,MAAM,OAAO,GAAuD;IAClE,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;CACH,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAyC,CAAA;AAE9F,SAAS,oBAAoB;IAC3B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAA;IAChF,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAA;IAEjD,IAAI,QAAQ,IAAI,QAAQ,IAAI,OAAO,EAAE,CAAC;QACpC,OAAO,QAA8C,CAAA;IACvD,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,WAA8B,MAAM;IAC5D,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,OAAO,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAA;IACxC,CAAC;IAED,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,EAAE,CAAA;AACxC,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC7C,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;KAClB,CAAC,CAAC,CAAA;AACL,CAAC"}
@@ -0,0 +1,13 @@
1
+ export const en = {
2
+ code: "en",
3
+ name: "English",
4
+ presence: {
5
+ active: (agent) => `Working with ${agent}`,
6
+ idle: (agent) => `${agent} is idle`,
7
+ },
8
+ status: {
9
+ opencode: "OpenCode",
10
+ tokens: (count) => `${count} tokens`,
11
+ },
12
+ };
13
+ //# sourceMappingURL=en.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en.js","sourceRoot":"","sources":["../../../src/i18n/locales/en.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,EAAE,GAAW;IACxB,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,SAAS;IAEf,QAAQ,EAAE;QACR,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,gBAAgB,KAAK,EAAE;QAClD,IAAI,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,KAAK,UAAU;KAC5C;IAED,MAAM,EAAE;QACN,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,KAAK,SAAS;KAC7C;CACF,CAAA"}
@@ -0,0 +1,13 @@
1
+ export const ja = {
2
+ code: "ja",
3
+ name: "日本語",
4
+ presence: {
5
+ active: (agent) => `${agent}で作業中`,
6
+ idle: (agent) => `${agent}は休憩中`,
7
+ },
8
+ status: {
9
+ opencode: "OpenCode",
10
+ tokens: (count) => `${count}トークン`,
11
+ },
12
+ };
13
+ //# sourceMappingURL=ja.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ja.js","sourceRoot":"","sources":["../../../src/i18n/locales/ja.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,EAAE,GAAW;IACxB,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,KAAK;IAEX,QAAQ,EAAE;QACR,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM;QACzC,IAAI,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM;KACxC;IAED,MAAM,EAAE;QACN,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM;KAC1C;CACF,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { withParticle } from "../../utils/particle";
2
+ export const ko = {
3
+ code: "ko",
4
+ name: "한국어",
5
+ presence: {
6
+ active: (agent) => `${withParticle(agent, "을/를")} 갈구는중`,
7
+ idle: (agent) => `${withParticle(agent, "은/는")} 휴식중`,
8
+ },
9
+ status: {
10
+ opencode: "OpenCode",
11
+ tokens: (count) => `${count} 토큰`,
12
+ },
13
+ };
14
+ //# sourceMappingURL=ko.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ko.js","sourceRoot":"","sources":["../../../src/i18n/locales/ko.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAenD,MAAM,CAAC,MAAM,EAAE,GAAW;IACxB,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,KAAK;IAEX,QAAQ,EAAE;QACR,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO;QAC/D,IAAI,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM;KAC7D;IAED,MAAM,EAAE;QACN,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,KAAK,KAAK;KACzC;CACF,CAAA"}
@@ -0,0 +1,13 @@
1
+ export const zh = {
2
+ code: "zh",
3
+ name: "中文",
4
+ presence: {
5
+ active: (agent) => `正在使用 ${agent}`,
6
+ idle: (agent) => `${agent} 休息中`,
7
+ },
8
+ status: {
9
+ opencode: "OpenCode",
10
+ tokens: (count) => `${count} 令牌`,
11
+ },
12
+ };
13
+ //# sourceMappingURL=zh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zh.js","sourceRoot":"","sources":["../../../src/i18n/locales/zh.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,EAAE,GAAW;IACxB,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IAEV,QAAQ,EAAE;QACR,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,QAAQ,KAAK,EAAE;QAC1C,IAAI,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM;KACxC;IAED,MAAM,EAAE;QACN,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,KAAK,KAAK;KACzC;CACF,CAAA"}