amxx-builder 1.5.1
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/AGENTS.md +111 -0
- package/README.md +485 -0
- package/action-entry.js +42 -0
- package/action.yml +55 -0
- package/defaults/amxbuild.defaults.yml +40 -0
- package/index.js +4 -0
- package/mcp/dep-resolver.js +75 -0
- package/mcp/handlers.js +862 -0
- package/mcp/mcp-server.js +112 -0
- package/mcp/registry.js +863 -0
- package/mcp/symbol-index.js +171 -0
- package/package.json +68 -0
- package/src/archiver.js +140 -0
- package/src/asset-fetcher.js +277 -0
- package/src/build-plan.js +101 -0
- package/src/build-service.js +188 -0
- package/src/cache-dir.js +21 -0
- package/src/cache-info.js +104 -0
- package/src/cli.js +302 -0
- package/src/collector.js +89 -0
- package/src/commands/build.js +49 -0
- package/src/commands/cache.js +77 -0
- package/src/commands/clean.js +33 -0
- package/src/commands/compile-renderer.js +38 -0
- package/src/commands/deploy.js +40 -0
- package/src/commands/deps-tree.js +92 -0
- package/src/commands/doctor.js +77 -0
- package/src/commands/dry-run.js +64 -0
- package/src/commands/init.js +228 -0
- package/src/commands/mcp.js +13 -0
- package/src/commands/releases.js +45 -0
- package/src/commands/resolve-manifest.js +27 -0
- package/src/commands/serve.js +489 -0
- package/src/commands/shared.js +24 -0
- package/src/commands/validate.js +34 -0
- package/src/commands/watch.js +209 -0
- package/src/compile-utils.js +65 -0
- package/src/compiler-fetcher.js +327 -0
- package/src/compiler.js +228 -0
- package/src/dep-graph.js +92 -0
- package/src/deployer.js +197 -0
- package/src/deps-resolver.js +127 -0
- package/src/deps-tree.js +202 -0
- package/src/env.js +18 -0
- package/src/events.js +29 -0
- package/src/format.js +23 -0
- package/src/fs-utils.js +87 -0
- package/src/include-tree.js +845 -0
- package/src/ini-builder.js +44 -0
- package/src/jsonrpc-transport.js +195 -0
- package/src/logger.js +50 -0
- package/src/manifest-path.js +34 -0
- package/src/manifest.js +373 -0
- package/src/progress.js +66 -0
- package/src/rcon.js +103 -0
- package/src/release-fetcher.js +206 -0
- package/src/release-lister.js +79 -0
- package/src/repo-fetcher.js +273 -0
- package/src/retry.js +50 -0
- package/src/schema.js +54 -0
- package/src/update-check.js +114 -0
- package/src/validate.js +69 -0
- package/src/watcher.js +135 -0
- package/templates/init-build.bat +11 -0
- package/templates/init-build.sh +7 -0
- package/templates/init-deploy.env +14 -0
- package/templates/init-manifest.yml +6 -0
- package/templates/init-workflow.yml +59 -0
package/mcp/registry.js
ADDED
|
@@ -0,0 +1,863 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { HANDLERS } = require('./handlers');
|
|
5
|
+
|
|
6
|
+
// Single source of truth for MCP tools: schemas, descriptions, handler wiring.
|
|
7
|
+
// Adding a tool = one entry here (+ its handler in handlers.js).
|
|
8
|
+
|
|
9
|
+
const TOOLS = [
|
|
10
|
+
|
|
11
|
+
{
|
|
12
|
+
name: 'get_dep_interface',
|
|
13
|
+
title: 'Get dependency public interface',
|
|
14
|
+
description:
|
|
15
|
+
'Download (if not cached) an AMXX dependency from a deps entry and return the ' +
|
|
16
|
+
'full contents of all its .inc files. Use this to understand the public API, ' +
|
|
17
|
+
'functions, constants, and defines that a dependency exposes.\n\n' +
|
|
18
|
+
'Supports:\n' +
|
|
19
|
+
' - git deps: "owner/repo@ref" or "owner/repo@ref:include_path"\n' +
|
|
20
|
+
' - release deps: { repo, ref, source: "release", include_path?, asset? }\n\n' +
|
|
21
|
+
'Results are cached in the same cache directory as amxb build (~/.cache/amxx-builder/).',
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
dep: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description:
|
|
28
|
+
'Dependency string in format "owner/repo@ref" or "owner/repo@ref:include_path". ' +
|
|
29
|
+
'Examples:\n' +
|
|
30
|
+
' "AmxxModularEcosystem/ParamsController@1.4.0"\n' +
|
|
31
|
+
' "Next21Team/AmxxEasyHttp@1.4.0:amxx/scripting/include"\n' +
|
|
32
|
+
' "rehlds/ReAPI@5.29.0.358"',
|
|
33
|
+
},
|
|
34
|
+
source: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: 'Fetch method: "git" (clone repo) or "release" (download release asset)',
|
|
37
|
+
default: 'git',
|
|
38
|
+
enum: ['git', 'release'],
|
|
39
|
+
},
|
|
40
|
+
include_path: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
description:
|
|
43
|
+
'Override the path inside the repo/asset where .inc files are located. ' +
|
|
44
|
+
'Auto-detected from the repo layout when omitted (same candidates as amxb build).',
|
|
45
|
+
},
|
|
46
|
+
asset: {
|
|
47
|
+
description:
|
|
48
|
+
'For source=release: which release asset to download. ' +
|
|
49
|
+
'Can be a glob pattern like "*-include*.zip" or an index number.',
|
|
50
|
+
},
|
|
51
|
+
token: {
|
|
52
|
+
type: 'string',
|
|
53
|
+
description:
|
|
54
|
+
'GitHub Personal Access Token for private repos. ' +
|
|
55
|
+
'Falls back to GITHUB_TOKEN env var if not provided.',
|
|
56
|
+
},
|
|
57
|
+
no_fetch: {
|
|
58
|
+
type: 'boolean',
|
|
59
|
+
description:
|
|
60
|
+
'If true, only return results from cache without fetching. ' +
|
|
61
|
+
'Throws if the dep is not cached.',
|
|
62
|
+
default: false,
|
|
63
|
+
},
|
|
64
|
+
grep: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
description:
|
|
67
|
+
'Optional substring (case-insensitive) to search for within include files. ' +
|
|
68
|
+
'When set, only matching lines with surrounding context are returned. ' +
|
|
69
|
+
'Use with `before` and `after` to control how many context lines to show.',
|
|
70
|
+
},
|
|
71
|
+
before: {
|
|
72
|
+
type: 'number',
|
|
73
|
+
description:
|
|
74
|
+
'Lines of context to show before each grep match. Default: 0.',
|
|
75
|
+
default: 0,
|
|
76
|
+
},
|
|
77
|
+
after: {
|
|
78
|
+
type: 'number',
|
|
79
|
+
description:
|
|
80
|
+
'Lines of context to show after each grep match. Default: 0.',
|
|
81
|
+
default: 0,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
required: ['dep'],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'list_dep_incs',
|
|
89
|
+
title: 'List dependency .inc files',
|
|
90
|
+
description:
|
|
91
|
+
'Download (if not cached) an AMXX dependency and list available .inc files ' +
|
|
92
|
+
'without reading their contents. Faster than get_dep_interface when you only ' +
|
|
93
|
+
'need to know what files exist.',
|
|
94
|
+
inputSchema: {
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: {
|
|
97
|
+
dep: {
|
|
98
|
+
type: 'string',
|
|
99
|
+
description:
|
|
100
|
+
'Dependency string in format "owner/repo@ref" or "owner/repo@ref:include_path".',
|
|
101
|
+
},
|
|
102
|
+
source: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
description: 'Fetch method: "git" or "release"',
|
|
105
|
+
default: 'git',
|
|
106
|
+
enum: ['git', 'release'],
|
|
107
|
+
},
|
|
108
|
+
include_path: {
|
|
109
|
+
type: 'string',
|
|
110
|
+
description: 'Override include path inside the repo/asset.',
|
|
111
|
+
},
|
|
112
|
+
asset: {
|
|
113
|
+
description:
|
|
114
|
+
'For source=release: asset selector (glob pattern or index).',
|
|
115
|
+
},
|
|
116
|
+
token: {
|
|
117
|
+
type: 'string',
|
|
118
|
+
description: 'GitHub PAT. Falls back to GITHUB_TOKEN env var.',
|
|
119
|
+
},
|
|
120
|
+
no_fetch: {
|
|
121
|
+
type: 'boolean',
|
|
122
|
+
description: 'Only use cache, skip network fetch.',
|
|
123
|
+
default: false,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
required: ['dep'],
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'get_dep_tree',
|
|
131
|
+
title: 'Get recursive dependency tree',
|
|
132
|
+
description:
|
|
133
|
+
'Build a recursive dependency tree starting from root deps or a manifest. ' +
|
|
134
|
+
'Walks each dependency, clones the repo, reads its DEPS_LIST, and recurses ' +
|
|
135
|
+
'into sub-dependencies. Detects cycles and handles deps_override.\n\n' +
|
|
136
|
+
'Provide either "manifest" (path to amxbuild.yml) or "deps" (array of dep entries).\n\n' +
|
|
137
|
+
'Each dep entry can be a string ("owner/repo@ref") or an object ' +
|
|
138
|
+
'({ repo, ref, source?, include_path?, asset? }).',
|
|
139
|
+
inputSchema: {
|
|
140
|
+
type: 'object',
|
|
141
|
+
properties: {
|
|
142
|
+
manifest: {
|
|
143
|
+
type: 'string',
|
|
144
|
+
description:
|
|
145
|
+
'Path to amxbuild.yml. When provided, root deps are extracted from ' +
|
|
146
|
+
'manifest repos and global deps. deps_override is respected.',
|
|
147
|
+
},
|
|
148
|
+
deps: {
|
|
149
|
+
type: 'array',
|
|
150
|
+
description:
|
|
151
|
+
'Array of dep entries (strings or objects). Alternative to manifest. ' +
|
|
152
|
+
'Example: ["owner/repo@ref"] or [{ repo: "owner/repo", ref: "v1", source: "git" }].',
|
|
153
|
+
items: {
|
|
154
|
+
oneOf: [
|
|
155
|
+
{ type: 'string' },
|
|
156
|
+
{
|
|
157
|
+
type: 'object',
|
|
158
|
+
properties: {
|
|
159
|
+
repo: { type: 'string' },
|
|
160
|
+
ref: { type: 'string' },
|
|
161
|
+
source: { type: 'string', enum: ['git', 'release'] },
|
|
162
|
+
include_path: { type: 'string' },
|
|
163
|
+
asset: { oneOf: [{ type: 'string' }, { type: 'number' }] },
|
|
164
|
+
},
|
|
165
|
+
required: ['repo', 'ref'],
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
depth: {
|
|
171
|
+
type: 'number',
|
|
172
|
+
description: 'Max recursion depth (0 = unlimited). Default: 0.',
|
|
173
|
+
default: 0,
|
|
174
|
+
},
|
|
175
|
+
token: {
|
|
176
|
+
type: 'string',
|
|
177
|
+
description:
|
|
178
|
+
'GitHub Personal Access Token for private repos. ' +
|
|
179
|
+
'Falls back to GITHUB_TOKEN env var if not provided.',
|
|
180
|
+
},
|
|
181
|
+
no_fetch: {
|
|
182
|
+
type: 'boolean',
|
|
183
|
+
description: 'Only use cache, skip network fetch.',
|
|
184
|
+
default: false,
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
oneOf: [
|
|
188
|
+
{ required: ['manifest'] },
|
|
189
|
+
{ required: ['deps'] },
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: 'resolve_manifest',
|
|
195
|
+
title: 'Resolve manifest with all overrides',
|
|
196
|
+
description:
|
|
197
|
+
'Parse an amxbuild.yml, merge with defaults, validate against schema, ' +
|
|
198
|
+
'and apply --set/--define overrides. Returns the fully resolved manifest object.\n\n' +
|
|
199
|
+
'If manifest is not provided, auto-detects amxbuild.yml in the working directory.',
|
|
200
|
+
inputSchema: {
|
|
201
|
+
type: 'object',
|
|
202
|
+
properties: {
|
|
203
|
+
manifest: {
|
|
204
|
+
type: 'string',
|
|
205
|
+
description:
|
|
206
|
+
'Path to amxbuild.yml. If omitted, looks for amxbuild.yml / amxbuild.yaml / ' +
|
|
207
|
+
'manifest.yml in the current working directory.',
|
|
208
|
+
},
|
|
209
|
+
set: {
|
|
210
|
+
type: 'array',
|
|
211
|
+
description:
|
|
212
|
+
'Override manifest fields via dot notation, e.g. ["version=1.2", "output.pack=false"].',
|
|
213
|
+
items: { type: 'string' },
|
|
214
|
+
},
|
|
215
|
+
define: {
|
|
216
|
+
type: 'array',
|
|
217
|
+
description:
|
|
218
|
+
'Compiler defines to add, e.g. ["DEBUG", "VERSION=1.2"]. ' +
|
|
219
|
+
'Appended to amxmodx.defines.',
|
|
220
|
+
items: { type: 'string' },
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: 'validate_manifest',
|
|
227
|
+
title: 'Validate manifest',
|
|
228
|
+
description:
|
|
229
|
+
'Validate an amxbuild.yml against the schema and return structured diagnostics ' +
|
|
230
|
+
'(errors and warnings) as data. Never throws — inspect the result.\n\n' +
|
|
231
|
+
'If manifest is not provided, auto-detects amxbuild.yml in the working directory.',
|
|
232
|
+
inputSchema: {
|
|
233
|
+
type: 'object',
|
|
234
|
+
properties: {
|
|
235
|
+
manifest: {
|
|
236
|
+
type: 'string',
|
|
237
|
+
description:
|
|
238
|
+
'Path to amxbuild.yml. If omitted, looks for amxbuild.yml / amxbuild.yaml / ' +
|
|
239
|
+
'manifest.yml in the current working directory.',
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: 'get_cache_info',
|
|
246
|
+
title: 'Get cache information',
|
|
247
|
+
description:
|
|
248
|
+
'Show contents of the local build cache (~/.cache/amxx-builder). ' +
|
|
249
|
+
'Includes cached compiler binaries, repo clones, release dependencies, ' +
|
|
250
|
+
'and optional local asset cache for a given manifest.\n\n' +
|
|
251
|
+
'If manifest is provided, also checks local .amxb-cache/ for asset cache info.',
|
|
252
|
+
inputSchema: {
|
|
253
|
+
type: 'object',
|
|
254
|
+
properties: {
|
|
255
|
+
manifest: {
|
|
256
|
+
type: 'string',
|
|
257
|
+
description:
|
|
258
|
+
'Optional path to manifest to also check local .amxb-cache/ assets.',
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: 'list_amxmodx_incs',
|
|
265
|
+
title: 'List standard AMX Mod X include files',
|
|
266
|
+
description:
|
|
267
|
+
'List available .inc files from the standard AMXX bundle (amxmodx.inc, ' +
|
|
268
|
+
'core.inc, float.inc, etc.).\n\n' +
|
|
269
|
+
'By default uses the version from amxbuild.yml (amxmodx.version), ' +
|
|
270
|
+
'or the latest available compiler version if no manifest is found.\n\n' +
|
|
271
|
+
'Supports optional glob pattern filtering.',
|
|
272
|
+
inputSchema: {
|
|
273
|
+
type: 'object',
|
|
274
|
+
properties: {
|
|
275
|
+
manifest: {
|
|
276
|
+
type: 'string',
|
|
277
|
+
description:
|
|
278
|
+
'Path to amxbuild.yml. If omitted, auto-detects in the working directory.',
|
|
279
|
+
},
|
|
280
|
+
version: {
|
|
281
|
+
type: 'string',
|
|
282
|
+
description:
|
|
283
|
+
'AMX Mod X version override (e.g. "1.10.5428"). ' +
|
|
284
|
+
'Default: from manifest amxmodx.version, or latest.',
|
|
285
|
+
},
|
|
286
|
+
pattern: {
|
|
287
|
+
type: 'string',
|
|
288
|
+
description:
|
|
289
|
+
'Glob pattern to filter include files. Example: "core.*" or "*.inc".',
|
|
290
|
+
default: '*.inc',
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
name: 'get_amxmodx_include',
|
|
297
|
+
title: 'Get standard AMX Mod X include file contents',
|
|
298
|
+
description:
|
|
299
|
+
'Download (if not cached) the AMXX compiler bundle and return the contents ' +
|
|
300
|
+
'of standard .inc files — functions, constants, defines from the AMXX stdlib.\n\n' +
|
|
301
|
+
'By default uses the version from amxbuild.yml (amxmodx.version), ' +
|
|
302
|
+
'or the latest available compiler version if no manifest is found.\n\n' +
|
|
303
|
+
'The `file` parameter supports glob patterns (e.g. "core.inc" or "cs*.inc"). ' +
|
|
304
|
+
'Omit to return all standard includes.',
|
|
305
|
+
inputSchema: {
|
|
306
|
+
type: 'object',
|
|
307
|
+
properties: {
|
|
308
|
+
manifest: {
|
|
309
|
+
type: 'string',
|
|
310
|
+
description:
|
|
311
|
+
'Path to amxbuild.yml. If omitted, auto-detects in the working directory.',
|
|
312
|
+
},
|
|
313
|
+
version: {
|
|
314
|
+
type: 'string',
|
|
315
|
+
description:
|
|
316
|
+
'AMX Mod X version override (e.g. "1.10.5428"). ' +
|
|
317
|
+
'Default: from manifest amxmodx.version, or latest.',
|
|
318
|
+
},
|
|
319
|
+
file: {
|
|
320
|
+
type: 'string',
|
|
321
|
+
description:
|
|
322
|
+
'Include file name or glob pattern. Examples: "amxmodx.inc", "core.*", "*.inc". ' +
|
|
323
|
+
'Default: "*.inc" (all).',
|
|
324
|
+
default: '*.inc',
|
|
325
|
+
},
|
|
326
|
+
grep: {
|
|
327
|
+
type: 'string',
|
|
328
|
+
description:
|
|
329
|
+
'Optional substring (case-insensitive) to search for within include files. ' +
|
|
330
|
+
'When set, only matching lines with surrounding context are returned. ' +
|
|
331
|
+
'Use with `before` and `after` to control how many context lines to show.',
|
|
332
|
+
},
|
|
333
|
+
before: {
|
|
334
|
+
type: 'number',
|
|
335
|
+
description:
|
|
336
|
+
'Lines of context to show before each grep match. Default: 0.',
|
|
337
|
+
default: 0,
|
|
338
|
+
},
|
|
339
|
+
after: {
|
|
340
|
+
type: 'number',
|
|
341
|
+
description:
|
|
342
|
+
'Lines of context to show after each grep match. Default: 0.',
|
|
343
|
+
default: 0,
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: 'resolve_include',
|
|
350
|
+
title: 'Resolve an `#include` directive against stdlib and deps',
|
|
351
|
+
description:
|
|
352
|
+
'Resolve an AMXX preprocessor `#include` directive — find which file it ' +
|
|
353
|
+
'refers to and return its contents.\n\n' +
|
|
354
|
+
'Accepts:\n' +
|
|
355
|
+
' - `#include <file>` — global search (stdlib + deps)\n' +
|
|
356
|
+
' - `#include "file"` — local (sma dir) first, then global\n' +
|
|
357
|
+
' - `#include file` — bare, equivalent to <>\n' +
|
|
358
|
+
' - The `#include` prefix is optional; just `<file>`, `"file"`, or `file` works.\n\n' +
|
|
359
|
+
'Extension defaults to `.inc` if omitted. Case-sensitive first, ' +
|
|
360
|
+
'then case-insensitive fallback.\n\n' +
|
|
361
|
+
'Search order: sma dir (for `""`, via sma_file or cwd) → manifest deps → stdlib ' +
|
|
362
|
+
'(deps before stdlib, matching the real build).',
|
|
363
|
+
inputSchema: {
|
|
364
|
+
type: 'object',
|
|
365
|
+
properties: {
|
|
366
|
+
directive: {
|
|
367
|
+
type: 'string',
|
|
368
|
+
description:
|
|
369
|
+
'The include directive to resolve. Examples:\n' +
|
|
370
|
+
' "#include <amxmodx>"\n' +
|
|
371
|
+
' "#include \\"ColorChat\\""\n' +
|
|
372
|
+
' "#include file"\n' +
|
|
373
|
+
' "<amxmodx>" or "amxmodx"',
|
|
374
|
+
},
|
|
375
|
+
sma_file: {
|
|
376
|
+
type: 'string',
|
|
377
|
+
description:
|
|
378
|
+
'Path to the .sma file containing the directive. ' +
|
|
379
|
+
'Optional — if omitted, uses the current working directory. ' +
|
|
380
|
+
'Useful when the include is declared in another include and ' +
|
|
381
|
+
'the originating .sma is unknown.',
|
|
382
|
+
},
|
|
383
|
+
manifest: {
|
|
384
|
+
type: 'string',
|
|
385
|
+
description:
|
|
386
|
+
'Path to amxbuild.yml. Optional — auto-detects amxbuild.yml / ' +
|
|
387
|
+
'amxbuild.yaml / manifest.yml in the working directory. ' +
|
|
388
|
+
'When found, searches manifest globalDeps for the include file.',
|
|
389
|
+
},
|
|
390
|
+
version: {
|
|
391
|
+
type: 'string',
|
|
392
|
+
description:
|
|
393
|
+
'AMX Mod X version override for stdlib lookup ' +
|
|
394
|
+
'(default: from manifest or latest).',
|
|
395
|
+
},
|
|
396
|
+
grep: {
|
|
397
|
+
type: 'string',
|
|
398
|
+
description:
|
|
399
|
+
'Optional substring (case-insensitive) to search for within the resolved include file. ' +
|
|
400
|
+
'When set, only matching lines with surrounding context are returned. ' +
|
|
401
|
+
'Use with `before` and `after` to control how many context lines to show.',
|
|
402
|
+
},
|
|
403
|
+
before: {
|
|
404
|
+
type: 'number',
|
|
405
|
+
description:
|
|
406
|
+
'Lines of context to show before each grep match. Default: 0.',
|
|
407
|
+
default: 0,
|
|
408
|
+
},
|
|
409
|
+
after: {
|
|
410
|
+
type: 'number',
|
|
411
|
+
description:
|
|
412
|
+
'Lines of context to show after each grep match. Default: 0.',
|
|
413
|
+
default: 0,
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
required: ['directive'],
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
name: 'build_include_tree',
|
|
421
|
+
title: 'Build #include dependency tree',
|
|
422
|
+
description:
|
|
423
|
+
'Build a bidirectional #include tree for an AMXX project. ' +
|
|
424
|
+
'Parses all .sma files (local + repos), resolves #include directives, ' +
|
|
425
|
+
'detects include guards, and returns a tree in the requested direction.\n\n' +
|
|
426
|
+
'Direction:\n' +
|
|
427
|
+
' - "down" (default for .sma): show everything the target file #includes (transitively)\n' +
|
|
428
|
+
' - "up" (default for .inc): show everything that #includes the target (transitively)\n' +
|
|
429
|
+
' - "both" or "auto": auto-select based on file extension\n\n' +
|
|
430
|
+
'Include guards (#if defined … #endinput … #define) are detected and ' +
|
|
431
|
+
'used to avoid re-expanding guarded files within the same compilation unit. ' +
|
|
432
|
+
'The tree also tracks <angle> vs "quoted" include style and annotates ' +
|
|
433
|
+
'each node with its origin (stdlib, dep, local, repo).',
|
|
434
|
+
inputSchema: {
|
|
435
|
+
type: 'object',
|
|
436
|
+
properties: {
|
|
437
|
+
file: {
|
|
438
|
+
type: 'string',
|
|
439
|
+
description:
|
|
440
|
+
'Path to the .sma or .inc file to build the tree from. ' +
|
|
441
|
+
'Required. Relative paths are resolved from the working directory.',
|
|
442
|
+
},
|
|
443
|
+
manifest: {
|
|
444
|
+
type: 'string',
|
|
445
|
+
description:
|
|
446
|
+
'Path to amxbuild.yml. Auto-detected if omitted ' +
|
|
447
|
+
'(searches for amxbuild.yml / amxbuild.yaml / manifest.yml in cwd).',
|
|
448
|
+
},
|
|
449
|
+
direction: {
|
|
450
|
+
type: 'string',
|
|
451
|
+
description:
|
|
452
|
+
'"down" — show includes (default for .sma)\n' +
|
|
453
|
+
'"up" — show includers (default for .inc)\n' +
|
|
454
|
+
'"auto" — auto-detect from file extension',
|
|
455
|
+
default: 'auto',
|
|
456
|
+
enum: ['auto', 'down', 'up'],
|
|
457
|
+
},
|
|
458
|
+
depth: {
|
|
459
|
+
type: 'number',
|
|
460
|
+
description:
|
|
461
|
+
'Max tree depth (0 = unlimited). Useful for limiting large trees.',
|
|
462
|
+
default: 0,
|
|
463
|
+
},
|
|
464
|
+
format: {
|
|
465
|
+
type: 'string',
|
|
466
|
+
description: 'Output format: "text" (tree with box-drawing) or "json".',
|
|
467
|
+
default: 'text',
|
|
468
|
+
enum: ['text', 'json'],
|
|
469
|
+
},
|
|
470
|
+
no_fetch: {
|
|
471
|
+
type: 'boolean',
|
|
472
|
+
description:
|
|
473
|
+
'If true, skip network fetches (compiler, repos, deps). ' +
|
|
474
|
+
'Only use what is already cached.',
|
|
475
|
+
default: false,
|
|
476
|
+
},
|
|
477
|
+
token: {
|
|
478
|
+
type: 'string',
|
|
479
|
+
description: 'GitHub PAT. Falls back to GITHUB_TOKEN env var.',
|
|
480
|
+
},
|
|
481
|
+
},
|
|
482
|
+
required: ['file'],
|
|
483
|
+
},
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
name: 'list_releases',
|
|
487
|
+
title: 'List GitHub releases or tags for a repository',
|
|
488
|
+
description:
|
|
489
|
+
'Get the list of releases (or git tags) for a GitHub repository. ' +
|
|
490
|
+
'Useful for discovering available versions of a dependency.\n\n' +
|
|
491
|
+
'By default returns releases. Use tags=true to list git tags instead ' +
|
|
492
|
+
'(useful for repos that do not publish GitHub Releases).',
|
|
493
|
+
inputSchema: {
|
|
494
|
+
type: 'object',
|
|
495
|
+
properties: {
|
|
496
|
+
repo: {
|
|
497
|
+
type: 'string',
|
|
498
|
+
description: 'Repository in format "owner/repo", e.g. "AmxxModularEcosystem/ParamsController"',
|
|
499
|
+
},
|
|
500
|
+
limit: {
|
|
501
|
+
type: 'number',
|
|
502
|
+
description: 'Max results to return (default: 10).',
|
|
503
|
+
default: 10,
|
|
504
|
+
},
|
|
505
|
+
includeAssets: {
|
|
506
|
+
type: 'boolean',
|
|
507
|
+
description: 'Include asset details (name, size, download count) per release.',
|
|
508
|
+
default: false,
|
|
509
|
+
},
|
|
510
|
+
tags: {
|
|
511
|
+
type: 'boolean',
|
|
512
|
+
description: 'List git tags instead of releases.',
|
|
513
|
+
default: false,
|
|
514
|
+
},
|
|
515
|
+
token: {
|
|
516
|
+
type: 'string',
|
|
517
|
+
description: 'GitHub PAT. Falls back to GITHUB_TOKEN env var.',
|
|
518
|
+
},
|
|
519
|
+
},
|
|
520
|
+
required: ['repo'],
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
name: 'build_plan',
|
|
525
|
+
title: 'Preview a full build plan (dry run)',
|
|
526
|
+
description:
|
|
527
|
+
'Resolve a manifest (defaults + set/define overrides) and return the complete build plan ' +
|
|
528
|
+
'without executing anything: compiler + version, repos with refs, deps, asset sources, ' +
|
|
529
|
+
'output layout. Equivalent to "amxb build --dry-run" but as structured JSON.',
|
|
530
|
+
inputSchema: {
|
|
531
|
+
type: 'object',
|
|
532
|
+
properties: {
|
|
533
|
+
manifest: {
|
|
534
|
+
type: 'string',
|
|
535
|
+
description: 'Path to amxbuild.yml. Auto-detected in cwd if omitted.',
|
|
536
|
+
},
|
|
537
|
+
set: {
|
|
538
|
+
type: 'array',
|
|
539
|
+
description: 'Field overrides via dot notation, e.g. ["version=1.2", "output.pack=false"].',
|
|
540
|
+
items: { type: 'string' },
|
|
541
|
+
},
|
|
542
|
+
define: {
|
|
543
|
+
type: 'array',
|
|
544
|
+
description: 'Compiler defines, e.g. ["DEBUG"]. Appended to amxmodx.defines.',
|
|
545
|
+
items: { type: 'string' },
|
|
546
|
+
},
|
|
547
|
+
},
|
|
548
|
+
},
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
name: 'list_repo_files',
|
|
552
|
+
title: 'List files in a dependency repo or release asset',
|
|
553
|
+
description:
|
|
554
|
+
'Fetch (if not cached) a git repo or release asset and list its files — not just .inc: ' +
|
|
555
|
+
'.sma sources, configs, lang files, README, etc. Useful to understand what a plugin provides.\n\n' +
|
|
556
|
+
'Supports git deps ("owner/repo@ref" via `dep`) or explicit { repo, ref?, source?, include_path?, asset? } fields.',
|
|
557
|
+
inputSchema: {
|
|
558
|
+
type: 'object',
|
|
559
|
+
properties: {
|
|
560
|
+
dep: {
|
|
561
|
+
type: 'string',
|
|
562
|
+
description: 'Dependency string "owner/repo@ref" or "owner/repo@ref:include_path".',
|
|
563
|
+
},
|
|
564
|
+
repo: {
|
|
565
|
+
type: 'string',
|
|
566
|
+
description: 'Alternative to `dep`: repository "owner/repo" (ref optional — default branch).',
|
|
567
|
+
},
|
|
568
|
+
ref: {
|
|
569
|
+
type: 'string',
|
|
570
|
+
description: 'Ref (tag/branch/commit) when using `repo`. Default: default branch.',
|
|
571
|
+
},
|
|
572
|
+
source: {
|
|
573
|
+
type: 'string',
|
|
574
|
+
description: 'Fetch method: "git" or "release".',
|
|
575
|
+
default: 'git',
|
|
576
|
+
enum: ['git', 'release'],
|
|
577
|
+
},
|
|
578
|
+
include_path: {
|
|
579
|
+
type: 'string',
|
|
580
|
+
description: 'Restrict listing to this path inside the repo/asset.',
|
|
581
|
+
},
|
|
582
|
+
asset: {
|
|
583
|
+
description: 'For source=release: asset selector (glob pattern or index).',
|
|
584
|
+
},
|
|
585
|
+
pattern: {
|
|
586
|
+
type: 'string',
|
|
587
|
+
description: 'Glob pattern, e.g. "**/*.sma", "amxmodx/**", "**/*".',
|
|
588
|
+
default: '**/*',
|
|
589
|
+
},
|
|
590
|
+
limit: {
|
|
591
|
+
type: 'number',
|
|
592
|
+
description: 'Max files to list.',
|
|
593
|
+
default: 500,
|
|
594
|
+
},
|
|
595
|
+
token: {
|
|
596
|
+
type: 'string',
|
|
597
|
+
description: 'GitHub PAT override. Defaults to GITHUB_TOKEN env.',
|
|
598
|
+
},
|
|
599
|
+
no_fetch: {
|
|
600
|
+
type: 'boolean',
|
|
601
|
+
description: 'Only use cache, skip network fetch.',
|
|
602
|
+
default: false,
|
|
603
|
+
},
|
|
604
|
+
},
|
|
605
|
+
},
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
name: 'read_repo_file',
|
|
609
|
+
title: 'Read any file from a dependency repo or release asset',
|
|
610
|
+
description:
|
|
611
|
+
'Fetch (if not cached) a git repo or release asset and return the contents of a specific file — ' +
|
|
612
|
+
'any file, not just .inc: .sma sources, configs, lang files, README.\n\n' +
|
|
613
|
+
'Path traversal outside the repo root is rejected.\n\n' +
|
|
614
|
+
'Supports git deps ("owner/repo@ref" via `dep`) or explicit { repo, ref?, source?, include_path?, asset? } fields.',
|
|
615
|
+
inputSchema: {
|
|
616
|
+
type: 'object',
|
|
617
|
+
properties: {
|
|
618
|
+
dep: {
|
|
619
|
+
type: 'string',
|
|
620
|
+
description: 'Dependency string "owner/repo@ref" or "owner/repo@ref:include_path".',
|
|
621
|
+
},
|
|
622
|
+
repo: {
|
|
623
|
+
type: 'string',
|
|
624
|
+
description: 'Alternative to `dep`: repository "owner/repo" (ref optional — default branch).',
|
|
625
|
+
},
|
|
626
|
+
ref: {
|
|
627
|
+
type: 'string',
|
|
628
|
+
description: 'Ref (tag/branch/commit) when using `repo`. Default: default branch.',
|
|
629
|
+
},
|
|
630
|
+
source: {
|
|
631
|
+
type: 'string',
|
|
632
|
+
description: 'Fetch method: "git" or "release".',
|
|
633
|
+
default: 'git',
|
|
634
|
+
enum: ['git', 'release'],
|
|
635
|
+
},
|
|
636
|
+
include_path: {
|
|
637
|
+
type: 'string',
|
|
638
|
+
description: 'Treat this path inside the repo as the root for `file`.',
|
|
639
|
+
},
|
|
640
|
+
asset: {
|
|
641
|
+
description: 'For source=release: asset selector (glob pattern or index).',
|
|
642
|
+
},
|
|
643
|
+
file: {
|
|
644
|
+
type: 'string',
|
|
645
|
+
description: 'Relative path inside the repo/asset root, e.g. "amxmodx/scripting/my_plugin.sma".',
|
|
646
|
+
},
|
|
647
|
+
grep: {
|
|
648
|
+
type: 'string',
|
|
649
|
+
description: 'Optional substring (case-insensitive) to search within the file.',
|
|
650
|
+
},
|
|
651
|
+
before: {
|
|
652
|
+
type: 'number',
|
|
653
|
+
description: 'Lines of context before each grep match.',
|
|
654
|
+
default: 0,
|
|
655
|
+
},
|
|
656
|
+
after: {
|
|
657
|
+
type: 'number',
|
|
658
|
+
description: 'Lines of context after each grep match.',
|
|
659
|
+
default: 0,
|
|
660
|
+
},
|
|
661
|
+
token: {
|
|
662
|
+
type: 'string',
|
|
663
|
+
description: 'GitHub PAT override. Defaults to GITHUB_TOKEN env.',
|
|
664
|
+
},
|
|
665
|
+
no_fetch: {
|
|
666
|
+
type: 'boolean',
|
|
667
|
+
description: 'Only use cache, skip network fetch.',
|
|
668
|
+
default: false,
|
|
669
|
+
},
|
|
670
|
+
},
|
|
671
|
+
required: ['file'],
|
|
672
|
+
},
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
name: 'compile_sma',
|
|
676
|
+
title: 'Compile a single .sma to check for errors',
|
|
677
|
+
description:
|
|
678
|
+
'Run amxxpc on a local .sma file without a full build and return the compiler output ' +
|
|
679
|
+
'(status, errors, warnings). Resolves the compiler version and include dirs ' +
|
|
680
|
+
'(stdlib + manifest deps) the same way a real build would. ' +
|
|
681
|
+
'Use it to iterate on code until it compiles clean.',
|
|
682
|
+
inputSchema: {
|
|
683
|
+
type: 'object',
|
|
684
|
+
properties: {
|
|
685
|
+
sma_file: {
|
|
686
|
+
type: 'string',
|
|
687
|
+
description: 'Path to the .sma file to compile.',
|
|
688
|
+
},
|
|
689
|
+
manifest: {
|
|
690
|
+
type: 'string',
|
|
691
|
+
description: 'Path to amxbuild.yml for deps + version. Auto-detected in cwd if omitted.',
|
|
692
|
+
},
|
|
693
|
+
version: {
|
|
694
|
+
type: 'string',
|
|
695
|
+
description: 'AMX Mod X version override (default: from manifest or latest).',
|
|
696
|
+
},
|
|
697
|
+
include_dirs: {
|
|
698
|
+
type: 'array',
|
|
699
|
+
description: 'Extra include dirs passed as -i.',
|
|
700
|
+
items: { type: 'string' },
|
|
701
|
+
},
|
|
702
|
+
define: {
|
|
703
|
+
type: 'array',
|
|
704
|
+
description: 'Extra compiler defines, e.g. ["DEBUG"].',
|
|
705
|
+
items: { type: 'string' },
|
|
706
|
+
},
|
|
707
|
+
keep_output: {
|
|
708
|
+
type: 'boolean',
|
|
709
|
+
description: 'Keep the compiled .amxx and return its path.',
|
|
710
|
+
default: false,
|
|
711
|
+
},
|
|
712
|
+
token: {
|
|
713
|
+
type: 'string',
|
|
714
|
+
description: 'GitHub PAT override. Defaults to GITHUB_TOKEN env.',
|
|
715
|
+
},
|
|
716
|
+
no_fetch: {
|
|
717
|
+
type: 'boolean',
|
|
718
|
+
description: 'Only use cache, skip network fetch.',
|
|
719
|
+
default: false,
|
|
720
|
+
},
|
|
721
|
+
},
|
|
722
|
+
required: ['sma_file'],
|
|
723
|
+
},
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
name: 'resolve_assets',
|
|
727
|
+
title: 'Preview asset sources without downloading',
|
|
728
|
+
description:
|
|
729
|
+
'Show the parsed asset plan from a manifest: every source (local/url/release/amxmodx), ' +
|
|
730
|
+
'its map rules (from → to), cache type, and for local sources the files that would be included. ' +
|
|
731
|
+
'No downloads — pure preview of the assets.sources configuration.',
|
|
732
|
+
inputSchema: {
|
|
733
|
+
type: 'object',
|
|
734
|
+
properties: {
|
|
735
|
+
manifest: {
|
|
736
|
+
type: 'string',
|
|
737
|
+
description: 'Path to amxbuild.yml. Auto-detected in cwd if omitted.',
|
|
738
|
+
},
|
|
739
|
+
list_local: {
|
|
740
|
+
type: 'boolean',
|
|
741
|
+
description: 'List files from the local assets/ dir.',
|
|
742
|
+
default: true,
|
|
743
|
+
},
|
|
744
|
+
},
|
|
745
|
+
},
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
name: 'manifest_schema',
|
|
749
|
+
title: 'Get the amxbuild.yml JSON schema',
|
|
750
|
+
description:
|
|
751
|
+
'Return the full JSON schema for amxbuild.yml (all fields, types, constraints). ' +
|
|
752
|
+
'Use this when writing or editing a manifest to know exactly which fields are valid.',
|
|
753
|
+
inputSchema: {
|
|
754
|
+
type: 'object',
|
|
755
|
+
properties: {},
|
|
756
|
+
},
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
name: 'search_symbol',
|
|
760
|
+
title: 'Search for a symbol across stdlib, deps and the local project',
|
|
761
|
+
description:
|
|
762
|
+
'Search for a symbol (function, native, define, enum member, constant) across ' +
|
|
763
|
+
'all available AMXX sources: the standard library, manifest dependencies ' +
|
|
764
|
+
'(git or release), and the local project\'s own code (amxmodx/ dir: shared ' +
|
|
765
|
+
'includes + .sma files). Uses a cached index — fast repeated lookups.\n\n' +
|
|
766
|
+
'Exact match by default; set partial=true for a case-insensitive substring search.',
|
|
767
|
+
inputSchema: {
|
|
768
|
+
type: 'object',
|
|
769
|
+
properties: {
|
|
770
|
+
symbol: {
|
|
771
|
+
type: 'string',
|
|
772
|
+
description: 'Symbol name to find, e.g. "register_cvar", "MAX_PLAYERS".',
|
|
773
|
+
},
|
|
774
|
+
manifest: {
|
|
775
|
+
type: 'string',
|
|
776
|
+
description: 'Path to amxbuild.yml — provides deps scope + local project dir. Auto-detected in cwd.',
|
|
777
|
+
},
|
|
778
|
+
scope: {
|
|
779
|
+
type: 'string',
|
|
780
|
+
description: '"all" (default), "stdlib", "deps" or "local".',
|
|
781
|
+
default: 'all',
|
|
782
|
+
enum: ['all', 'stdlib', 'deps', 'local'],
|
|
783
|
+
},
|
|
784
|
+
deps: {
|
|
785
|
+
type: 'array',
|
|
786
|
+
description: 'Inline deps as alternative to manifest (strings "owner/repo@ref" or objects).',
|
|
787
|
+
items: {
|
|
788
|
+
oneOf: [
|
|
789
|
+
{ type: 'string' },
|
|
790
|
+
{
|
|
791
|
+
type: 'object',
|
|
792
|
+
properties: {
|
|
793
|
+
repo: { type: 'string' },
|
|
794
|
+
ref: { type: 'string' },
|
|
795
|
+
source: { type: 'string', enum: ['git', 'release'] },
|
|
796
|
+
include_path: { type: 'string' },
|
|
797
|
+
asset: { oneOf: [{ type: 'string' }, { type: 'number' }] },
|
|
798
|
+
},
|
|
799
|
+
required: ['repo', 'ref'],
|
|
800
|
+
},
|
|
801
|
+
],
|
|
802
|
+
},
|
|
803
|
+
},
|
|
804
|
+
version: {
|
|
805
|
+
type: 'string',
|
|
806
|
+
description: 'AMX Mod X version for the stdlib scope (default: from manifest or latest).',
|
|
807
|
+
},
|
|
808
|
+
partial: {
|
|
809
|
+
type: 'boolean',
|
|
810
|
+
description: 'Case-insensitive substring search instead of exact match.',
|
|
811
|
+
default: false,
|
|
812
|
+
},
|
|
813
|
+
token: {
|
|
814
|
+
type: 'string',
|
|
815
|
+
description: 'GitHub PAT override. Defaults to GITHUB_TOKEN env.',
|
|
816
|
+
},
|
|
817
|
+
no_fetch: {
|
|
818
|
+
type: 'boolean',
|
|
819
|
+
description: 'Only use cache, skip network fetch.',
|
|
820
|
+
default: false,
|
|
821
|
+
},
|
|
822
|
+
},
|
|
823
|
+
required: ['symbol'],
|
|
824
|
+
},
|
|
825
|
+
},
|
|
826
|
+
|
|
827
|
+
];
|
|
828
|
+
|
|
829
|
+
TOOLS.forEach((t) => {
|
|
830
|
+
t.handler = HANDLERS[t.name];
|
|
831
|
+
if (!t.inputSchema.properties) t.inputSchema.properties = {};
|
|
832
|
+
t.inputSchema.properties.full_output = {
|
|
833
|
+
type: 'boolean',
|
|
834
|
+
description: 'Return the complete output, bypassing the default 200 KB / 50-file limits.',
|
|
835
|
+
default: false,
|
|
836
|
+
};
|
|
837
|
+
const tok = t.inputSchema.properties.token;
|
|
838
|
+
if (tok) {
|
|
839
|
+
tok.description =
|
|
840
|
+
'GitHub PAT override. Defaults to the GITHUB_TOKEN env var ' +
|
|
841
|
+
'(the project .env is auto-loaded); env/manifest data is preferred.';
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
function listTools() {
|
|
846
|
+
return { tools: TOOLS.map(({ handler, ...def }) => def) };
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
async function callTool(name, args) {
|
|
850
|
+
const tool = TOOLS.find((t) => t.name === name);
|
|
851
|
+
if (!tool) {
|
|
852
|
+
return {
|
|
853
|
+
content: [{ type: 'text', text: 'Error: Unknown tool: ' + name }],
|
|
854
|
+
isError: true,
|
|
855
|
+
_meta: { code: -32601 },
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
const token = args?.token || null; // explicit override; handlers fall back to env/manifest per-owner
|
|
859
|
+
const noFetch = args?.no_fetch === true;
|
|
860
|
+
return tool.handler(args, token, noFetch);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
module.exports = { TOOLS, listTools, callTool };
|