@bastiangx/opencode-unmoji 0.1.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.
Files changed (44) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +116 -0
  3. package/dist/core/config.d.ts +22 -0
  4. package/dist/core/config.d.ts.map +1 -0
  5. package/dist/core/config.js +82 -0
  6. package/dist/core/config.js.map +1 -0
  7. package/dist/core/emoji-data-generated.d.ts +6 -0
  8. package/dist/core/emoji-data-generated.d.ts.map +1 -0
  9. package/dist/core/emoji-data-generated.js +28363 -0
  10. package/dist/core/emoji-data-generated.js.map +1 -0
  11. package/dist/core/emoji-data.d.ts +8 -0
  12. package/dist/core/emoji-data.d.ts.map +1 -0
  13. package/dist/core/emoji-data.js +61 -0
  14. package/dist/core/emoji-data.js.map +1 -0
  15. package/dist/core/processor.d.ts +5 -0
  16. package/dist/core/processor.d.ts.map +1 -0
  17. package/dist/core/processor.js +60 -0
  18. package/dist/core/processor.js.map +1 -0
  19. package/dist/index.d.ts +3 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +21 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/plugin.bundled.js +51559 -0
  24. package/dist/types/config.d.ts +36 -0
  25. package/dist/types/config.d.ts.map +1 -0
  26. package/dist/types/config.js +24 -0
  27. package/dist/types/config.js.map +1 -0
  28. package/dist/types/errors.d.ts +59 -0
  29. package/dist/types/errors.d.ts.map +1 -0
  30. package/dist/types/errors.js +6 -0
  31. package/dist/types/errors.js.map +1 -0
  32. package/dist/utils/code-detector.d.ts +17 -0
  33. package/dist/utils/code-detector.d.ts.map +1 -0
  34. package/dist/utils/code-detector.js +252 -0
  35. package/dist/utils/code-detector.js.map +1 -0
  36. package/dist/utils/debug.d.ts +18 -0
  37. package/dist/utils/debug.d.ts.map +1 -0
  38. package/dist/utils/debug.js +10 -0
  39. package/dist/utils/debug.js.map +1 -0
  40. package/dist/utils/grapheme.d.ts +20 -0
  41. package/dist/utils/grapheme.d.ts.map +1 -0
  42. package/dist/utils/grapheme.js +64 -0
  43. package/dist/utils/grapheme.js.map +1 -0
  44. package/package.json +59 -0
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 bastiangx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+
11
+ ---
12
+
13
+ DISCLAIMER: This project is not affiliated with, endorsed by, or associated with OpenCode (https://opencode.ai) or SST (https://sst.dev). "OpenCode" is a trademark of their respective owners. This is an independent, community-developed plugin for the OpenCode platform.
package/README.md ADDED
@@ -0,0 +1,116 @@
1
+ <div align="center">
2
+ <a href="https://codeberg.org/bastiangx/opencode-unmoji">
3
+ <img src="https://github.com/user-attachments/assets/420baa83-4349-41ab-b6f1-a8252c43dee1"/>
4
+ </a>
5
+ </div>
6
+
7
+ # UNMOJI
8
+
9
+ <a href="https://npm.io/package/@bastiangx/opencode-unmoji"><img src="https://img.shields.io/badge/package-black?style=for-the-badge&logo=npm&logoSize=auto&labelColor=%23141010&color=%231F1A1A" alt="NPM Package"></a> <a href="https://opencode.cafe/plugin/unmoji"><img src="https://img.shields.io/badge/cafe-black?style=for-the-badge&logo=awesomelists&logoSize=auto&labelColor=%23141010&color=%231F1A1A" alt="OpenCode Cafe"></a> <a href="https://www.codeberg.org/bastiangx/opencode-unmoji"><img src="https://img.shields.io/badge/codeberg-black?style=for-the-badge&logo=codeberg&logoSize=auto&labelColor=%23141010&color=%231F1A1A" alt="codeberg"></a>
10
+
11
+ An [OpenCode](https://opencode.ai) plugin that strips and replace _all_ emojis from agent outputs.
12
+
13
+ <img src="https://github.com/user-attachments/assets/fe606d89-01b0-4da6-81b7-5014d6aff972"/>
14
+
15
+ ## Installation
16
+
17
+ Add the following to your `opencode.json` file:
18
+
19
+ ```json
20
+ {
21
+ "plugin": ["@bastiangx/opencode-unmoji"]
22
+ }
23
+ ```
24
+
25
+ > You can find your OpenCode file in a couple of different locations:
26
+ >
27
+ > 1. Global: in **`~/.config/opencode/opencode.json`**. You’ll want to use the global config for things like themes, providers, or keybinds.
28
+ > 2. Per Project: You can also add a `opencode.json` in your project. Settings from this config are merged with and can override the global config.
29
+
30
+ > Visit [OpenCode docs](https://opencode.ai/docs/) for more info.
31
+
32
+ ## What It Does
33
+
34
+ UNMOJI automatically removes _all_ _standard_ unicode emojis and glyphs from your agent outputs.
35
+
36
+ Specially useful when you are using models like Claude which seem to _LOVE_ spamming emojis on summaries, README files and documentations.
37
+
38
+ - ~ 4000 emojis covered.
39
+
40
+ > _Thinking_ tokens as output targets are not supported.
41
+
42
+ ## Configuration
43
+
44
+ Create and add the `unmoji.json` file to your OpenCode [config path](https://opencode.ai/docs/config/):
45
+
46
+ ### Options
47
+
48
+ ```json
49
+ {
50
+ "enabled": true,
51
+ "mode": "strip",
52
+ "preserveCodeBlocks": true,
53
+ "preserveInlineCode": true,
54
+ "skipQuotes": false,
55
+ "replacementStyle": "github",
56
+ "replacementFormat": "[:name:]"
57
+ }
58
+ ```
59
+
60
+ | Option | Default | Possible Values | Desc |
61
+ | :------------------- | :--------: | :---------------------------------------------------------- | :-------------------------------------------------- |
62
+ | `enabled` | `true` | `true`, `false` | Enable / disable the plugin without uninstalling it |
63
+ | `mode` | `strip` | `strip`, `replace` | `strip` removes emojis, `replace` puts shortcodes |
64
+ | `preserveCodeBlocks` | `true` | `true`, `false` | Do not process emojis inside code blocks |
65
+ | `preserveInlineCode` | `true` | `true`, `false` | Do not process emojis inside inline code |
66
+ | `skipQuotes` | `false` | `true`, `false` | Do not process emojis inside quoted text blocks |
67
+ | `replacementStyle` | `github` | `github`, `slack`, `discord`, `cldr`, `iamcal`, `joypixels` | Shortcode style used when mode is `replace` |
68
+ | `replacementFormat` | `[:name:]` | `:name:`, `[:name:]`, `{name}` | Template format for shortcode outputs |
69
+
70
+ #### `replace` Examples
71
+
72
+ ##### GitHub Shortcodes
73
+
74
+ ```json
75
+ {
76
+ "mode": "replace",
77
+ "replacementStyle": "github",
78
+ "replacementFormat": ":name:"
79
+ }
80
+ ```
81
+
82
+ ```bash
83
+ # Agent Output
84
+ Great work! 🎉 The tests are passing ✅
85
+ # Processed Output
86
+ Great work! :tada: The tests are passing :white_check_mark:
87
+ ```
88
+
89
+ ##### Slack Shortcodes
90
+
91
+ ```json
92
+ {
93
+ "mode": "replace",
94
+ "replacementStyle": "slack",
95
+ "replacementFormat": "[:name:]"
96
+ }
97
+ ```
98
+
99
+ ```bash
100
+ # Agent Output
101
+ Deploy successful 🚀 Bug fixed 🐛
102
+ # Processed Output
103
+ Deploy successful [:rocket:] Bug fixed [:bug:]
104
+ ```
105
+
106
+ ---
107
+
108
+ ## Contributing
109
+
110
+ Contributions are welcome!
111
+
112
+ Follow the [Contributing guide](/CONTRIBUTING.md) for instructions.
113
+
114
+ ---
115
+
116
+ > License: MIT
@@ -0,0 +1,22 @@
1
+ /**
2
+ * config.ts - Configuration management and validation
3
+ *
4
+ * Handles configuration discovery by merging defaults with global (~/.config)
5
+ * and project-specific (.opencode) settings. Validates schemas using Zod.
6
+ *
7
+ * Key concepts:
8
+ * - Layered configuration merging (Default -> Global -> Project)
9
+ * - Strict schema validation via Zod
10
+ * - Functional error handling using neverthrow Result pattern
11
+ *
12
+ * Main exports:
13
+ * - loadConfig: (projectDir: string) => Result<UnmojiConfig, ConfigError>
14
+ *
15
+ * @see src/types/config.ts
16
+ * @see src/types/errors.ts
17
+ */
18
+ import { type Result } from "neverthrow";
19
+ import { type UnmojiConfig } from "../types/config.js";
20
+ import type { ConfigError } from "../types/errors.js";
21
+ export declare function loadConfig(projectDir: string): Result<UnmojiConfig, ConfigError>;
22
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,YAAY,CAAC;AAClD,OAAO,EAGN,KAAK,YAAY,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,wBAAgB,UAAU,CACzB,UAAU,EAAE,MAAM,GAChB,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,CAoCnC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * config.ts - Configuration management and validation
3
+ *
4
+ * Handles configuration discovery by merging defaults with global (~/.config)
5
+ * and project-specific (.opencode) settings. Validates schemas using Zod.
6
+ *
7
+ * Key concepts:
8
+ * - Layered configuration merging (Default -> Global -> Project)
9
+ * - Strict schema validation via Zod
10
+ * - Functional error handling using neverthrow Result pattern
11
+ *
12
+ * Main exports:
13
+ * - loadConfig: (projectDir: string) => Result<UnmojiConfig, ConfigError>
14
+ *
15
+ * @see src/types/config.ts
16
+ * @see src/types/errors.ts
17
+ */
18
+ import { existsSync, readFileSync } from "node:fs";
19
+ import { join } from "node:path";
20
+ import { ok, err } from "neverthrow";
21
+ import { ConfigSchema, DEFAULT_CONFIG, } from "../types/config.js";
22
+ export function loadConfig(projectDir) {
23
+ const configs = [DEFAULT_CONFIG];
24
+ const homeDir = process.env.HOME || process.env.USERPROFILE;
25
+ if (homeDir) {
26
+ const globalConfigPath = join(homeDir, ".config", "opencode", "unmoji.json");
27
+ const globalConfigResult = loadConfigFile(globalConfigPath);
28
+ if (globalConfigResult.isOk()) {
29
+ configs.push(globalConfigResult.value);
30
+ }
31
+ }
32
+ const projectConfigPath = join(projectDir, ".opencode", "unmoji.json");
33
+ const projectConfigResult = loadConfigFile(projectConfigPath);
34
+ if (projectConfigResult.isOk()) {
35
+ configs.push(projectConfigResult.value);
36
+ }
37
+ const merged = Object.assign({}, ...configs);
38
+ const result = ConfigSchema.safeParse(merged);
39
+ if (!result.success) {
40
+ return err({
41
+ domain: "config",
42
+ code: "INVALID_SCHEMA",
43
+ details: result.error.message,
44
+ });
45
+ }
46
+ return ok(result.data);
47
+ }
48
+ function loadConfigFile(path) {
49
+ if (!existsSync(path)) {
50
+ return err({
51
+ domain: "config",
52
+ code: "FILE_NOT_FOUND",
53
+ path,
54
+ });
55
+ }
56
+ let content;
57
+ try {
58
+ content = readFileSync(path, "utf-8");
59
+ }
60
+ catch (e) {
61
+ return err({
62
+ domain: "config",
63
+ code: "READ_FAILED",
64
+ path,
65
+ reason: String(e),
66
+ });
67
+ }
68
+ let json;
69
+ try {
70
+ json = JSON.parse(content);
71
+ }
72
+ catch {
73
+ return err({
74
+ domain: "config",
75
+ code: "INVALID_JSON",
76
+ path,
77
+ raw: content.slice(0, 100),
78
+ });
79
+ }
80
+ return ok(json);
81
+ }
82
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EA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OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,cAAc,CACtB,IAAY;IAEZ,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC;YACV,MAAM,EAAE,QAAiB;YACzB,IAAI,EAAE,gBAAyB;YAC/B,IAAI;SACJ,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACJ,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,OAAO,GAAG,CAAC;YACV,MAAM,EAAE,QAAiB;YACzB,IAAI,EAAE,aAAsB;YAC5B,IAAI;YACJ,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;SACjB,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACJ,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,GAAG,CAAC;YACV,MAAM,EAAE,QAAiB;YACzB,IAAI,EAAE,cAAuB;YAC7B,IAAI;YACJ,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;SAC1B,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,CAAC,IAA6B,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const EMOJI_SET: Set<string>;
2
+ export declare const EMOJI_MAP_CLDR: Map<string, string>;
3
+ export declare const EMOJI_MAP_GITHUB: Map<string, string>;
4
+ export declare const EMOJI_MAP_IAMCAL: Map<string, string>;
5
+ export declare const EMOJI_MAP_JOYPIXELS: Map<string, string>;
6
+ //# sourceMappingURL=emoji-data-generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emoji-data-generated.d.ts","sourceRoot":"","sources":["../../src/core/emoji-data-generated.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,aAuiLpB,CAAC;AAEH,eAAO,MAAM,cAAc,qBAuiLzB,CAAC;AAEH,eAAO,MAAM,gBAAgB,qBAuiL3B,CAAC;AAEH,eAAO,MAAM,gBAAgB,qBAuiL3B,CAAC;AAEH,eAAO,MAAM,mBAAmB,qBAuiL9B,CAAC"}