@doreamonjs/page-creator
v1.15.0
Published
page-creator for doreamonjs
Maintainers
Readme
@doreamonjs/page-creator (doremaonjs soul)
@doreamonjs/page-creator compiles a manifest into runtime config/model/page factories.
Agent Skills (CLI: Cursor, Claude, Gemini, …)
The published package includes an Agent Skill (Cursor-compatible) under skills/page-creator/: SKILL.md (main instructions) and reference.md (extra detail). Skills are not loaded from node_modules automatically—you copy the folder into a location your agent reads.
Install the package
yarn add @doreamonjs/page-creator
# or: npm install @doreamonjs/page-creatorUse yarn upgrade @doreamonjs/page-creator (or reinstall) when you want a newer skill text; then run install-skill again.
CLI: install-skill (recommended)
The npm package is @doreamonjs/page-creator. It registers a page-creator executable (see bin in this package’s package.json — that name is the CLI command, not the npm package name).
A — With the package already in your project (recommended):
yarn add -D @doreamonjs/page-creator
# or: npm install --save-dev @doreamonjs/page-creatorThen run the local binary (executable name page-creator, from this package):
npm exec page-creator install-skill
# Yarn 2+ (Berry):
yarn exec page-creator install-skill
# Yarn 1 (Classic): no `yarn exec`; use the bin path or an npm script (below)
./node_modules/.bin/page-creator install-skillOr add to package.json:
"scripts": {
"install-skill": "page-creator install-skill"
}and run yarn install-skill / npm run install-skill (PATH includes node_modules/.bin).
B — One-shot, without saving the dependency
Use the scoped package name and invoke the page-creator binary explicitly:
# npm (npm 7+)
npm exec --yes --package=@doreamonjs/page-creator -- page-creator install-skill
# npx (same idea)
npx --yes --package=@doreamonjs/page-creator page-creator install-skill
# Yarn 2+ (Berry): dlx downloads a temp copy of the package
yarn dlx @doreamonjs/page-creator page-creator install-skill
# pnpm
pnpm dlx @doreamonjs/page-creator page-creator install-skillDefault behavior: Cursor + Claude Code + Gemini CLI, project scope (under current directory).
Options:
| Flag | Meaning |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| --targets | Comma list: cursor, claude, gemini, agents (Codex / .agents/skills), or all. Default: cursor,claude,gemini. |
| --scope | project (default) — install under --cwd. user — install under your home directory (global skills for that tool). |
| --cwd | Base path for project scope (default: current working directory). |
| --dry-run | Print destinations only. |
Examples:
npm exec --yes --package=@doreamonjs/page-creator -- page-creator install-skill --targets all --scope project
yarn exec page-creator install-skill --targets cursor,claude --scope user
yarn dlx @doreamonjs/page-creator page-creator install-skill --cwd /path/to/repoDestination roots:
- Cursor:
.cursor/skills/page-creatoror~/.cursor/skills/page-creator - Claude Code:
.claude/skills/page-creatoror~/.claude/skills/page-creator - Gemini CLI:
.gemini/skills/page-creatoror~/.gemini/skills/page-creator - agents (Codex-style):
.agents/skills/page-creatoror~/.agents/skills/page-creator
Manual copy (optional)
From your app root:
mkdir -p .cursor/skills
cp -R node_modules/@doreamonjs/page-creator/skills/page-creator .cursor/skills/Repeat for .claude/skills, .gemini/skills, .agents/skills if needed. With pnpm, resolve the real package path under .pnpm/ if the package is not hoisted.
Do not put custom skills in ~/.cursor/skills-cursor/ — that area is for Cursor’s built-in skills.
Using the skill in Cursor
- Reload the Cursor window after installing, so skills are picked up.
- In Chat / Composer, @-mention the skill (
**page-creator**inSKILL.mdfrontmatter — e.g.@page-creator).disable-model-invocation: truemeans you usually must attach it explicitly unless you change your local copy. - Full manifest typings:
node_modules/@doreamonjs/page-creator/lib/manifest.d.ts.
Other agents
Claude Code / Gemini CLI use the same copied folder; install paths are listed above. Reload or restart the CLI after install-skill if skills do not appear.
Core APIs
createManifest(manifest)- normalize manifest inputcompileManifest(manifest, options?)- compile manifest into runtimeConfigcreateModel(manifest)- create Dva model from compiled configcreateModelWithCompileOptions(manifest, options?)- model creation with compile optionscreatePage(namespace, options?)- create page component
Phase-based refactor extensions
Validation
validateManifest(manifest)performs lightweight structural checksvalidateManifest(manifest, { strict: true })enables reference checks- Throws
ManifestValidationErrorwith structuredissues:codepathmessage
Strict mode currently validates:
- action pipeline
service.apistring references - action
pipelineTo.actiontarget references - field
ui.search.options.apireferences - field
ui.form.options.apireferences
Extensibility registries
registerFormFieldNormalizer(type, normalizer)registerSearchFieldNormalizer(type, normalizer)registerTableColumnNormalizer(type, normalizer)registerPipelineHandler(stepType, handler)registerPreset(preset)/applyPreset(nameOrPreset)/listPresets()enterprisePreset(built-in example preset)
These APIs are backward-compatible: existing manifests continue to work without registration.
Preset usage example
import {
registerPreset,
applyPreset,
enterprisePreset,
} from '@doreamonjs/page-creator';
registerPreset(enterprisePreset);
applyPreset('enterprise');You can also apply a custom inline preset:
applyPreset({
name: 'custom',
formFieldNormalizers: {
'my-type': (field) => ({ ...field, placeholder: 'customized' }),
},
});Pipeline compile options
compileManifest and createModelWithCompileOptions support:
pipeline.context.resolveDialogRender(name)to avoid hard window couplingpipeline.hooks.beforeEachStep(step, action)pipeline.hooks.afterEachStep(step, action)validation.strictfor strict manifest reference validation
Conditional Form Rules (when/then/else)
ManifestField.ui.form now supports declarative linkage rules:
when: condition group (alland/orany)then: branch applied whenwhenis matchedelse: branch applied whenwhenis not matched
Supported branch controls:
visible- show/hide fieldrequired- toggle required validationinitialValue- set field value when current value is emptyoptions- replace options dynamically (useful for select/cascader)
Supported condition operators:
eq,nein,notInexistsregexp
Example: province-city linkage
const manifest = {
path: '/orders',
title: '订单',
fields: [
{
key: 'region',
title: '区域',
type: 'string',
ui: {
form: {
type: 'select',
options: [
{ label: '中国', value: 'cn' },
{ label: '海外', value: 'global' },
],
},
},
},
{
key: 'city',
title: '城市',
type: 'string',
ui: {
form: {
type: 'select',
when: {
all: [{ key: 'region', eq: 'cn' }],
},
then: {
visible: true,
required: true,
initialValue: 'hangzhou',
options: [
{ label: '杭州', value: 'hangzhou' },
{ label: '上海', value: 'shanghai' },
],
},
else: {
visible: false,
required: false,
},
},
},
},
],
};Example: condition with any + regexp
{
key: 'contact',
title: '联系人',
type: 'string',
ui: {
form: {
when: {
any: [
{ key: 'scene', in: ['prod', 'pre'] },
{ key: 'namespace', regexp: '^team-' },
],
},
then: { required: true, visible: true },
else: { required: false, visible: false },
},
},
}Notes
- Current validation is intentionally lightweight to avoid breaking legacy manifests.
- Future phases can introduce stricter schema checks incrementally.
Test commands
yarn test- run both groups (test:unit+test:contract)yarn test:unit- unit tests with coverage thresholdyarn test:contract- manifest->config contract snapshots (fixtures-based, no coverage)
Manifest lint CLI
After build, run:
yarn build
yarn lint:manifest ./manifests --strict --compileOptions:
--strict: enable strict reference checks--compile: also run compile stage checks--format pretty|json: output style--ext .json,.manifest.json: file suffix list (comma-separated)--ignore node_modules,dist,.git: skip paths containing these segments--config ./.manifestlintrc: load config from file (CLI flags override config)
Config auto-discovery (from current directory upward):
.manifestlintrc.manifestlintrc.jsonmanifestlint.config.json
Example config:
{
"strict": true,
"compile": true,
"format": "pretty",
"ext": [".json", ".manifest.json"],
"ignore": ["node_modules", "dist"],
"targets": ["./manifests"]
}CI example
yarn build
yarn lint:manifest ./manifests --strict --compile --format pretty --ignore node_modules,dist