opencode-ascii 0.1.1 → 0.1.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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Plugin } from "@opencode-ai/plugin";
2
- import { type SubstitutionConfig } from "./substitutions.js";
2
+ import { type SubstitutionConfig } from "./substitutions";
3
3
  /**
4
4
  * Options accepted by AsciiPlugin.
5
5
  *
@@ -22,3 +22,4 @@ export type AsciiPluginOptions = SubstitutionConfig;
22
22
  * - `tool.execute.before` : rewrites `write` and `edit` tool arguments
23
23
  */
24
24
  export declare const AsciiPlugin: Plugin;
25
+ export default AsciiPlugin;
package/dist/index.js CHANGED
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AsciiPlugin = void 0;
4
- const substitutions_js_1 = require("./substitutions.js");
1
+ import { buildSubstitutions, buildRegex, applySubstitutions, } from "./substitutions";
5
2
  function resolveConfig(options) {
6
3
  if (!options)
7
4
  return {};
@@ -24,9 +21,9 @@ function resolveConfig(options) {
24
21
  * - `experimental.text.complete` : rewrites completed AI text parts
25
22
  * - `tool.execute.before` : rewrites `write` and `edit` tool arguments
26
23
  */
27
- const AsciiPlugin = async (_ctx, options) => {
24
+ export const AsciiPlugin = async (_ctx, options) => {
28
25
  const config = resolveConfig(options);
29
- const substitutions = (0, substitutions_js_1.buildSubstitutions)(config);
26
+ const substitutions = buildSubstitutions(config);
30
27
  if (substitutions.length === 0) {
31
28
  // All categories disabled — nothing to do.
32
29
  return {};
@@ -35,11 +32,11 @@ const AsciiPlugin = async (_ctx, options) => {
35
32
  // Reset regex lastIndex before reuse by always using a fresh call to
36
33
  // buildRegex; the 'g' flag is stateful so we rebuild per call or use
37
34
  // a factory. We build once and rely on String.prototype.replace resetting it.
38
- const regex = (0, substitutions_js_1.buildRegex)(substitutions);
35
+ const regex = buildRegex(substitutions);
39
36
  function substitute(text) {
40
37
  // Reset the regex state (stateful with /g flag)
41
38
  regex.lastIndex = 0;
42
- return (0, substitutions_js_1.applySubstitutions)(text, regex, map);
39
+ return applySubstitutions(text, regex, map);
43
40
  }
44
41
  return {
45
42
  /**
@@ -84,4 +81,4 @@ const AsciiPlugin = async (_ctx, options) => {
84
81
  },
85
82
  };
86
83
  };
87
- exports.AsciiPlugin = AsciiPlugin;
84
+ export default AsciiPlugin;
@@ -1,14 +1,8 @@
1
- "use strict";
2
1
  /**
3
2
  * Unicode → ASCII substitution mappings, organised by category.
4
3
  * Each entry is a tuple of [unicode, ascii].
5
4
  */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.EMOJIS = exports.MATH = exports.ARROWS = exports.PUNCTUATION = void 0;
8
- exports.buildSubstitutions = buildSubstitutions;
9
- exports.buildRegex = buildRegex;
10
- exports.applySubstitutions = applySubstitutions;
11
- exports.PUNCTUATION = [
5
+ export const PUNCTUATION = [
12
6
  // Dashes
13
7
  ["\u2014", "--"], // em dash (—)
14
8
  ["\u2013", "-"], // en dash (–)
@@ -39,7 +33,7 @@ exports.PUNCTUATION = [
39
33
  ["\u2032", "'"], // prime (′)
40
34
  ["\u2033", '"'], // double prime (″)
41
35
  ];
42
- exports.ARROWS = [
36
+ export const ARROWS = [
43
37
  ["\u2192", "->"], // rightwards arrow (→)
44
38
  ["\u2190", "<-"], // leftwards arrow (←)
45
39
  ["\u2191", "^"], // upwards arrow (↑)
@@ -58,7 +52,7 @@ exports.ARROWS = [
58
52
  ["\u2B06", "^"], // upwards black arrow (⬆)
59
53
  ["\u2B07", "v"], // downwards black arrow (⬇)
60
54
  ];
61
- exports.MATH = [
55
+ export const MATH = [
62
56
  ["\u2260", "!="], // not equal to (≠)
63
57
  ["\u2264", "<="], // less-than or equal to (≤)
64
58
  ["\u2265", ">="], // greater-than or equal to (≥)
@@ -86,7 +80,7 @@ exports.MATH = [
86
80
  ["\u2234", ":."], // therefore (∴)
87
81
  ["\u2235", ":'"], // because (∵)
88
82
  ];
89
- exports.EMOJIS = [
83
+ export const EMOJIS = [
90
84
  // Checkmarks / cross marks
91
85
  ["\u2713", "[x]"], // check mark (✓)
92
86
  ["\u2714", "[x]"], // heavy check mark (✔)
@@ -163,24 +157,24 @@ const DEFAULT_CONFIG = {
163
157
  /**
164
158
  * Build a combined substitution map from enabled categories.
165
159
  */
166
- function buildSubstitutions(config = {}) {
160
+ export function buildSubstitutions(config = {}) {
167
161
  const resolved = { ...DEFAULT_CONFIG, ...config };
168
162
  const entries = [];
169
163
  if (resolved.punctuation)
170
- entries.push(...exports.PUNCTUATION);
164
+ entries.push(...PUNCTUATION);
171
165
  if (resolved.arrows)
172
- entries.push(...exports.ARROWS);
166
+ entries.push(...ARROWS);
173
167
  if (resolved.math)
174
- entries.push(...exports.MATH);
168
+ entries.push(...MATH);
175
169
  if (resolved.emojis)
176
- entries.push(...exports.EMOJIS);
170
+ entries.push(...EMOJIS);
177
171
  return entries;
178
172
  }
179
173
  /**
180
174
  * Build a compiled RegExp that matches all active unicode characters at once.
181
175
  * This is much faster than running replace() N times.
182
176
  */
183
- function buildRegex(substitutions) {
177
+ export function buildRegex(substitutions) {
184
178
  const pattern = substitutions
185
179
  .map(([ch]) => ch.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
186
180
  .join("|");
@@ -189,6 +183,6 @@ function buildRegex(substitutions) {
189
183
  /**
190
184
  * Apply substitutions to a string using a pre-built map and regex.
191
185
  */
192
- function applySubstitutions(text, regex, map) {
186
+ export function applySubstitutions(text, regex, map) {
193
187
  return text.replace(regex, (match) => map.get(match) ?? match);
194
188
  }
package/package.json CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "opencode-ascii",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "OpenCode plugin that substitutes unicode characters with ASCII equivalents in AI responses and file edits",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
7
15
  "files": [
8
16
  "dist"
9
17
  ],