Capability Graph Builder by daffy0208/ai-dev-standards
npx skills add https://github.com/daffy0208/ai-dev-standards --skill 'Capability Graph Builder'利用 Codex 进行关系推断,从清单文件构建可查询的能力图谱
消费能力清单(由清单生成器生成)并构建一个可查询的图结构,以表示所有能力及其关系。使用 OpenAI Codex 推断缺失的关系并验证兼容性声明。
inputs:
manifest_dir: string # 包含 manifest.yaml 文件的目录(例如 SKILLS/)
output_path: string # 写入 capability-graph.json 的位置
validate_consistency: boolean # 对关系运行 Codex 验证
infer_missing: boolean # 使用 Codex 推断缺失的兼容性字段
#!/bin/bash
# 查找所有 manifest.yaml 文件
MANIFESTS=$(find SKILLS MCP-SERVERS TOOLS COMPONENTS INTEGRATIONS -name 'manifest.yaml' 2>/dev/null)
# 加载每个清单
echo "Loading manifests..."
for manifest in $MANIFESTS; do
echo " - $manifest"
done
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
// 图谱构建的伪代码
const graph = {
nodes: [],
edges: [],
domains: {},
effects: {}
}
for (const manifest of manifests) {
// 添加节点
graph.nodes.push({
id: manifest.name,
kind: manifest.kind,
description: manifest.description,
preconditions: manifest.preconditions,
effects: manifest.effects,
domains: manifest.domains,
cost: manifest.cost,
latency: manifest.latency,
risk_level: manifest.risk_level
})
// 从兼容性添加边
if (manifest.compatibility) {
if (manifest.compatibility.requires) {
for (const required of manifest.compatibility.requires) {
graph.edges.push({
from: required,
to: manifest.name,
type: 'requires'
})
}
}
if (manifest.compatibility.enables) {
for (const enabled of manifest.compatibility.enables) {
graph.edges.push({
from: manifest.name,
to: enabled,
type: 'enables'
})
}
}
if (manifest.compatibility.conflicts_with) {
for (const conflict of manifest.compatibility.conflicts_with) {
graph.edges.push({
from: manifest.name,
to: conflict,
type: 'conflicts_with'
})
}
}
if (manifest.compatibility.composes_with) {
for (const compose of manifest.compatibility.composes_with) {
graph.edges.push({
from: manifest.name,
to: compose,
type: 'composes_with'
})
}
}
}
// 按领域索引
for (const domain of manifest.domains) {
if (!graph.domains[domain]) graph.domains[domain] = []
graph.domains[domain].push(manifest.name)
}
// 按效果索引
for (const effect of manifest.effects) {
if (!graph.effects[effect]) graph.effects[effect] = []
graph.effects[effect].push(manifest.name)
}
}
# 对于每对能力,向 Codex 询问关系
for capability_a in "${capabilities[@]}"; do
for capability_b in "${capabilities[@]}"; do
if [ "$capability_a" != "$capability_b" ]; then
# 获取清单
MANIFEST_A=$(cat "path/to/$capability_a/manifest.yaml")
MANIFEST_B=$(cat "path/to/$capability_b/manifest.yaml")
# 询问 Codex
codex exec "
Analyze these two capabilities and determine their relationship:
CAPABILITY A:
$MANIFEST_A
CAPABILITY B:
$MANIFEST_B
Questions:
1. Does A require B to function?
2. Does A enable B (make B possible)?
3. Do A and B conflict (can't coexist)?
4. Do A and B compose well together?
5. Are there any implicit dependencies or relationships?
Output JSON:
{
\"requires\": boolean,
\"enables\": boolean,
\"conflicts_with\": boolean,
\"composes_with\": boolean,
\"reasoning\": \"explanation\"
}
" > /tmp/relationship-${capability_a}-${capability_b}.json
fi
done
done
# 检查双向关系
codex exec "
Analyze this capability graph for consistency issues:
GRAPH:
$(cat /tmp/capability-graph.json)
Check for:
1. Asymmetric relationships (A enables B but B doesn't require A)
2. Conflicting declarations (A enables B but B conflicts with A)
3. Missing transitive relationships (A requires B, B requires C, but A doesn't require C)
4. Circular dependencies (A requires B, B requires A)
Output JSON array of issues:
[
{
\"type\": \"asymmetric_enables\",
\"from\": \"capability-a\",
\"to\": \"capability-b\",
\"issue\": \"A enables B but B doesn't list A as required\",
\"severity\": \"warning\"
}
]
"
# 写入带有元数据的最终图谱
cat > META/capability-graph.json <<EOF
{
"version": "1.0.0",
"generated_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"node_count": ${node_count},
"edge_count": ${edge_count},
"graph": $(cat /tmp/capability-graph.json)
}
EOF
生成的图谱支持以下查询:
// 查找所有创建向量索引的能力
const creators = graph.effects['creates_vector_index']
// => ['rag-implementer', 'pinecone-mcp', 'weaviate-mcp']
// 查找所有与 RAG 相关的能力
const ragCapabilities = graph.domains['rag']
// => ['rag-implementer', 'embedding-generator-mcp', 'vector-search-tool', ...]
// rag-implementer 需要什么?
const deps = findDependencies('rag-implementer')
// => ['openai-integration', 'pinecone-mcp']
function findDependencies(capabilityName) {
return graph.edges.filter(e => e.to === capabilityName && e.type === 'requires').map(e => e.from)
}
// 拥有 openai-integration 会启用什么?
const enabled = findEnabled('openai-integration')
// => ['rag-implementer', 'embedding-generator-mcp', 'gpt-vision-analyzer']
function findEnabled(capabilityName) {
return graph.edges.filter(e => e.from === capabilityName && e.type === 'enables').map(e => e.to)
}
// 什么与 existing-vector-database 冲突?
const conflicts = findConflicts('existing-vector-database')
// => ['rag-implementer']
function findConflicts(capabilityName) {
return graph.edges
.filter(
e => (e.from === capabilityName || e.to === capabilityName) && e.type === 'conflicts_with'
)
.map(e => (e.from === capabilityName ? e.to : e.from))
}
// 什么与 rag-implementer 能很好地组合?
const partners = findCompositionPartners('rag-implementer')
// => ['pinecone-mcp', 'weaviate-mcp', 'semantic-search-tool']
function findCompositionPartners(capabilityName) {
return graph.edges
.filter(
e => (e.from === capabilityName || e.to === capabilityName) && e.type === 'composes_with'
)
.map(e => (e.from === capabilityName ? e.to : e.from))
}
// 实现 "semantic_search" 需要哪些能力?
const path = findPathToEffect('semantic_search')
// => ['openai-integration', 'rag-implementer', 'vector-search-tool']
function findPathToEffect(effect) {
// 通过 requires/enables 边进行 BFS
const capabilities = graph.effects[effect] || []
const visited = new Set()
const path = []
for (const cap of capabilities) {
const deps = findAllDependencies(cap, visited)
path.push(...deps, cap)
}
return [...new Set(path)]
}
function findAllDependencies(capabilityName, visited = new Set()) {
if (visited.has(capabilityName)) return []
visited.add(capabilityName)
const directDeps = graph.edges
.filter(e => e.to === capabilityName && e.type === 'requires')
.map(e => e.from)
const allDeps = []
for (const dep of directDeps) {
allDeps.push(...findAllDependencies(dep, visited), dep)
}
return allDeps
}
{
"version": "1.0.0",
"generated_at": "2025-10-28T12:00:00Z",
"node_count": 109,
"edge_count": 287,
"graph": {
"nodes": [
{
"id": "rag-implementer",
"kind": "skill",
"description": "Implement retrieval-augmented generation systems",
"preconditions": [
{ "check": "file_exists('package.json')", "required": true },
{ "check": "env_var_set('OPENAI_API_KEY')", "required": true }
],
"effects": ["creates_vector_index", "adds_embedding_pipeline", "configures_retrieval_api"],
"domains": ["rag", "ai", "search"],
"cost": "medium",
"latency": "slow",
"risk_level": "low"
},
{
"id": "pinecone-mcp",
"kind": "mcp",
"description": "Vector database operations for Pinecone",
"effects": ["creates_vector_index", "performs_similarity_search"],
"domains": ["rag", "vector-db"],
"cost": "low",
"latency": "fast",
"risk_level": "safe"
}
],
"edges": [
{
"from": "openai-integration",
"to": "rag-implementer",
"type": "requires"
},
{
"from": "rag-implementer",
"to": "pinecone-mcp",
"type": "composes_with"
},
{
"from": "rag-implementer",
"to": "semantic-search",
"type": "enables"
}
],
"domains": {
"rag": ["rag-implementer", "pinecone-mcp", "weaviate-mcp", "embedding-generator-mcp"],
"auth": ["frontend-builder", "api-designer", "security-engineer"],
"api": ["api-designer", "frontend-builder", "performance-optimizer"]
},
"effects": {
"creates_vector_index": ["rag-implementer", "pinecone-mcp", "weaviate-mcp"],
"adds_auth": ["frontend-builder", "api-designer"],
"configures_database": ["api-designer", "data-engineer"]
}
}
}
消费由 manifest-generator 技能生成的清单。
为查找符合目标要求的能力提供可查询的图谱。
图谱结构有助于验证所声称的关系是否实际存在。
每周安装次数
–
代码仓库
GitHub 星标数
21
首次出现时间
–
安全审计
Build queryable capability graphs from manifests using Codex for relationship inference
Consumes capability manifests (generated by manifest-generator) and constructs a queryable graph structure representing all capabilities and their relationships. Uses OpenAI Codex to infer missing relationships and validate compatibility declarations.
inputs:
manifest_dir: string # Directory containing manifest.yaml files (e.g., SKILLS/)
output_path: string # Where to write capability-graph.json
validate_consistency: boolean # Run Codex validation on relationships
infer_missing: boolean # Use Codex to infer missing compatibility fields
#!/bin/bash
# Find all manifest.yaml files
MANIFESTS=$(find SKILLS MCP-SERVERS TOOLS COMPONENTS INTEGRATIONS -name 'manifest.yaml' 2>/dev/null)
# Load each manifest
echo "Loading manifests..."
for manifest in $MANIFESTS; do
echo " - $manifest"
done
// Pseudocode for graph construction
const graph = {
nodes: [],
edges: [],
domains: {},
effects: {}
}
for (const manifest of manifests) {
// Add node
graph.nodes.push({
id: manifest.name,
kind: manifest.kind,
description: manifest.description,
preconditions: manifest.preconditions,
effects: manifest.effects,
domains: manifest.domains,
cost: manifest.cost,
latency: manifest.latency,
risk_level: manifest.risk_level
})
// Add edges from compatibility
if (manifest.compatibility) {
if (manifest.compatibility.requires) {
for (const required of manifest.compatibility.requires) {
graph.edges.push({
from: required,
to: manifest.name,
type: 'requires'
})
}
}
if (manifest.compatibility.enables) {
for (const enabled of manifest.compatibility.enables) {
graph.edges.push({
from: manifest.name,
to: enabled,
type: 'enables'
})
}
}
if (manifest.compatibility.conflicts_with) {
for (const conflict of manifest.compatibility.conflicts_with) {
graph.edges.push({
from: manifest.name,
to: conflict,
type: 'conflicts_with'
})
}
}
if (manifest.compatibility.composes_with) {
for (const compose of manifest.compatibility.composes_with) {
graph.edges.push({
from: manifest.name,
to: compose,
type: 'composes_with'
})
}
}
}
// Index by domain
for (const domain of manifest.domains) {
if (!graph.domains[domain]) graph.domains[domain] = []
graph.domains[domain].push(manifest.name)
}
// Index by effect
for (const effect of manifest.effects) {
if (!graph.effects[effect]) graph.effects[effect] = []
graph.effects[effect].push(manifest.name)
}
}
# For each pair of capabilities, ask Codex about relationships
for capability_a in "${capabilities[@]}"; do
for capability_b in "${capabilities[@]}"; do
if [ "$capability_a" != "$capability_b" ]; then
# Get manifests
MANIFEST_A=$(cat "path/to/$capability_a/manifest.yaml")
MANIFEST_B=$(cat "path/to/$capability_b/manifest.yaml")
# Ask Codex
codex exec "
Analyze these two capabilities and determine their relationship:
CAPABILITY A:
$MANIFEST_A
CAPABILITY B:
$MANIFEST_B
Questions:
1. Does A require B to function?
2. Does A enable B (make B possible)?
3. Do A and B conflict (can't coexist)?
4. Do A and B compose well together?
5. Are there any implicit dependencies or relationships?
Output JSON:
{
\"requires\": boolean,
\"enables\": boolean,
\"conflicts_with\": boolean,
\"composes_with\": boolean,
\"reasoning\": \"explanation\"
}
" > /tmp/relationship-${capability_a}-${capability_b}.json
fi
done
done
# Check bidirectional relationships
codex exec "
Analyze this capability graph for consistency issues:
GRAPH:
$(cat /tmp/capability-graph.json)
Check for:
1. Asymmetric relationships (A enables B but B doesn't require A)
2. Conflicting declarations (A enables B but B conflicts with A)
3. Missing transitive relationships (A requires B, B requires C, but A doesn't require C)
4. Circular dependencies (A requires B, B requires A)
Output JSON array of issues:
[
{
\"type\": \"asymmetric_enables\",
\"from\": \"capability-a\",
\"to\": \"capability-b\",
\"issue\": \"A enables B but B doesn't list A as required\",
\"severity\": \"warning\"
}
]
"
# Write final graph with metadata
cat > META/capability-graph.json <<EOF
{
"version": "1.0.0",
"generated_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"node_count": ${node_count},
"edge_count": ${edge_count},
"graph": $(cat /tmp/capability-graph.json)
}
EOF
The generated graph supports these queries:
// Find all capabilities that create vector indexes
const creators = graph.effects['creates_vector_index']
// => ['rag-implementer', 'pinecone-mcp', 'weaviate-mcp']
// Find all RAG-related capabilities
const ragCapabilities = graph.domains['rag']
// => ['rag-implementer', 'embedding-generator-mcp', 'vector-search-tool', ...]
// What does rag-implementer require?
const deps = findDependencies('rag-implementer')
// => ['openai-integration', 'pinecone-mcp']
function findDependencies(capabilityName) {
return graph.edges.filter(e => e.to === capabilityName && e.type === 'requires').map(e => e.from)
}
// What does having openai-integration enable?
const enabled = findEnabled('openai-integration')
// => ['rag-implementer', 'embedding-generator-mcp', 'gpt-vision-analyzer']
function findEnabled(capabilityName) {
return graph.edges.filter(e => e.from === capabilityName && e.type === 'enables').map(e => e.to)
}
// What conflicts with existing-vector-database?
const conflicts = findConflicts('existing-vector-database')
// => ['rag-implementer']
function findConflicts(capabilityName) {
return graph.edges
.filter(
e => (e.from === capabilityName || e.to === capabilityName) && e.type === 'conflicts_with'
)
.map(e => (e.from === capabilityName ? e.to : e.from))
}
// What composes well with rag-implementer?
const partners = findCompositionPartners('rag-implementer')
// => ['pinecone-mcp', 'weaviate-mcp', 'semantic-search-tool']
function findCompositionPartners(capabilityName) {
return graph.edges
.filter(
e => (e.from === capabilityName || e.to === capabilityName) && e.type === 'composes_with'
)
.map(e => (e.from === capabilityName ? e.to : e.from))
}
// What capabilities are needed to achieve "semantic_search"?
const path = findPathToEffect('semantic_search')
// => ['openai-integration', 'rag-implementer', 'vector-search-tool']
function findPathToEffect(effect) {
// BFS through requires/enables edges
const capabilities = graph.effects[effect] || []
const visited = new Set()
const path = []
for (const cap of capabilities) {
const deps = findAllDependencies(cap, visited)
path.push(...deps, cap)
}
return [...new Set(path)]
}
function findAllDependencies(capabilityName, visited = new Set()) {
if (visited.has(capabilityName)) return []
visited.add(capabilityName)
const directDeps = graph.edges
.filter(e => e.to === capabilityName && e.type === 'requires')
.map(e => e.from)
const allDeps = []
for (const dep of directDeps) {
allDeps.push(...findAllDependencies(dep, visited), dep)
}
return allDeps
}
{
"version": "1.0.0",
"generated_at": "2025-10-28T12:00:00Z",
"node_count": 109,
"edge_count": 287,
"graph": {
"nodes": [
{
"id": "rag-implementer",
"kind": "skill",
"description": "Implement retrieval-augmented generation systems",
"preconditions": [
{ "check": "file_exists('package.json')", "required": true },
{ "check": "env_var_set('OPENAI_API_KEY')", "required": true }
],
"effects": ["creates_vector_index", "adds_embedding_pipeline", "configures_retrieval_api"],
"domains": ["rag", "ai", "search"],
"cost": "medium",
"latency": "slow",
"risk_level": "low"
},
{
"id": "pinecone-mcp",
"kind": "mcp",
"description": "Vector database operations for Pinecone",
"effects": ["creates_vector_index", "performs_similarity_search"],
"domains": ["rag", "vector-db"],
"cost": "low",
"latency": "fast",
"risk_level": "safe"
}
],
"edges": [
{
"from": "openai-integration",
"to": "rag-implementer",
"type": "requires"
},
{
"from": "rag-implementer",
"to": "pinecone-mcp",
"type": "composes_with"
},
{
"from": "rag-implementer",
"to": "semantic-search",
"type": "enables"
}
],
"domains": {
"rag": ["rag-implementer", "pinecone-mcp", "weaviate-mcp", "embedding-generator-mcp"],
"auth": ["frontend-builder", "api-designer", "security-engineer"],
"api": ["api-designer", "frontend-builder", "performance-optimizer"]
},
"effects": {
"creates_vector_index": ["rag-implementer", "pinecone-mcp", "weaviate-mcp"],
"adds_auth": ["frontend-builder", "api-designer"],
"configures_database": ["api-designer", "data-engineer"]
}
}
}
Consumes manifests generated by manifest-generator skill.
Provides queryable graph for finding capabilities matching goal requirements.
Graph structure helps validate that claimed relationships actually exist.
Weekly Installs
–
Repository
GitHub Stars
21
First Seen
–
Security Audits
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
60,400 周安装