opencode-ascii 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/index.d.ts CHANGED
@@ -19,7 +19,7 @@ export type AsciiPluginOptions = SubstitutionConfig;
19
19
  *
20
20
  * Covered hooks:
21
21
  * - `experimental.text.complete` : rewrites completed AI text parts
22
- * - `tool.execute.before` : rewrites `write` and `edit` tool arguments
22
+ * - `tool.execute.before` : rewrites `write`, `edit`, `multiedit`, and `apply_patch` tool arguments
23
23
  */
24
24
  export declare const AsciiPlugin: Plugin;
25
25
  export default AsciiPlugin;
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ function resolveConfig(options) {
19
19
  *
20
20
  * Covered hooks:
21
21
  * - `experimental.text.complete` : rewrites completed AI text parts
22
- * - `tool.execute.before` : rewrites `write` and `edit` tool arguments
22
+ * - `tool.execute.before` : rewrites `write`, `edit`, `multiedit`, and `apply_patch` tool arguments
23
23
  */
24
24
  export const AsciiPlugin = async (_ctx, options) => {
25
25
  const config = resolveConfig(options);
@@ -53,9 +53,10 @@ export const AsciiPlugin = async (_ctx, options) => {
53
53
  * Rewrite file-writing tool arguments before execution.
54
54
  *
55
55
  * Tools handled:
56
- * - `write` : `args.content`
57
- * - `edit` : `args.newString` (NOT `oldString` it must match existing file content)
58
- * - `patch` : `args.patch` (unified diff content)
56
+ * - `write` : `args.content`
57
+ * - `edit` : `args.newString` (NOT `oldString` -- it must match existing file content)
58
+ * - `multiedit` : each `args.edits[].newString`
59
+ * - `apply_patch` : `args.patchText` (unified diff content)
59
60
  */
60
61
  "tool.execute.before": async (input, output) => {
61
62
  switch (input.tool) {
@@ -71,9 +72,19 @@ export const AsciiPlugin = async (_ctx, options) => {
71
72
  }
72
73
  break;
73
74
  }
74
- case "patch": {
75
- if (typeof output.args?.patch === "string") {
76
- output.args.patch = substitute(output.args.patch);
75
+ case "multiedit": {
76
+ if (Array.isArray(output.args?.edits)) {
77
+ for (const edit of output.args.edits) {
78
+ if (typeof edit?.newString === "string") {
79
+ edit.newString = substitute(edit.newString);
80
+ }
81
+ }
82
+ }
83
+ break;
84
+ }
85
+ case "apply_patch": {
86
+ if (typeof output.args?.patchText === "string") {
87
+ output.args.patchText = substitute(output.args.patchText);
77
88
  }
78
89
  break;
79
90
  }
@@ -96,57 +96,57 @@ export const EMOJIS = [
96
96
  ["\u2755", "[!]"], // white exclamation mark ornament (❕)
97
97
  ["\u26A1", "[!]"], // high voltage sign (⚡)
98
98
  // Info / ideas
99
- ["\u2139", "[i]"], // information source ()
100
- ["\u1F4A1", "[i]"], // light bulb (💡)
99
+ ["\u2139", "[i]"], // information source ([i])
100
+ ["\u{1F4A1}", "[i]"], // light bulb (💡)
101
101
  // Stars / rating
102
- ["\u2B50", "[*]"], // white medium star ()
103
- ["\u1F31F", "[*]"], // glowing star (🌟)
104
- ["\u2605", "[*]"], // black star ()
105
- ["\u2606", "[*]"], // white star ()
102
+ ["\u2B50", "[*]"], // white medium star ([*])
103
+ ["\u{1F31F}", "[*]"], // glowing star (🌟)
104
+ ["\u2605", "[*]"], // black star ([*])
105
+ ["\u2606", "[*]"], // white star ([*])
106
106
  // Common emoji sequences
107
- ["\u1F525", "[fire]"], // fire (🔥)
108
- ["\u1F680", "[>>]"], // rocket (🚀)
109
- ["\u1F41B", "[bug]"], // bug (🐛)
110
- ["\u1F41E", "[bug]"], // lady beetle (🐞)
111
- ["\u1F4DD", "[note]"], // memo (📝)
112
- ["\u270F", "[note]"], // pencil ()
113
- ["\u1F512", "[lock]"], // lock (🔒)
114
- ["\u1F513", "[open]"], // open lock (🔓)
115
- ["\u1F4C1", "[dir]"], // file folder (📁)
116
- ["\u1F4C2", "[dir]"], // open file folder (📂)
117
- ["\u1F4C4", "[file]"], // page facing up (📄)
118
- ["\u1F4C3", "[file]"], // page with curl (📃)
119
- ["\u1F44D", "[+1]"], // thumbs up (👍)
120
- ["\u1F44E", "[-1]"], // thumbs down (👎)
121
- ["\u1F4AC", "[comment]"], // speech balloon (💬)
122
- ["\u1F4E6", "[pkg]"], // package (📦)
123
- ["\u1F517", "[link]"], // link (🔗)
124
- ["\u1F6A7", "[wip]"], // construction sign (🚧)
125
- ["\u2699", "[config]"], // gear ()
126
- ["\u1F527", "[fix]"], // wrench (🔧)
127
- ["\u1F5D1", "[del]"], // wastebasket (🗑)
128
- ["\u1F310", "[web]"], // globe with meridians (🌐)
129
- ["\u1F4BB", "[pc]"], // personal computer (💻)
130
- ["\u1F4F1", "[phone]"], // mobile phone (📱)
131
- ["\u1F4E7", "[email]"], // e-mail (📧)
132
- ["\u1F4CA", "[chart]"], // bar chart (📊)
133
- ["\u1F4C8", "[up]"], // chart with upwards trend (📈)
134
- ["\u1F4C9", "[down]"], // chart with downwards trend (📉)
135
- ["\u2764", "[<3]"], // heavy black heart ()
136
- ["\u1F4AF", "[100]"], // hundred points (💯)
137
- ["\u1F44B", "[wave]"], // waving hand (👋)
138
- ["\u1F91D", "[deal]"], // handshake (🤝)
139
- ["\u1F4AA", "[strong]"], // flexed biceps (💪)
140
- ["\u1F914", "[?]"], // thinking face (🤔)
141
- ["\u1F644", "[eye-roll]"], // face with rolling eyes (🙄)
142
- ["\u1F4A5", "[boom]"], // collision (💥)
143
- ["\u1F389", "[party]"], // party popper (🎉)
144
- ["\u1F3C6", "[trophy]"], // trophy (🏆)
145
- ["\u1F4B0", "[money]"], // money bag (💰)
146
- ["\u231B", "[wait]"], // hourglass ()
147
- ["\u23F3", "[wait]"], // hourglass with flowing sand ()
148
- ["\u1F504", "[refresh]"], // counterclockwise arrows button (🔄)
149
- ["\u2705", "[done]"], // white heavy check mark () already above, kept for completeness
107
+ ["\u{1F525}", "[fire]"], // fire (🔥)
108
+ ["\u{1F680}", "[>>]"], // rocket (🚀)
109
+ ["\u{1F41B}", "[bug]"], // bug (🐛)
110
+ ["\u{1F41E}", "[bug]"], // lady beetle (🐞)
111
+ ["\u{1F4DD}", "[note]"], // memo (📝)
112
+ ["\u270F", "[note]"], // pencil ([note])
113
+ ["\u{1F512}", "[lock]"], // lock (🔒)
114
+ ["\u{1F513}", "[open]"], // open lock (🔓)
115
+ ["\u{1F4C1}", "[dir]"], // file folder (📁)
116
+ ["\u{1F4C2}", "[dir]"], // open file folder (📂)
117
+ ["\u{1F4C4}", "[file]"], // page facing up (📄)
118
+ ["\u{1F4C3}", "[file]"], // page with curl (📃)
119
+ ["\u{1F44D}", "[+1]"], // thumbs up (👍)
120
+ ["\u{1F44E}", "[-1]"], // thumbs down (👎)
121
+ ["\u{1F4AC}", "[comment]"], // speech balloon (💬)
122
+ ["\u{1F4E6}", "[pkg]"], // package (📦)
123
+ ["\u{1F517}", "[link]"], // link (🔗)
124
+ ["\u{1F6A7}", "[wip]"], // construction sign (🚧)
125
+ ["\u2699", "[config]"], // gear ([config])
126
+ ["\u{1F527}", "[fix]"], // wrench (🔧)
127
+ ["\u{1F5D1}", "[del]"], // wastebasket (🗑)
128
+ ["\u{1F310}", "[web]"], // globe with meridians (🌐)
129
+ ["\u{1F4BB}", "[pc]"], // personal computer (💻)
130
+ ["\u{1F4F1}", "[phone]"], // mobile phone (📱)
131
+ ["\u{1F4E7}", "[email]"], // e-mail (📧)
132
+ ["\u{1F4CA}", "[chart]"], // bar chart (📊)
133
+ ["\u{1F4C8}", "[up]"], // chart with upwards trend (📈)
134
+ ["\u{1F4C9}", "[down]"], // chart with downwards trend (📉)
135
+ ["\u2764", "[<3]"], // heavy black heart ([<3])
136
+ ["\u{1F4AF}", "[100]"], // hundred points (💯)
137
+ ["\u{1F44B}", "[wave]"], // waving hand (👋)
138
+ ["\u{1F91D}", "[deal]"], // handshake (🤝)
139
+ ["\u{1F4AA}", "[strong]"], // flexed biceps (💪)
140
+ ["\u{1F914}", "[?]"], // thinking face (🤔)
141
+ ["\u{1F644}", "[eye-roll]"], // face with rolling eyes (🙄)
142
+ ["\u{1F4A5}", "[boom]"], // collision (💥)
143
+ ["\u{1F389}", "[party]"], // party popper (🎉)
144
+ ["\u{1F3C6}", "[trophy]"], // trophy (🏆)
145
+ ["\u{1F4B0}", "[money]"], // money bag (💰)
146
+ ["\u231B", "[wait]"], // hourglass ([wait])
147
+ ["\u23F3", "[wait]"], // hourglass with flowing sand ([wait])
148
+ ["\u{1F504}", "[refresh]"], // counterclockwise arrows button (🔄)
149
+ ["\u2705", "[done]"], // white heavy check mark ([done]) -- already above, kept for completeness
150
150
  ];
151
151
  const DEFAULT_CONFIG = {
152
152
  punctuation: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-ascii",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "OpenCode plugin that substitutes unicode characters with ASCII equivalents in AI responses and file edits",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -17,6 +17,8 @@
17
17
  ],
18
18
  "scripts": {
19
19
  "build": "tsc",
20
+ "test": "vitest run",
21
+ "test:watch": "vitest",
20
22
  "prepublishOnly": "npm run build"
21
23
  },
22
24
  "peerDependencies": {
@@ -24,7 +26,8 @@
24
26
  },
25
27
  "devDependencies": {
26
28
  "@opencode-ai/plugin": "latest",
27
- "typescript": "^5"
29
+ "typescript": "^5",
30
+ "vitest": "^4.1.2"
28
31
  },
29
32
  "keywords": [
30
33
  "opencode",