Skip to content

Commit 059ca89

Browse files
feat(semantic-layer-builder): add meta-skill for interface-to-semantic-layer modeling
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 18ab911 commit 059ca89

15 files changed

Lines changed: 780 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ SemanticSkills/
6767
| --- | --- | --- | --- |
6868
| `huawei-cloud-billing-scout` | 2.3.8 | **Huawei Cloud Read-Only Billing — Spend, Charges & Reconciliation** — one-page BSS briefing via KooCLI | [details](docs/skills/huawei-cloud-billing-scout.md) · [changelog](qa/huawei-cloud-billing-scout/CHANGELOG.md) |
6969
| `huawei-cloud-cost-estimation` | 1.0.0 | **Huawei Cloud Pre-Order Cost Estimation** — period and on-demand quotes via hcloud BSS | [details](docs/skills/huawei-cloud-cost-estimation.md) · [changelog](qa/huawei-cloud-cost-estimation/CHANGELOG.md) |
70+
| `semantic-layer-builder` | 0.1.0 | **Semantic Layer Builder** — meta-skill: interface → governed Kimball semantic layer + OKF export | [details](docs/skills/semantic-layer-builder.md) · [changelog](qa/semantic-layer-builder/CHANGELOG.md) |
7071

7172
Index: [docs/catalog.yml](docs/catalog.yml).
7273

docs/catalog.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,17 @@ skills:
3030
compatibility: hcloud KooCLI 7.2+, BSS IAM (bss:order:view permission), outbound network; no agent auto-install
3131
marketplaces: [skills-sh, skillsmp]
3232
distribution: direct-skill
33+
- id: semantic-layer-builder
34+
path: skills/semantic-layer-builder
35+
qa: qa/semantic-layer-builder
36+
display_name: "Semantic Layer Builder — Interface to Governed Semantic Layer (Meta-Skill)"
37+
display_name_zh: "语义层构建器 · 接口转语义元技能"
38+
domain: meta
39+
subdomains: [semantic-layer, dimensional-modeling, ontology, okf]
40+
summary: Meta-skill—turns a REST/OpenAPI, CLI, or table/DDL interface into a governed Kimball semantic layer via a guided one-fact-at-a-time interview (facts/grain/dimensions/measures/routing); emits semantic objects as repo YAML or markdown and a Google OKF v0.1 bundle; evidence-only, refuses to invent fields or values
41+
summary_zh: 元技能 · 把 REST/CLI/数据表接口逐项确认建成 Kimball 语义层(事实/粒度/维度/度量/路由);输出仓库 YAML 或 markdown,并可导出 Google OKF v0.1;只依据接口证据,不臆造
42+
version: "0.1.0"
43+
agents: [cursor, claude-code, codex, openclaw]
44+
compatibility: No external tools or network; pure modeling + file generation; optional YAML/markdown linter for validation
45+
marketplaces: [skills-sh, skillsmp]
46+
distribution: direct-skill
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# 语义层构建器(元技能)
2+
3+
`semantic-layer-builder` · **Semantic Layer Builder — Interface to Governed Semantic Layer (Meta-Skill)**
4+
5+
把一份**接口契约**(REST/OpenAPI、CLI 帮助、或数据表/DDL)通过**逐项确认**的引导式访谈,建成受治理的 Kimball 语义层:先锁事实与粒度,再挂维度与度量,最后按 Schema 生成语义对象。输出本仓 YAML 或 markdown,并可导出 **Google OKF v0.1**(推荐)。唯一真源是用户给的接口——**不臆造**字段、粒度、枚举或取值。
6+
7+
> **元技能** · 它生产的是「别的领域的语义层」,本身不连任何云或数据库。
8+
9+
**Version:** 0.1.0 · Changelog: [qa/semantic-layer-builder/CHANGELOG.md](../../qa/semantic-layer-builder/CHANGELOG.md)
10+
11+
## What it does
12+
13+
| Capability | Typical questions |
14+
| --- | --- |
15+
| Ingest interface | 把 REST/OpenAPI、CLI help、表/DDL 归一成操作清单 |
16+
| Confirm facts & grain | 「一行 = 什么」?锁定可证伪的 grain |
17+
| Model dimensions | conformed / snowflake / scope / degenerate / abstract / encoded_constant |
18+
| Model measures | 可加性(additive / semi / non-additive)+ 口径 |
19+
| Routing & boundary | entry_points 与 evidence_boundary(不能回答什么) |
20+
| Emit | 本仓 Kimball YAML / markdown / **Google OKF v0.1(推荐)** |
21+
| Out of scope | 不臆造接口未给的字段/枚举/取值;写操作只 frame 不擅自建模 |
22+
23+
## In-skill flow
24+
25+
```text
26+
Interface (REST / CLI / table)
27+
28+
29+
Phase 1 · Ingest ── 操作清单(name/method/safety/inputs/outputs/doc)
30+
31+
32+
Phase 1 · Frame ── fact | dimension-lookup | scope(按 fact·dimension·measure·time·scope 路由)
33+
34+
35+
Phase 2 · Confirm ── 一次一问,逐步回显小表:Facts&Grain → Dimensions → Measures → Selection/Pairing → Routing/Boundary
36+
37+
38+
Phase 3 · Emit ── 按 schema-spec 生成;okf-emitter 导出 OKF;跑 Conformance
39+
```
40+
41+
## SKILL.md structure
42+
43+
| Section | Purpose |
44+
| --- | --- |
45+
| Workflow | Phase 1 Ingest & Frame → Phase 2 Confirm(逐项)→ Phase 3 Emit |
46+
| Critical Rules | Evidence-only;grain first;one blocking ask;layer split;stable names |
47+
| Reference Index | 何时加载 playbook / schema-spec / okf-emitter / examples |
48+
49+
## Runtime bundle (install payload)
50+
51+
```text
52+
skills/semantic-layer-builder/
53+
├── SKILL.md
54+
└── references/
55+
├── elicitation-playbook.md # 抽取规则 + 确认顺序 + 检查表
56+
├── schema-spec.md # 语义对象 Schema 约束 + Conformance
57+
├── okf-emitter.md # Google OKF v0.1 映射 + 硬约束
58+
└── examples.md # 接口 → 确认 → YAML + OKF 端到端样例
59+
```
60+
61+
No `evals/`, `qa/`, or `*-workspace/` under `skills/`.
62+
63+
## QA (not installed with skill)
64+
65+
```text
66+
qa/semantic-layer-builder/
67+
├── validate.sh
68+
├── VERSION
69+
├── .markdownlint.json
70+
├── evals/evals.json # 5 offline eval cases
71+
└── assertions/README.md
72+
```
73+
74+
```bash
75+
./qa/semantic-layer-builder/validate.sh
76+
```
77+
78+
## Install
79+
80+
```bash
81+
npx skills add ontology-of-everything/SemanticSkills \
82+
--skill semantic-layer-builder \
83+
--agent cursor \
84+
--copy -y
85+
```
86+
87+
No external tools or network required — pure modeling and file generation.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"default": true,
3+
"MD003": { "style": "atx" },
4+
"MD004": { "style": "dash" },
5+
"MD013": { "line_length": 200, "code_blocks": false, "tables": false },
6+
"MD024": { "siblings_only": true },
7+
"MD033": false,
8+
"MD034": false,
9+
"MD040": false,
10+
"MD041": false,
11+
"MD046": false
12+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# semantic-layer-builder Changelog
2+
3+
Skill-only history. Repository tooling changes: [../../CHANGELOG.md](../../CHANGELOG.md).
4+
5+
## 0.1.0 - 2026-06-29
6+
7+
First release — meta-skill that turns an interface into a governed semantic layer.
8+
9+
### Features
10+
11+
- Guided, one-fact-at-a-time interview: Ingest → Frame → Confirm (facts/grain/dimensions/measures/routing) → Emit
12+
- Schema constraints for semantic objects (Kimball star/constellation): `catalog` (thin router) → shared-dimensions → model, in `references/schema-spec.md` with a Conformance checklist
13+
- Google OKF v0.1 export (recommended): concept-per-file mapping, reserved files, frontmatter, and OKF §9 hard-constraint check in `references/okf-emitter.md`
14+
- Evidence-only discipline: refuses to invent fields, grain, enums, or values; missing sources marked `TODO(verify)`
15+
- Ingest rules for REST/OpenAPI, CLI, and table/DDL inputs; end-to-end worked example (`references/examples.md`)
16+
17+
### qa
18+
19+
- `validate.sh` (layout, version sync, skills-ref, markdownlint, skillcheck)
20+
- Five offline evals in `evals/evals.json` (grain-first, no-invented-fields, OKF default target, one-blocking-ask, layer-split)
21+
22+
### Documentation
23+
24+
- `docs/skills/semantic-layer-builder.md`; `docs/catalog.yml` index entry
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# semantic-layer-builder QA
2+
3+
Per-skill quality gate. Run `validate.sh` locally and in CI via
4+
`tools/validate-all.sh`.
5+
6+
## Layout
7+
8+
```text
9+
qa/semantic-layer-builder/
10+
├── validate.sh # entry point (required)
11+
├── README.md
12+
├── evals/evals.json # Skill Creator eval cases
13+
├── assertions/README.md # assertion rubric for eval authors
14+
├── fixtures/ # optional: contract YAML, golden files
15+
└── bin/ # optional: helper scripts
16+
```
17+
18+
Add `fixtures/` and `bin/` when a skill needs cross-layer checks beyond
19+
`skills-ref`, markdownlint, and skillcheck.
20+
21+
## Commands
22+
23+
```bash
24+
./qa/semantic-layer-builder/validate.sh
25+
```

qa/semantic-layer-builder/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Assertions
2+
3+
Define objective checks for Skill Creator runs. Copy assertions into each eval in `../evals/evals.json`.
4+
5+
Include interaction-discipline cases when the skill has routing or scope decisions:
6+
7+
- User already stated scope, billing cycle, or read-only intent → agent proceeds without re-asking.
8+
- Blocking ID missing (partner customer, full order id) → one clarifying question, not a questionnaire.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"skill_name": "semantic-layer-builder",
3+
"evals": [
4+
{
5+
"id": 1,
6+
"name": "grain-first-before-dimensions",
7+
"prompt": "这是一个 REST 接口:GET /v1/orders 返回 { orders: [ { order_id, store_id, placed_at, total_amount } ] }。帮我建语义层。",
8+
"expected_output": "先确认事实与 grain(一行=一笔订单)再挂维度;回显小表请确认;不直接跳到生成。",
9+
"expectations": [
10+
"Identifies a fact for the orders array before listing dimensions",
11+
"States a falsifiable grain such as one row per order (orders[] element)",
12+
"Echoes a confirmation table (fact/grain or dimensions) and asks to confirm before emitting",
13+
"Does not produce final YAML/OKF before grain is confirmed"
14+
],
15+
"files": []
16+
},
17+
{
18+
"id": 2,
19+
"name": "no-invented-fields",
20+
"prompt": "把这个 CLI 转成语义层:`mytool list-invoices --customer` 输出每行 invoice_id, amount, currency。币种字典接口我没给你。",
21+
"expected_output": "只用给出的字段;缺失的字典来源标 TODO(verify),不编造 source_operations 或枚举值。",
22+
"expectations": [
23+
"Only models fields evidenced by the interface (invoice_id, amount, currency)",
24+
"Marks the missing currency dictionary source as TODO(verify) instead of inventing an operation",
25+
"Does not fabricate enum values, codes, or field paths not present in the input",
26+
"Lists open TODO(verify) items in the deliverable"
27+
],
28+
"files": []
29+
},
30+
{
31+
"id": 3,
32+
"name": "okf-default-target",
33+
"prompt": "我有一个 orders 表(order_id PK, store_id FK, placed_at, total_amount)。直接生成语义对象,用推荐格式。",
34+
"expected_output": "默认/推荐 Google OKF v0.1:每概念一文件、frontmatter 含非空 type、根 index.md 仅 okf_version;事实/维度/度量分别为 concept。",
35+
"expectations": [
36+
"Chooses Google OKF v0.1 as the recommended/default output target",
37+
"Each concept is one markdown file with YAML frontmatter containing a non-empty type",
38+
"Fact, dimension(s), and measure(s) are emitted as separate concepts",
39+
"Root index.md carries only okf_version frontmatter (or none in sub-index)"
40+
],
41+
"files": []
42+
},
43+
{
44+
"id": 4,
45+
"name": "one-blocking-ask-on-grain-ambiguity",
46+
"prompt": "把 GET /v1/usage 转语义层,响应是 { data: [...] },结构我暂时说不清。",
47+
"expected_output": "在改变建模结果的歧义(grain/响应结构未知)处一次一问,给候选;不做问卷连环问,不臆造结构。",
48+
"expectations": [
49+
"Asks one blocking question about the unknown response structure / grain",
50+
"Offers candidate grains or asks for the array element shape",
51+
"Does not invent a schema or proceed to emit without the structure",
52+
"Does not fire a long multi-question questionnaire"
53+
],
54+
"files": []
55+
},
56+
{
57+
"id": 5,
58+
"name": "layer-split-values-to-contract",
59+
"prompt": "ListProducts 返回 category 字段,枚举有 ELECTRONICS/FOOD/TOYS 等几十个。帮我建语义层维度。",
60+
"expected_output": "语义层维度只描述形态(kind/business_key/source_operations),枚举取值不内联进语义对象,指向命令/契约层。",
61+
"expectations": [
62+
"Models category as a dimension with kind and business_key",
63+
"Does NOT inline the full enum value list into the semantic object",
64+
"Points enum/code values to the command/contract layer (notes references contract)",
65+
"Keeps the semantic layer thin (shape, not concrete typed-in values)"
66+
],
67+
"files": []
68+
}
69+
]
70+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env bash
2+
# 通用 skill QA 模板:布局 + skills-ref + markdownlint + skillcheck。
3+
set -euo pipefail
4+
5+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
6+
QA_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
SKILL_DIR="$(cd "$QA_DIR/../../skills/semantic-layer-builder" && pwd)"
8+
9+
fail() { printf 'FAIL: %s\n' "$1" >&2; exit 1; }
10+
need_cmd() { command -v "$1" >/dev/null 2>&1 || fail "missing command: $1"; }
11+
12+
run_local_or_npx() {
13+
local bin=$1; shift
14+
if command -v "$bin" >/dev/null 2>&1; then "$bin" "$@"
15+
else need_cmd npx; npx "$bin" "$@"; fi
16+
}
17+
18+
# skill 安装包纯度:不含 eval/qa/.workspaces 等
19+
check_skill_layout() {
20+
[[ -f "$SKILL_DIR/SKILL.md" ]] || fail "missing SKILL.md"
21+
[[ -f "$QA_DIR/README.md" ]] || fail "missing QA README"
22+
local item
23+
local forbidden=(.DS_Store .agents analysis evals qa scripts tests .workspaces)
24+
for item in "${forbidden[@]}"; do
25+
[[ ! -e "$SKILL_DIR/$item" ]] || fail "forbidden in skill dir: $item"
26+
done
27+
local sibling
28+
for sibling in "$SKILL_DIR"/*-workspace; do
29+
[[ -e "$sibling" ]] || continue
30+
fail "Skill Creator workspace belongs at repo root, not skills/: $(basename "$sibling")"
31+
done
32+
[[ -f "$QA_DIR/evals/evals.json" ]] || fail "missing evals file: $QA_DIR/evals/evals.json"
33+
[[ -f "$QA_DIR/assertions/README.md" ]] || fail "missing assertions guide"
34+
[[ ! -f "$QA_DIR/evals.json" ]] || fail "duplicate eval source: $QA_DIR/evals.json"
35+
}
36+
37+
check_version_sync() {
38+
need_cmd python3
39+
QA_DIR="$QA_DIR" ROOT="$ROOT" SKILL_DIR="$SKILL_DIR" python3 - <<'PY'
40+
import os, sys
41+
from pathlib import Path
42+
try:
43+
import yaml
44+
except ImportError:
45+
sys.exit("FAIL: PyYAML required for version sync check")
46+
qa = Path(os.environ["QA_DIR"])
47+
root = Path(os.environ["ROOT"])
48+
skill = Path(os.environ["SKILL_DIR"])
49+
expected = (qa / "VERSION").read_text(encoding="utf-8").strip()
50+
catalog = yaml.safe_load((root / "docs/catalog.yml").read_text(encoding="utf-8"))
51+
entry = next(x for x in catalog.get("skills", []) if x.get("id") == "semantic-layer-builder")
52+
if entry.get("version") != expected:
53+
sys.exit(f"FAIL: docs/catalog.yml version {entry.get('version')!r} != qa/VERSION ({expected})")
54+
body = skill.joinpath("SKILL.md").read_text(encoding="utf-8").split("---", 2)[1]
55+
meta = yaml.safe_load(body).get("metadata") or {}
56+
if meta.get("version") != expected:
57+
sys.exit(f"FAIL: SKILL.md metadata.version != qa/VERSION ({expected})")
58+
PY
59+
}
60+
61+
need_cmd rg
62+
check_skill_layout
63+
check_version_sync
64+
run_local_or_npx skills-ref validate "$SKILL_DIR"
65+
run_local_or_npx markdownlint-cli2 --config "$QA_DIR/.markdownlint.json" "$SKILL_DIR/**/*.md"
66+
need_cmd skillcheck
67+
skillcheck "$SKILL_DIR" --target-agent cursor --strict-cursor --min-desc-score 70
68+
69+
printf 'OK: semantic-layer-builder validation passed\n'

0 commit comments

Comments
 (0)