Skip to Content
@package-system

Directory contract and discovery

The shape of a Neuralis package and exactly what file-first discovery scans.

A Neuralis package is an npm-style directory with a manifest and a set of file-first declarations. Nothing a package contributes is registered in code against the host — the host discovers everything from the package's files at load time and merges the result into the package's PackageDefinition.

Directory contract

my-package/
  package.json          # manifest: the `neuralis` block declares the package
  tools/                # *.json — strict JSON-Schema tool definitions
  workflows/            # *.json — declarative workflow templates
  skills/               # <name>/SKILL.md — folder-per-skill bundles
  instructions/         # *.md — system-prompt instruction contributions
  rules/                # *.md — always-on rule contributions
  agents/               # *.md — delegate agent personas
  docs/                 # *.md — reference docs, listed in the overview + read on demand (not injected)
  commands/             # *.json — prompt/slash command definitions
  hooks.json            # declarative lifecycle hooks
  team/                 # <slug>/member.json + identity/*.md + files/**/*.md
  src/                  # runtime code (lifecycle, routes, tool handlers)
  dist/                 # compiled runtime output (node) or package.wasm

Only package.json is required. Everything else is optional — a purely declarative package can ship nothing but tool schemas and markdown.

A package that ships runtime code is ESM: "type": "module", module/moduleResolution: "NodeNext", target: "ES2022", and an explicit .js extension on every relative import. The runtime loads the compiled dist/ through the package exports map. (A WASM guest bundle is CommonJS for the QuickJS runtime: WASM build.)

What discovery scans

PathBecomesNotes
tools/*.jsonPackageTool[]Tool name = filename without .json. Invalid schemas fail the package load.
workflows/*.jsonPackageWorkflow[]Workflow templates — a parallel typed JSON array like tools, never prompt-injected. Template id = filename; invalid templates fail the package load. See Workflows.
skills/<name>/SKILL.mdskills array (category: 'skill')Folder-per-skill; the walk is recursive under skills/.
instructions/**/*.mdinstructions array (category: 'instruction')Arbitrarily named, recursive.
rules/**/*.mdrules array (category: 'rule')Arbitrarily named, recursive.
agents/**/*.mdagents array (category: 'agent')Delegate personas.
docs/**/*.mddocs array (category: 'docs')Reference material.
commands/*.jsonPackageCommand[]Each file carries an id; served as static prompt text, no executor, arguments not substituted. See Commands.
hooks.jsonPackageHook[]Seven events: PreToolUse, PostToolUse, PostToolUseFailure, SessionStart, SessionEnd, Stop, PrePrompt; any other is skipped. Per-event semantics are validated at load: PostToolUse may only observe, Stop only forceContinue, PrePrompt only inject. Invalid entries are skipped, never crash bootstrap. Only the in-process callback kind executes today. See Hooks.
team/<slug>/member.jsonTeamMemberContribution[]Plus identity/*.md and files/**/*.md. The slug is a single safe path segment, and every template path stays inside the package: relative, no .. or . segment, no absolute prefix, backslash or control character, at most 512 characters, at most 64 entries per list. A manifest that breaks this is rejected at load and the package registers nothing (markdown in a directory also synced as a source is still discovered as a source package). See Team.
src/routes/*.tsRoute handlersAuthored the same for node builtins AND WASM project packages; WASM builds emit dist/routes.json for the host feature-gate. See Routes.
src/tools/*.tsTool handlersDefault-export handler, paired with tools/<name>.json by filename.
src/channels/*.tsNative realtime channelsExport matching channel, feature, and subscribe; compiled modules feed the shared events hub.
src/events/*.tsNative event sourcesExport matching subject, a required visible, and an optional bridge; see events.
src/runtimeProvider.tsRuntime providerA native provides: ["runtime"] package exports the named runtimeProvider.
src/lifecycle.tsLifecycle moduleSee Lifecycle. WASM init is lazy/cached.

Two additional skill paths exist for agentskills.io import compatibility:

  • <root-subdir>/SKILL.md — a skill package whose skills sit directly under the package root instead of skills/. Reserved directories (src, dist, tools, node_modules, the category folders, …) are never treated as skill folders.
  • <root>/SKILL.md — a bare single-skill folder with no package.json at all: the package root is the skill, and ${SKILL_DIR} resolves to it.

What is NOT scanned

  • Package-root loose .md files. README.md, AGENTS.md, PLAN.md, and any other markdown at the package root are package-meta files, never contributions. The only root-level exception is a root SKILL.md.
  • Anything outside the category folders. There is no generic files/ contribution directory and no cross-folder contribution nesting — a rule must live under rules/, an instruction under instructions/, and so on.

Category comes from the folder

Every discovered markdown file carries a required category ('skill' | 'instruction' | 'rule' | 'agent' | 'docs') set authoritatively from its source folder — never from frontmatter. A role: frontmatter key is ignored with a warning (role denotes the user rank elsewhere in the system), and a category: key is not read at all. One exception re-categorizes a file: a skill that declares context: fork in its frontmatter registers as an agent (a skill-fork delegate persona).

Flat contributions (instructions/, rules/, agents/, docs/) — and any *.agent.md — need a frontmatter name (or id) to be discovered; a bare markdown file without one is skipped silently. The exceptions are the forms whose filename is the identity by protocol: skills/<name>/SKILL.md (the skill id falls back to the folder name), commands/*.md, the identity basenames (AGENTS.md, AGENTS.local.md, AGENT.md, CLAUDE.md, CLAUDE.local.md, GEMINI.md, .github/copilot-instructions.md), .cursorrules, .windsurfrules and .cursor/rules/*.mdc. The same admission rule applies to a package drop and to a synced source, so the three package forms never disagree about what a contribution is.

Skill bundles — the directory is the scope

A skill's scope is its whole directory. Discovery enumerates the bundle into PackageFile.files[] (SKILL.md first, then scripts/**, references/**, assets/**, the rest; at most 64 entries; dotfiles, node_modules, .git and dist skipped). The bundle directory is always dirname(path). The enumeration is display metadata, never a permission boundary.

File-based entries override inline entries

Inline tools, files, commands, hooks or team members in the neuralis block are a fallback for imported manifests: a discovered file wins by id (name for tools, slug for team members); an inline entry without a file passes through. Prefer files.

Trust-tier sanitization at discovery

Discovery applies the package's trust tier to what it found. For any package that is not native:

  • rules/ contributions are downgraded to docs — a non-native package cannot inject always-on behavioral constraints into the system prompt.
  • A frontmatter overwrite: true flag is stripped.
  • An activation.target: 'prompt-context' declaration is retargeted to workspace.

This keeps the system-prompt injection surface a native privilege while still loading the contribution as readable reference material. See Features and access for the caller-side visibility rules that apply on top.

On this page