A Moth project is the directory you select. That directory is both the build root and the source root. There is no implicit src/ folder.
Starter config
@config.moth uses two ordinary named records:
project #= (
name = "my_site",
)
html #= ()
name is optional and falls back to the selected folder name. There are no $project or $html_builder directives.
Where things live
@config.moth at the selected root is optional and controls build settings. It is not module source, and a helper named config.moth is ordinary source.- Everything below the selected root is source unless it is excluded or is generated output.
_dev/ and _release/ are generated output. Do not edit them.- A folder name starting with
_ is excluded from the build unless you select it directly.
Up to three root files per module folder
Each source folder can contain @mod.moth, @package.moth and @entry.moth. Any subset works. They form one module with shared helper files and separate root scopes.
@mod.moth exports the normal API.@package.moth exports a scoped support API, or the project package API at the project root.@entry.moth holds page code and document metadata.
A page appears for every folder with @entry.moth. The file can be empty, hold only metadata or hold runtime code:
[$in title:Welcome]
That metadata-only entry still produces a page. No other filename creates a page.
Shared scoped packages
An @package.moth root creates a scoped support surface. For example, shared/@package.moth creates @shared. Its owner module, normal sibling modules and their descendants may depend on it. Other support packages in the same scope and the package's private implementation subtree cannot.
When a folder has both an @mod.moth and an @package.moth, helpers are shared while each root keeps its own declarations and public interface. A project-root @package.moth is the external project package surface. Internal modules cannot import it.
Outputs are generated
The build command creates hidden output folders. They are not source. The builder cleans up stale artefacts automatically.
A Moth project is a directory tree rooted at the directory selected by the command. That directory is both the build root and the source root. There is no implicit src/ entry directory, and a nested @config.moth never applies to an enclosing build.
Starter shape
The optional project config uses ordinary named compile-time records:
project #= (
name = "my_site",
)
html #= ()
The project record and its name field are optional. An omitted name uses the selected directory name. The active builder section follows its own required or optional presence rule. HTML permits an omitted section and applies its defaults.
A configurable value uses $config before one explicitly typed top-level # binding. project and html stay ordinary record values. No $project, $builder or $html_builder directive exists.
Project root contents
website/
├── @config.moth # optional
├── @entry.moth
├── @package.moth # optional external package surface
├── shared/
│ └── @package.moth
├── pages/
│ └── @mod.moth
├── _dev/
│ └── .moth_manifest
├── _release/
│ └── .moth_manifest
└── .gitignore
Directory roles
- The selected directory is the build root and the top of the discoverable source tree.
@config.moth is optional. When present, only the one at the selected root applies. It is not module source. A helper named config.moth is ordinary source and @config resolves it.- A directory named
src/ is ordinary source content. There is no configured entry directory or entry_root. _dev/ and _release/ are hidden generated output folders, not source folders. The build system manages them through manifests..moth_manifest files are build-system metadata used for safe stale-output cleanup. They are not source.- A directory component below the selected root whose name starts with
_ is excluded from that build. Select it directly to compile it.
Reserved package namespace roots
@core and @builder are reserved package namespace roots. Compiler-shipped Core packages register below @core/, such as @core/html, @core/css and @core/math, and Builder packages below @builder/, such as @builder/web/site. Neither root alone names an importable package.
A project-local import name whose first path component claims core or builder, in any ASCII case, is rejected. This covers normal and support facades, importable helpers and aliases. A directory name alone claims nothing, so entry-only modules, their private helpers, folders that contain only entries and plain asset directories below core/ or builder/ stay legal.
A project folder whose full path matches a registered source package path, such as core/html/ or builder/web/site/, collides whichever module owns it, even when the folder holds no importable surface. Comparison ignores ASCII case. A binding-backed package has no source module, so an asset folder at builder/web/canvas/ stays legal. An ancestor folder such as core/ alone stays legal, and so do unrelated project folders named html/, css/, styles/ or web/. @project remains a separate reserved interface for project globals.
Root files inside source directories
A source directory recognises exactly three optional root files: @mod.moth, @package.moth and @entry.moth. The directory may contain any present subset. One directory forms one structural module with shared helper files. @config.moth is the reserved build-only filename, not a fourth root, and a nested copy stays inert.
@mod.moth publishes a normal API facade. @package.moth publishes a scoped support facade, or the external project package surface when it sits at the selected project root. @entry.moth owns executable page or application work. Only entry roots may hold top-level runtime code, page fragments and direct builder slots.
Apart from the reserved @config.moth, any other @*.moth or +*.moth spelling, such as @page.moth, is rejected as a structure error. The exact filename is the role. See Module roots for the full vocabulary and visibility rules.
A project produces an HTML page for each @entry.moth directory. Entry eligibility comes from file presence, not from the amount of authored activity:
[$in title:Welcome]
This metadata-only entry still produces a complete document. An empty @entry.moth is also eligible.
Helpers in ordinary files stay inside the surrounding module. They never become entries on their own.
Structural packages
Project-local source-backed packages use @package.moth. An @package.moth file marks its directory as a scoped support package root named by that directory.
In the example above, shared/@package.moth creates the scoped @shared support package. It is visible to its normal-position owner module, normal sibling modules and their descendants. It is not dependency-bound from its own private implementation subtree or from another support package in the same scope.
A project-root @package.moth is the external project package surface. Internal project modules cannot import it. It is an ordinary support surface, not a separate graph node.
No folder gains package meaning without an @package.moth root. Ordinary directories do not automatically become packages.
Copying a compiler-shipped source package folder, one with @package.moth such as packages/core/html, to a non-colliding project path gives an ordinary project-local support package. It never gains Core or Builder identity, capabilities or registration. Copying a binding asset folder, such as packages/builder/web/canvas/, creates no package, registers none of the original symbols and gains no namespace identity.
A directory may contain both an @mod.moth normal root and an @package.moth support root. They are two isolated surfaces of one structural module. Helpers are shared, roots cannot import each other and both interfaces publish only from one successful semantic transaction.
For the full package contract see Project-local packages.
Project scaffold
moth new html creates an @config.moth with an explicit valid project name, a root-level @entry.moth and a .gitignore containing /_dev and /_release. The generated config is:
project #= (
name = "my_site",
)
html #= ()
The generated entry contributes document metadata and a starter page through direct root inserts. Deleting the generated config is valid when the directory name is a valid project identifier.
Source versus output
Developers own source directories. The builder generates hidden output folders and owns their stale-output cleanup. Treat generated artefacts as output, not source. A visible directory named release remains ordinary source.
Builder-neutral frontend versus builder-owned output
The compiler frontend discovers modules, resolves dependencies, checks types, lowers code and validates borrowing. A project builder then decides how compiled modules become real output files. The HTML project builder uses this frontend.
This separation lets the same frontend feed other builders. The frontend does not decide which modules produce artefacts. The builder owns that decision.
Only @config.moth has config semantics
Only the selected project's root-level @config.moth defines its settings. A nested @config.moth does not configure the enclosing build. An ordinary config.moth helper never gains config meaning, and @config resolves that helper. Invalid special root filenames are rejected during source discovery.
Concepts related to project layout