Skill: fantasy0102/lqs-skill (version 1.0.1)

--- name: lqs-skill description: | LQS Skill — prompt/schema/template driven artifact generator for the LQS codebase. Manual-run only: users paste free-text requirement or exported document text; the Skill guides prompt-driven generation of RequirementDraft → Spec → RenderPlan → Preview Diff. This Skill does NOT execute code, run migrations, or fetch external documents automatically. activation: - "lqs-skill" - "generate controller" - "generate model" - "render artifacts" - "preview diff" version: "0.2.0" author: "LQS Team" entry_prompts: - .skill/prompts/01_parse_requirement.md - .skill/prompts/02_mine_patterns.md - .skill/prompts/03_build_templates.md - .skill/prompts/04_resolve_spec.md - .skill/prompts/05_render_artifacts.md - .skill/prompts/06_preview_diff.md - .skill/prompts/07_write_files.md examples: .skill/examples/ notes: | Workflow is intentionally manual to preserve safety and cross-repo compatibility. Recommended usage: follow .skill/quickstart.md and .skill/implementation_runbook.md. --- # LQS Skill (human-run) overview This SKILL.md provides metadata and a short usage note for packaging the `.skill` assets for skill platforms such as OpenClaw. - Purpose: provide prompts, templates, schemas and examples to guide human-in-the-loop generation of boilerplate artifacts (controller/model/view/migration) for Admin module. - Non-goal: no code execution, no remote fetching, no automatic migrations. See also: .skill/quickstart.md, .skill/implementation_runbook.md, .skill/mvp_delivery_checklist.md

path: patterns/project_pattern_profile.json
content: {
  "source": {
    "controllers": [
      "application/modules/Admin/controllers/Post.php",
      "application/modules/Admin/controllers/Members.php",
      "application/modules/Admin/controllers/Orders.php"
    ],
    "views": [
      "application/modules/Admin/views/post/index.tpl",
      "application/modules/Admin/views/members/index.tpl",
      "application/modules/Admin/views/orders/index.tpl"
    ],
    "base": "application/controllers/BackendBase.php",
    "trait": "application/library/repositories/HoutaiRepository.php"
  },
  "controller_patterns": {
    "base_class": "BackendBaseController",
    "traits": ["repositories\\HoutaiRepository"],
    "confidence": "high",
    "required_methods": [
      "indexAction",
      "getModelClass",
      "getPkName",
      "getLogDesc"
    ],
    "common_overrides": [
      "listAjaxIteration",
      "getSearchWhereParam",
      "formatKey",
      "saveAfterCallback",
      "listAjaxWhere",
      "getDesc"
    ],
    "ajax_actions": ["listAjaxAction", "saveAction", "deleteAction|delAction", "delAllAction"]
  },
  "query_contract": {
    "where": "exact match params",
    "search": "prefix like (value%)",
    "like": "contains like (%value%)",
    "between": "range params between[field][from|to]",
    "orderBy": "orderBy[field]=asc|desc",
    "pagination": ["page", "limit"],
    "special": ["__undefined__ as empty"],
    "confidence": "high",
    "field_heuristics": {
      "id_like_fields": "prefer where",
      "text_fields": "prefer like",
      "time_fields": "prefer between"
    }
  },
  "response_contract": {
    "listAjax": {
      "fields": ["count", "data", "msg", "desc", "code"],
      "success_code": 0
    },
    "ajax_helpers": ["ajaxSuccess", "ajaxError", "ajaxReturn", "ajaxSuccessMsg"],
    "confidence": "high"
  },
  "view_patterns": {
    "includes": ["header.tpl", "fooler.tpl"],
    "layout": ["search-form", "layui-table", "toolbar", "operate-toolbar", "dialog-form"],
    "table_data": "lay-data uses {%url('listAjax')%}",
    "search_names": ["where[*]", "search[*]", "like[*]", "between[*]", "orderBy[*]"],
    "form_convention": "dialog id usually user-edit-dialog, lay-filter=form-save",
    "confidence": "high"
  },
  "naming_rules": {
    "controller": "{Entity}Controller",
    "model": "{Entity}Model",
    "view_dir": "lowercase entity",
    "pk_default": "id",
    "admin_module": "Admin"
  },
  "migration_rules": {
    "prefix": "typecho_",
    "must_have": ["up", "down"],
    "execution": "generate only, no auto run"
  },
  "known_exceptions": [
    {
      "topic": "delete action naming",
      "variants": ["deleteAction", "delAction", "delAllAction"],
      "default_pick": "delAction",
      "confidence": "medium"
    },
    {
      "topic": "list query key",
      "variants": ["where", "search", "like", "between"],
      "default_pick": "mix by field type",
      "confidence": "high"
    }
  ],
  "update_policy": {
    "on_each_requirement": "append at least one validated pattern or one corrected assumption",
    "on_conflict": "preserve old pattern and add conflict note with confidence downgrade"
  }
}


path: skill_spec.md
content: # LQS Skill 实施规范（MVP）

## 1. 目标
输入自由文本需求或 Google Doc 导出的正文文本，先做需求分析，再基于项目现有代码模式自动沉淀模板，最终生成后台默认工件：Model、Controller、View、Migration。

重点：模板来自项目分析，不依赖固定脚手架命令，也不依赖仓库内专用执行器代码。

## 2. MVP 边界
- 支持输入：
  - 纯文本需求
  - Google Doc 导出的正文文本（手动粘贴或外部抓取后粘贴）
- 默认产物：`model,controller,view,migration`
- 默认模块：`Admin`
- 默认控制器基类：`BackendBaseController`
- 默认行为：先预览 diff，确认后写入

## 3. 端到端流程
1) Ingest
- 接收自由文本或“已提取的文档正文”
- 对输入正文做归一化与清洗（标题编号、注释、页眉页脚）

2) Analyze
- 输出需求草案 `RequirementDraft`
- 内容：实体、字段、动作、页面、约束、验收点

3) Mine Patterns
- 从项目现有控制器/视图/模型提取高频模式
- 产出 `ProjectPatternProfile`

4) Build Templates
- 用 `ProjectPatternProfile` 生成模板包 `TemplatePack`
- 模板包括：controller/model/view/migration

5) Resolve Spec
- 将 `RequirementDraft` 映射为 `Spec`
- 补全默认值（模块、前缀、基类、命名）

6) Render Preview
- 使用 `TemplatePack + Spec` 生成候选文件
- 输出 unified diff（dry-run）

7) Confirm & Write
- 用户 approve 后，由外部执行环境或人工确认写入
- 返回变更清单 + 风险提示

## 4. 数据对象

### 4.1 RequirementDraft
- feature_name
- business_goal
- entities[]
- actions[]
- ui_pages[]
- constraints[]
- acceptance[]

### 4.2 ProjectPatternProfile
- controller_patterns
- view_patterns
- response_contract
- naming_rules
- path_rules
- migration_rules

### 4.3 Spec
- module
- entity
- table
- pk
- fields[]
- apis[]
- artifacts[]
- target_paths

## 5. 默认路径规则（后台）
- Controller: `application/modules/Admin/controllers/{Entity}.php`
- Model: `application/models/{Entity}Model.php`
- View: `application/modules/Admin/views/{entity}/index.tpl`
- Migration: `migrations/{timestamp}_{action}_{table}.php`

## 6. 质量门槛
- Parse 准确率：字段与动作不漏主语义
- Diff 可读：新增/修改/覆盖分组
- Migration 合规：必须含 `up()` 与 `down()`
- 安全：不含任何凭证

## 7. 非目标（MVP）
- 不做自动执行 migration
- 不做复杂权限系统自动接入
- 不做跨模块联动代码重写
- 不在仓库内维护专用 Skill 命令执行器


path: mvp_delivery_checklist.md
content: # LQS Skill MVP 交付清单

> 说明：当前以“可实施交付”为目标。
> - [x] = 规范/模板资产已完成
> - [ ] = 后续可选集成项

## A. 输入能力
- [x] 支持自由文本输入
- [x] 支持 Google Doc 导出正文输入（手动粘贴或外部抓取后粘贴）
- [x] 文本归一化（基础版）

## B. 需求分析
- [x] 生成 RequirementDraft
- [x] 识别实体、字段、操作、后台页面
- [x] 输出缺失项（如主键/状态字段）建议（assumptions）

## C. 项目分析与模板沉淀
- [x] 扫描 Admin 代表性控制器
- [x] 扫描 Admin 代表性 views 模板
- [x] 归纳查询参数与响应结构
- [x] 自动产出 TemplatePack（controller/model/view/migration）

## D. 规格解析与渲染
- [x] RequirementDraft -> Spec（Schema 与 Prompt 已定义）
- [x] 默认模块 Admin
- [x] 默认基类 BackendBaseController
- [x] 使用 typecho_ 前缀生成 migration 表名

## E. 预览与写入
- [x] 默认 dry-run 输出 unified diff（Prompt 与流程已定义）
- [x] approve 后写入文件（Prompt 已定义）
- [x] 输出最终变更清单（路径、类型、风险）（Schema 已定义）

## F. 验收用例
- [x] 输入"文章管理 CRUD"可生成四类工件（样例与模板已就绪）
- [x] 输出路径符合项目目录规则
- [x] migration 具备 up/down
- [x] 全流程不包含任何凭证

## G. 渲染执行层
- [x] RenderPlan Schema 定义完成
- [x] 渲染 Prompt（Spec -> RenderPlan）完成
- [x] Diff Prompt（RenderPlan -> unified diff）完成
- [x] Article 全链路样例（RequirementDraft/Spec/RenderPlan）完成

## H. 非代码化流程约束
- [x] Skill 流程不依赖仓库内命令执行器
- [x] 交付以 Prompt / Schema / Template 为核心
- [x] 保留后续外部集成空间，但不在仓库内固化执行代码

## I. 纯自然语言推断能力（核心目标）
- [x] 不要求执行器、不要求编码、不要求命令行
- [x] 每轮输出包含 assumptions/evidence/confidence/ambiguities
- [x] 歧义项可保留，但必须显式记录默认处理策略
- [x] 每轮至少沉淀一条可复用上下文或模式修正

## J. 渐进式精度验收
- [x] 第二轮分析相比第一轮，歧义项数量减少或定义更精确
- [x] 低置信度项在后续轮次转为中/高置信度，或给出明确保留原因
- [x] 需求变化时，能保留旧模式并新增例外说明，避免“覆盖式遗忘”


path: quickstart.md
content: # LQS Skill Quickstart

> 定位：纯自然语言分析 Skill。
> 不要求执行器、不要求编码、不要求命令行、不要求内置抓取。

## 使用方式
- 输入一段自由文本需求，或一份 Google Doc 需求文档正文
- 先用 [.skill/prompts/01_parse_requirement.md](.skill/prompts/01_parse_requirement.md) 生成 `RequirementDraft`
- 再用 [.skill/prompts/04_resolve_spec.md](.skill/prompts/04_resolve_spec.md) 生成 `Spec`
- 再用 [.skill/prompts/05_render_artifacts.md](.skill/prompts/05_render_artifacts.md) 生成 `RenderPlan`
- 最后用 [.skill/prompts/06_preview_diff.md](.skill/prompts/06_preview_diff.md) 做 dry-run diff 预览

## 推荐输入
- 需求示例： [.skill/examples/free_text_input_example.md](.skill/examples/free_text_input_example.md)
- Google Doc 约定： [.skill/examples/google_doc_ingest_contract.md](.skill/examples/google_doc_ingest_contract.md)

## 推荐输出
- `RequirementDraft`
- `Spec`
- `RenderPlan`
- `Preview Diff`
- `ChangeReport`

## 每轮分析的必带结构
- `assumptions`：本轮做了哪些默认推断
- `evidence`：每条关键推断来自哪里
- `confidence`：整体置信度（high/medium/low）
- `ambiguities`：尚未完全确定、但已给出默认处理策略的点

## 逐轮变准（最小闭环）
1. 先保证主语义可落地（实体/动作/页面）
2. 把不确定项显式列入 `ambiguities`
3. 完成后回写一条新证据或修正一条旧假设到上下文
4. 下一轮优先处理上轮歧义项

## 注意
- 整个流程以 Prompt、Schema、Template 为主，不依赖仓库内命令执行器。
- migration 只生成预览与文件，不自动执行。
- 默认后台模块：Admin。
- 默认控制器基类：BackendBaseController。


path: implementation_runbook.md
content: # LQS Skill 实施 Runbook（纯自然语言版）

说明：本 Runbook 面向 Prompt / Template / Schema 驱动的 Skill 流程，核心是“上下文完备 + 渐进式推断精度提升”，不依赖仓库内命令执行器。

## 0) 核心原则（必须遵守）
1. 不引入执行器，不要求编码，不要求命令行流程。
2. 所有推断都要显式给出：`assumptions`、`evidence`、`confidence`。
3. 允许不确定，但必须沉淀到 `ambiguities`，并在下一轮收敛。
4. 每次需求处理后，至少回写一条“可复用模式”到上下文或 patterns。
5. 默认先求稳，再求全：先覆盖主语义，再补细节分支。

---

## 阶段 1：准备（上下文对齐）
输入：
- .skill/context.json
- 目标需求文本或文档正文

输出：
- 需求原文（脱敏）
- 本轮分析范围声明（本轮覆盖/暂不覆盖）

通过标准：
- 不包含数据库凭证
- 明确边界：是“后台 CRUD”，还是“含权限/工作流/跨模块”

## 阶段 2：需求解析（RequirementDraft）
执行：
- 使用 prompts/01_parse_requirement.md
- 输出 RequirementDraft（符合 schemas/requirement_draft.schema.json）

额外要求：
- 同时输出：`assumptions[]`、`evidence[]`、`confidence`、`ambiguities[]`

通过标准：
- 至少识别 1 个实体
- 至少识别 4 个基础动作（list/view/create/update/delete 可合并）
- 每个关键推断都有证据来源（用户原文/项目上下文/历史模式）

## 阶段 3：项目模式挖掘（ProjectPatternProfile）
执行：
- 使用 prompts/02_mine_patterns.md
- 扫描 Admin 控制器 + Admin views 样本

输出：
- ProjectPatternProfile

额外要求：
- 给高频模式标记置信度（高/中/低）
- 标记例外场景（exceptions）

通过标准：
- 明确 query_contract 与 response_contract
- 明确控制器与视图骨架
- 有“模式适用范围”和“已知例外”

## 阶段 4：模板资产化（TemplatePack）
执行：
- 使用 prompts/03_build_templates.md
- 更新 templates/template_pack.blueprint.json

输出：
- TemplatePack（controller/model/view/migration）

通过标准：
- 每个模板具备 placeholder 清单与适配条件
- 每个模板都注明“何时不该套用”

## 阶段 5：生成规格（Spec）
执行：
- 使用 prompts/04_resolve_spec.md
- 产出 Spec（符合 schemas/spec.schema.json）

额外要求：
- 输出 `assumptions`、`evidence`、`confidence`、`ambiguities`

通过标准：
- 默认 module=Admin
- 默认 base_controller=BackendBaseController
- migration 前缀=typecho_
- 对低置信度字段给出“待确认项”

补充产物：
- 示例：.skill/examples/article.spec.json

## 阶段 6：预览（RenderPlan + Diff）
执行：
- 使用 prompts/05_render_artifacts.md 输出 RenderPlan
- 依据 RenderPlan 渲染目标文件文本
- 使用 prompts/06_preview_diff.md 输出 unified diff（默认 dry-run）

通过标准：
- 显示新增/修改/覆盖类别
- 给出冲突风险提示
- 标记“基于假设的变更块”

补充产物：
- Schema：.skill/schemas/render_plan.schema.json
- 示例：.skill/examples/article.render_plan.json

## 阶段 7：确认与沉淀（关键增量）
执行：
- 用户确认后（approve/edit/reject），记录本轮结论
- 将“被验证正确/错误的推断”回写上下文

输出：
- 变更清单
- 未覆盖项提示
- 迭代记忆（本轮新增模式、修正点、剩余歧义）

通过标准：
- 仅写入批准文件
- 完整记录目标路径
- 形成下轮可复用证据

---

## 迭代精度策略（每轮必须做）
1. 本轮新增证据 >= 1 条。
2. 本轮歧义项减少或更具体（即使未归零）。
3. 本轮“低置信度推断”数量不高于上一轮，或解释更充分。
4. 如果遇到新类型需求，将其归类并更新 context/patterns 的边界说明。


path: schemas/project_pattern_profile.schema.json
content: {
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://lqs.local/skill/schemas/project_pattern_profile.schema.json",
  "title": "ProjectPatternProfile",
  "type": "object",
  "required": ["controller_patterns", "query_contract", "response_contract", "view_patterns"],
  "properties": {
    "source": { "type": "object" },
    "controller_patterns": { "type": "object" },
    "query_contract": { "type": "object" },
    "response_contract": { "type": "object" },
    "view_patterns": { "type": "object" },
    "naming_rules": { "type": "object" },
    "migration_rules": { "type": "object" }
  }
}


path: schemas/change_report.schema.json
content: {
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://lqs.local/skill/schemas/change_report.schema.json",
  "title": "ChangeReport",
  "type": "object",
  "required": ["mode", "summary", "files"],
  "properties": {
    "mode": { "type": "string", "enum": ["dry-run", "write"] },
    "summary": {
      "type": "object",
      "required": ["added", "modified", "skipped"],
      "properties": {
        "added": { "type": "integer" },
        "modified": { "type": "integer" },
        "skipped": { "type": "integer" }
      }
    },
    "files": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["path", "status"],
        "properties": {
          "path": { "type": "string" },
          "status": { "type": "string", "enum": ["added", "modified", "skipped"] },
          "reason": { "type": "string" }
        }
      }
    },
    "risks": {
      "type": "array",
      "items": { "type": "string" }
    }
  }
}


path: schemas/template_pack.schema.json
content: {
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://lqs.local/skill/schemas/template_pack.schema.json",
  "title": "TemplatePack",
  "type": "object",
  "required": ["version", "templates"],
  "properties": {
    "version": { "type": "string" },
    "generated_at": { "type": "string" },
    "origin": { "type": "string" },
    "templates": {
      "type": "object",
      "required": ["controller", "model", "view", "migration"],
      "properties": {
        "controller": { "type": "object", "required": ["path", "target"] },
        "model": { "type": "object", "required": ["path", "target"] },
        "view": { "type": "object", "required": ["path", "target"] },
        "migration": { "type": "object", "required": ["path", "target"] }
      }
    },
    "contracts": { "type": "object" }
  }
}


path: schemas/render_plan.schema.json
content: {
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://lqs.local/skill/schemas/render_plan.schema.json",
  "title": "RenderPlan",
  "type": "object",
  "required": ["entity", "artifacts", "outputs"],
  "properties": {
    "entity": { "type": "string" },
    "module": { "type": "string" },
    "artifacts": { "type": "array", "items": { "type": "string" } },
    "outputs": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["artifact", "template", "target", "variables"],
        "properties": {
          "artifact": { "type": "string" },
          "template": { "type": "string" },
          "target": { "type": "string" },
          "variables": { "type": "object" }
        }
      }
    }
  }
}


path: schemas/requirement_draft.schema.json
content: {
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://lqs.local/skill/schemas/requirement_draft.schema.json",
  "title": "RequirementDraft",
  "type": "object",
  "required": ["feature_name", "entities", "actions"],
  "properties": {
    "feature_name": { "type": "string", "minLength": 1 },
    "business_goal": { "type": "string" },
    "entities": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "fields"],
        "properties": {
          "name": { "type": "string" },
          "fields": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["name", "type"],
              "properties": {
                "name": { "type": "string" },
                "type": { "type": "string" },
                "required": { "type": "boolean" },
                "default": {},
                "enum": { "type": "array", "items": { "type": "string" } },
                "description": { "type": "string" }
              }
            }
          }
        }
      }
    },
    "actions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["method", "path", "action"],
        "properties": {
          "method": { "type": "string" },
          "path": { "type": "string" },
          "action": { "type": "string" },
          "params": { "type": "array", "items": { "type": "string" } }
        }
      }
    },
    "ui_pages": { "type": "array", "items": { "type": "string" } },
    "constraints": { "type": "array", "items": { "type": "string" } },
    "acceptance": { "type": "array", "items": { "type": "string" } },
    "assumptions": { "type": "array", "items": { "type": "string" } },
    "evidence": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["claim", "source"],
        "properties": {
          "claim": { "type": "string" },
          "source": { "type": "string", "enum": ["requirement", "context", "pattern", "history"] },
          "detail": { "type": "string" }
        }
      }
    },
    "confidence": { "type": "string", "enum": ["high", "medium", "low"] },
    "ambiguities": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["topic", "impact"],
        "properties": {
          "topic": { "type": "string" },
          "impact": { "type": "string" },
          "default_resolution": { "type": "string" },
          "confidence": { "type": "string", "enum": ["high", "medium", "low"] }
        }
      }
    }
  }
}


path: schemas/spec.schema.json
content: {
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://lqs.local/skill/schemas/spec.schema.json",
  "title": "SkillSpec",
  "type": "object",
  "required": ["module", "entity", "table", "fields", "artifacts"],
  "properties": {
    "module": { "type": "string", "default": "Admin" },
    "entity": { "type": "string" },
    "table": { "type": "string" },
    "pk": { "type": "string", "default": "id" },
    "base_controller": { "type": "string", "default": "BackendBaseController" },
    "fields": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "type"],
        "properties": {
          "name": { "type": "string" },
          "type": { "type": "string" },
          "required": { "type": "boolean" },
          "default": {},
          "enum": { "type": "array", "items": { "type": "string" } },
          "searchable": { "type": "boolean" },
          "editable": { "type": "boolean" },
          "label": { "type": "string" }
        }
      }
    },
    "apis": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["method", "path", "action"],
        "properties": {
          "method": { "type": "string" },
          "path": { "type": "string" },
          "action": { "type": "string" }
        }
      }
    },
    "artifacts": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["controller", "model", "view", "migration", "test"]
      },
      "default": ["controller", "model", "view", "migration"]
    },
    "target_paths": {
      "type": "object",
      "properties": {
        "controller": { "type": "string" },
        "model": { "type": "string" },
        "view": { "type": "string" },
        "migration": { "type": "string" }
      }
    },
    "assumptions": { "type": "array", "items": { "type": "string" } },
    "evidence": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["mapping", "source"],
        "properties": {
          "mapping": { "type": "string" },
          "source": { "type": "string", "enum": ["requirement", "context", "template_pack", "pattern", "history"] },
          "detail": { "type": "string" }
        }
      }
    },
    "confidence": { "type": "string", "enum": ["high", "medium", "low"] },
    "ambiguities": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["topic", "impact"],
        "properties": {
          "topic": { "type": "string" },
          "impact": { "type": "string" },
          "default_resolution": { "type": "string" },
          "next_step": { "type": "string" }
        }
      }
    }
  }
}


path: examples/google_doc_ingest_contract.md
content: # Google Doc 输入约定（MVP）

## 输入
- Google Doc 公开链接（只读）

## 处理
1. 抓取文档正文
2. 转为纯文本/Markdown（保留标题层级与列表）
3. 删除无关块（页眉页脚、评论、修订标记）
4. 输出给需求解析 Prompt（01_parse_requirement）

## 输出
- RequirementDraft JSON
- 同步输出 assumptions（若字段类型或动作缺失）

## 安全
- 不缓存原始链接中的敏感参数
- 不写入任何凭证到 .skill 目录


path: examples/article.requirement_draft.json
content: {
  "feature_name": "文章管理",
  "business_goal": "后台管理文章，支持列表筛选与增删改",
  "entities": [
    {
      "name": "Article",
      "fields": [
        { "name": "id", "type": "int", "required": true, "description": "主键" },
        { "name": "title", "type": "string", "required": true },
        { "name": "content", "type": "text", "required": true },
        { "name": "author_id", "type": "int", "required": true },
        { "name": "status", "type": "enum", "enum": ["draft", "active"], "default": "active" },
        { "name": "created_at", "type": "datetime" },
        { "name": "updated_at", "type": "datetime" }
      ]
    }
  ],
  "actions": [
    { "method": "GET", "path": "/admin/article/index", "action": "index" },
    { "method": "GET", "path": "/admin/article/listAjax", "action": "listAjax" },
    { "method": "POST", "path": "/admin/article/save", "action": "save" },
    { "method": "POST", "path": "/admin/article/delete", "action": "delete" }
  ],
  "ui_pages": ["admin/article/index"],
  "constraints": ["兼容 layui table", "支持 where/like/between/orderBy"],
  "acceptance": ["可预览 diff", "确认后写入"]
  ,
  "assumptions": [
    "列表页默认 Admin 模块，路由 /admin/article/*",
    "删除行为为硬删（直接 DELETE），未明确软删需求",
    "author_id 关联 members 表，本期仅存 ID 不做联查"
  ],
  "evidence": [
    { "claim": "字段列表来自需求原文逐条映射", "source": "requirement", "detail": "id/title/content/status/author_id/created_at/updated_at 均在需求文本中明确" },
    { "claim": "default module=Admin", "source": "context", "detail": "context.json defaults.new_backoffice_module=Admin" },
    { "claim": "where/like/between 筛选类型来自 query_contract", "source": "pattern", "detail": "project_pattern_profile.json field_heuristics: id→where, title→like, created_at→between" }
  ],
  "confidence": "high",
  "ambiguities": [
    {
      "topic": "删除行为：软删还是硬删",
      "impact": "影响 Model 是否需要 SoftDeletes、列表是否需要回收站",
      "default_resolution": "默认硬删，等后续需求明确",
      "confidence": "medium"
    }
  ]
}


path: examples/article.spec.json
content: {
  "module": "Admin",
  "entity": "Article",
  "table": "typecho_articles",
  "pk": "id",
  "base_controller": "BackendBaseController",
  "fields": [
    { "name": "id", "type": "int", "required": true, "label": "ID", "searchable": true, "editable": false },
    { "name": "title", "type": "string", "required": true, "label": "标题", "searchable": true, "editable": true },
    { "name": "content", "type": "text", "required": true, "label": "内容", "searchable": false, "editable": true },
    { "name": "author_id", "type": "int", "required": true, "label": "作者", "searchable": true, "editable": true },
    { "name": "status", "type": "enum", "enum": ["draft", "active"], "default": "active", "label": "状态", "searchable": true, "editable": true },
    { "name": "created_at", "type": "datetime", "label": "创建时间", "searchable": true, "editable": false },
    { "name": "updated_at", "type": "datetime", "label": "更新时间", "searchable": true, "editable": false }
  ],
  "apis": [
    { "method": "GET", "path": "/admin/article/index", "action": "index" },
    { "method": "GET", "path": "/admin/article/listAjax", "action": "listAjax" },
    { "method": "POST", "path": "/admin/article/save", "action": "save" },
    { "method": "POST", "path": "/admin/article/delete", "action": "delete" }
  ],
  "artifacts": ["controller", "model", "view", "migration"]
  ,
  "assumptions": [
    "table 前缀 typecho_ 来自 context defaults.migration_prefix",
    "base_controller=BackendBaseController，Admin 模块默认值",
    "delete 操作映射到 HoutaiRepository.delAction（非 deleteAction）"
  ],
  "evidence": [
    { "mapping": "entity=Article → controller path", "source": "template_pack", "detail": "admin_controller.txt target: application/modules/{{module}}/controllers/{{Entity}}.php" },
    { "mapping": "table=typecho_articles", "source": "context", "detail": "context defaults.migration_prefix=typecho_，实体名 article → typecho_articles" },
    { "mapping": "searchable fields → query_contract", "source": "pattern", "detail": "id:where, title:like, status:where, created_at:between，来自 project_pattern_profile field_heuristics" }
  ],
  "confidence": "high",
  "ambiguities": [
    {
      "topic": "删除行为：软删还是硬删",
      "impact": "Model 是否引入 SoftDeletes",
      "default_resolution": "本版本按硬删生成，migration 不加 deleted_at",
      "next_step": "如需软删，在 RequirementDraft constraints 中显式标注"
    }
  ]
}


path: examples/free_text_input_example.md
content: # 需求示例

做一个后台“文章管理”功能，支持列表、搜索、创建、编辑、删除。

字段：
- id: 主键
- title: 标题，必填
- content: 内容，必填
- status: 状态（draft,active），默认 active
- author_id: 作者ID，必填
- created_at: 创建时间
- updated_at: 更新时间

后台页面要求：
- 列表支持 where[id], like[title], where[status] 和创建时间 between
- 列表返回兼容当前 Admin layui table
- 提供弹窗编辑表单


path: examples/article.render_plan.json
content: {
  "entity": "Article",
  "module": "Admin",
  "artifacts": ["controller", "model", "view", "migration"],
  "outputs": [
    {
      "artifact": "controller",
      "template": ".skill/templates/generated/admin_controller.txt",
      "target": "application/modules/Admin/controllers/Article.php",
      "variables": {
        "module": "Admin",
        "Entity": "Article",
        "entity": "article",
        "base_controller": "BackendBaseController",
        "pk": "id",
        "model_class": "ArticleModel",
        "index_assignments": "",
        "list_item_mapping": "",
        "search_where_logic": "",
        "format_key_logic": "",
        "log_desc": "文章管理",
        "desc_logic": "return '';"
      }
    },
    {
      "artifact": "model",
      "template": ".skill/templates/generated/admin_model.txt",
      "target": "application/models/ArticleModel.php",
      "variables": {
        "Entity": "Article",
        "table": "typecho_articles",
        "pk": "id",
        "timestamps": "true",
        "fillable_lines": "    'title',\n    'content',\n    'author_id',\n    'status',",
        "casts_lines": "",
        "relations_block": ""
      }
    },
    {
      "artifact": "view",
      "template": ".skill/templates/generated/admin_index_view.txt",
      "target": "application/modules/Admin/views/article/index.tpl",
      "variables": {
        "page_title": "文章管理",
        "entity": "article",
        "Entity": "Article",
        "search_fields_block": "",
        "table_columns_block": "",
        "toolbar_buttons_block": "",
        "operate_buttons_block": "",
        "form_fields_block": ""
      }
    },
    {
      "artifact": "migration",
      "template": ".skill/templates/generated/migration_create_table.txt",
      "target": "migrations/202603170001_create_typecho_articles.php",
      "variables": {
        "table": "typecho_articles",
        "class_name": [REDACTED_SECRET],
        "fields_block": "",
        "fields_json": "[]",
        "indexes_block": "",
        "down_drop_table": ""
      }
    }
  ]
}


path: context.json
content: {
  "project": "lqs",
  "scanTime": "2026-03-17T00:00:00Z",
  "summary": {
    "models_count": 155,
    "modules_controllers_count": 159,
    "modules": [
      { "name": "Api", "controllers_sample": ["HomeController", "UserController", "OrderController", "NotifyController", "ContentsController"] },
      { "name": "Admin", "controllers_sample": ["IndexController", "PostController", "MembersController", "OrdersController", "SettingController"] },
      { "name": "Script", "controllers_sample": ["ImageController", "CronController", "ImportController"] },
      { "name": "Transit", "controllers_sample": ["IndexController"] },
      { "name": "Pro", "controllers_sample": ["IndexController"] },
      { "name": "Index", "controllers_sample": ["IndexController"] },
      { "name": "Web", "controllers_sample": ["WebController"] },
      { "name": "Home", "controllers_sample": ["HomeController"] }
    ],
    "base_controllers": [
      "BackendBaseController",
      "WebBaseController",
      "RemoteBaseController",
      "Controller_Abstract",
      "\\Yaf\\Controller_Abstract"
    ],
    "entry_scripts": ["api.php", "web.php", "m.php", "t.php", "admin.php", "d.php", "index.php"],
    "router_plugin": {
      "path": "application/plugins/Router.php",
      "notes": "script-name routing logic + theme controller override + module/controller/action rewrite"
    },
    "bootstrap": "application/bootstrap/Bootstrap.php",
    "notes": "multi-module Yaf app; CLI routes to Index/Command/index"
  },
  "databases": [
    { "section": "common", "database": "lqs", "prefix": "typecho_", "note": "credentials removed" },
    { "section": "im", "database": "im_duoshan", "prefix": "im_", "note": "credentials removed" },
    { "section": "mhsync", "database": "down_dm", "prefix": "wyw_", "note": "credentials removed" },
    { "section": "tbr", "database": "t_bure", "prefix": "tbr_", "note": "credentials removed" }
  ],
  "defaults": {
    "new_backoffice_module": "Admin",
    "new_backoffice_base_controller": "BackendBaseController",
    "migration_prefix": "typecho_"
  },
  "nl_analysis_policy": {
    "mode": "pure-natural-language",
    "no_executor": true,
    "no_code_required": true,
    "no_command_required": true,
    "no_builtin_google_doc_fetch": true,
    "principles": [
      "context first, inference second",
      "always output assumptions/evidence/confidence",
      "allow ambiguity but keep an explicit ambiguity backlog",
      "improve a little every iteration"
    ]
  },
  "inference_memory": {
    "confidence_scale": {
      "high": "evidence from user requirement + project pattern both support",
      "medium": "evidence from one side only, another side inferred",
      "low": "weak evidence, temporary assumption"
    },
    "domain_glossary": {
      "后台": "Admin module pages and actions",
      "列表": "index page + listAjax data API + pagination",
      "保存": "save action handling create/update",
      "删除": "delete/delAction style destructive action",
      "预览": "dry-run diff before write"
    },
    "known_preference_order": [
      "match existing Admin conventions first",
      "prefer low-risk defaults when requirement is ambiguous",
      "mark unresolved items explicitly instead of overfitting"
    ],
    "ambiguity_backlog": [
      {
        "id": "AMB-001",
        "topic": "status 字段语义",
        "why": "不同业务使用 draft/active 或 0/1，表达不一致",
        "default_resolution": "优先沿用需求原词；若缺失则使用 enum 并在 assumptions 标记",
        "confidence": "medium"
      },
      {
        "id": "AMB-002",
        "topic": "删除行为是软删还是硬删",
        "why": "现有模块行为不完全统一",
        "default_resolution": "默认按现有模式输出 delAction 风格删除动作，并在 constraints 中显式标记",
        "confidence": "medium"
      },
      {
        "id": "AMB-003",
        "topic": "列表筛选优先 where 还是 like",
        "why": "字段类型与业务意图常缺失",
        "default_resolution": "id/status 用 where，标题类文本用 like",
        "confidence": "high"
      }
    ],
    "iteration_log_template": {
      "new_evidence": [],
      "fixed_misjudgements": [],
      "new_patterns": [],
      "remaining_ambiguities": []
    }
  },
  "generation_guidelines": {
    "db_migrations": "Generate migration files only; do not execute automatically.",
    "controllers": "Respect existing base controllers and module paths.",
    "preview_mode": "Always support dry-run and produce diffs before write.",
    "safety": "Never include credentials in prompts/cache/artifacts."
  }
}


path: prompts/03_build_templates.md
content: 你是模板资产生成器。

输入：
1) ProjectPatternProfile JSON

任务：
- 生成模板定义（非具体业务代码）
- 输出 TemplatePack 清单：controller/model/view/migration
- 每个模板给出 placeholders、默认值、适用模块、禁用条件

输出：TemplatePack JSON。
仅输出 JSON。


path: prompts/07_write_files.md
content: 你是 LQS Skill 的写入执行器。

输入：
1) RenderPlan JSON
2) 用户确认状态（approve/edit/reject）
3) 渲染后的文件内容映射

任务：
- 仅当状态为 approve 时写入文件
- 生成 ChangeReport JSON（新增/修改/跳过）
- 对覆盖文件给出备份建议

约束：
- 不执行 migration
- 不写入任何凭证
- 保留 dry-run 模式

输出：仅 ChangeReport JSON。


path: prompts/05_render_artifacts.md
content: 你是 LQS Skill 的模板渲染器。

输入：
1) Spec JSON
2) TemplatePack JSON
3) path_rules.json

任务：
- 为每个 artifact 计算 target path
- 用 spec 字段填充模板占位符
- 输出 RenderPlan JSON（不直接写文件）

约束：
- 默认 module=Admin
- 默认 base_controller=BackendBaseController
- migration 表名前缀使用 typecho_
- 输出必须包含 variables，便于审计与 dry-run

输出：仅 RenderPlan JSON。


path: prompts/01_parse_requirement.md
content: 你是 LQS 项目的需求分析器。

输入：
1) 自由文本需求或 Google Doc 提取正文
2) 项目上下文 JSON（.skill/context.json）

任务：
- 提取 feature 名称、实体、字段、动作、后台页面诉求
- 输出 RequirementDraft JSON
- 如果信息缺失，按最小后台 CRUD 进行推断并标记 assumptions
- 每条关键推断都要给 evidence（来自需求原文/项目上下文/历史模式）
- 给出整体 confidence（high/medium/low）
- 输出 ambiguities（当前仍不确定但不阻塞主流程的点）

输出要求：
- 仅输出 JSON
- 不包含任何凭证
- 字段类型尽量使用 int/string/text/datetime/enum/bool
- 推荐附加字段：assumptions/evidence/confidence/ambiguities


path: prompts/04_resolve_spec.md
content: 你是规格解析器。

输入：
1) RequirementDraft JSON
2) .skill/context.json
3) TemplatePack JSON

任务：
- 输出最终 Spec JSON
- 默认 module=Admin
- 默认 base_controller=BackendBaseController
- migration table 前缀使用 context defaults.migration_prefix
- artifacts 默认 controller,model,view,migration
- 输出 assumptions（补全默认值时的前提）
- 输出 evidence（字段/动作映射依据）
- 输出 confidence（high/medium/low）
- 输出 ambiguities（仍需后续澄清但先按默认推进）

输出：仅 JSON。


path: prompts/02_mine_patterns.md
content: 你是 LQS 项目的模式挖掘器。

输入：
1) 项目代码片段（Admin 控制器/视图/模型）
2) 项目上下文 JSON

任务：
- 归纳控制器动作模式（index/listAjax/save/delete 等）
- 归纳查询参数契约（where/like/orderBy/page/limit）
- 归纳统一返回结构
- 归纳视图骨架（搜索区、table、弹窗表单、includes）

输出：ProjectPatternProfile JSON。
仅输出 JSON。


path: prompts/06_preview_diff.md
content: 你是 LQS Skill 的变更预览器。

输入：
1) RenderPlan JSON
2) 目标路径当前文件内容（可空）
3) 渲染后的新文件文本

任务：
- 输出统一 diff（unified diff）
- 按文件分组
- 标注风险：覆盖已有文件、主键不匹配、命名冲突

输出：
仅输出 diff 文本与风险摘要，不要输出解释性段落。


path: templates/generated/migration_add_menu.txt
content: <?php

use Illuminate\Database\Capsule\Manager as DB;

// 注意：生成器会把目标文件名设为 "{{timestamp}}_add_menu_{{module}}.php"
// 迁移加载器期望类名为 Migration{filename}，因此类名需包含 module。
class Migration{{timestamp}}_add_menu_{{module}}
{
    public function up()
    {
        // 请在生成时替换下面的变量：module, controller, action, name, p_id
        $module = '{{module}}';
        $controller = '{{controller}}';
        $action = '{{action}}';
        $name = '{{name}}';
        $p_id = {{p_id}};

        // 检查是否已存在（幂等插入）
        $checkSql = "select count(1) as c from `permissions` where `module` = ? and `controller` = ? and `action` = ?";
        $exists = DB::select($checkSql, [$module, $controller, $action]);
        $count = 0;
        if (!empty($exists) && isset($exists[0]->c)) {
            $count = intval($exists[0]->c);
        }

        if ($count === 0) {
            $sql = "insert into `permissions` (`p_id`,`module`,`controller`,`action`,`args`,`name`,`icon`) values (?, ?, ?, ?, '', ?, '')";
            DB::statement($sql, [$p_id, $module, $controller, $action, $name]);
        }
    }

    public function down()
    {
        // 回滚：删除由此迁移创建的菜单项（基于 module/controller/action/name 精确匹配）
        $module = '{{module}}';
        $controller = '{{controller}}';
        $action = '{{action}}';
        $name = '{{name}}';
        $sql = "delete from `permissions` where `module` = ? and `controller` = ? and `action` = ? and `name` = ?";
        DB::statement($sql, [$module, $controller, $action, $name]);
    }
}


path: templates/generated/template_pack.generated.json
content: {
  "version": "0.2.0",
  "generated_at": "2026-03-17",
  "origin": "mined_from_existing_admin_code",
  "templates": {
    "controller": {
      "path": ".skill/templates/generated/admin_controller.txt",
      "target": "application/modules/{{module}}/controllers/{{Entity}}.php",
      "defaults": {
        "module": "Admin",
        "base_controller": "BackendBaseController",
        "pk": "id"
      }
    },
    "model": {
      "path": ".skill/templates/generated/admin_model.txt",
      "target": "application/models/{{Entity}}Model.php",
      "defaults": {
        "pk": "id",
        "timestamps": "true"
      }
    },
    "view": {
      "path": ".skill/templates/generated/admin_index_view.txt",
      "target": "application/modules/{{module}}/views/{{entity}}/index.tpl",
      "defaults": {
        "module": "Admin"
      }
    },
    "migration": {
      "path": ".skill/templates/generated/migration_create_table.txt",
      "target": "migrations/{{timestamp}}_create_{{table}}.php",
      "defaults": {
        "prefix": "typecho_"
      }
    }
  },
  "contracts": {
    "query": ["where", "search", "like", "between", "orderBy", "page", "limit"],
    "response": ["count", "data", "msg", "desc", "code"]
  }
}


path: templates/generated/migration_create_table.txt
content: <?php

/**
 * Auto-generated migration template from LQS project patterns.
 * Note: generate only, do not auto-execute.
 */
class {{class_name}}
{
    public function up()
    {
        $table = '{{table}}';

        // 安全说明：优先使用结构化字段描述 `fields_json` 来生成字段定义，
        // `fields_json` 应为 JSON 数组，每项为 {"name":"col","type":"varchar","length":255,"nullable":false,"default":null}
        // 如果未提供 `fields_json`（空字符串），将回退到传统的 `fields_block` 文本插入（不推荐）。
        $fieldsSql = '';
        if (!empty('{{fields_json}}')) {
            $fields = json_decode('{{fields_json}}', true);
            if (!is_array($fields)) {
                throw new \Exception('Invalid fields_json provided for migration {{class_name}}');
            }
            $parts = [];
            $typeWhitelist = ['int','bigint','varchar','text','datetime','timestamp','tinyint','boolean','float','double','decimal'];
            foreach ($fields as $f) {
                if (!isset($f['name']) || !preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $f['name'])) {
                    throw new \Exception('Invalid column name in fields_json for migration {{class_name}}');
                }
                $name = $f['name'];
                $type = isset($f['type']) ? strtolower($f['type']) : 'varchar';
                if (!in_array($type, $typeWhitelist)) {
                    throw new \Exception('Unsupported column type: ' . $type);
                }
                $col = "`{$name}` ";
                if ($type === 'varchar') {
                    $len = isset($f['length']) ? intval($f['length']) : 255;
                    $col .= "VARCHAR({$len})";
                } elseif ($type === 'int') {
                    $col .= 'INT';
                } elseif ($type === 'bigint') {
                    $col .= 'BIGINT';
                } elseif ($type === 'text') {
                    $col .= 'TEXT';
                } elseif ($type === 'datetime') {
                    $col .= 'DATETIME';
                } elseif ($type === 'timestamp') {
                    $col .= 'TIMESTAMP';
                } elseif ($type === 'tinyint') {
                    $col .= 'TINYINT';
                } elseif ($type === 'boolean') {
                    $col .= 'TINYINT(1)';
                } elseif ($type === 'float' || $type === 'double' || $type === 'decimal') {
                    $col .= strtoupper($type);
                }
                $col .= isset($f['nullable']) && $f['nullable'] ? ' NULL' : ' NOT NULL';
                if (array_key_exists('default', $f) && $f['default'] !== null) {
                    $col .= " DEFAULT '" . addslashes($f['default']) . "'";
                }
                $parts[] = $col;
            }
            $fieldsSql = implode("\n", $parts);
        } else {
            // 回退：使用原始占位（注意安全）
            $fieldsSql = "{{fields_block}}";
        }

        $sql = <<<SQL
CREATE TABLE IF NOT EXISTS `{$table}` (
{$fieldsSql}
{{indexes_block}}
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
SQL;
        \DB::statement($sql);
    }

    public function down()
    {
        // Optional custom down logic
        {{down_drop_table}}
        $table = '{{table}}';
        $sql = "DROP TABLE IF EXISTS `{$table}`";
        \DB::statement($sql);
    }
}


path: templates/generated/admin_index_view.txt
content: {%include file="header.tpl"%}
<body>

<div class="page-loading">
    <div class="ball-loader">
        <span></span><span></span><span></span><span></span>
    </div>
</div>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">{{page_title}}</div>

                <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                    <div class="layui-form-item">
{{search_fields_block}}
                        <div class="layui-inline">
                            <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="search">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                            </button>
                        </div>
                    </div>
                </div>

                <div class="layui-card-body">
                    <table class="layui-table"
                           lay-data="{url:'{%url('listAjax')%}', page:true, id:'test',toolbar:'#toolbar'}"
                           lay-filter="table-toolbar">
                        <thead>
                        <tr>
{{table_columns_block}}
                            <th lay-data="{fixed: 'right',minWidth: 160 ,align:'center', toolbar: '#operate-toolbar'}">操作</th>
                        </tr>
                        </thead>
                    </table>

                    <script type="text/html" id="toolbar">
                        <div class="layui-btn-container">
{{toolbar_buttons_block}}
                        </div>
                    </script>

                    <script type="text/html" id="operate-toolbar">
{{operate_buttons_block}}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" class="data-dialog" id="user-edit-dialog">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>信息</legend>
    </fieldset>
    <form class="layui-form form-dialog" action="" lay-filter="form-save">
{{form_fields_block}}
    </form>
</script>

{%include file="fooler.tpl"%}


path: templates/generated/admin_controller.txt
content: <?php

/**
 * Auto-generated template from LQS project patterns.
 * Module: {{module}}
 * Entity: {{Entity}}
 */
class {{Entity}}Controller extends {{base_controller}}
{
    use \repositories\HoutaiRepository;

    /**
     * 列表页面渲染
     */
    public function indexAction()
    {
        {{index_assignments}}
        $this->display();
    }

    /**
     * 列表数据格式化
     * @return Closure
     */
    protected function listAjaxIteration()
    {
        return function ({{model_class}} $item) {
            {{list_item_mapping}}
            return $item;
        };
    }

    /**
     * 可选：where 特殊转换
     */
    protected function getSearchWhereParam()
    {
        {{search_where_logic}}
    }

    /**
     * 可选：字段名映射（如 aff_code -> aff）
     */
    protected function formatKey($key, $value)
    {
        {{format_key_logic}}
    }

    protected function getModelClass(): string
    {
        return {{model_class}}::class;
    }

    protected function getPkName(): string
    {
        return '{{pk}}';
    }

    protected function getLogDesc(): string
    {
        return '{{log_desc}}';
    }

    protected function getDesc($query): string
    {
        {{desc_logic}}
    }
}


path: templates/generated/admin_model.txt
content: <?php

/**
 * Auto-generated template from LQS project patterns.
 */
class {{Entity}}Model extends \Illuminate\Database\Eloquent\Model
{
    protected $table = '{{table}}';
    protected $primaryKey = '{{pk}}';
    public $timestamps = {{timestamps}};

    protected $fillable = [
{{fillable_lines}}
    ];

    protected $casts = [
{{casts_lines}}
    ];

{{relations_block}}
}


path: templates/template_pack.blueprint.json
content: {
  "version": "0.2.0",
  "generated_at": "2026-03-19",
  "origin": "project-mined",
  "templates": {
    "controller": {
      "path": ".skill/templates/generated/admin_controller.txt",
      "target": "application/modules/{{module}}/controllers/{{Entity}}.php",
      "defaults": {
        "module": "Admin",
        "base_controller": "BackendBaseController",
        "pk": "id"
      },
      "placeholders": [
        "module", "Entity", "base_controller",
        "pk", "model_class", "index_assignments",
        "list_item_mapping", "search_where_logic",
        "format_key_logic", "log_desc", "desc_logic"
      ],
      "placeholder_types": {
        "module": "identifier",
        "Entity": "identifier",
        "base_controller": "identifier",
        "pk": "identifier",
        "model_class": "identifier",
        "index_assignments": "string",
        "list_item_mapping": "string",
        "search_where_logic": "string",
        "format_key_logic": "string",
        "log_desc": "string",
        "desc_logic": "string"
      },
      "notes": "Requires HoutaiRepository trait; delete action is delAction not deleteAction"
    },
    "model": {
      "path": ".skill/templates/generated/admin_model.txt",
      "target": "application/models/{{Entity}}Model.php",
      "defaults": { "pk": "id", "timestamps": "true" },
      "placeholders": ["Entity", "table", "pk", "fillable_lines", "casts_lines", "relations_block", "timestamps"] ,
      "placeholder_types": {
        "Entity": "identifier",
        "table": "identifier",
        "pk": "identifier",
        "fillable_lines": "string",
        "casts_lines": "string",
        "relations_block": "string",
        "timestamps": "boolean"
      }
    },
    "view": {
      "path": ".skill/templates/generated/admin_index_view.txt",
      "target": "application/modules/{{module}}/views/{{entity}}/index.tpl",
      "defaults": { "module": "Admin" },
      "placeholders": [
        "page_title",
        "search_fields_block", "table_columns_block",
        "toolbar_buttons_block", "operate_buttons_block", "form_fields_block"
      ],
      "placeholder_types": {
        "page_title": "string",
        "search_fields_block": "string",
        "table_columns_block": "string",
        "toolbar_buttons_block": "string",
        "operate_buttons_block": "string",
        "form_fields_block": "string"
      }
    },
    "migration": {
      "path": ".skill/templates/generated/migration_create_table.txt",
      "target": "migrations/{{timestamp}}_create_{{table}}.php",
      "defaults": { "prefix": "typecho_" },
      "placeholders": ["class_name", "table", "fields_block", "indexes_block", "down_drop_table"],
      "placeholder_types": {
        "class_name": "identifier",
        "table": "identifier",
        "fields_block": "string",
        "indexes_block": "string",
        "down_drop_table": "string",
        "fields_json": "json"
      }
    }
    ,
    "migration_add_menu": {
      "path": ".skill/templates/generated/migration_add_menu.txt",
      "target": "migrations/{{timestamp}}_add_menu_{{module}}.php",
      "defaults": {},
      "placeholders": ["timestamp","module", "controller", "action", "name", "p_id"],
      "placeholder_types": {
        "timestamp": "identifier",
        "module": "identifier",
        "controller": "identifier",
        "action": "identifier",
        "name": "string",
        "p_id": "int"
      }
    }
  },
  "contracts": {
    "query": ["where", "search", "like", "between", "orderBy", "page", "limit"],
    "response": ["code", "msg", "desc", "count", "data"]
  }
}


path: templates/path_rules.json
content: {
  "defaults": {
    "module": "Admin",
    "base_controller": "BackendBaseController",
    "migration_prefix": "typecho_"
  },
  "paths": {
    "controller": "application/modules/{{module}}/controllers/{{Entity}}.php",
    "model": "application/models/{{Entity}}Model.php",
    "view": "application/modules/{{module}}/views/{{entity}}/index.tpl",
    "migration": "migrations/{{timestamp}}_create_{{table}}.php"
  },
  "naming": {
    "entity_class": "PascalCase",
    "entity_var": "snake_case",
    "table": "prefix + snake_plural"
  }
}


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (HIGH)