launch-doctor 0.4.2 → 0.4.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/CHANGELOG.md +18 -1
- package/README.md +22 -3
- package/dist/src/baseline.d.ts +9 -0
- package/dist/src/baseline.js +26 -0
- package/dist/src/cli.js +169 -77
- package/dist/src/core.d.ts +85 -0
- package/dist/src/core.js +166 -0
- package/dist/src/explanations.d.ts +24 -0
- package/dist/src/explanations.js +562 -0
- package/dist/src/index.js +2 -1
- package/dist/src/init.d.ts +12 -0
- package/dist/src/init.js +55 -0
- package/dist/src/live.js +3 -0
- package/dist/src/mcp.d.ts +126 -11
- package/dist/src/mcp.js +285 -148
- package/dist/src/report-md.d.ts +14 -0
- package/dist/src/report-md.js +71 -0
- package/dist/src/short-report.d.ts +2 -0
- package/dist/src/short-report.js +5 -0
- package/dist/src/types.d.ts +6 -0
- package/package.json +2 -2
package/dist/src/init.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
|
+
import { CONFIG_FILE_MAX_BYTES } from './project.js';
|
|
4
|
+
import { entryKind, readRegularFile, writeRegularFile } from './safe-fs.js';
|
|
3
5
|
import { version } from './version.js';
|
|
4
6
|
/** The same workflow as the README's "CI integration" example. */
|
|
5
7
|
export const WORKFLOW_TEMPLATE = `name: Launch Doctor
|
|
@@ -161,3 +163,56 @@ export function runInit(root, { monitor = false } = {}) {
|
|
|
161
163
|
}
|
|
162
164
|
return result;
|
|
163
165
|
}
|
|
166
|
+
/** The line init adds to .gitignore, so .launchdoctor/ (grades, badge, report.md) is not committed by accident. */
|
|
167
|
+
export const GITIGNORE_LINE = '.launchdoctor/';
|
|
168
|
+
/**
|
|
169
|
+
* Add .launchdoctor/ to the project's .gitignore (creating the file if there is none). Returns what happened. A
|
|
170
|
+
* .gitignore that is a link or a special file is left alone, like every file Launch Doctor writes.
|
|
171
|
+
*/
|
|
172
|
+
export function ensureGitignore(root) {
|
|
173
|
+
const path = join(root, '.gitignore');
|
|
174
|
+
const kind = entryKind(path);
|
|
175
|
+
if (kind === 'missing') {
|
|
176
|
+
writeRegularFile(path, `${GITIGNORE_LINE}\n`);
|
|
177
|
+
return 'created';
|
|
178
|
+
}
|
|
179
|
+
const text = kind === 'file' ? readRegularFile(path, CONFIG_FILE_MAX_BYTES) : null;
|
|
180
|
+
if (text === null)
|
|
181
|
+
return 'skipped';
|
|
182
|
+
if (/^\/?\.launchdoctor\/?\s*$/m.test(text))
|
|
183
|
+
return 'present';
|
|
184
|
+
writeRegularFile(path, `${text}${text === '' || text.endsWith('\n') ? '' : '\n'}${GITIGNORE_LINE}\n`);
|
|
185
|
+
return 'updated';
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* `init --mcp`: the exact commands and snippets to connect Launch Doctor to Claude Code, Cursor and Claude Desktop.
|
|
189
|
+
* Nothing is written: the user pastes them where they want.
|
|
190
|
+
*/
|
|
191
|
+
export function mcpSetupText(root, pkg) {
|
|
192
|
+
const desktopArgs = ['-y', pkg, 'mcp', root];
|
|
193
|
+
const projectArgs = ['-y', pkg, 'mcp'];
|
|
194
|
+
const json = (args) => JSON.stringify({ mcpServers: { 'launch-doctor': { command: 'npx', args } } }, null, 2)
|
|
195
|
+
.split('\n')
|
|
196
|
+
.map((l) => ` ${l}`)
|
|
197
|
+
.join('\n');
|
|
198
|
+
return [
|
|
199
|
+
'',
|
|
200
|
+
' Claude Code (run in this project folder):',
|
|
201
|
+
'',
|
|
202
|
+
` claude mcp add launch-doctor -- npx -y "${pkg}" mcp`,
|
|
203
|
+
'',
|
|
204
|
+
' Cursor: add this to .cursor/mcp.json in this project:',
|
|
205
|
+
'',
|
|
206
|
+
json(projectArgs),
|
|
207
|
+
'',
|
|
208
|
+
' Claude Desktop: add this to claude_desktop_config.json',
|
|
209
|
+
' (macOS: ~/Library/Application Support/Claude/, Windows: %APPDATA%\\Claude\\).',
|
|
210
|
+
' Claude Desktop does not start servers in your project, so the folder is given:',
|
|
211
|
+
'',
|
|
212
|
+
json(desktopArgs),
|
|
213
|
+
'',
|
|
214
|
+
' Then ask: "Scan this app with Launch Doctor", "Explain finding 2", or "Fix the top issue, then rescan".',
|
|
215
|
+
' The server only reads this folder and uses the network only for scan_url. Nothing was written.',
|
|
216
|
+
'',
|
|
217
|
+
].join('\n');
|
|
218
|
+
}
|
package/dist/src/live.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assignRefs } from './baseline.js';
|
|
1
2
|
import { emptyOutput, notApplicable } from './checks/common.js';
|
|
2
3
|
import { leakPlaybook, matchKeys, usageLink } from './checks/secrets.js';
|
|
3
4
|
import { overall, scoreCategory, toGrade } from './grade.js';
|
|
@@ -580,6 +581,8 @@ export async function runLiveScan(input, options = {}) {
|
|
|
580
581
|
const hosts = [...new Set(fetcher.blocked.map((b) => b.split(' ')[0]))].slice(0, 3).join(', ');
|
|
581
582
|
categories[0].passed.push(`Skipped ${plural(fetcher.blocked.length, 'request')} to private or local network addresses (${hosts}) that this public site pointed to`);
|
|
582
583
|
}
|
|
584
|
+
// No lines in a live scan: a finding is told apart by its rule and the URL it is about.
|
|
585
|
+
assignRefs(categories.flatMap((c) => c.findings), () => '');
|
|
583
586
|
// Text from the site (table names, paths) can hold terminal escape sequences; none reach any output.
|
|
584
587
|
return sanitizeReport({
|
|
585
588
|
tool: 'launch-doctor',
|
package/dist/src/mcp.d.ts
CHANGED
|
@@ -4,9 +4,16 @@ import type { Report } from './types.js';
|
|
|
4
4
|
* A Model Context Protocol server over stdio, so AI coding tools (Claude Code, Cursor, ...)
|
|
5
5
|
* can run Launch Doctor themselves. One JSON-RPC 2.0 message per line on stdin and stdout.
|
|
6
6
|
* Nothing else may be written to stdout: it is the protocol channel.
|
|
7
|
+
*
|
|
8
|
+
* Every tool goes through the shared core (src/core.ts), like the CLI. The server only reads the project: it
|
|
9
|
+
* writes nothing, and it makes no network request except for scan_url, with the address the caller gives.
|
|
7
10
|
*/
|
|
8
11
|
/** Protocol versions this server speaks, newest first. */
|
|
9
12
|
export declare const PROTOCOL_VERSIONS: string[];
|
|
13
|
+
/** Findings listed in a scan result; the rest are counted. Each entry is one line, so this caps the size. */
|
|
14
|
+
export declare const MAX_LISTED = 25;
|
|
15
|
+
/** The most text one tool result may hold, so a big app can't flood the model's context. */
|
|
16
|
+
export declare const MAX_TEXT = 12000;
|
|
10
17
|
interface ToolResult {
|
|
11
18
|
content: {
|
|
12
19
|
type: 'text';
|
|
@@ -47,15 +54,119 @@ export declare function mcpTools(): ({
|
|
|
47
54
|
type: string;
|
|
48
55
|
description: string;
|
|
49
56
|
};
|
|
50
|
-
|
|
57
|
+
history: {
|
|
51
58
|
type: string;
|
|
52
59
|
description: string;
|
|
53
60
|
};
|
|
54
|
-
|
|
61
|
+
includeBaseline: {
|
|
55
62
|
type: string;
|
|
56
63
|
description: string;
|
|
57
64
|
};
|
|
58
|
-
|
|
65
|
+
id?: undefined;
|
|
66
|
+
ids?: undefined;
|
|
67
|
+
paths?: undefined;
|
|
68
|
+
url?: undefined;
|
|
69
|
+
skipDatabase?: undefined;
|
|
70
|
+
};
|
|
71
|
+
additionalProperties: boolean;
|
|
72
|
+
required?: undefined;
|
|
73
|
+
};
|
|
74
|
+
annotations: {
|
|
75
|
+
readOnlyHint: boolean;
|
|
76
|
+
idempotentHint: boolean;
|
|
77
|
+
openWorldHint: boolean;
|
|
78
|
+
};
|
|
79
|
+
} | {
|
|
80
|
+
name: string;
|
|
81
|
+
title: string;
|
|
82
|
+
description: string;
|
|
83
|
+
inputSchema: {
|
|
84
|
+
type: string;
|
|
85
|
+
properties: {
|
|
86
|
+
only?: undefined;
|
|
87
|
+
skip?: undefined;
|
|
88
|
+
offline?: undefined;
|
|
89
|
+
history?: undefined;
|
|
90
|
+
includeBaseline?: undefined;
|
|
91
|
+
id: {
|
|
92
|
+
type: string;
|
|
93
|
+
description: string;
|
|
94
|
+
};
|
|
95
|
+
path: {
|
|
96
|
+
type: string;
|
|
97
|
+
description: string;
|
|
98
|
+
};
|
|
99
|
+
ids?: undefined;
|
|
100
|
+
paths?: undefined;
|
|
101
|
+
url?: undefined;
|
|
102
|
+
skipDatabase?: undefined;
|
|
103
|
+
};
|
|
104
|
+
required: string[];
|
|
105
|
+
additionalProperties: boolean;
|
|
106
|
+
};
|
|
107
|
+
annotations: {
|
|
108
|
+
readOnlyHint: boolean;
|
|
109
|
+
idempotentHint: boolean;
|
|
110
|
+
openWorldHint: boolean;
|
|
111
|
+
};
|
|
112
|
+
} | {
|
|
113
|
+
name: string;
|
|
114
|
+
title: string;
|
|
115
|
+
description: string;
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: string;
|
|
118
|
+
properties: {
|
|
119
|
+
only?: undefined;
|
|
120
|
+
skip?: undefined;
|
|
121
|
+
offline?: undefined;
|
|
122
|
+
history?: undefined;
|
|
123
|
+
includeBaseline?: undefined;
|
|
124
|
+
id?: undefined;
|
|
125
|
+
path: {
|
|
126
|
+
type: string;
|
|
127
|
+
description: string;
|
|
128
|
+
};
|
|
129
|
+
ids: {
|
|
130
|
+
type: string;
|
|
131
|
+
items: {
|
|
132
|
+
type: string;
|
|
133
|
+
};
|
|
134
|
+
description: string;
|
|
135
|
+
};
|
|
136
|
+
paths: {
|
|
137
|
+
type: string;
|
|
138
|
+
items: {
|
|
139
|
+
type: string;
|
|
140
|
+
};
|
|
141
|
+
description: string;
|
|
142
|
+
};
|
|
143
|
+
url?: undefined;
|
|
144
|
+
skipDatabase?: undefined;
|
|
145
|
+
};
|
|
146
|
+
additionalProperties: boolean;
|
|
147
|
+
required?: undefined;
|
|
148
|
+
};
|
|
149
|
+
annotations: {
|
|
150
|
+
readOnlyHint: boolean;
|
|
151
|
+
idempotentHint: boolean;
|
|
152
|
+
openWorldHint: boolean;
|
|
153
|
+
};
|
|
154
|
+
} | {
|
|
155
|
+
name: string;
|
|
156
|
+
title: string;
|
|
157
|
+
description: string;
|
|
158
|
+
inputSchema: {
|
|
159
|
+
type: string;
|
|
160
|
+
properties: {
|
|
161
|
+
only?: undefined;
|
|
162
|
+
skip?: undefined;
|
|
163
|
+
offline?: undefined;
|
|
164
|
+
history?: undefined;
|
|
165
|
+
includeBaseline?: undefined;
|
|
166
|
+
id?: undefined;
|
|
167
|
+
ids?: undefined;
|
|
168
|
+
paths?: undefined;
|
|
169
|
+
path: {
|
|
59
170
|
type: string;
|
|
60
171
|
description: string;
|
|
61
172
|
};
|
|
@@ -77,13 +188,15 @@ export declare function mcpTools(): ({
|
|
|
77
188
|
inputSchema: {
|
|
78
189
|
type: string;
|
|
79
190
|
properties: {
|
|
80
|
-
path?: undefined;
|
|
81
191
|
only?: undefined;
|
|
82
192
|
skip?: undefined;
|
|
83
193
|
offline?: undefined;
|
|
84
|
-
domain?: undefined;
|
|
85
194
|
history?: undefined;
|
|
86
195
|
includeBaseline?: undefined;
|
|
196
|
+
id?: undefined;
|
|
197
|
+
ids?: undefined;
|
|
198
|
+
paths?: undefined;
|
|
199
|
+
path?: undefined;
|
|
87
200
|
url: {
|
|
88
201
|
type: string;
|
|
89
202
|
description: string;
|
|
@@ -109,13 +222,15 @@ export declare function mcpTools(): ({
|
|
|
109
222
|
required?: undefined;
|
|
110
223
|
type: string;
|
|
111
224
|
properties: {
|
|
112
|
-
path?: undefined;
|
|
113
225
|
only?: undefined;
|
|
114
226
|
skip?: undefined;
|
|
115
227
|
offline?: undefined;
|
|
116
|
-
domain?: undefined;
|
|
117
228
|
history?: undefined;
|
|
118
229
|
includeBaseline?: undefined;
|
|
230
|
+
id?: undefined;
|
|
231
|
+
ids?: undefined;
|
|
232
|
+
paths?: undefined;
|
|
233
|
+
path?: undefined;
|
|
119
234
|
url?: undefined;
|
|
120
235
|
skipDatabase?: undefined;
|
|
121
236
|
};
|
|
@@ -127,10 +242,10 @@ export declare function mcpTools(): ({
|
|
|
127
242
|
openWorldHint: boolean;
|
|
128
243
|
};
|
|
129
244
|
})[];
|
|
130
|
-
/**
|
|
131
|
-
export declare function
|
|
132
|
-
/**
|
|
133
|
-
export declare function
|
|
245
|
+
/** Text for the model: control characters removed, and cut at MAX_TEXT with a note. */
|
|
246
|
+
export declare function capText(text: string, max?: number): string;
|
|
247
|
+
/** A scan as a short summary (text) and data, with at most MAX_LISTED findings. */
|
|
248
|
+
export declare function scanResult(report: Report, includeBaseline?: boolean, extra?: string[]): ToolResult;
|
|
134
249
|
/** Run one tool. Unknown tool names are a protocol error; bad arguments are a tool error the model can fix. */
|
|
135
250
|
export declare function callTool(name: unknown, args: unknown, cwd?: string): Promise<ToolResult>;
|
|
136
251
|
/** Handle one parsed message (or a batch). Returns what to send back, or null for nothing. */
|