@mdocui/cli 0.4.2 → 0.5.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/dist/index.js +5 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6,14 +6,10 @@ import path2 from "path";
|
|
|
6
6
|
import { ComponentRegistry, generatePrompt } from "@mdocui/core";
|
|
7
7
|
|
|
8
8
|
// src/config.ts
|
|
9
|
-
import { pathToFileURL } from "url";
|
|
10
|
-
import path from "path";
|
|
11
9
|
import fs from "fs";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"mdocui.config.mjs"
|
|
16
|
-
];
|
|
10
|
+
import path from "path";
|
|
11
|
+
import { pathToFileURL } from "url";
|
|
12
|
+
var CONFIG_FILES = ["mdocui.config.ts", "mdocui.config.js", "mdocui.config.mjs"];
|
|
17
13
|
async function loadConfig(cwd2) {
|
|
18
14
|
for (const name of CONFIG_FILES) {
|
|
19
15
|
const configPath = path.resolve(cwd2, name);
|
|
@@ -26,9 +22,7 @@ async function loadConfig(cwd2) {
|
|
|
26
22
|
}
|
|
27
23
|
return config;
|
|
28
24
|
}
|
|
29
|
-
throw new Error(
|
|
30
|
-
`No config file found. Create one of: ${CONFIG_FILES.join(", ")}`
|
|
31
|
-
);
|
|
25
|
+
throw new Error(`No config file found. Create one of: ${CONFIG_FILES.join(", ")}`);
|
|
32
26
|
}
|
|
33
27
|
function toPromptOptions(config) {
|
|
34
28
|
return {
|
|
@@ -96,11 +90,7 @@ async function init(cwd2) {
|
|
|
96
90
|
}
|
|
97
91
|
fs3.writeFileSync(configPath, CONFIG_TEMPLATE, "utf-8");
|
|
98
92
|
fs3.mkdirSync(generatedDir, { recursive: true });
|
|
99
|
-
fs3.writeFileSync(
|
|
100
|
-
path3.resolve(generatedDir, ".gitkeep"),
|
|
101
|
-
"",
|
|
102
|
-
"utf-8"
|
|
103
|
-
);
|
|
93
|
+
fs3.writeFileSync(path3.resolve(generatedDir, ".gitkeep"), "", "utf-8");
|
|
104
94
|
console.log("Created:");
|
|
105
95
|
console.log(" mdocui.config.ts \u2014 component definitions + config");
|
|
106
96
|
console.log(" generated/ \u2014 output directory for system prompts");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/generate.ts","../src/config.ts","../src/commands/init.ts","../src/commands/preview.ts","../src/index.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport { ComponentRegistry, generatePrompt } from '@mdocui/core'\nimport { loadConfig, toPromptOptions } from '../config'\n\nexport async function generate(cwd: string) {\n\tconst config = await loadConfig(cwd)\n\tconst registry = new ComponentRegistry()\n\tregistry.registerAll(config.components)\n\n\tconst prompt = generatePrompt(registry, toPromptOptions(config))\n\tconst outputPath = path.resolve(cwd, config.output ?? 'system-prompt.txt')\n\n\tfs.mkdirSync(path.dirname(outputPath), { recursive: true })\n\tfs.writeFileSync(outputPath, prompt, 'utf-8')\n\n\tconsole.log(`Generated system prompt → ${path.relative(cwd, outputPath)}`)\n\tconsole.log(`${registry.names().length} components, ${prompt.length} chars`)\n}\n","import
|
|
1
|
+
{"version":3,"sources":["../src/commands/generate.ts","../src/config.ts","../src/commands/init.ts","../src/commands/preview.ts","../src/index.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport { ComponentRegistry, generatePrompt } from '@mdocui/core'\nimport { loadConfig, toPromptOptions } from '../config'\n\nexport async function generate(cwd: string) {\n\tconst config = await loadConfig(cwd)\n\tconst registry = new ComponentRegistry()\n\tregistry.registerAll(config.components)\n\n\tconst prompt = generatePrompt(registry, toPromptOptions(config))\n\tconst outputPath = path.resolve(cwd, config.output ?? 'system-prompt.txt')\n\n\tfs.mkdirSync(path.dirname(outputPath), { recursive: true })\n\tfs.writeFileSync(outputPath, prompt, 'utf-8')\n\n\tconsole.log(`Generated system prompt → ${path.relative(cwd, outputPath)}`)\n\tconsole.log(`${registry.names().length} components, ${prompt.length} chars`)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport type { ComponentDefinition, ComponentGroup, PromptOptions } from '@mdocui/core'\n\nexport interface MdocUIConfig {\n\tcomponents: ComponentDefinition[]\n\toutput?: string\n\tpreamble?: string\n\tadditionalRules?: string[]\n\texamples?: string[]\n\tgroups?: ComponentGroup[]\n}\n\nconst CONFIG_FILES = ['mdocui.config.ts', 'mdocui.config.js', 'mdocui.config.mjs']\n\nexport async function loadConfig(cwd: string): Promise<MdocUIConfig> {\n\tfor (const name of CONFIG_FILES) {\n\t\tconst configPath = path.resolve(cwd, name)\n\t\tif (!fs.existsSync(configPath)) continue\n\n\t\tconst url = pathToFileURL(configPath).href\n\t\tconst mod = await import(url)\n\t\tconst config = mod.default ?? mod\n\n\t\tif (!config.components || !Array.isArray(config.components)) {\n\t\t\tthrow new Error(`${name}: \"components\" must be an array of ComponentDefinition`)\n\t\t}\n\n\t\treturn config as MdocUIConfig\n\t}\n\n\tthrow new Error(`No config file found. Create one of: ${CONFIG_FILES.join(', ')}`)\n}\n\nexport function toPromptOptions(config: MdocUIConfig): PromptOptions {\n\treturn {\n\t\tpreamble: config.preamble,\n\t\tadditionalRules: config.additionalRules,\n\t\texamples: config.examples,\n\t\tgroups: config.groups,\n\t}\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nconst CONFIG_TEMPLATE = `import { defineComponent } from '@mdocui/core'\nimport { z } from 'zod'\n\nconst button = defineComponent({\n name: 'button',\n description: 'Clickable action button',\n props: z.object({\n action: z.string().describe('Action to perform'),\n label: z.string().describe('Button text'),\n }),\n children: 'none',\n})\n\nconst callout = defineComponent({\n name: 'callout',\n description: 'Highlighted message block',\n props: z.object({\n type: z.enum(['info', 'warning', 'error', 'success']).describe('Severity'),\n title: z.string().optional().describe('Heading'),\n }),\n children: 'any',\n})\n\nexport default {\n components: [button, callout],\n output: './generated/system-prompt.txt',\n preamble: 'You are a helpful assistant.',\n additionalRules: [\n 'End responses with follow-up buttons using action=\"continue\"',\n ],\n}\n`\n\nexport async function init(cwd: string) {\n\tconst configPath = path.resolve(cwd, 'mdocui.config.ts')\n\tconst generatedDir = path.resolve(cwd, 'generated')\n\n\tif (fs.existsSync(configPath)) {\n\t\tconsole.log('mdocui.config.ts already exists — skipping')\n\t\treturn\n\t}\n\n\tfs.writeFileSync(configPath, CONFIG_TEMPLATE, 'utf-8')\n\tfs.mkdirSync(generatedDir, { recursive: true })\n\tfs.writeFileSync(path.resolve(generatedDir, '.gitkeep'), '', 'utf-8')\n\n\tconsole.log('Created:')\n\tconsole.log(' mdocui.config.ts — component definitions + config')\n\tconsole.log(' generated/ — output directory for system prompts')\n\tconsole.log('')\n\tconsole.log('Next steps:')\n\tconsole.log(' 1. Edit mdocui.config.ts — add your components')\n\tconsole.log(' 2. Run: npx @mdocui/cli generate')\n}\n","import { ComponentRegistry, generatePrompt } from '@mdocui/core'\nimport { loadConfig, toPromptOptions } from '../config'\n\nexport async function preview(cwd: string) {\n\tconst config = await loadConfig(cwd)\n\tconst registry = new ComponentRegistry()\n\tregistry.registerAll(config.components)\n\n\tconst prompt = generatePrompt(registry, toPromptOptions(config))\n\tconsole.log(prompt)\n}\n","import { generate } from './commands/generate'\nimport { init } from './commands/init'\nimport { preview } from './commands/preview'\n\nconst args = process.argv.slice(2)\nconst command = args[0]\nconst cwd = process.cwd()\n\nasync function main() {\n\tswitch (command) {\n\t\tcase 'generate':\n\t\t\tawait generate(cwd)\n\t\t\tbreak\n\t\tcase 'preview':\n\t\t\tawait preview(cwd)\n\t\t\tbreak\n\t\tcase 'init':\n\t\t\tawait init(cwd)\n\t\t\tbreak\n\t\tcase '--help':\n\t\tcase '-h':\n\t\tcase undefined:\n\t\t\tprintHelp()\n\t\t\tbreak\n\t\tdefault:\n\t\t\tconsole.error(`Unknown command: ${command}`)\n\t\t\tprintHelp()\n\t\t\tprocess.exit(1)\n\t}\n}\n\nfunction printHelp() {\n\tconsole.log(`\nmdocui — CLI for mdocUI generative UI library\n\nCommands:\n init Scaffold a new mdocui config file\n generate Generate system prompt from component registry\n preview Print generated system prompt to stdout\n\nUsage:\n npx @mdocui/cli init\n npx @mdocui/cli generate\n npx @mdocui/cli preview\n`)\n}\n\nmain().catch((err) => {\n\tconsole.error(err.message)\n\tprocess.exit(1)\n})\n"],"mappings":";;;AAAA,OAAOA,SAAQ;AACf,OAAOC,WAAU;AACjB,SAAS,mBAAmB,sBAAsB;;;ACFlD,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAY9B,IAAM,eAAe,CAAC,oBAAoB,oBAAoB,mBAAmB;AAEjF,eAAsB,WAAWC,MAAoC;AACpE,aAAW,QAAQ,cAAc;AAChC,UAAM,aAAa,KAAK,QAAQA,MAAK,IAAI;AACzC,QAAI,CAAC,GAAG,WAAW,UAAU,EAAG;AAEhC,UAAM,MAAM,cAAc,UAAU,EAAE;AACtC,UAAM,MAAM,MAAM,OAAO;AACzB,UAAM,SAAS,IAAI,WAAW;AAE9B,QAAI,CAAC,OAAO,cAAc,CAAC,MAAM,QAAQ,OAAO,UAAU,GAAG;AAC5D,YAAM,IAAI,MAAM,GAAG,IAAI,wDAAwD;AAAA,IAChF;AAEA,WAAO;AAAA,EACR;AAEA,QAAM,IAAI,MAAM,wCAAwC,aAAa,KAAK,IAAI,CAAC,EAAE;AAClF;AAEO,SAAS,gBAAgB,QAAqC;AACpE,SAAO;AAAA,IACN,UAAU,OAAO;AAAA,IACjB,iBAAiB,OAAO;AAAA,IACxB,UAAU,OAAO;AAAA,IACjB,QAAQ,OAAO;AAAA,EAChB;AACD;;;ADrCA,eAAsB,SAASC,MAAa;AAC3C,QAAM,SAAS,MAAM,WAAWA,IAAG;AACnC,QAAM,WAAW,IAAI,kBAAkB;AACvC,WAAS,YAAY,OAAO,UAAU;AAEtC,QAAM,SAAS,eAAe,UAAU,gBAAgB,MAAM,CAAC;AAC/D,QAAM,a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,MAAM,WAAWA,IAAG;AACnC,QAAM,WAAW,IAAIC,mBAAkB;AACvC,WAAS,YAAY,OAAO,UAAU;AAEtC,QAAM,SAASC,gBAAe,UAAU,gBAAgB,MAAM,CAAC;AAC/D,UAAQ,IAAI,MAAM;AACnB;;;ACNA,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,IAAM,UAAU,KAAK,CAAC;AACtB,IAAM,MAAM,QAAQ,IAAI;AAExB,eAAe,OAAO;AACrB,UAAQ,SAAS;AAAA,IAChB,KAAK;AACJ,YAAM,SAAS,GAAG;AAClB;AAAA,IACD,KAAK;AACJ,YAAM,QAAQ,GAAG;AACjB;AAAA,IACD,KAAK;AACJ,YAAM,KAAK,GAAG;AACd;AAAA,IACD,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACJ,gBAAU;AACV;AAAA,IACD;AACC,cAAQ,MAAM,oBAAoB,OAAO,EAAE;AAC3C,gBAAU;AACV,cAAQ,KAAK,CAAC;AAAA,EAChB;AACD;AAEA,SAAS,YAAY;AACpB,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAYZ;AACD;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACrB,UAAQ,MAAM,IAAI,OAAO;AACzB,UAAQ,KAAK,CAAC;AACf,CAAC;","names":["fs","path","cwd","cwd","path","fs","fs","path","cwd","ComponentRegistry","generatePrompt","cwd","ComponentRegistry","generatePrompt"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdocui/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "CLI for mdocUI — scaffold, generate system prompts, preview",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"zod": "^4.3.0",
|
|
16
|
-
"@mdocui/core": "0.
|
|
16
|
+
"@mdocui/core": "0.5.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/node": "^25.5.0",
|