@qodalis/mcp-cli 0.0.0-stage → 0.2.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.
- package/CHANGELOG.md +50 -0
- package/LICENSE +21 -0
- package/README.md +384 -2
- package/dist/src/cli.d.ts +3 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +102 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/config.d.ts +60 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +149 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/dev/api.d.ts +94 -0
- package/dist/src/dev/api.d.ts.map +1 -0
- package/dist/src/dev/api.js +425 -0
- package/dist/src/dev/api.js.map +1 -0
- package/dist/src/dev/docs.d.ts +93 -0
- package/dist/src/dev/docs.d.ts.map +1 -0
- package/dist/src/dev/docs.js +275 -0
- package/dist/src/dev/docs.js.map +1 -0
- package/dist/src/dev/prompts.d.ts +11 -0
- package/dist/src/dev/prompts.d.ts.map +1 -0
- package/dist/src/dev/prompts.js +141 -0
- package/dist/src/dev/prompts.js.map +1 -0
- package/dist/src/dev/scaffold.d.ts +55 -0
- package/dist/src/dev/scaffold.d.ts.map +1 -0
- package/dist/src/dev/scaffold.js +213 -0
- package/dist/src/dev/scaffold.js.map +1 -0
- package/dist/src/dev/tools.d.ts +170 -0
- package/dist/src/dev/tools.d.ts.map +1 -0
- package/dist/src/dev/tools.js +258 -0
- package/dist/src/dev/tools.js.map +1 -0
- package/dist/src/env-file.d.ts +9 -0
- package/dist/src/env-file.d.ts.map +1 -0
- package/dist/src/env-file.js +54 -0
- package/dist/src/env-file.js.map +1 -0
- package/dist/src/errors.d.ts +22 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +115 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/filters.d.ts +13 -0
- package/dist/src/filters.d.ts.map +1 -0
- package/dist/src/filters.js +16 -0
- package/dist/src/filters.js.map +1 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +12 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/remote.d.ts +64 -0
- package/dist/src/remote.d.ts.map +1 -0
- package/dist/src/remote.js +242 -0
- package/dist/src/remote.js.map +1 -0
- package/dist/src/server.d.ts +22 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +156 -0
- package/dist/src/server.js.map +1 -0
- package/docs/llms-full.txt +1740 -0
- package/package.json +70 -5
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
export class ConfigError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = 'ConfigError';
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export const DEFAULT_DOCS_URL = 'https://cli.qodalis.com/llms-full.txt';
|
|
8
|
+
export const PREFIXES = ['QCLI', 'QODALIS_CLI'];
|
|
9
|
+
/** `QCLI_<suffix>` plus the `QODALIS_CLI_<suffix>` alias. */
|
|
10
|
+
export const names = (suffix) => PREFIXES.map((prefix) => `${prefix}_${suffix}`);
|
|
11
|
+
export const ENV_FILE_VARIABLES = names('ENV_FILE');
|
|
12
|
+
const TRUE_VALUES = new Set(['1', 'true', 'yes', 'on']);
|
|
13
|
+
const FALSE_VALUES = new Set(['0', 'false', 'no', 'off']);
|
|
14
|
+
/** Typed readers over an environment map; the first non-empty name wins. */
|
|
15
|
+
export const createEnvReader = (env) => {
|
|
16
|
+
const optional = (names) => {
|
|
17
|
+
for (const name of names) {
|
|
18
|
+
const value = env[name]?.trim();
|
|
19
|
+
if (value) {
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
};
|
|
25
|
+
const describe = (names) => names.length > 1
|
|
26
|
+
? `${names[0]} (or its alias ${names.slice(1).join(' / ')})`
|
|
27
|
+
: (names[0] ?? '');
|
|
28
|
+
const required = (names) => {
|
|
29
|
+
const value = optional(names);
|
|
30
|
+
if (!value) {
|
|
31
|
+
throw new ConfigError(`${describe(names)} is required.`);
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
};
|
|
35
|
+
const boolean = (names, fallback) => {
|
|
36
|
+
const value = optional(names);
|
|
37
|
+
if (value === undefined) {
|
|
38
|
+
return fallback;
|
|
39
|
+
}
|
|
40
|
+
const normalized = value.toLowerCase();
|
|
41
|
+
if (TRUE_VALUES.has(normalized)) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
if (FALSE_VALUES.has(normalized)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
throw new ConfigError(`${names[0]} must be a boolean (true/false), got "${value}".`);
|
|
48
|
+
};
|
|
49
|
+
const positiveInteger = (names, fallback) => {
|
|
50
|
+
const value = optional(names);
|
|
51
|
+
if (value === undefined) {
|
|
52
|
+
return fallback;
|
|
53
|
+
}
|
|
54
|
+
const parsed = Number(value);
|
|
55
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
56
|
+
throw new ConfigError(`${names[0]} must be a positive integer, got "${value}".`);
|
|
57
|
+
}
|
|
58
|
+
return parsed;
|
|
59
|
+
};
|
|
60
|
+
const list = (names) => (optional(names) ?? '')
|
|
61
|
+
.split(',')
|
|
62
|
+
.map((entry) => entry.trim())
|
|
63
|
+
.filter((entry) => entry.length > 0);
|
|
64
|
+
return { boolean, list, optional, positiveInteger, required };
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Canonical server URL: scheme and host, optional base path, no trailing slash.
|
|
68
|
+
* A pasted endpoint URL (`…/api/qcli/mcp`) is accepted and reduced to the base.
|
|
69
|
+
*/
|
|
70
|
+
const parseHttpUrl = (input, variable) => {
|
|
71
|
+
let url;
|
|
72
|
+
try {
|
|
73
|
+
url = new URL(input);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
throw new ConfigError(`${variable} must be an http(s) URL, got "${input}".`);
|
|
77
|
+
}
|
|
78
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
79
|
+
throw new ConfigError(`${variable} must be an http(s) URL, got "${input}".`);
|
|
80
|
+
}
|
|
81
|
+
return url;
|
|
82
|
+
};
|
|
83
|
+
export const normalizeUrl = (input) => {
|
|
84
|
+
const url = parseHttpUrl(input, 'QCLI_URL');
|
|
85
|
+
const path = url.pathname.replace(/\/+$/, '').replace(/\/api\/qcli\/mcp$/i, '');
|
|
86
|
+
return `${url.protocol}//${url.host}${path}`;
|
|
87
|
+
};
|
|
88
|
+
const loadAuth = (read) => {
|
|
89
|
+
const token = read.optional(names('TOKEN'));
|
|
90
|
+
const user = read.optional(names('USER'));
|
|
91
|
+
const password = read.optional(names('PASSWORD'));
|
|
92
|
+
if (token && (user || password)) {
|
|
93
|
+
throw new ConfigError('Set either QCLI_TOKEN or QCLI_USER + QCLI_PASSWORD, not both.');
|
|
94
|
+
}
|
|
95
|
+
if (token) {
|
|
96
|
+
return { kind: 'token', token };
|
|
97
|
+
}
|
|
98
|
+
if (user || password) {
|
|
99
|
+
if (!user || !password) {
|
|
100
|
+
throw new ConfigError('QCLI_USER and QCLI_PASSWORD must be set together.');
|
|
101
|
+
}
|
|
102
|
+
return { kind: 'password', password, user };
|
|
103
|
+
}
|
|
104
|
+
return { kind: 'none' };
|
|
105
|
+
};
|
|
106
|
+
export const loadConfig = (env = process.env) => {
|
|
107
|
+
const read = createEnvReader(env);
|
|
108
|
+
const url = read.optional(names('URL'));
|
|
109
|
+
const devTools = read.boolean(names('DEV_TOOLS'), true);
|
|
110
|
+
if (!url && !devTools) {
|
|
111
|
+
throw new ConfigError('Nothing to serve: set QCLI_URL to proxy a Qodalis CLI server, or leave QCLI_DEV_TOOLS on for the plugin-development tools.');
|
|
112
|
+
}
|
|
113
|
+
const auth = loadAuth(read);
|
|
114
|
+
const docsUrl = read.optional(names('DOCS_URL')) ?? DEFAULT_DOCS_URL;
|
|
115
|
+
parseHttpUrl(docsUrl, 'QCLI_DOCS_URL');
|
|
116
|
+
return {
|
|
117
|
+
auth,
|
|
118
|
+
connectionTimeoutMs: read.positiveInteger(names('CONNECTION_TIMEOUT'), 8000),
|
|
119
|
+
devTools,
|
|
120
|
+
docsUrl,
|
|
121
|
+
exclude: read.list(names('EXCLUDE')),
|
|
122
|
+
readOnly: read.boolean(names('READ_ONLY'), false),
|
|
123
|
+
requestTimeoutMs: read.positiveInteger(names('REQUEST_TIMEOUT'), 60000),
|
|
124
|
+
tools: read.list(names('TOOLS')),
|
|
125
|
+
trustCert: read.boolean(names('TRUST_CERT'), false),
|
|
126
|
+
url: url ? normalizeUrl(url) : undefined,
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
/** One-line summary for the startup log (never contains secrets). */
|
|
130
|
+
export const describeConfig = (config) => {
|
|
131
|
+
const auth = config.auth.kind === 'token'
|
|
132
|
+
? 'token auth'
|
|
133
|
+
: config.auth.kind === 'password'
|
|
134
|
+
? `signs in as ${config.auth.user}`
|
|
135
|
+
: 'no auth';
|
|
136
|
+
const filters = [
|
|
137
|
+
config.readOnly ? 'read-only tools' : 'all tools',
|
|
138
|
+
config.tools.length ? `allow ${config.tools.join(',')}` : '',
|
|
139
|
+
config.exclude.length ? `exclude ${config.exclude.join(',')}` : '',
|
|
140
|
+
]
|
|
141
|
+
.filter(Boolean)
|
|
142
|
+
.join(', ');
|
|
143
|
+
const dev = config.devTools ? ' + plugin-development tools' : '';
|
|
144
|
+
if (!config.url) {
|
|
145
|
+
return `developer mode (plugin-development tools only; ${filters})`;
|
|
146
|
+
}
|
|
147
|
+
return `${config.url} (${auth}; ${filters})${dev}`;
|
|
148
|
+
};
|
|
149
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,WAAY,SAAQ,KAAK;IAClC,YAAY,OAAe;QACvB,KAAK,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,MAAM,IAAI,GACN,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO;QACxB,CAAC,CAAC,YAAY;QACd,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU;YAC/B,CAAC,CAAC,eAAe,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE;YACnC,CAAC,CAAC,SAAS,CAAC;IACtB,MAAM,OAAO,GAAG;QACZ,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,WAAW;QACjD,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;QAC5D,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;KACrE;SACI,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACd,OAAO,kDAAkD,OAAO,GAAG,CAAC;IACxE,CAAC;IACD,OAAO,GAAG,MAAM,CAAC,GAAG,KAAK,IAAI,KAAK,OAAO,IAAI,GAAG,EAAE,CAAC;AACvD,CAAC,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `qcli_api`: TypeScript declarations of the published `@qodalis/*` packages, read from
|
|
3
|
+
* the project's node_modules when installed there, otherwise from the npm registry
|
|
4
|
+
* (`latest`) through a CDN, cached in memory and in a temp directory.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_API_PACKAGE = "@qodalis/cli-core";
|
|
7
|
+
/** `cli-core`, `@qodalis/cli-core` → `@qodalis/cli-core`; anything outside @qodalis is refused. */
|
|
8
|
+
export declare const normalizePackageName: (input: string | undefined) => string;
|
|
9
|
+
export type Declaration = {
|
|
10
|
+
/** The declaration with its JSDoc, as written in the .d.ts */
|
|
11
|
+
text: string;
|
|
12
|
+
/** File it came from, relative to the package root */
|
|
13
|
+
file: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* `source` with comments, strings and template literals replaced by spaces (newlines
|
|
17
|
+
* kept), so offsets match the original and braces in JSDoc or string types do not count.
|
|
18
|
+
*/
|
|
19
|
+
export declare const blankNonCode: (source: string) => string;
|
|
20
|
+
/** Every top-level declaration of `symbol` in `source` (overloads and merged interfaces included). */
|
|
21
|
+
export declare const extractDeclarations: (source: string, symbol: string) => string[];
|
|
22
|
+
/** Names of every top-level declaration in the files. */
|
|
23
|
+
export declare const declaredNames: (sources: string[]) => Set<string>;
|
|
24
|
+
/** `export { Local as Symbol }` aliases: the local name a public symbol is declared under. */
|
|
25
|
+
export declare const aliasOf: (sources: string[], symbol: string) => string | undefined;
|
|
26
|
+
export type TypeFiles = {
|
|
27
|
+
/** Relative path → content */
|
|
28
|
+
files: Map<string, string>;
|
|
29
|
+
package: string;
|
|
30
|
+
/** `node_modules (<path>)`, `cache`, `https://…` */
|
|
31
|
+
source: string;
|
|
32
|
+
version: string;
|
|
33
|
+
};
|
|
34
|
+
export type ApiLookup = {
|
|
35
|
+
declarations: Declaration[];
|
|
36
|
+
/** Declared names referenced by the declarations, to look up next */
|
|
37
|
+
related: string[];
|
|
38
|
+
/** Close names when nothing matched */
|
|
39
|
+
suggestions: string[];
|
|
40
|
+
types: TypeFiles;
|
|
41
|
+
};
|
|
42
|
+
/** Finds `symbol` in the package's declaration files. */
|
|
43
|
+
export declare const lookupSymbol: (types: TypeFiles, symbol: string) => ApiLookup;
|
|
44
|
+
type PackageJson = {
|
|
45
|
+
exports?: unknown;
|
|
46
|
+
name?: string;
|
|
47
|
+
types?: string;
|
|
48
|
+
typings?: string;
|
|
49
|
+
version?: string;
|
|
50
|
+
};
|
|
51
|
+
/** The declaration entry of a package.json: `types`, `typings`, `exports["."].types`. */
|
|
52
|
+
export declare const typesEntry: (pkg: PackageJson) => string;
|
|
53
|
+
/**
|
|
54
|
+
* Loads the entry file and every .d.ts reachable through relative imports/re-exports
|
|
55
|
+
* with `read` (returns undefined for a missing file).
|
|
56
|
+
*/
|
|
57
|
+
export declare const collectTypeFiles: (entry: string, read: (relativePath: string) => Promise<string | undefined>) => Promise<Map<string, string>>;
|
|
58
|
+
/** `<dir>/node_modules/<pkg>` for `dir` and each of its parents. */
|
|
59
|
+
export declare const findInstalledPackage: (cwd: string, name: string) => string | undefined;
|
|
60
|
+
export type ApiSourceOptions = {
|
|
61
|
+
/** Project directory searched for node_modules (default: process.cwd()) */
|
|
62
|
+
cwd?: string;
|
|
63
|
+
/** Overrides the HTTP client (tests) */
|
|
64
|
+
fetch?: typeof fetch;
|
|
65
|
+
log?: (message: string) => void;
|
|
66
|
+
/** Directory for downloaded declarations (default: `<os tmp>/qodalis-mcp-cli`); null disables it */
|
|
67
|
+
cacheDir?: string | null;
|
|
68
|
+
registryUrl?: string;
|
|
69
|
+
/** CDN base URLs tried in order; `<base>/<name>@<version>/<file>` */
|
|
70
|
+
cdns?: string[];
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Resolves a package's declaration files: (1) the project's node_modules, (2) an
|
|
74
|
+
* in-memory copy, (3) the registry's `latest` version from the temp-dir cache or a CDN,
|
|
75
|
+
* (4) without network, the newest version in the temp-dir cache.
|
|
76
|
+
*/
|
|
77
|
+
export declare class ApiSource {
|
|
78
|
+
private readonly options;
|
|
79
|
+
private readonly memory;
|
|
80
|
+
constructor(options?: ApiSourceOptions);
|
|
81
|
+
get(name: string): Promise<TypeFiles>;
|
|
82
|
+
private fromDirectory;
|
|
83
|
+
private get cacheDir();
|
|
84
|
+
private fetchText;
|
|
85
|
+
private download;
|
|
86
|
+
private cacheFile;
|
|
87
|
+
private readCache;
|
|
88
|
+
private writeCache;
|
|
89
|
+
private newestCached;
|
|
90
|
+
}
|
|
91
|
+
/** Markdown answer for `qcli_api`. */
|
|
92
|
+
export declare const formatLookup: (symbol: string, lookup: ApiLookup) => string;
|
|
93
|
+
export {};
|
|
94
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/dev/api.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAKvD,mGAAmG;AACnG,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,GAAG,SAAS,KAAG,MAShE,CAAC;AAIF,MAAM,MAAM,WAAW,GAAG;IACtB,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAQF;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,KAAG,MAkC7C,CAAC;AA0EF,sGAAsG;AACtG,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,KAAG,MAAM,EAY1E,CAAC;AAEF,yDAAyD;AACzD,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,EAAE,KAAG,GAAG,CAAC,MAAM,CACiB,CAAC;AAE9E,8FAA8F;AAC9F,eAAO,MAAM,OAAO,GAAI,SAAS,MAAM,EAAE,EAAE,QAAQ,MAAM,KAAG,MAAM,GAAG,SAYpE,CAAC;AAMF,MAAM,MAAM,SAAS,GAAG;IACpB,8BAA8B;IAC9B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CAC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