@tooldeck/cli 1.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.
@@ -0,0 +1,127 @@
1
+ //#region ../../packages/sdk-node/dist/index.js
2
+ function definePlugin(input) {
3
+ if (typeof input === "function") return defineBuilderPlugin(input);
4
+ if ("activate" in input && typeof input.activate === "function") return input;
5
+ return defineObjectPlugin(input);
6
+ }
7
+ function defineBuilderPlugin(setup) {
8
+ let definition;
9
+ return {
10
+ async activate(ctx) {
11
+ definition = createNormalizedPluginDefinition();
12
+ await setup(createPluginBuilder(definition));
13
+ await activateDefinition(ctx, definition);
14
+ },
15
+ async deactivate(ctx) {
16
+ if (!definition) return;
17
+ await deactivateDefinition(ctx, definition);
18
+ }
19
+ };
20
+ }
21
+ function defineObjectPlugin(definition) {
22
+ const normalizedDefinition = createNormalizedPluginDefinition(definition);
23
+ return {
24
+ async activate(ctx) {
25
+ await activateDefinition(ctx, normalizedDefinition);
26
+ },
27
+ async deactivate(ctx) {
28
+ await deactivateDefinition(ctx, normalizedDefinition);
29
+ }
30
+ };
31
+ }
32
+ function createPluginBuilder(definition) {
33
+ return {
34
+ command(commandId, handler) {
35
+ definition.commands.push({
36
+ commandId,
37
+ handler
38
+ });
39
+ },
40
+ onActivate(handler) {
41
+ definition.onActivate.push(handler);
42
+ },
43
+ onDeactivate(handler) {
44
+ definition.onDeactivate.push(handler);
45
+ }
46
+ };
47
+ }
48
+ function createNormalizedPluginDefinition(definition) {
49
+ return {
50
+ commands: definition?.commands ? normalizeCommands(definition.commands) : [],
51
+ onActivate: definition?.onActivate ? [definition.onActivate] : [],
52
+ onDeactivate: definition?.onDeactivate ? [definition.onDeactivate] : []
53
+ };
54
+ }
55
+ function normalizeCommands(commands) {
56
+ return Object.entries(commands).map(([commandId, handler]) => ({
57
+ commandId,
58
+ handler
59
+ }));
60
+ }
61
+ async function activateDefinition(ctx, definition) {
62
+ for (const onActivate of definition.onActivate) await onActivate(ctx);
63
+ for (const command of definition.commands) ctx.subscriptions.push(ctx.commands.register(command.commandId, command.handler));
64
+ }
65
+ async function deactivateDefinition(ctx, definition) {
66
+ for (const onDeactivate of definition.onDeactivate.toReversed()) await onDeactivate(ctx);
67
+ }
68
+ function textBlock(text) {
69
+ return {
70
+ type: "text",
71
+ text
72
+ };
73
+ }
74
+ function codeBlock(text, language) {
75
+ return {
76
+ type: "code",
77
+ text,
78
+ ...language === void 0 ? {} : { language }
79
+ };
80
+ }
81
+ function ok(blocks) {
82
+ return {
83
+ status: "success",
84
+ blocks
85
+ };
86
+ }
87
+ function fail(code, message, blocks = []) {
88
+ return {
89
+ status: "error",
90
+ blocks,
91
+ error: {
92
+ code,
93
+ message
94
+ }
95
+ };
96
+ }
97
+ function failText(code, message, text) {
98
+ return fail(code, message, text === void 0 ? [] : [textBlock(text)]);
99
+ }
100
+ //#endregion
101
+ //#region src/index.ts
102
+ var src_default = definePlugin((plugin) => {
103
+ plugin.command("json.format", formatJson);
104
+ });
105
+ var formatJson = async (input) => {
106
+ if (typeof input.text !== "string") {
107
+ const message = "json.format requires a text string.";
108
+ return failText("ERR_INVALID_INPUT", message, message);
109
+ }
110
+ try {
111
+ const value = JSON.parse(input.text);
112
+ const indent = normalizeIndent(input.indent);
113
+ return ok([codeBlock(JSON.stringify(value, null, indent), "json")]);
114
+ } catch (error) {
115
+ const message = error instanceof Error ? error.message : String(error);
116
+ return failText("ERR_INVALID_JSON", message, `Invalid JSON: ${message}`);
117
+ }
118
+ };
119
+ function normalizeIndent(value) {
120
+ if (value === void 0) return 2;
121
+ if (!Number.isInteger(value) || value < 0 || value > 8) return 2;
122
+ return value;
123
+ }
124
+ //#endregion
125
+ export { src_default as default };
126
+
127
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../packages/sdk-node/dist/index.js","../src/index.ts"],"sourcesContent":["//#region src/disposable.ts\nfunction toDisposable(dispose) {\n\treturn { dispose };\n}\n//#endregion\n//#region src/plugin.ts\nfunction definePlugin(input) {\n\tif (typeof input === \"function\") return defineBuilderPlugin(input);\n\tif (\"activate\" in input && typeof input.activate === \"function\") return input;\n\treturn defineObjectPlugin(input);\n}\nfunction defineBuilderPlugin(setup) {\n\tlet definition;\n\treturn {\n\t\tasync activate(ctx) {\n\t\t\tdefinition = createNormalizedPluginDefinition();\n\t\t\tawait setup(createPluginBuilder(definition));\n\t\t\tawait activateDefinition(ctx, definition);\n\t\t},\n\t\tasync deactivate(ctx) {\n\t\t\tif (!definition) return;\n\t\t\tawait deactivateDefinition(ctx, definition);\n\t\t}\n\t};\n}\nfunction defineObjectPlugin(definition) {\n\tconst normalizedDefinition = createNormalizedPluginDefinition(definition);\n\treturn {\n\t\tasync activate(ctx) {\n\t\t\tawait activateDefinition(ctx, normalizedDefinition);\n\t\t},\n\t\tasync deactivate(ctx) {\n\t\t\tawait deactivateDefinition(ctx, normalizedDefinition);\n\t\t}\n\t};\n}\nfunction createPluginBuilder(definition) {\n\treturn {\n\t\tcommand(commandId, handler) {\n\t\t\tdefinition.commands.push({\n\t\t\t\tcommandId,\n\t\t\t\thandler\n\t\t\t});\n\t\t},\n\t\tonActivate(handler) {\n\t\t\tdefinition.onActivate.push(handler);\n\t\t},\n\t\tonDeactivate(handler) {\n\t\t\tdefinition.onDeactivate.push(handler);\n\t\t}\n\t};\n}\nfunction createNormalizedPluginDefinition(definition) {\n\treturn {\n\t\tcommands: definition?.commands ? normalizeCommands(definition.commands) : [],\n\t\tonActivate: definition?.onActivate ? [definition.onActivate] : [],\n\t\tonDeactivate: definition?.onDeactivate ? [definition.onDeactivate] : []\n\t};\n}\nfunction normalizeCommands(commands) {\n\treturn Object.entries(commands).map(([commandId, handler]) => ({\n\t\tcommandId,\n\t\thandler\n\t}));\n}\nasync function activateDefinition(ctx, definition) {\n\tfor (const onActivate of definition.onActivate) await onActivate(ctx);\n\tfor (const command of definition.commands) ctx.subscriptions.push(ctx.commands.register(command.commandId, command.handler));\n}\nasync function deactivateDefinition(ctx, definition) {\n\tfor (const onDeactivate of definition.onDeactivate.toReversed()) await onDeactivate(ctx);\n}\n//#endregion\n//#region src/results.ts\nfunction textBlock(text) {\n\treturn {\n\t\ttype: \"text\",\n\t\ttext\n\t};\n}\nfunction codeBlock(text, language) {\n\treturn {\n\t\ttype: \"code\",\n\t\ttext,\n\t\t...language === void 0 ? {} : { language }\n\t};\n}\nfunction jsonBlock(value) {\n\treturn {\n\t\ttype: \"json\",\n\t\tvalue\n\t};\n}\nfunction propertiesBlock(items) {\n\treturn {\n\t\ttype: \"properties\",\n\t\titems\n\t};\n}\nfunction ok(blocks) {\n\treturn {\n\t\tstatus: \"success\",\n\t\tblocks\n\t};\n}\nfunction okText(text) {\n\treturn ok([textBlock(text)]);\n}\nfunction fail(code, message, blocks = []) {\n\treturn {\n\t\tstatus: \"error\",\n\t\tblocks,\n\t\terror: {\n\t\t\tcode,\n\t\t\tmessage\n\t\t}\n\t};\n}\nfunction failText(code, message, text) {\n\treturn fail(code, message, text === void 0 ? [] : [textBlock(text)]);\n}\n//#endregion\nexport { codeBlock, definePlugin, fail, failText, jsonBlock, ok, okText, propertiesBlock, textBlock, toDisposable };\n\n//# sourceMappingURL=index.js.map","import type { CommandHandler } from \"@tooldeck/sdk-node\";\nimport { codeBlock, definePlugin, failText, ok } from \"@tooldeck/sdk-node\";\n\nimport type { JsonFormatInput, PluginCommandInputs } from \"./generated/commands\";\n\nexport default definePlugin<PluginCommandInputs>((plugin) => {\n plugin.command(\"json.format\", formatJson);\n});\n\nconst formatJson: CommandHandler<JsonFormatInput> = async (input) => {\n if (typeof input.text !== \"string\") {\n const message = \"json.format requires a text string.\";\n\n return failText(\"ERR_INVALID_INPUT\", message, message);\n }\n\n try {\n const value = JSON.parse(input.text);\n const indent = normalizeIndent(input.indent);\n\n return ok([codeBlock(JSON.stringify(value, null, indent), \"json\")]);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n return failText(\"ERR_INVALID_JSON\", message, `Invalid JSON: ${message}`);\n }\n};\n\nfunction normalizeIndent(value: number | undefined): number {\n if (value === undefined) {\n return 2;\n }\n\n if (!Number.isInteger(value) || value < 0 || value > 8) {\n return 2;\n }\n\n return value;\n}\n"],"mappings":";AAMA,SAAS,aAAa,OAAO;CAC5B,IAAI,OAAO,UAAU,YAAY,OAAO,oBAAoB,KAAK;CACjE,IAAI,cAAc,SAAS,OAAO,MAAM,aAAa,YAAY,OAAO;CACxE,OAAO,mBAAmB,KAAK;AAChC;AACA,SAAS,oBAAoB,OAAO;CACnC,IAAI;CACJ,OAAO;EACN,MAAM,SAAS,KAAK;GACnB,aAAa,iCAAiC;GAC9C,MAAM,MAAM,oBAAoB,UAAU,CAAC;GAC3C,MAAM,mBAAmB,KAAK,UAAU;EACzC;EACA,MAAM,WAAW,KAAK;GACrB,IAAI,CAAC,YAAY;GACjB,MAAM,qBAAqB,KAAK,UAAU;EAC3C;CACD;AACD;AACA,SAAS,mBAAmB,YAAY;CACvC,MAAM,uBAAuB,iCAAiC,UAAU;CACxE,OAAO;EACN,MAAM,SAAS,KAAK;GACnB,MAAM,mBAAmB,KAAK,oBAAoB;EACnD;EACA,MAAM,WAAW,KAAK;GACrB,MAAM,qBAAqB,KAAK,oBAAoB;EACrD;CACD;AACD;AACA,SAAS,oBAAoB,YAAY;CACxC,OAAO;EACN,QAAQ,WAAW,SAAS;GAC3B,WAAW,SAAS,KAAK;IACxB;IACA;GACD,CAAC;EACF;EACA,WAAW,SAAS;GACnB,WAAW,WAAW,KAAK,OAAO;EACnC;EACA,aAAa,SAAS;GACrB,WAAW,aAAa,KAAK,OAAO;EACrC;CACD;AACD;AACA,SAAS,iCAAiC,YAAY;CACrD,OAAO;EACN,UAAU,YAAY,WAAW,kBAAkB,WAAW,QAAQ,IAAI,CAAC;EAC3E,YAAY,YAAY,aAAa,CAAC,WAAW,UAAU,IAAI,CAAC;EAChE,cAAc,YAAY,eAAe,CAAC,WAAW,YAAY,IAAI,CAAC;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AO,GAAG,CAAC,UAAU,KAAK,UAAU,OAAO,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC;CACpE,SAAS,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAErE,OAAO,SAAS,oBAAoB,SAAS,iBAAiB,SAAS;CACzE;AACF;AAEA,SAAS,gBAAgB,OAAmC;CAC1D,IAAI,UAAU,KAAA,GACZ,OAAO;CAGT,IAAI,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,KAAK,QAAQ,GACnD,OAAO;CAGT,OAAO;AACT"}
@@ -0,0 +1,8 @@
1
+ {
2
+ "plugin.name": "JSON Tools",
3
+ "plugin.description": "Tools for formatting JSON.",
4
+ "commands.format.title": "Format JSON",
5
+ "commands.format.description": "Format JSON text with configurable indentation.",
6
+ "schema.format.text.title": "JSON Text",
7
+ "schema.format.indent.title": "Indent Size"
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "plugin.name": "JSON 工具",
3
+ "plugin.description": "用于格式化 JSON 的工具。",
4
+ "commands.format.title": "格式化 JSON",
5
+ "commands.format.description": "使用可配置缩进格式化 JSON 文本。",
6
+ "schema.format.text.title": "JSON 文本",
7
+ "schema.format.indent.title": "缩进大小"
8
+ }
@@ -0,0 +1,69 @@
1
+ {
2
+ "$schema": "../../packages/protocol/schema/manifest-v1.schema.json",
3
+ "schemaVersion": "1.0",
4
+ "id": "dev.tooldeck.json-tools",
5
+ "name": {
6
+ "key": "plugin.name",
7
+ "default": "JSON Tools"
8
+ },
9
+ "description": {
10
+ "key": "plugin.description",
11
+ "default": "Tools for formatting JSON."
12
+ },
13
+ "version": "1.1.0",
14
+ "runtime": {
15
+ "kind": "node",
16
+ "entry": "./dist/index.js"
17
+ },
18
+ "defaultLocale": "en",
19
+ "locales": {
20
+ "en": "./locales/en.json",
21
+ "zh-CN": "./locales/zh-CN.json"
22
+ },
23
+ "contributes": {
24
+ "commands": [
25
+ {
26
+ "id": "json.format",
27
+ "title": {
28
+ "key": "commands.format.title",
29
+ "default": "Format JSON"
30
+ },
31
+ "description": {
32
+ "key": "commands.format.description",
33
+ "default": "Format JSON text with configurable indentation."
34
+ },
35
+ "x-ui": {
36
+ "layout": "split"
37
+ },
38
+ "inputSchema": {
39
+ "type": "object",
40
+ "required": ["text"],
41
+ "additionalProperties": false,
42
+ "x-ui": {
43
+ "fieldOrder": ["text", "indent"]
44
+ },
45
+ "properties": {
46
+ "text": {
47
+ "type": "string",
48
+ "title": "JSON Text",
49
+ "minLength": 1,
50
+ "x-i18n": {
51
+ "title": "schema.format.text.title"
52
+ }
53
+ },
54
+ "indent": {
55
+ "type": "integer",
56
+ "title": "Indent Size",
57
+ "default": 2,
58
+ "minimum": 0,
59
+ "maximum": 8,
60
+ "x-i18n": {
61
+ "title": "schema.format.indent.title"
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ ]
68
+ }
69
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@tooldeck/json-tools",
3
+ "version": "1.1.0",
4
+ "private": true,
5
+ "description": "JSON tools plugin for Tooldeck.",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": "./dist/index.js"
9
+ },
10
+ "scripts": {
11
+ "generate:types": "pnpm --dir ../.. --filter @tooldeck/plugin-tools build && node ../../packages/plugin-tools/dist/generate-command-types.js manifest.json src/generated/commands.ts",
12
+ "build": "pnpm generate:types && vite build --configLoader runner",
13
+ "typecheck": "pnpm generate:types && tsc --noEmit"
14
+ },
15
+ "dependencies": {
16
+ "@tooldeck/plugin-tools": "workspace:*",
17
+ "@tooldeck/sdk-node": "workspace:*"
18
+ }
19
+ }
@@ -0,0 +1,310 @@
1
+ //#region ../../packages/sdk-node/dist/index.js
2
+ function definePlugin(input) {
3
+ if (typeof input === "function") return defineBuilderPlugin(input);
4
+ if ("activate" in input && typeof input.activate === "function") return input;
5
+ return defineObjectPlugin(input);
6
+ }
7
+ function defineBuilderPlugin(setup) {
8
+ let definition;
9
+ return {
10
+ async activate(ctx) {
11
+ definition = createNormalizedPluginDefinition();
12
+ await setup(createPluginBuilder(definition));
13
+ await activateDefinition(ctx, definition);
14
+ },
15
+ async deactivate(ctx) {
16
+ if (!definition) return;
17
+ await deactivateDefinition(ctx, definition);
18
+ }
19
+ };
20
+ }
21
+ function defineObjectPlugin(definition) {
22
+ const normalizedDefinition = createNormalizedPluginDefinition(definition);
23
+ return {
24
+ async activate(ctx) {
25
+ await activateDefinition(ctx, normalizedDefinition);
26
+ },
27
+ async deactivate(ctx) {
28
+ await deactivateDefinition(ctx, normalizedDefinition);
29
+ }
30
+ };
31
+ }
32
+ function createPluginBuilder(definition) {
33
+ return {
34
+ command(commandId, handler) {
35
+ definition.commands.push({
36
+ commandId,
37
+ handler
38
+ });
39
+ },
40
+ onActivate(handler) {
41
+ definition.onActivate.push(handler);
42
+ },
43
+ onDeactivate(handler) {
44
+ definition.onDeactivate.push(handler);
45
+ }
46
+ };
47
+ }
48
+ function createNormalizedPluginDefinition(definition) {
49
+ return {
50
+ commands: definition?.commands ? normalizeCommands(definition.commands) : [],
51
+ onActivate: definition?.onActivate ? [definition.onActivate] : [],
52
+ onDeactivate: definition?.onDeactivate ? [definition.onDeactivate] : []
53
+ };
54
+ }
55
+ function normalizeCommands(commands) {
56
+ return Object.entries(commands).map(([commandId, handler]) => ({
57
+ commandId,
58
+ handler
59
+ }));
60
+ }
61
+ async function activateDefinition(ctx, definition) {
62
+ for (const onActivate of definition.onActivate) await onActivate(ctx);
63
+ for (const command of definition.commands) ctx.subscriptions.push(ctx.commands.register(command.commandId, command.handler));
64
+ }
65
+ async function deactivateDefinition(ctx, definition) {
66
+ for (const onDeactivate of definition.onDeactivate.toReversed()) await onDeactivate(ctx);
67
+ }
68
+ function textBlock(text) {
69
+ return {
70
+ type: "text",
71
+ text
72
+ };
73
+ }
74
+ function codeBlock(text, language) {
75
+ return {
76
+ type: "code",
77
+ text,
78
+ ...language === void 0 ? {} : { language }
79
+ };
80
+ }
81
+ function jsonBlock(value) {
82
+ return {
83
+ type: "json",
84
+ value
85
+ };
86
+ }
87
+ function propertiesBlock(items) {
88
+ return {
89
+ type: "properties",
90
+ items
91
+ };
92
+ }
93
+ function ok(blocks) {
94
+ return {
95
+ status: "success",
96
+ blocks
97
+ };
98
+ }
99
+ function fail(code, message, blocks = []) {
100
+ return {
101
+ status: "error",
102
+ blocks,
103
+ error: {
104
+ code,
105
+ message
106
+ }
107
+ };
108
+ }
109
+ function failText(code, message, text) {
110
+ return fail(code, message, text === void 0 ? [] : [textBlock(text)]);
111
+ }
112
+ //#endregion
113
+ //#region src/index.ts
114
+ var flagOrder = [
115
+ "g",
116
+ "i",
117
+ "m",
118
+ "s",
119
+ "u",
120
+ "y"
121
+ ];
122
+ var defaultExtractSections = [
123
+ "match",
124
+ "index",
125
+ "groups",
126
+ "stats"
127
+ ];
128
+ var src_default = definePlugin((plugin) => {
129
+ plugin.command("regex.test", testRegex);
130
+ plugin.command("regex.extract", extractRegex);
131
+ plugin.command("regex.replace", replaceRegex);
132
+ plugin.command("regex.escape", escapeRegex);
133
+ });
134
+ var testRegex = async (input) => {
135
+ const regex = createRegex(input.mode === "full" ? `^(?:${input.pattern})$` : input.pattern, input.flags);
136
+ if (regex instanceof Error) return invalidRegex(regex);
137
+ const match = regex.exec(input.text);
138
+ const matched = match !== null;
139
+ return ok([propertiesBlock([
140
+ {
141
+ label: outputLabel("matched", "Matched"),
142
+ value: matched
143
+ },
144
+ {
145
+ label: outputLabel("mode", "Mode"),
146
+ value: input.mode ?? "contains"
147
+ },
148
+ {
149
+ label: outputLabel("flags", "Flags"),
150
+ value: normalizeFlags(input.flags).join("") || "(none)"
151
+ },
152
+ {
153
+ label: outputLabel("index", "Index"),
154
+ value: match?.index ?? null
155
+ },
156
+ {
157
+ label: outputLabel("match", "Match"),
158
+ value: match?.[0] ?? null
159
+ }
160
+ ]), jsonBlock({
161
+ matched,
162
+ mode: input.mode ?? "contains",
163
+ pattern: input.pattern,
164
+ flags: normalizeFlags(input.flags),
165
+ match: match ? {
166
+ text: match[0],
167
+ index: match.index,
168
+ end: match.index + match[0].length,
169
+ groups: normalizeCaptureGroups(match.slice(1)),
170
+ namedGroups: normalizeNamedGroups(match.groups)
171
+ } : null
172
+ })]);
173
+ };
174
+ var extractRegex = async (input) => {
175
+ const maxMatches = normalizeMaxMatches(input.maxMatches);
176
+ const flags = normalizeFlags(input.flags);
177
+ const regex = createRegex(input.pattern, ensureFlag(flags, "g"));
178
+ if (regex instanceof Error) return invalidRegex(regex);
179
+ const sections = input.sections?.length ? input.sections : defaultExtractSections;
180
+ const includeGroups = input.includeGroups ?? true;
181
+ const matches = [];
182
+ let truncated = false;
183
+ for (const match of input.text.matchAll(regex)) {
184
+ if (matches.length >= maxMatches) {
185
+ truncated = true;
186
+ break;
187
+ }
188
+ matches.push(createJsonMatch(match, input.text, sections, includeGroups));
189
+ }
190
+ return ok([propertiesBlock([
191
+ {
192
+ label: outputLabel("matches", "Matches"),
193
+ value: matches.length
194
+ },
195
+ {
196
+ label: outputLabel("maxMatches", "Max Matches"),
197
+ value: maxMatches
198
+ },
199
+ {
200
+ label: outputLabel("flags", "Flags"),
201
+ value: ensureFlag(flags, "g").join("")
202
+ },
203
+ {
204
+ label: outputLabel("truncated", "Truncated"),
205
+ value: truncated
206
+ }
207
+ ]), sections.includes("json") ? jsonBlock({ matches }) : codeBlock(JSON.stringify(matches, null, 2), "json")]);
208
+ };
209
+ var replaceRegex = async (input) => {
210
+ const flags = input.scope === "first" ? removeFlag(normalizeFlags(input.flags), "g") : ensureFlag(normalizeFlags(input.flags), "g");
211
+ const regex = createRegex(input.pattern, flags);
212
+ if (regex instanceof Error) return invalidRegex(regex);
213
+ const matchCount = countReplacements(input.text, regex, input.scope ?? "all");
214
+ const result = input.text.replace(regex, input.replacement);
215
+ return ok([propertiesBlock([
216
+ {
217
+ label: outputLabel("replacements", "Replacements"),
218
+ value: matchCount
219
+ },
220
+ {
221
+ label: outputLabel("scope", "Scope"),
222
+ value: input.scope ?? "all"
223
+ },
224
+ {
225
+ label: outputLabel("flags", "Flags"),
226
+ value: flags.join("") || "(none)"
227
+ }
228
+ ]), codeBlock(result, "text")]);
229
+ };
230
+ var escapeRegex = async (input) => {
231
+ const escaped = escapeRegExp(input.text);
232
+ const wrapped = input.wrapWithSlashes ? `/${escaped}/` : escaped;
233
+ const target = input.target ?? "pattern";
234
+ const output = target === "javascript-string" ? JSON.stringify(wrapped) : target === "javascript-regexp" ? input.wrapWithSlashes ? `/${escaped}/` : `new RegExp(${JSON.stringify(escaped)})` : wrapped;
235
+ return ok([propertiesBlock([{
236
+ label: outputLabel("target", "Target"),
237
+ value: target
238
+ }, {
239
+ label: outputLabel("wrapped", "Wrapped"),
240
+ value: input.wrapWithSlashes ?? false
241
+ }]), codeBlock(output, target === "pattern" ? "text" : "javascript")]);
242
+ };
243
+ function createRegex(pattern, flags) {
244
+ try {
245
+ return new RegExp(pattern, normalizeFlags(flags).join(""));
246
+ } catch (error) {
247
+ return error instanceof Error ? error : new Error(String(error));
248
+ }
249
+ }
250
+ function normalizeFlags(flags) {
251
+ const set = new Set(flags ?? []);
252
+ return flagOrder.filter((flag) => set.has(flag));
253
+ }
254
+ function ensureFlag(flags, flag) {
255
+ return flags.includes(flag) ? flags : normalizeFlags([...flags, flag]);
256
+ }
257
+ function removeFlag(flags, flag) {
258
+ return flags.filter((value) => value !== flag);
259
+ }
260
+ function normalizeMaxMatches(value) {
261
+ if (!Number.isInteger(value) || value === void 0) return 50;
262
+ return Math.min(Math.max(value, 1), 500);
263
+ }
264
+ function createJsonMatch(match, text, sections, includeGroups) {
265
+ const index = match.index ?? 0;
266
+ const value = match[0];
267
+ const result = {};
268
+ if (sections.includes("match")) result.match = value;
269
+ if (sections.includes("index")) {
270
+ result.index = index;
271
+ result.end = index + value.length;
272
+ }
273
+ if (includeGroups && sections.includes("groups")) result.groups = normalizeCaptureGroups(match.slice(1));
274
+ if (includeGroups && sections.includes("namedGroups")) result.namedGroups = normalizeNamedGroups(match.groups);
275
+ if (sections.includes("context")) result.context = text.slice(Math.max(0, index - 20), index + value.length + 20);
276
+ return result;
277
+ }
278
+ function countReplacements(text, regex, scope) {
279
+ if (scope === "first") {
280
+ regex.lastIndex = 0;
281
+ const matched = regex.exec(text) !== null;
282
+ regex.lastIndex = 0;
283
+ return matched ? 1 : 0;
284
+ }
285
+ const countRegex = createRegex(regex.source, ensureFlag(normalizeFlags(regex.flags.split("")), "g"));
286
+ if (countRegex instanceof Error) return 0;
287
+ return [...text.matchAll(countRegex)].length;
288
+ }
289
+ function escapeRegExp(text) {
290
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
291
+ }
292
+ function normalizeCaptureGroups(groups) {
293
+ return groups.map((group) => group ?? null);
294
+ }
295
+ function normalizeNamedGroups(groups) {
296
+ return Object.fromEntries(Object.entries(groups ?? {}).map(([key, value]) => [key, value ?? null]));
297
+ }
298
+ function invalidRegex(error) {
299
+ return failText("ERR_INVALID_REGEX", error.message, `Invalid regular expression: ${error.message}`);
300
+ }
301
+ function outputLabel(key, fallback) {
302
+ return {
303
+ key: `output.properties.${key}`,
304
+ default: fallback
305
+ };
306
+ }
307
+ //#endregion
308
+ export { src_default as default };
309
+
310
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../packages/sdk-node/dist/index.js","../src/index.ts"],"sourcesContent":["//#region src/disposable.ts\nfunction toDisposable(dispose) {\n\treturn { dispose };\n}\n//#endregion\n//#region src/plugin.ts\nfunction definePlugin(input) {\n\tif (typeof input === \"function\") return defineBuilderPlugin(input);\n\tif (\"activate\" in input && typeof input.activate === \"function\") return input;\n\treturn defineObjectPlugin(input);\n}\nfunction defineBuilderPlugin(setup) {\n\tlet definition;\n\treturn {\n\t\tasync activate(ctx) {\n\t\t\tdefinition = createNormalizedPluginDefinition();\n\t\t\tawait setup(createPluginBuilder(definition));\n\t\t\tawait activateDefinition(ctx, definition);\n\t\t},\n\t\tasync deactivate(ctx) {\n\t\t\tif (!definition) return;\n\t\t\tawait deactivateDefinition(ctx, definition);\n\t\t}\n\t};\n}\nfunction defineObjectPlugin(definition) {\n\tconst normalizedDefinition = createNormalizedPluginDefinition(definition);\n\treturn {\n\t\tasync activate(ctx) {\n\t\t\tawait activateDefinition(ctx, normalizedDefinition);\n\t\t},\n\t\tasync deactivate(ctx) {\n\t\t\tawait deactivateDefinition(ctx, normalizedDefinition);\n\t\t}\n\t};\n}\nfunction createPluginBuilder(definition) {\n\treturn {\n\t\tcommand(commandId, handler) {\n\t\t\tdefinition.commands.push({\n\t\t\t\tcommandId,\n\t\t\t\thandler\n\t\t\t});\n\t\t},\n\t\tonActivate(handler) {\n\t\t\tdefinition.onActivate.push(handler);\n\t\t},\n\t\tonDeactivate(handler) {\n\t\t\tdefinition.onDeactivate.push(handler);\n\t\t}\n\t};\n}\nfunction createNormalizedPluginDefinition(definition) {\n\treturn {\n\t\tcommands: definition?.commands ? normalizeCommands(definition.commands) : [],\n\t\tonActivate: definition?.onActivate ? [definition.onActivate] : [],\n\t\tonDeactivate: definition?.onDeactivate ? [definition.onDeactivate] : []\n\t};\n}\nfunction normalizeCommands(commands) {\n\treturn Object.entries(commands).map(([commandId, handler]) => ({\n\t\tcommandId,\n\t\thandler\n\t}));\n}\nasync function activateDefinition(ctx, definition) {\n\tfor (const onActivate of definition.onActivate) await onActivate(ctx);\n\tfor (const command of definition.commands) ctx.subscriptions.push(ctx.commands.register(command.commandId, command.handler));\n}\nasync function deactivateDefinition(ctx, definition) {\n\tfor (const onDeactivate of definition.onDeactivate.toReversed()) await onDeactivate(ctx);\n}\n//#endregion\n//#region src/results.ts\nfunction textBlock(text) {\n\treturn {\n\t\ttype: \"text\",\n\t\ttext\n\t};\n}\nfunction codeBlock(text, language) {\n\treturn {\n\t\ttype: \"code\",\n\t\ttext,\n\t\t...language === void 0 ? {} : { language }\n\t};\n}\nfunction jsonBlock(value) {\n\treturn {\n\t\ttype: \"json\",\n\t\tvalue\n\t};\n}\nfunction propertiesBlock(items) {\n\treturn {\n\t\ttype: \"properties\",\n\t\titems\n\t};\n}\nfunction ok(blocks) {\n\treturn {\n\t\tstatus: \"success\",\n\t\tblocks\n\t};\n}\nfunction okText(text) {\n\treturn ok([textBlock(text)]);\n}\nfunction fail(code, message, blocks = []) {\n\treturn {\n\t\tstatus: \"error\",\n\t\tblocks,\n\t\terror: {\n\t\t\tcode,\n\t\t\tmessage\n\t\t}\n\t};\n}\nfunction failText(code, message, text) {\n\treturn fail(code, message, text === void 0 ? [] : [textBlock(text)]);\n}\n//#endregion\nexport { codeBlock, definePlugin, fail, failText, jsonBlock, ok, okText, propertiesBlock, textBlock, toDisposable };\n\n//# sourceMappingURL=index.js.map","import type { CommandHandler } from \"@tooldeck/sdk-node\";\nimport {\n codeBlock,\n definePlugin,\n failText,\n jsonBlock,\n ok,\n propertiesBlock,\n} from \"@tooldeck/sdk-node\";\n\nimport type {\n PluginCommandInputs,\n RegexEscapeInput,\n RegexExtractInput,\n RegexReplaceInput,\n RegexTestInput,\n} from \"./generated/commands\";\n\ntype RegexFlag = NonNullable<RegexTestInput[\"flags\"]>[number];\ntype ExtractSection = NonNullable<RegexExtractInput[\"sections\"]>[number];\ntype JsonMatch = {\n match?: string;\n index?: number;\n end?: number;\n groups?: Array<string | null>;\n namedGroups?: Record<string, string | null>;\n context?: string;\n};\n\nconst flagOrder: RegexFlag[] = [\"g\", \"i\", \"m\", \"s\", \"u\", \"y\"];\nconst defaultExtractSections: ExtractSection[] = [\"match\", \"index\", \"groups\", \"stats\"];\n\nexport default definePlugin<PluginCommandInputs>((plugin) => {\n plugin.command(\"regex.test\", testRegex);\n plugin.command(\"regex.extract\", extractRegex);\n plugin.command(\"regex.replace\", replaceRegex);\n plugin.command(\"regex.escape\", escapeRegex);\n});\n\nconst testRegex: CommandHandler<RegexTestInput> = async (input) => {\n const pattern = input.mode === \"full\" ? `^(?:${input.pattern})$` : input.pattern;\n const regex = createRegex(pattern, input.flags);\n\n if (regex instanceof Error) {\n return invalidRegex(regex);\n }\n\n const match = regex.exec(input.text);\n const matched = match !== null;\n\n return ok([\n propertiesBlock([\n { label: outputLabel(\"matched\", \"Matched\"), value: matched },\n { label: outputLabel(\"mode\", \"Mode\"), value: input.mode ?? \"contains\" },\n {\n label: outputLabel(\"flags\", \"Flags\"),\n value: normalizeFlags(input.flags).join(\"\") || \"(none)\",\n },\n { label: outputLabel(\"index\", \"Index\"), value: match?.index ?? null },\n { label: outputLabel(\"match\", \"Match\"), value: match?.[0] ?? null },\n ]),\n jsonBlock({\n matched,\n mode: input.mode ?? \"contains\",\n pattern: input.pattern,\n flags: normalizeFlags(input.flags),\n match: match\n ? {\n text: match[0],\n index: match.index,\n end: match.index + match[0].length,\n groups: normalizeCaptureGroups(match.slice(1)),\n namedGroups: normalizeNamedGroups(match.groups),\n }\n : null,\n }),\n ]);\n};\n\nconst extractRegex: CommandHandler<RegexExtractInput> = async (input) => {\n const maxMatches = normalizeMaxMatches(input.maxMatches);\n const flags = normalizeFlags(input.flags);\n const regex = createRegex(input.pattern, ensureFlag(flags, \"g\"));\n\n if (regex instanceof Error) {\n return invalidRegex(regex);\n }\n\n const sections = input.sections?.length ? input.sections : defaultExtractSections;\n const includeGroups = input.includeGroups ?? true;\n const matches: JsonMatch[] = [];\n let truncated = false;\n\n for (const match of input.text.matchAll(regex)) {\n if (matches.length >= maxMatches) {\n truncated = true;\n break;\n }\n\n matches.push(createJsonMatch(match, input.text, sections, includeGroups));\n }\n\n const summaryBlock = propertiesBlock([\n { label: outputLabel(\"matches\", \"Matches\"), value: matches.length },\n { label: outputLabel(\"maxMatches\", \"Max Matches\"), value: maxMatches },\n { label: outputLabel(\"flags\", \"Flags\"), value: ensureFlag(flags, \"g\").join(\"\") },\n { label: outputLabel(\"truncated\", \"Truncated\"), value: truncated },\n ]);\n const outputBlock = sections.includes(\"json\")\n ? jsonBlock({ matches })\n : codeBlock(JSON.stringify(matches, null, 2), \"json\");\n\n return ok([summaryBlock, outputBlock]);\n};\n\nconst replaceRegex: CommandHandler<RegexReplaceInput> = async (input) => {\n const flags =\n input.scope === \"first\"\n ? removeFlag(normalizeFlags(input.flags), \"g\")\n : ensureFlag(normalizeFlags(input.flags), \"g\");\n const regex = createRegex(input.pattern, flags);\n\n if (regex instanceof Error) {\n return invalidRegex(regex);\n }\n\n const matchCount = countReplacements(input.text, regex, input.scope ?? \"all\");\n const result = input.text.replace(regex, input.replacement);\n\n return ok([\n propertiesBlock([\n { label: outputLabel(\"replacements\", \"Replacements\"), value: matchCount },\n { label: outputLabel(\"scope\", \"Scope\"), value: input.scope ?? \"all\" },\n { label: outputLabel(\"flags\", \"Flags\"), value: flags.join(\"\") || \"(none)\" },\n ]),\n codeBlock(result, \"text\"),\n ]);\n};\n\nconst escapeRegex: CommandHandler<RegexEscapeInput> = async (input) => {\n const escaped = escapeRegExp(input.text);\n const wrapped = input.wrapWithSlashes ? `/${escaped}/` : escaped;\n const target = input.target ?? \"pattern\";\n const output =\n target === \"javascript-string\"\n ? JSON.stringify(wrapped)\n : target === \"javascript-regexp\"\n ? input.wrapWithSlashes\n ? `/${escaped}/`\n : `new RegExp(${JSON.stringify(escaped)})`\n : wrapped;\n\n return ok([\n propertiesBlock([\n { label: outputLabel(\"target\", \"Target\"), value: target },\n { label: outputLabel(\"wrapped\", \"Wrapped\"), value: input.wrapWithSlashes ?? false },\n ]),\n codeBlock(output, target === \"pattern\" ? \"text\" : \"javascript\"),\n ]);\n};\n\nfunction createRegex(pattern: string, flags: RegexFlag[] | undefined): RegExp | Error {\n try {\n return new RegExp(pattern, normalizeFlags(flags).join(\"\"));\n } catch (error) {\n return error instanceof Error ? error : new Error(String(error));\n }\n}\n\nfunction normalizeFlags(flags: RegexFlag[] | undefined): RegexFlag[] {\n const set = new Set(flags ?? []);\n\n return flagOrder.filter((flag) => set.has(flag));\n}\n\nfunction ensureFlag(flags: RegexFlag[], flag: RegexFlag): RegexFlag[] {\n return flags.includes(flag) ? flags : normalizeFlags([...flags, flag]);\n}\n\nfunction removeFlag(flags: RegexFlag[], flag: RegexFlag): RegexFlag[] {\n return flags.filter((value) => value !== flag);\n}\n\nfunction normalizeMaxMatches(value: number | undefined): number {\n if (!Number.isInteger(value) || value === undefined) {\n return 50;\n }\n\n return Math.min(Math.max(value, 1), 500);\n}\n\nfunction createJsonMatch(\n match: RegExpMatchArray,\n text: string,\n sections: ExtractSection[],\n includeGroups: boolean,\n): JsonMatch {\n const index = match.index ?? 0;\n const value = match[0];\n const result: JsonMatch = {};\n\n if (sections.includes(\"match\")) {\n result.match = value;\n }\n\n if (sections.includes(\"index\")) {\n result.index = index;\n result.end = index + value.length;\n }\n\n if (includeGroups && sections.includes(\"groups\")) {\n result.groups = normalizeCaptureGroups(match.slice(1));\n }\n\n if (includeGroups && sections.includes(\"namedGroups\")) {\n result.namedGroups = normalizeNamedGroups(match.groups);\n }\n\n if (sections.includes(\"context\")) {\n result.context = text.slice(Math.max(0, index - 20), index + value.length + 20);\n }\n\n return result;\n}\n\nfunction countReplacements(text: string, regex: RegExp, scope: \"first\" | \"all\"): number {\n if (scope === \"first\") {\n regex.lastIndex = 0;\n const matched = regex.exec(text) !== null;\n regex.lastIndex = 0;\n\n return matched ? 1 : 0;\n }\n\n const countRegex = createRegex(\n regex.source,\n ensureFlag(normalizeFlags(regex.flags.split(\"\") as RegexFlag[]), \"g\"),\n );\n\n if (countRegex instanceof Error) {\n return 0;\n }\n\n return [...text.matchAll(countRegex)].length;\n}\n\nfunction escapeRegExp(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction normalizeCaptureGroups(groups: string[]): Array<string | null> {\n return groups.map((group) => group ?? null);\n}\n\nfunction normalizeNamedGroups(\n groups: Record<string, string> | undefined,\n): Record<string, string | null> {\n return Object.fromEntries(\n Object.entries(groups ?? {}).map(([key, value]) => [key, value ?? null]),\n );\n}\n\nfunction invalidRegex(error: Error) {\n return failText(\n \"ERR_INVALID_REGEX\",\n error.message,\n `Invalid regular expression: ${error.message}`,\n );\n}\n\nfunction outputLabel(key: string, fallback: string) {\n return {\n key: `output.properties.${key}`,\n default: fallback,\n };\n}\n"],"mappings":";AAMA,SAAS,aAAa,OAAO;CAC5B,IAAI,OAAO,UAAU,YAAY,OAAO,oBAAoB,KAAK;CACjE,IAAI,cAAc,SAAS,OAAO,MAAM,aAAa,YAAY,OAAO;CACxE,OAAO,mBAAmB,KAAK;AAChC;AACA,SAAS,oBAAoB,OAAO;CACnC,IAAI;CACJ,OAAO;EACN,MAAM,SAAS,KAAK;GACnB,aAAa,iCAAiC;GAC9C,MAAM,MAAM,oBAAoB,UAAU,CAAC;GAC3C,MAAM,mBAAmB,KAAK,UAAU;EACzC;EACA,MAAM,WAAW,KAAK;GACrB,IAAI,CAAC,YAAY;GACjB,MAAM,qBAAqB,KAAK,UAAU;EAC3C;CACD;AACD;AACA,SAAS,mBAAmB,YAAY;CACvC,MAAM,uBAAuB,iCAAiC,UAAU;CACxE,OAAO;EACN,MAAM,SAAS,KAAK;GACnB,MAAM,mBAAmB,KAAK,oBAAoB;EACnD;EACA,MAAM,WAAW,KAAK;GACrB,MAAM,qBAAqB,KAAK,oBAAoB;EACrD;CACD;AACD;AACA,SAAS,oBAAoB,YAAY;CACxC,OAAO;EACN,QAAQ,WAAW,SAAS;GAC3B,WAAW,SAAS,KAAK;IACxB;IACA;GACD,CAAC;EACF;EACA,WAAW,SAAS;GACnB,WAAW,WAAW,KAAK,OAAO;EACnC;EACA,aAAa,SAAS;GACrB,WAAW,aAAa,KAAK,OAAO;EACrC;CACD;AACD;AACA,SAAS,iCAAiC,YAAY;CACrD,OAAO;EACN,UAAU,YAAY,WAAW,kBAAkB,WAAW,QAAQ,IAAI,CAAC;EAC3E,YAAY,YAAY,aAAa,CAAC,WAAW,UAAU,IAAI,CAAC;EAChE,cAAc,YAAY,eAAe,CAAC,WAAW,YAAY,IAAI,CAAC;CACvE;AACD;AACA,SAAS,kBAAkB,UAAU;CACpC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AAO,OAAO,YACZ,OAAO,QAAQ,UAAU,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,SAAS,IAAI,CAAC,CACzE;AACF;AAEA,SAAS,aAAa,OAAc;CAClC,OAAO,SACL,qBACA,MAAM,SACN,+BAA+B,MAAM,SACvC;AACF;AAEA,SAAS,YAAY,KAAa,UAAkB;CAClD,OAAO;EACL,KAAK,qBAAqB;EAC1B,SAAS;CACX;AACF"}
@@ -0,0 +1,49 @@
1
+ {
2
+ "plugin.name": "Regex Tools",
3
+ "plugin.description": "Tools for testing, extracting, replacing, and escaping regular expressions.",
4
+ "commands.test.title": "Test Regex",
5
+ "commands.test.description": "Check whether a regular expression matches text.",
6
+ "commands.extract.title": "Extract Regex Matches",
7
+ "commands.extract.description": "Extract matching text, indexes, groups, and summary details.",
8
+ "commands.replace.title": "Replace Regex Matches",
9
+ "commands.replace.description": "Replace regex matches with a replacement string.",
10
+ "commands.escape.title": "Escape Regex Text",
11
+ "commands.escape.description": "Escape literal text so it can be used safely in a regular expression.",
12
+ "schema.common.pattern.title": "Pattern",
13
+ "schema.common.pattern.placeholder": "\\bword\\b",
14
+ "schema.common.text.title": "Text",
15
+ "schema.common.text.placeholder": "Paste text to inspect",
16
+ "schema.common.flags.title": "Flags",
17
+ "schema.test.mode.title": "Match Mode",
18
+ "schema.test.mode.options.contains": "Contains",
19
+ "schema.test.mode.options.full": "Full match",
20
+ "schema.extract.maxMatches.title": "Max Matches",
21
+ "schema.extract.maxMatches.placeholder": "50",
22
+ "schema.extract.includeGroups.title": "Include Groups",
23
+ "schema.extract.sections.title": "Output Sections",
24
+ "schema.extract.sections.placeholder": "Choose output sections",
25
+ "schema.replace.replacement.title": "Replacement",
26
+ "schema.replace.replacement.placeholder": "$&",
27
+ "schema.replace.scope.title": "Replacement Scope",
28
+ "schema.replace.scope.options.first": "First",
29
+ "schema.replace.scope.options.all": "All",
30
+ "schema.escape.text.placeholder": "Text such as a+b?(c)",
31
+ "schema.escape.target.title": "Output Target",
32
+ "schema.escape.target.options.pattern": "Pattern",
33
+ "schema.escape.target.options.javascriptString": "JavaScript string",
34
+ "schema.escape.target.options.javascriptRegexp": "JavaScript RegExp",
35
+ "schema.escape.target.placeholder": "Choose output target",
36
+ "schema.escape.wrapWithSlashes.title": "Wrap With Slashes",
37
+ "output.properties.matched": "Matched",
38
+ "output.properties.mode": "Mode",
39
+ "output.properties.flags": "Flags",
40
+ "output.properties.index": "Index",
41
+ "output.properties.match": "Match",
42
+ "output.properties.matches": "Matches",
43
+ "output.properties.maxMatches": "Max Matches",
44
+ "output.properties.truncated": "Truncated",
45
+ "output.properties.replacements": "Replacements",
46
+ "output.properties.scope": "Scope",
47
+ "output.properties.target": "Target",
48
+ "output.properties.wrapped": "Wrapped"
49
+ }