{
  "name": "generate-node-feature",
  "description": "Generate a multi-file backend feature bundle for Node/TypeScript projects.",
  "origin": "EOC",
  "level": "L3",
  "languages": [
    "javascript",
    "typescript"
  ],
  "frameworks": [
    "express",
    "fastify",
    "nest",
    "node"
  ],
  "triggers": [
    "generate feature",
    "add backend feature",
    "create module"
  ],
  "inputs": [
    {
      "name": "name",
      "required": true
    },
    {
      "name": "subject",
      "required": true
    },
    {
      "name": "feature_kind",
      "default": "crud"
    },
    {
      "name": "entrypoint",
      "default": "http"
    },
    {
      "name": "with_repository",
      "default": true
    },
    {
      "name": "with_test",
      "default": true
    },
    {
      "name": "with_docs",
      "default": true
    }
  ],
  "actions": [
    {
      "id": "node-feature",
      "type": "feature_bundle",
      "when": {
        "runtime": "node"
      },
      "plan": {
        "strategy": "auto",
        "dependency_graph": {
          "controller": [
            "service"
          ],
          "service": [
            "repository",
            "schema"
          ],
          "repository": [],
          "schema": [],
          "route": [
            "controller"
          ],
          "test": [
            "route",
            "service"
          ],
          "docs": [
            "route",
            "controller",
            "service"
          ],
          "integration": [
            "route",
            "service",
            "repository",
            "schema"
          ]
        }
      },
      "modules": [
        {
          "id": "controller",
          "template": "feature/controller.ts.tpl",
          "output": "{{paths.controller}}/{{controller_filename}}",
          "primary": true
        },
        {
          "id": "service",
          "template": "feature/service.ts.tpl",
          "output": "{{paths.service}}/{{service_filename}}"
        },
        {
          "id": "repository",
          "template": "feature/repository.ts.tpl",
          "output": "{{paths.repository}}/{{repository_filename}}",
          "condition": "with_repository"
        },
        {
          "id": "schema",
          "template": "feature/schema.ts.tpl",
          "output": "{{paths.schema}}/{{schema_filename}}"
        },
        {
          "id": "route",
          "template": "feature/route.ts.tpl",
          "output": "{{paths.route}}/{{route_filename}}"
        },
        {
          "id": "test",
          "template": "feature/test.spec.ts.tpl",
          "output": "{{paths.test}}/{{test_filename}}",
          "condition": "with_test"
        },
        {
          "id": "docs",
          "template": "feature/api.md.tpl",
          "output": "{{paths.docs}}/{{docs_filename}}",
          "condition": "with_docs"
        },
        {
          "id": "integration",
          "template": "feature/integration.md.tpl",
          "output": ".opencode/feature-bundles/{{kebab_name}}.integration.md"
        }
      ],
      "updates": [
        {
          "type": "ensure_line",
          "file": "{{paths.route_index}}",
          "content": "export * from '{{route_export_target}}';",
          "create_if_missing": true
        },
        {
          "type": "ensure_block",
          "file": "{{paths.docs_index}}",
          "content": "- [{{subject}}](./{{docs_filename}}) — generated feature",
          "create_if_missing": true
        }
      ]
    }
  ],
  "verify": [
    "npm run build",
    "npm test"
  ],
  "task_family": "feature"
}
