'use strict';

/**
 * Wall-E plugin manifest types — shared across all 5 plugin shapes.
 *
 * Inspired by OpenClaw's `src/plugins/manifest-types.ts` + `plugin-kind.types.ts`,
 * adapted for Wall-E's leaner footprint. We don't need 1,115 LOC of schema; a
 * 5-field core + per-kind extensions covers our needs.
 */

/** Plugin kinds Wall-E recognizes. */
const PLUGIN_KINDS = Object.freeze([
  'skill',     // _bundled/<name>/, ~/.wall-e/skills/<name>/
  'provider',  // llm/<name>.js
  'channel',   // channels/<name>.js
  'adapter',   // adapters/<name>.js
  'tool',      // tools/<name>.js (future, not enforced yet)
  'mcp',       // skills/_bundled/<name>/ with mcp config (future)
]);

/** Plugin source — where the manifest came from. */
const PLUGIN_SOURCES = Object.freeze([
  'bundled',   // shipped with Wall-E
  'workspace', // <workspace>/.wall-e/plugins/<name>
  'user',      // ~/.wall-e/plugins/<name>
  'registry',  // ~/.wall-e/registry-plugins/<name>
  'npm',       // node_modules/<pkg> with walle.plugin.json (Item H)
  'project',   // <project>/.walle/skills.json
]);

/** Diagnostic levels matching OpenClaw's PluginDiagnostic. */
const DIAGNOSTIC_LEVELS = Object.freeze(['warn', 'error']);

/**
 * Shape of a parsed plugin manifest.
 * @typedef {object} PluginManifest
 * @property {string} id            - Plugin id, must be unique within its kind
 * @property {string} kind          - One of PLUGIN_KINDS
 * @property {string} version       - Plugin's own semver (e.g. "1.0.0")
 * @property {string} pluginApi     - Semver range against Wall-E's PLUGIN_API_VERSION
 * @property {string} [walleVersion] - Built-with Wall-E version (informational)
 * @property {string} [name]        - Human-readable name
 * @property {string} [description] - One-line description
 * @property {string} [entry]       - Entry file (e.g. "index.js" or "run.js")
 * @property {object} [capabilities]- Per-kind capability flags (markdownCapable, etc.)
 * @property {object} [requires]    - { bins, env, mcp } — same shape as SKILL.md requires
 * @property {string[]} [modelPrefixes] - For kind=provider, e.g. ["claude-"]
 * @property {object} [auth]        - Auth metadata (envVars, choices, etc.)
 * @property {boolean} [enabled]    - Default enabled state (default: true)
 */

/**
 * Shape of a single diagnostic entry from the validator.
 * @typedef {object} PluginDiagnostic
 * @property {'warn'|'error'} level
 * @property {string} message
 * @property {string} [pluginId]
 * @property {string} [source]
 * @property {string} [fieldPath]   - For validation errors, the offending field
 */

module.exports = {
  PLUGIN_KINDS,
  PLUGIN_SOURCES,
  DIAGNOSTIC_LEVELS,
};
