@mushi-mushi/cli 0.25.0 → 0.26.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/CONTRIBUTING.md +10 -2
- package/SECURITY.md +24 -1
- package/dist/{chunk-3JRQN6S4.js → chunk-2ZLYNNA3.js} +5 -5
- package/dist/chunk-6XYPFV23.js +10 -0
- package/dist/chunk-PCTMFRKN.js +8 -0
- package/dist/{chunk-2WHQONHK.js → chunk-QOY3DULB.js} +118 -2
- package/dist/{connect-22IHGT2L.js → connect-2LCLLN7R.js} +2 -1
- package/dist/{connect-XFWRSEMW.js → connect-PXLW4D64.js} +7 -106
- package/dist/index.js +3855 -3185
- package/dist/init.d.ts +2 -0
- package/dist/init.js +804 -12
- package/dist/snippet-inject-LPRWTQDE.js +83 -0
- package/dist/snippet-inject-NDAPEL2T.js +81 -0
- package/dist/version-5DCYWDRK.js +9 -0
- package/dist/version.d.ts +9 -1
- package/dist/version.js +5 -3
- package/dist/wizard-args.d.ts +45 -0
- package/dist/wizard-args.js +100 -0
- package/package.json +7 -1
- package/dist/chunk-SS42XQ57.js +0 -6
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/snippet-inject.ts
|
|
4
|
+
import { readFile, readdir } from "fs/promises";
|
|
5
|
+
import { join } from "path";
|
|
6
|
+
var MUSHI_MARKER_START = "// <mushi-mushi:init>";
|
|
7
|
+
var MUSHI_MARKER_END = "// </mushi-mushi:init>";
|
|
8
|
+
var ENTRY_CANDIDATES = {
|
|
9
|
+
vanilla: ["src/main.ts", "src/main.js", "src/index.ts", "src/index.js", "main.ts", "main.js", "index.js"]
|
|
10
|
+
};
|
|
11
|
+
function injectSnippet(source, snippet) {
|
|
12
|
+
const block = `${MUSHI_MARKER_START}
|
|
13
|
+
${snippet.trim()}
|
|
14
|
+
${MUSHI_MARKER_END}`;
|
|
15
|
+
const startIdx = source.indexOf(MUSHI_MARKER_START);
|
|
16
|
+
const endIdx = source.indexOf(MUSHI_MARKER_END);
|
|
17
|
+
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
|
|
18
|
+
return source.slice(0, startIdx) + block + source.slice(endIdx + MUSHI_MARKER_END.length);
|
|
19
|
+
}
|
|
20
|
+
const cleaned = source.split("\n").filter((l) => !l.includes(MUSHI_MARKER_START) && !l.includes(MUSHI_MARKER_END)).join("\n");
|
|
21
|
+
if (cleaned.startsWith("#!")) {
|
|
22
|
+
const nl = cleaned.indexOf("\n");
|
|
23
|
+
return `${cleaned.slice(0, nl + 1)}${block}
|
|
24
|
+
${cleaned.slice(nl + 1)}`;
|
|
25
|
+
}
|
|
26
|
+
return `${block}
|
|
27
|
+
|
|
28
|
+
${cleaned}`;
|
|
29
|
+
}
|
|
30
|
+
var SOURCE_DIRS = ["src", "app", "pages", "lib", "components"];
|
|
31
|
+
var SOURCE_EXTS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".vue", ".svelte"]);
|
|
32
|
+
var MAX_FILES_SCANNED = 2e3;
|
|
33
|
+
async function findSdkImport(cwd) {
|
|
34
|
+
let scanned = 0;
|
|
35
|
+
async function walk(dir, depth) {
|
|
36
|
+
if (depth > 6 || scanned >= MAX_FILES_SCANNED) return null;
|
|
37
|
+
let entries;
|
|
38
|
+
try {
|
|
39
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
for (const entry of entries) {
|
|
44
|
+
if (scanned >= MAX_FILES_SCANNED) return null;
|
|
45
|
+
if (entry.isDirectory()) {
|
|
46
|
+
if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
47
|
+
const hit = await walk(join(dir, entry.name), depth + 1);
|
|
48
|
+
if (hit) return hit;
|
|
49
|
+
} else if (SOURCE_EXTS.has(entry.name.slice(entry.name.lastIndexOf(".")))) {
|
|
50
|
+
scanned += 1;
|
|
51
|
+
try {
|
|
52
|
+
const content = await readFile(join(dir, entry.name), "utf8");
|
|
53
|
+
if (content.includes("@mushi-mushi/") || content.includes("MushiProvider")) {
|
|
54
|
+
return { file: join(dir, entry.name) };
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
for (const dirName of SOURCE_DIRS) {
|
|
63
|
+
const hit = await walk(join(cwd, dirName), 0);
|
|
64
|
+
if (hit) return hit;
|
|
65
|
+
}
|
|
66
|
+
for (const name of ["main.ts", "main.js", "index.js", "index.ts", "index.html"]) {
|
|
67
|
+
try {
|
|
68
|
+
const content = await readFile(join(cwd, name), "utf8");
|
|
69
|
+
if (content.includes("@mushi-mushi/") || content.includes("MushiProvider") || content.includes("mushi-mushi")) {
|
|
70
|
+
return { file: join(cwd, name) };
|
|
71
|
+
}
|
|
72
|
+
} catch {
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
ENTRY_CANDIDATES,
|
|
79
|
+
MUSHI_MARKER_END,
|
|
80
|
+
MUSHI_MARKER_START,
|
|
81
|
+
findSdkImport,
|
|
82
|
+
injectSnippet
|
|
83
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// src/snippet-inject.ts
|
|
2
|
+
import { readFile, readdir } from "fs/promises";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
var MUSHI_MARKER_START = "// <mushi-mushi:init>";
|
|
5
|
+
var MUSHI_MARKER_END = "// </mushi-mushi:init>";
|
|
6
|
+
var ENTRY_CANDIDATES = {
|
|
7
|
+
vanilla: ["src/main.ts", "src/main.js", "src/index.ts", "src/index.js", "main.ts", "main.js", "index.js"]
|
|
8
|
+
};
|
|
9
|
+
function injectSnippet(source, snippet) {
|
|
10
|
+
const block = `${MUSHI_MARKER_START}
|
|
11
|
+
${snippet.trim()}
|
|
12
|
+
${MUSHI_MARKER_END}`;
|
|
13
|
+
const startIdx = source.indexOf(MUSHI_MARKER_START);
|
|
14
|
+
const endIdx = source.indexOf(MUSHI_MARKER_END);
|
|
15
|
+
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
|
|
16
|
+
return source.slice(0, startIdx) + block + source.slice(endIdx + MUSHI_MARKER_END.length);
|
|
17
|
+
}
|
|
18
|
+
const cleaned = source.split("\n").filter((l) => !l.includes(MUSHI_MARKER_START) && !l.includes(MUSHI_MARKER_END)).join("\n");
|
|
19
|
+
if (cleaned.startsWith("#!")) {
|
|
20
|
+
const nl = cleaned.indexOf("\n");
|
|
21
|
+
return `${cleaned.slice(0, nl + 1)}${block}
|
|
22
|
+
${cleaned.slice(nl + 1)}`;
|
|
23
|
+
}
|
|
24
|
+
return `${block}
|
|
25
|
+
|
|
26
|
+
${cleaned}`;
|
|
27
|
+
}
|
|
28
|
+
var SOURCE_DIRS = ["src", "app", "pages", "lib", "components"];
|
|
29
|
+
var SOURCE_EXTS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".vue", ".svelte"]);
|
|
30
|
+
var MAX_FILES_SCANNED = 2e3;
|
|
31
|
+
async function findSdkImport(cwd) {
|
|
32
|
+
let scanned = 0;
|
|
33
|
+
async function walk(dir, depth) {
|
|
34
|
+
if (depth > 6 || scanned >= MAX_FILES_SCANNED) return null;
|
|
35
|
+
let entries;
|
|
36
|
+
try {
|
|
37
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
for (const entry of entries) {
|
|
42
|
+
if (scanned >= MAX_FILES_SCANNED) return null;
|
|
43
|
+
if (entry.isDirectory()) {
|
|
44
|
+
if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
45
|
+
const hit = await walk(join(dir, entry.name), depth + 1);
|
|
46
|
+
if (hit) return hit;
|
|
47
|
+
} else if (SOURCE_EXTS.has(entry.name.slice(entry.name.lastIndexOf(".")))) {
|
|
48
|
+
scanned += 1;
|
|
49
|
+
try {
|
|
50
|
+
const content = await readFile(join(dir, entry.name), "utf8");
|
|
51
|
+
if (content.includes("@mushi-mushi/") || content.includes("MushiProvider")) {
|
|
52
|
+
return { file: join(dir, entry.name) };
|
|
53
|
+
}
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
for (const dirName of SOURCE_DIRS) {
|
|
61
|
+
const hit = await walk(join(cwd, dirName), 0);
|
|
62
|
+
if (hit) return hit;
|
|
63
|
+
}
|
|
64
|
+
for (const name of ["main.ts", "main.js", "index.js", "index.ts", "index.html"]) {
|
|
65
|
+
try {
|
|
66
|
+
const content = await readFile(join(cwd, name), "utf8");
|
|
67
|
+
if (content.includes("@mushi-mushi/") || content.includes("MushiProvider") || content.includes("mushi-mushi")) {
|
|
68
|
+
return { file: join(cwd, name) };
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
ENTRY_CANDIDATES,
|
|
77
|
+
MUSHI_MARKER_END,
|
|
78
|
+
MUSHI_MARKER_START,
|
|
79
|
+
findSdkImport,
|
|
80
|
+
injectSnippet
|
|
81
|
+
};
|
package/dist/version.d.ts
CHANGED
|
@@ -7,5 +7,13 @@
|
|
|
7
7
|
* `tsc --noEmit` happy during development.
|
|
8
8
|
*/
|
|
9
9
|
declare const MUSHI_CLI_VERSION: string;
|
|
10
|
+
/**
|
|
11
|
+
* Pinned npm spec for the MCP server written into persistent IDE configs
|
|
12
|
+
* (mcp.json, Zed settings). Pinning avoids the supply-chain and cold-start
|
|
13
|
+
* costs of `@latest` on every editor launch; `mushi upgrade` / re-running
|
|
14
|
+
* setup refreshes the pin. Synced to packages/mcp/package.json by
|
|
15
|
+
* `scripts/sync-mcp-pin.mjs` — never hand-edit the version.
|
|
16
|
+
*/
|
|
17
|
+
declare const MUSHI_MCP_PIN_SPEC = "@mushi-mushi/mcp@0.19.0";
|
|
10
18
|
|
|
11
|
-
export { MUSHI_CLI_VERSION };
|
|
19
|
+
export { MUSHI_CLI_VERSION, MUSHI_MCP_PIN_SPEC };
|
package/dist/version.js
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { FrameworkId } from './detect.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* FILE: packages/cli/src/wizard-args.ts
|
|
5
|
+
* PURPOSE: Shared argument parsing, Node-version guard, and help text for the
|
|
6
|
+
* two thin entry-point shims (`mushi-mushi` launcher and
|
|
7
|
+
* `create-mushi-mushi`). Both bins forward the same flags to
|
|
8
|
+
* `runInit`, so the parsing and the flags help live here once. Each
|
|
9
|
+
* shim keeps only its own bin name, header, and usage lines.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Minimum Node major both shims require. Kept in sync with each package's `engines.node`. */
|
|
13
|
+
declare const MIN_NODE_MAJOR = 20;
|
|
14
|
+
interface ParsedArgs {
|
|
15
|
+
showHelp: boolean;
|
|
16
|
+
showVersion: boolean;
|
|
17
|
+
projectId?: string;
|
|
18
|
+
apiKey?: string;
|
|
19
|
+
framework?: FrameworkId;
|
|
20
|
+
skipInstall?: boolean;
|
|
21
|
+
skipTestReport?: boolean;
|
|
22
|
+
yes?: boolean;
|
|
23
|
+
cwd?: string;
|
|
24
|
+
endpoint?: string;
|
|
25
|
+
audit?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The flags block shared by both shims' help text. Ends with the Node
|
|
29
|
+
* requirement line and the docs footer. Each shim prepends its own
|
|
30
|
+
* bin-specific header and usage section.
|
|
31
|
+
*/
|
|
32
|
+
declare const FLAGS_HELP: string;
|
|
33
|
+
/**
|
|
34
|
+
* Parse the wizard flags. A leading `init` token is tolerated (so
|
|
35
|
+
* `npx mushi-mushi init --yes` works the same as `npx mushi-mushi --yes`).
|
|
36
|
+
*/
|
|
37
|
+
declare function parseArgs(argv: readonly string[]): ParsedArgs;
|
|
38
|
+
/**
|
|
39
|
+
* Exit with a friendly message if the running Node is older than
|
|
40
|
+
* {@link MIN_NODE_MAJOR}. `binName` is the invoking command (e.g. `mushi-mushi`
|
|
41
|
+
* or `create-mushi-mushi`) so the error reads naturally.
|
|
42
|
+
*/
|
|
43
|
+
declare function assertNodeVersion(binName: string): void;
|
|
44
|
+
|
|
45
|
+
export { FLAGS_HELP, MIN_NODE_MAJOR, type ParsedArgs, assertNodeVersion, parseArgs };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FRAMEWORK_IDS,
|
|
3
|
+
isFrameworkId
|
|
4
|
+
} from "./chunk-AIZRI665.js";
|
|
5
|
+
|
|
6
|
+
// src/wizard-args.ts
|
|
7
|
+
var MIN_NODE_MAJOR = 20;
|
|
8
|
+
var FLAGS_HELP = `Flags (forwarded to the wizard):
|
|
9
|
+
--project-id <uuid> skip the project ID prompt (UUID from the Projects page)
|
|
10
|
+
--api-key <key> skip the API key prompt (CI only \u2014 leaks into \`ps\`)
|
|
11
|
+
--framework <id> force a framework (${FRAMEWORK_IDS.join(", ")})
|
|
12
|
+
--skip-install print the install command instead of running it
|
|
13
|
+
--skip-test-report don't offer to send a test report at the end
|
|
14
|
+
--audit health-check an existing install (doctor checks) instead of re-running the wizard
|
|
15
|
+
--cwd <path> run in a different directory
|
|
16
|
+
--endpoint <url> override the Mushi API endpoint (self-hosted)
|
|
17
|
+
-y, --yes accept the detected framework without prompting
|
|
18
|
+
-v, --version print the version and exit
|
|
19
|
+
-h, --help show this help
|
|
20
|
+
|
|
21
|
+
Requires Node.js ${MIN_NODE_MAJOR} or newer.
|
|
22
|
+
|
|
23
|
+
Docs: https://github.com/kensaurus/mushi-mushi
|
|
24
|
+
Console: https://kensaur.us/mushi-mushi/`;
|
|
25
|
+
function parseArgs(argv) {
|
|
26
|
+
const args = argv[0] === "init" ? argv.slice(1) : argv;
|
|
27
|
+
const out = { showHelp: false, showVersion: false };
|
|
28
|
+
for (let i = 0; i < args.length; i++) {
|
|
29
|
+
const a = args[i];
|
|
30
|
+
if (a === "-h" || a === "--help") {
|
|
31
|
+
out.showHelp = true;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (a === "-v" || a === "--version") {
|
|
35
|
+
out.showVersion = true;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (a === "-y" || a === "--yes") {
|
|
39
|
+
out.yes = true;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (a === "--skip-install") {
|
|
43
|
+
out.skipInstall = true;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (a === "--skip-test-report") {
|
|
47
|
+
out.skipTestReport = true;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (a === "--audit") {
|
|
51
|
+
out.audit = true;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (a === "--project-id") {
|
|
55
|
+
out.projectId = args[++i];
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (a === "--api-key") {
|
|
59
|
+
out.apiKey = args[++i];
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (a === "--cwd") {
|
|
63
|
+
out.cwd = args[++i];
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (a === "--endpoint") {
|
|
67
|
+
out.endpoint = args[++i];
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (a === "--framework") {
|
|
71
|
+
const fw = args[++i];
|
|
72
|
+
if (!isFrameworkId(fw)) {
|
|
73
|
+
throw new Error(`Unknown framework: ${fw}. Valid: ${FRAMEWORK_IDS.join(", ")}`);
|
|
74
|
+
}
|
|
75
|
+
out.framework = fw;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (a.startsWith("-")) {
|
|
79
|
+
throw new Error(`Unknown flag: ${a}. Try --help.`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
function assertNodeVersion(binName) {
|
|
85
|
+
const major = Number(process.versions.node.split(".")[0]);
|
|
86
|
+
if (!Number.isFinite(major) || major < MIN_NODE_MAJOR) {
|
|
87
|
+
process.stderr.write(
|
|
88
|
+
`${binName} requires Node.js ${MIN_NODE_MAJOR} or newer. You are on ${process.versions.node}.
|
|
89
|
+
Upgrade Node (https://nodejs.org/) and try again.
|
|
90
|
+
`
|
|
91
|
+
);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
FLAGS_HELP,
|
|
97
|
+
MIN_NODE_MAJOR,
|
|
98
|
+
assertNodeVersion,
|
|
99
|
+
parseArgs
|
|
100
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mushi-mushi/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "CLI for Mushi Mushi — `mushi init` wizard installs the right SDK for your framework, plus report triage and pipeline health commands",
|
|
6
6
|
"bin": {
|
|
@@ -91,6 +91,12 @@
|
|
|
91
91
|
"default": "./dist/detect.js"
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
|
+
"./wizard-args": {
|
|
95
|
+
"import": {
|
|
96
|
+
"types": "./dist/wizard-args.d.ts",
|
|
97
|
+
"default": "./dist/wizard-args.js"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
94
100
|
"./version": {
|
|
95
101
|
"import": {
|
|
96
102
|
"types": "./dist/version.d.ts",
|