create-mushin 0.2.2 → 0.3.0-next.20261122141505

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Mushin.js
3
+ Copyright (c) 2026 Setobox
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ // A published install runs the compiled dist/. Inside the repository the TypeScript sources run through tsx.
3
+ import { existsSync } from 'node:fs'
4
+
5
+ const source = new URL('../src/cli.ts', import.meta.url)
6
+ if (existsSync(source)) {
7
+ const { register } = await import('tsx/esm/api')
8
+ register()
9
+ await import(source.href)
10
+ } else {
11
+ await import('../dist/cli.js')
12
+ }
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {}
package/dist/cli.js ADDED
@@ -0,0 +1,60 @@
1
+ import { VERSION, addSkills, createApp, detectPackageManager, install } from "./index.js";
2
+ import { relative } from "node:path";
3
+ import { parseArgs } from "node:util";
4
+ // src/cli.ts
5
+ const usage = `Usage: npm create mushin@latest [folder] [-- options]
6
+
7
+ Creates a Mushin.js app in a new folder (default: my-bot) and installs it.
8
+
9
+ Options:
10
+ --pm <npm|pnpm> Package manager to install with (default: the one that ran this)
11
+ --no-install Only write the files
12
+ -h, --help Show this help`;
13
+ const { values, positionals } = parseArgs({
14
+ allowPositionals: true,
15
+ options: {
16
+ pm: { type: "string" },
17
+ "no-install": { type: "boolean" },
18
+ help: {
19
+ type: "boolean",
20
+ short: "h"
21
+ }
22
+ }
23
+ });
24
+ if (values.help) {
25
+ console.log(usage);
26
+ process.exit(0);
27
+ }
28
+ const pm = values.pm ?? detectPackageManager();
29
+ if (pm !== "npm" && pm !== "pnpm") {
30
+ console.error(`--pm must be npm or pnpm, not ${pm}`);
31
+ process.exit(1);
32
+ }
33
+ const folder = positionals[0] ?? "my-bot";
34
+ try {
35
+ console.log(`Creating a Mushin.js ${VERSION} app in ${folder}`);
36
+ const { dir } = await createApp(folder, { packageManager: pm });
37
+ if (!values["no-install"]) {
38
+ console.log(`Installing with ${pm}…`);
39
+ await install(dir, pm);
40
+ await addSkills(dir);
41
+ }
42
+ const cd = relative(process.cwd(), dir) || ".";
43
+ const run = pm === "npm" ? "npm" : "pnpm";
44
+ console.log([
45
+ "",
46
+ "Done. Next:",
47
+ ...cd === "." ? [] : [` cd ${cd.includes(" ") ? JSON.stringify(cd) : cd}`],
48
+ ...values["no-install"] ? [` ${run} install`] : [],
49
+ ` ${run} start`,
50
+ "",
51
+ "Open the sign-in link it prints, then follow Quick setup in the dashboard.",
52
+ "AGENTS.md explains the folder to you and to your AI."
53
+ ].join("\n"));
54
+ } catch (error) {
55
+ console.error(error.message);
56
+ process.exit(1);
57
+ }
58
+ export {};
59
+
60
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["import { relative } from 'node:path'\nimport { parseArgs } from 'node:util'\nimport { addSkills, createApp, detectPackageManager, install, type PackageManager, VERSION } from './index'\n\nconst usage = `Usage: npm create mushin@latest [folder] [-- options]\n\nCreates a Mushin.js app in a new folder (default: my-bot) and installs it.\n\nOptions:\n --pm <npm|pnpm> Package manager to install with (default: the one that ran this)\n --no-install Only write the files\n -h, --help Show this help`\n\nconst { values, positionals } = parseArgs({\n allowPositionals: true,\n options: {\n pm: { type: 'string' },\n 'no-install': { type: 'boolean' },\n help: { type: 'boolean', short: 'h' },\n },\n})\n\nif (values.help) {\n console.log(usage)\n process.exit(0)\n}\n\nconst pm = (values.pm ?? detectPackageManager()) as PackageManager\nif (pm !== 'npm' && pm !== 'pnpm') {\n console.error(`--pm must be npm or pnpm, not ${pm}`)\n process.exit(1)\n}\n\nconst folder = positionals[0] ?? 'my-bot'\ntry {\n console.log(`Creating a Mushin.js ${VERSION} app in ${folder}`)\n const { dir } = await createApp(folder, { packageManager: pm })\n if (!values['no-install']) {\n console.log(`Installing with ${pm}…`)\n await install(dir, pm)\n await addSkills(dir)\n }\n const cd = relative(process.cwd(), dir) || '.'\n const run = pm === 'npm' ? 'npm' : 'pnpm'\n console.log([\n '',\n 'Done. Next:',\n ...(cd === '.' ? [] : [` cd ${cd.includes(' ') ? JSON.stringify(cd) : cd}`]),\n ...(values['no-install'] ? [` ${run} install`] : []),\n ` ${run} start`,\n '',\n 'Open the sign-in link it prints, then follow Quick setup in the dashboard.',\n 'AGENTS.md explains the folder to you and to your AI.',\n ].join('\\n'))\n} catch (error) {\n console.error((error as Error).message)\n process.exit(1)\n}\n"],"mappings":";;;;AAIA,MAAM,QAAQ;;;;;;;;AASd,MAAM,EAAE,QAAQ,gBAAgB,UAAU;CACxC,kBAAkB;CAClB,SAAS;EACP,IAAI,EAAE,MAAM,SAAS;EACrB,cAAc,EAAE,MAAM,UAAU;EAChC,MAAM;GAAE,MAAM;GAAW,OAAO;EAAI;CACtC;AACF,CAAC;AAED,IAAI,OAAO,MAAM;CACf,QAAQ,IAAI,KAAK;CACjB,QAAQ,KAAK,CAAC;AAChB;AAEA,MAAM,KAAM,OAAO,MAAM,qBAAqB;AAC9C,IAAI,OAAO,SAAS,OAAO,QAAQ;CACjC,QAAQ,MAAM,iCAAiC,IAAI;CACnD,QAAQ,KAAK,CAAC;AAChB;AAEA,MAAM,SAAS,YAAY,MAAM;AACjC,IAAI;CACF,QAAQ,IAAI,wBAAwB,QAAQ,UAAU,QAAQ;CAC9D,MAAM,EAAE,QAAQ,MAAM,UAAU,QAAQ,EAAE,gBAAgB,GAAG,CAAC;CAC9D,IAAI,CAAC,OAAO,eAAe;EACzB,QAAQ,IAAI,mBAAmB,GAAG,EAAE;EACpC,MAAM,QAAQ,KAAK,EAAE;EACrB,MAAM,UAAU,GAAG;CACrB;CACA,MAAM,KAAK,SAAS,QAAQ,IAAI,GAAG,GAAG,KAAK;CAC3C,MAAM,MAAM,OAAO,QAAQ,QAAQ;CACnC,QAAQ,IAAI;EACV;EACA;EACA,GAAI,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,GAAG,SAAS,GAAG,IAAI,KAAK,UAAU,EAAE,IAAI,IAAI;EAC3E,GAAI,OAAO,gBAAgB,CAAC,KAAK,IAAI,SAAS,IAAI,CAAC;EACnD,KAAK,IAAI;EACT;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI,CAAC;AACd,SAAS,OAAO;CACd,QAAQ,MAAO,MAAgB,OAAO;CACtC,QAAQ,KAAK,CAAC;AAChB"}
@@ -0,0 +1,23 @@
1
+ /** The version of this package, which every `@mushinjs/*` package shares. */
2
+ export declare const VERSION: string;
3
+ export type PackageManager = 'npm' | 'pnpm';
4
+ /** The package manager that ran `npm create` / `pnpm create`, from the user agent it sets. */
5
+ export declare function detectPackageManager(userAgent?: string): PackageManager;
6
+ /** The version range the app depends on: a preview is pinned exactly, a release takes compatible updates. */
7
+ export declare function dependencyRange(version?: string): string;
8
+ /** A package name made from a folder name: `My Bot` gives `my-bot`. */
9
+ export declare function packageName(dir: string): string;
10
+ /** The files of a new app, by path relative to its folder. */
11
+ export declare function appFiles(name: string, version?: string, packageManager?: PackageManager): Record<string, string>;
12
+ /** Writes a new app into `dir`, which must be missing or empty. */
13
+ export declare function createApp(dir: string, options?: {
14
+ version?: string;
15
+ packageManager?: PackageManager;
16
+ }): Promise<{
17
+ dir: string;
18
+ files: string[];
19
+ }>;
20
+ /** Puts the official skills into the app, with the CLI that was just installed. */
21
+ export declare function addSkills(dir: string): Promise<void>;
22
+ /** Runs the package manager's install in the app folder, with its output shown. */
23
+ export declare function install(dir: string, packageManager: PackageManager): Promise<void>;
package/dist/index.js CHANGED
@@ -1,88 +1,184 @@
1
+ import { spawn } from "node:child_process";
2
+ import { readFileSync } from "node:fs";
3
+ import { mkdir, readdir, writeFile } from "node:fs/promises";
4
+ import { basename, join, resolve } from "node:path";
1
5
  // src/index.ts
2
- import { exec } from "node:child_process";
3
- import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
4
- import { join, resolve } from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import prompts from "prompts";
7
- async function getName() {
8
- const { name } = await prompts({
9
- type: "text",
10
- name: "name",
11
- message: "What is your project name?",
12
- initial: "mushin-app"
13
- });
14
- if (!name) {
15
- console.error("Please provide a project name.");
16
- process.exit(1);
17
- }
18
- return name.trim();
6
+ /** The version of this package, which every `@mushinjs/*` package shares. */
7
+ const VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
8
+ /** The package manager that ran `npm create` / `pnpm create`, from the user agent it sets. */
9
+ function detectPackageManager(userAgent = process.env.npm_config_user_agent ?? "") {
10
+ return userAgent.startsWith("pnpm") ? "pnpm" : "npm";
19
11
  }
20
- async function init() {
21
- const cwd = process.cwd();
22
- const name = await getName();
23
- const projectDir = resolve(cwd, name);
24
- let exist = false;
25
- await mkdir(projectDir, {}).catch((error) => {
26
- if (error.code === "EEXIST") {
27
- exist = true;
28
- }
29
- });
30
- if (exist) {
31
- const { overwrite } = await prompts({
32
- type: "confirm",
33
- name: "overwrite",
34
- message: "The project directory is not empty. Do you want to overwrite it?",
35
- initial: false
36
- });
37
- if (!overwrite) {
38
- process.exit(0);
39
- }
40
- }
41
- const __dirname = fileURLToPath(import.meta.url);
42
- const templateDir = resolve(__dirname, "../../template-mushin");
43
- const files = await readdir(templateDir);
44
- for (const file of files) {
45
- const filePath = join(templateDir, file);
46
- const fileStat = await stat(filePath);
47
- if (fileStat.isFile()) {
48
- const content = await readFile(filePath, "utf-8");
49
- const targetFilePath = join(projectDir, file);
50
- await writeFile(targetFilePath, content);
51
- }
52
- }
53
- const { install } = await prompts({
54
- type: "confirm",
55
- name: "install",
56
- message: 'Do you want to run "pnpm install" now?',
57
- initial: true
58
- });
59
- if (install) {
60
- console.log("Installing dependencies...");
61
- exec("pnpm install", { cwd: projectDir }, async (error) => {
62
- if (error) {
63
- console.error("Failed to install dependencies.");
64
- process.exit(1);
65
- }
66
- console.log("Dependencies installed successfully.");
67
- const { start } = await prompts({
68
- type: "confirm",
69
- name: "start",
70
- message: 'Do you want to run "pnpm start" now?',
71
- initial: true
72
- });
73
- if (start) {
74
- console.log("Starting the application...");
75
- exec("pnpm start", { cwd: projectDir }, (error2) => {
76
- if (error2) {
77
- console.error("Failed to start the application.");
78
- process.exit(1);
79
- }
80
- });
81
- }
82
- });
83
- }
12
+ /** The version range the app depends on: a preview is pinned exactly, a release takes compatible updates. */
13
+ function dependencyRange(version = VERSION) {
14
+ return version.includes("-") ? version : `^${version}`;
84
15
  }
85
- init().catch((error) => {
86
- console.error(error);
87
- process.exit(1);
88
- });
16
+ /** A package name made from a folder name: `My Bot` gives `my-bot`. */
17
+ function packageName(dir) {
18
+ return basename(resolve(dir)).toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+|-+$/g, "") || "mushin-app";
19
+ }
20
+ /** The files of a new app, by path relative to its folder. */
21
+ function appFiles(name, version = VERSION, packageManager = "npm") {
22
+ const range = dependencyRange(version);
23
+ const json = (value) => JSON.stringify(value, null, 2) + "\n";
24
+ return {
25
+ "package.json": json({
26
+ name,
27
+ private: true,
28
+ type: "module",
29
+ scripts: {
30
+ start: "mushin start",
31
+ upgrade: "mushin upgrade",
32
+ typecheck: "tsc"
33
+ },
34
+ dependencies: {
35
+ "@mushinjs/cli": range,
36
+ "@mushinjs/core": range
37
+ },
38
+ devDependencies: {
39
+ "@types/node": "^22.13.0",
40
+ typescript: "^6.0.3"
41
+ },
42
+ engines: { node: ">=22.13" }
43
+ }),
44
+ "tsconfig.json": json({
45
+ compilerOptions: {
46
+ target: "es2023",
47
+ lib: ["es2023"],
48
+ module: "preserve",
49
+ moduleResolution: "bundler",
50
+ types: ["node"],
51
+ strict: true,
52
+ noEmit: true,
53
+ skipLibCheck: true,
54
+ isolatedModules: true,
55
+ verbatimModuleSyntax: true
56
+ },
57
+ include: ["plugins/*/src"]
58
+ }),
59
+ ".gitignore": [
60
+ "node_modules/",
61
+ "# Secrets: keys, tokens. Never commit or share this file.",
62
+ ".env",
63
+ "# Written by Mushin.js. Back up data/; cache/ and logs/ can be deleted.",
64
+ "data/",
65
+ "cache/",
66
+ "logs/",
67
+ ""
68
+ ].join("\n"),
69
+ "AGENTS.md": agentsGuide(name),
70
+ ".mcp.json": json({ mcpServers: { mushin: {
71
+ type: "stdio",
72
+ command: "node",
73
+ args: ["node_modules/@mushinjs/cli/bin/mushin.js", "mcp"]
74
+ } } }),
75
+ "plugins/.gitkeep": "",
76
+ "skills/.gitkeep": "",
77
+ ...packageManager === "pnpm" ? { "pnpm-workspace.yaml": PNPM_SETTINGS } : {}
78
+ };
79
+ }
80
+ /**
81
+ * pnpm runs no install scripts it was not told about, and stops the install over them. esbuild (through tsx,
82
+ * for TypeScript plugins) needs its script; ssh2 (the terminal plugin) works without its optional native parts.
83
+ */
84
+ const PNPM_SETTINGS = `allowBuilds:
85
+ esbuild: true
86
+ cpu-features: false
87
+ ssh2: false
88
+ `;
89
+ function agentsGuide(name) {
90
+ return `# ${name}
91
+
92
+ This folder is a [Mushin.js](https://github.com/mushinjs/mushin) app: a chatbot framework for QQ (through OneBot / NapCat) with LLM chat, conversation flows and an Agent. Read this before changing anything here.
93
+
94
+ ## Commands
95
+
96
+ - \`npm start\` starts Mushin.js and prints the dashboard sign-in link (\`pnpm start\` with pnpm).
97
+ - \`npm run upgrade\` updates every \`@mushinjs/*\` package and moves the data to the new version's layout. Stop Mushin.js first.
98
+ - \`npx mushin new plugin <name>\` creates a TypeScript plugin in \`plugins/<name>/\` and turns it on.
99
+ - \`npm run typecheck\` checks the plugins in \`plugins/\`.
100
+ - \`npx mushin token reset\` makes a new admin token for the dashboard.
101
+
102
+ ## Managing Mushin.js from an AI tool
103
+
104
+ \`.mcp.json\` connects the AI tool you open in this folder (Claude Code and others that read it) to the running Mushin.js through \`mushin mcp\`. Start Mushin.js first. The tools are Mushin.js actions: list bots, read logs, build and test flows, and more. Dangerous ones wait for approval in the dashboard. The admin token is read from \`.env\`; do not copy it anywhere.
105
+
106
+ ## Skills
107
+
108
+ \`.claude/skills/\` holds the official skills. Read the matching \`SKILL.md\` before you start one of these jobs, whichever AI tool you are:
109
+
110
+ - \`mushin-plugin-dev\`: writing or changing a plugin in \`plugins/\`. It starts with the questions to ask the user first.
111
+ - \`mushin-flows\`: building and testing conversation flows.
112
+ - \`mushin-troubleshoot\`: finding out why a bot, command, flow or plugin does not work.
113
+ - \`mushin-operations\`: upgrades, backups, restores, moving machines, the admin token.
114
+
115
+ \`npm run upgrade\` replaces them with the new version's; put your own skills in other folders.
116
+
117
+ ## Layout
118
+
119
+ | Path | What it is | Who writes it |
120
+ | --- | --- | --- |
121
+ | \`mushin.config.json\` | Which plugins run, and their settings. Holds no secrets. | People, the dashboard, the Agent |
122
+ | \`.mcp.json\` | Connects the AI tool opened here to Mushin.js. Holds no secrets. | create-mushin |
123
+ | \`.claude/skills/\` | The official skills for AI tools | Mushin.js (on create and upgrade) |
124
+ | \`.env\` | Secrets: the admin token, provider keys, bot tokens. Configuration refers to them as \`\${NAME}\`. | Mushin.js and people |
125
+ | \`plugins/\` | Local plugins, run as TypeScript without a build step | People and AIs |
126
+ | \`skills/\` | Your own skills, one folder each with a \`SKILL.md\` | People and AIs |
127
+ | \`data/\` | Everything Mushin.js keeps: database, bots, providers, flows, message logs. Back up this folder. | Mushin.js only |
128
+ | \`cache/\`, \`logs/\` | Safe to delete | Mushin.js only |
129
+
130
+ ## Rules
131
+
132
+ - Do not edit files under \`data/\` by hand while Mushin.js runs. Change things through the dashboard or its actions.
133
+ - Never print, commit or copy the contents of \`.env\`. To use a secret in a setting, write \`\${NAME}\` and put \`NAME=value\` in \`.env\`.
134
+ - A plugin is a package in \`plugins/<name>/\` with a \`mushin\` field in its \`package.json\`. It exports \`name\`, optionally \`inject\` and \`Config\` (a zod schema), and \`apply(ctx, config)\`. Import everything from \`@mushinjs/core\`.
135
+ - After changing a plugin, reload it from the dashboard's Plugins page or restart Mushin.js.
136
+ `;
137
+ }
138
+ /** Writes a new app into `dir`, which must be missing or empty. */
139
+ async function createApp(dir, options = {}) {
140
+ const target = resolve(dir);
141
+ if ((await readdir(target).catch(() => [])).length) throw new Error(`${target} is not empty. Choose a new folder name.`);
142
+ const files = appFiles(packageName(target), options.version, options.packageManager);
143
+ for (const [path, content] of Object.entries(files)) {
144
+ const file = join(target, path);
145
+ await mkdir(join(file, ".."), { recursive: true });
146
+ await writeFile(file, content);
147
+ }
148
+ return {
149
+ dir: target,
150
+ files: Object.keys(files)
151
+ };
152
+ }
153
+ /** Puts the official skills into the app, with the CLI that was just installed. */
154
+ function addSkills(dir) {
155
+ return new Promise((done, reject) => {
156
+ const bin = join(dir, "node_modules", "@mushinjs", "cli", "bin", "mushin.js");
157
+ const child = spawn(process.execPath, [
158
+ bin,
159
+ "skills",
160
+ "--dir",
161
+ dir
162
+ ], {
163
+ cwd: dir,
164
+ stdio: "inherit"
165
+ });
166
+ child.on("error", reject);
167
+ child.on("exit", (code) => code ? reject(/* @__PURE__ */ new Error(`mushin skills exited with ${code}`)) : done());
168
+ });
169
+ }
170
+ /** Runs the package manager's install in the app folder, with its output shown. */
171
+ function install(dir, packageManager) {
172
+ return new Promise((done, reject) => {
173
+ const child = spawn(packageManager, ["install"], {
174
+ cwd: dir,
175
+ stdio: "inherit",
176
+ shell: process.platform === "win32"
177
+ });
178
+ child.on("error", reject);
179
+ child.on("exit", (code) => code ? reject(/* @__PURE__ */ new Error(`${packageManager} install exited with ${code}`)) : done());
180
+ });
181
+ }
182
+ export { VERSION, addSkills, appFiles, createApp, dependencyRange, detectPackageManager, install, packageName };
183
+
184
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\nimport { readFileSync } from 'node:fs'\nimport { mkdir, readdir, writeFile } from 'node:fs/promises'\nimport { basename, join, resolve } from 'node:path'\n\n/** The version of this package, which every `@mushinjs/*` package shares. */\nexport const VERSION: string = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version\n\nexport type PackageManager = 'npm' | 'pnpm'\n\n/** The package manager that ran `npm create` / `pnpm create`, from the user agent it sets. */\nexport function detectPackageManager(userAgent = process.env.npm_config_user_agent ?? ''): PackageManager {\n return userAgent.startsWith('pnpm') ? 'pnpm' : 'npm'\n}\n\n/** The version range the app depends on: a preview is pinned exactly, a release takes compatible updates. */\nexport function dependencyRange(version = VERSION) {\n return version.includes('-') ? version : `^${version}`\n}\n\n/** A package name made from a folder name: `My Bot` gives `my-bot`. */\nexport function packageName(dir: string) {\n const name = basename(resolve(dir)).toLowerCase().replace(/[^a-z0-9._-]+/g, '-').replace(/^[._-]+|-+$/g, '')\n return name || 'mushin-app'\n}\n\n/** The files of a new app, by path relative to its folder. */\nexport function appFiles(name: string, version = VERSION, packageManager: PackageManager = 'npm'): Record<string, string> {\n const range = dependencyRange(version)\n const json = (value: unknown) => JSON.stringify(value, null, 2) + '\\n'\n return {\n 'package.json': json({\n name,\n private: true,\n type: 'module',\n scripts: {\n start: 'mushin start',\n upgrade: 'mushin upgrade',\n typecheck: 'tsc',\n },\n dependencies: {\n '@mushinjs/cli': range,\n // Local plugins in plugins/ import it; with pnpm they only see the app's own dependencies.\n '@mushinjs/core': range,\n },\n devDependencies: {\n '@types/node': '^22.13.0',\n typescript: '^6.0.3',\n },\n engines: { node: '>=22.13' },\n }),\n 'tsconfig.json': json({\n compilerOptions: {\n target: 'es2023',\n lib: ['es2023'],\n module: 'preserve',\n moduleResolution: 'bundler',\n types: ['node'],\n strict: true,\n noEmit: true,\n skipLibCheck: true,\n isolatedModules: true,\n verbatimModuleSyntax: true,\n },\n include: ['plugins/*/src'],\n }),\n '.gitignore': [\n 'node_modules/',\n '# Secrets: keys, tokens. Never commit or share this file.',\n '.env',\n '# Written by Mushin.js. Back up data/; cache/ and logs/ can be deleted.',\n 'data/',\n 'cache/',\n 'logs/',\n '',\n ].join('\\n'),\n 'AGENTS.md': agentsGuide(name),\n // Connects the AI tool opened in this folder to the running Mushin.js; the token stays in .env.\n '.mcp.json': json({\n mcpServers: {\n mushin: { type: 'stdio', command: 'node', args: ['node_modules/@mushinjs/cli/bin/mushin.js', 'mcp'] },\n },\n }),\n 'plugins/.gitkeep': '',\n 'skills/.gitkeep': '',\n ...(packageManager === 'pnpm' ? { 'pnpm-workspace.yaml': PNPM_SETTINGS } : {}),\n }\n}\n\n/**\n * pnpm runs no install scripts it was not told about, and stops the install over them. esbuild (through tsx,\n * for TypeScript plugins) needs its script; ssh2 (the terminal plugin) works without its optional native parts.\n */\nconst PNPM_SETTINGS = `allowBuilds:\n esbuild: true\n cpu-features: false\n ssh2: false\n`\n\nfunction agentsGuide(name: string) {\n return `# ${name}\n\nThis folder is a [Mushin.js](https://github.com/mushinjs/mushin) app: a chatbot framework for QQ (through OneBot / NapCat) with LLM chat, conversation flows and an Agent. Read this before changing anything here.\n\n## Commands\n\n- \\`npm start\\` starts Mushin.js and prints the dashboard sign-in link (\\`pnpm start\\` with pnpm).\n- \\`npm run upgrade\\` updates every \\`@mushinjs/*\\` package and moves the data to the new version's layout. Stop Mushin.js first.\n- \\`npx mushin new plugin <name>\\` creates a TypeScript plugin in \\`plugins/<name>/\\` and turns it on.\n- \\`npm run typecheck\\` checks the plugins in \\`plugins/\\`.\n- \\`npx mushin token reset\\` makes a new admin token for the dashboard.\n\n## Managing Mushin.js from an AI tool\n\n\\`.mcp.json\\` connects the AI tool you open in this folder (Claude Code and others that read it) to the running Mushin.js through \\`mushin mcp\\`. Start Mushin.js first. The tools are Mushin.js actions: list bots, read logs, build and test flows, and more. Dangerous ones wait for approval in the dashboard. The admin token is read from \\`.env\\`; do not copy it anywhere.\n\n## Skills\n\n\\`.claude/skills/\\` holds the official skills. Read the matching \\`SKILL.md\\` before you start one of these jobs, whichever AI tool you are:\n\n- \\`mushin-plugin-dev\\`: writing or changing a plugin in \\`plugins/\\`. It starts with the questions to ask the user first.\n- \\`mushin-flows\\`: building and testing conversation flows.\n- \\`mushin-troubleshoot\\`: finding out why a bot, command, flow or plugin does not work.\n- \\`mushin-operations\\`: upgrades, backups, restores, moving machines, the admin token.\n\n\\`npm run upgrade\\` replaces them with the new version's; put your own skills in other folders.\n\n## Layout\n\n| Path | What it is | Who writes it |\n| --- | --- | --- |\n| \\`mushin.config.json\\` | Which plugins run, and their settings. Holds no secrets. | People, the dashboard, the Agent |\n| \\`.mcp.json\\` | Connects the AI tool opened here to Mushin.js. Holds no secrets. | create-mushin |\n| \\`.claude/skills/\\` | The official skills for AI tools | Mushin.js (on create and upgrade) |\n| \\`.env\\` | Secrets: the admin token, provider keys, bot tokens. Configuration refers to them as \\`\\${NAME}\\`. | Mushin.js and people |\n| \\`plugins/\\` | Local plugins, run as TypeScript without a build step | People and AIs |\n| \\`skills/\\` | Your own skills, one folder each with a \\`SKILL.md\\` | People and AIs |\n| \\`data/\\` | Everything Mushin.js keeps: database, bots, providers, flows, message logs. Back up this folder. | Mushin.js only |\n| \\`cache/\\`, \\`logs/\\` | Safe to delete | Mushin.js only |\n\n## Rules\n\n- Do not edit files under \\`data/\\` by hand while Mushin.js runs. Change things through the dashboard or its actions.\n- Never print, commit or copy the contents of \\`.env\\`. To use a secret in a setting, write \\`\\${NAME}\\` and put \\`NAME=value\\` in \\`.env\\`.\n- A plugin is a package in \\`plugins/<name>/\\` with a \\`mushin\\` field in its \\`package.json\\`. It exports \\`name\\`, optionally \\`inject\\` and \\`Config\\` (a zod schema), and \\`apply(ctx, config)\\`. Import everything from \\`@mushinjs/core\\`.\n- After changing a plugin, reload it from the dashboard's Plugins page or restart Mushin.js.\n`\n}\n\n/** Writes a new app into `dir`, which must be missing or empty. */\nexport async function createApp(dir: string, options: { version?: string; packageManager?: PackageManager } = {}) {\n const target = resolve(dir)\n const existing = await readdir(target).catch(() => [] as string[])\n if (existing.length) throw new Error(`${target} is not empty. Choose a new folder name.`)\n const files = appFiles(packageName(target), options.version, options.packageManager)\n for (const [path, content] of Object.entries(files)) {\n const file = join(target, path)\n await mkdir(join(file, '..'), { recursive: true })\n await writeFile(file, content)\n }\n return { dir: target, files: Object.keys(files) }\n}\n\n/** Puts the official skills into the app, with the CLI that was just installed. */\nexport function addSkills(dir: string) {\n return new Promise<void>((done, reject) => {\n const bin = join(dir, 'node_modules', '@mushinjs', 'cli', 'bin', 'mushin.js')\n const child = spawn(process.execPath, [bin, 'skills', '--dir', dir], { cwd: dir, stdio: 'inherit' })\n child.on('error', reject)\n child.on('exit', (code) => (code ? reject(new Error(`mushin skills exited with ${code}`)) : done()))\n })\n}\n\n/** Runs the package manager's install in the app folder, with its output shown. */\nexport function install(dir: string, packageManager: PackageManager) {\n return new Promise<void>((done, reject) => {\n // npm and pnpm are .cmd files on Windows, which only start through a shell.\n const child = spawn(packageManager, ['install'], { cwd: dir, stdio: 'inherit', shell: process.platform === 'win32' })\n child.on('error', reject)\n child.on('exit', (code) => (code ? reject(new Error(`${packageManager} install exited with ${code}`)) : done()))\n })\n}\n"],"mappings":";;;;;;AAMA,MAAa,UAAkB,KAAK,MAAM,aAAa,IAAI,IAAI,mBAAmB,YAAY,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC;;AAK7G,SAAgB,qBAAqB,YAAY,QAAQ,IAAI,yBAAyB,IAAoB;CACxG,OAAO,UAAU,WAAW,MAAM,IAAI,SAAS;AACjD;;AAGA,SAAg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GAAG,SAAS,SAAU,OAAO,uBAAO,IAAI,MAAM,GAAG,eAAe,uBAAuB,MAAM,CAAC,IAAI,KAAK,CAAE;CACjH,CAAC;AACH"}
package/package.json CHANGED
@@ -1,29 +1,32 @@
1
1
  {
2
2
  "name": "create-mushin",
3
+ "version": "0.3.0-next.20261122141505",
4
+ "description": "Create a Mushin.js app: npm create mushin@latest my-bot",
3
5
  "type": "module",
4
- "version": "0.2.2",
5
- "author": "Setobox",
6
6
  "license": "MIT",
7
- "module": "dist/index.js",
8
- "bin": "dist/index.js",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/mushinjs/mushin.git",
10
+ "directory": "packages/create-mushin"
11
+ },
12
+ "bin": {
13
+ "create-mushin": "./bin/create-mushin.js"
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
9
22
  "files": [
10
- "template-mushin",
23
+ "bin",
11
24
  "dist"
12
25
  ],
13
- "engines": {
14
- "node": ">=16.0.0"
26
+ "publishConfig": {
27
+ "access": "public"
15
28
  },
16
- "scripts": {
17
- "build": "tsup src/index.ts --format esm --clean",
18
- "prepublish": "pnpm build"
19
- },
20
- "dependencies": {
21
- "prompts": "^2.4.2"
22
- },
23
- "devDependencies": {
24
- "@types/node": "^18.15.0",
25
- "@types/prompts": "^2.4.3",
26
- "tsup": "^6.6.3",
27
- "typescript": "^4.9.5"
29
+ "engines": {
30
+ "node": ">=22.13"
28
31
  }
29
- }
32
+ }
package/README.md DELETED
@@ -1 +0,0 @@
1
- # create-mushin
@@ -1,5 +0,0 @@
1
- import { defineConfig } from 'mushin'
2
-
3
- defineConfig({
4
- port: 8180,
5
- })
@@ -1,10 +0,0 @@
1
- {
2
- "name": "mushin-app",
3
- "private": true,
4
- "scripts": {
5
- "start": "mushin start"
6
- },
7
- "devDependencies": {
8
- "mushin": "~0.1.0"
9
- }
10
- }
@@ -1,2 +0,0 @@
1
- packages:
2
- - plugins
@@ -1,101 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
-
5
- /* Projects */
6
- // "incremental": true, /* Enable incremental compilation */
7
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
- // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
9
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
10
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
-
13
- /* Language and Environment */
14
- "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
- // "jsx": "preserve", /* Specify what JSX code is generated. */
17
- // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
20
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
22
- // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
23
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
-
26
- /* Modules */
27
- "module": "ESNext" /* Specify what module code is generated. */,
28
- // "rootDir": "./", /* Specify the root folder within your source files. */
29
- "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
30
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
31
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
32
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
33
- // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
34
- // "types": [], /* Specify type package names to be included without being referenced in a source file. */
35
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
36
- // "resolveJsonModule": true, /* Enable importing .json files */
37
- // "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
38
-
39
- /* JavaScript Support */
40
- // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
41
- // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
42
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
43
-
44
- /* Emit */
45
- // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
46
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
47
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
48
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
49
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
50
- // "outDir": "./", /* Specify an output folder for all emitted files. */
51
- // "removeComments": true, /* Disable emitting comments. */
52
- // "noEmit": true, /* Disable emitting files from a compilation. */
53
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
54
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
55
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
56
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
57
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
58
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
59
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
60
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
61
- // "newLine": "crlf", /* Set the newline character for emitting files. */
62
- // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
63
- // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
64
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
65
- // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
66
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
67
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
68
-
69
- /* Interop Constraints */
70
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
71
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
72
- "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
73
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
74
- "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
75
-
76
- /* Type Checking */
77
- "strict": true /* Enable all strict type-checking options. */,
78
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
79
- // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
80
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
81
- // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
82
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
83
- // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
84
- // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
85
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
86
- // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
87
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
88
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
89
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
90
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
91
- // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
92
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
93
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
94
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
95
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
96
-
97
- /* Completeness */
98
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
99
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
100
- }
101
- }