Loading...
Loading...
Update the graft (feature flag) inventory when flags are added or removed. Use when adding new grafts via migrations, after CI flags inventory mismatches, or periodically to ensure docs match production D1.
npx skill4agent add autumnsgrove/groveengine update-graft-inventory| File | Purpose |
|---|---|
| Source of truth for graft counts and metadata |
| Migration files that define grafts |
| Type definitions ( |
| Developer guide |
{
"grafts": {
"total": 10,
"breakdown": {
"platform": 8,
"greenhouse": 2
},
"byType": {
"boolean": 9,
"number": 1
}
},
"flags": [
{
"id": "fireside_mode",
"name": "Fireside Mode",
"type": "boolean",
"greenhouseOnly": true,
"migration": "040_fireside_scribe_grafts.sql",
"description": "AI-assisted writing prompts"
}
]
}# Extract all flag IDs from migration INSERT statements
grep -hoP "INSERT OR IGNORE INTO feature_flags.*?VALUES\s*\(\s*'\K[a-z_]+" packages/engine/migrations/*.sql | sort -u# Get actual flags from production database
npx wrangler d1 execute grove-engine-db --remote --command="SELECT id, name, flag_type, greenhouse_only, enabled FROM feature_flags ORDER BY id;"# Read current inventory
cat .github/graft-inventory.json | jq '.flags[].id' | sort.github/graft-inventory.json"grafts": {
"total": <new count>,
"breakdown": {
"platform": <non-greenhouse count>,
"greenhouse": <greenhouse_only count>
}
}"flags": [
{
"id": "new_flag_id",
"name": "Human Readable Name",
"type": "boolean",
"greenhouseOnly": false,
"migration": "XXX_migration_name.sql",
"description": "What this flag controls"
}
]"lastUpdated": "YYYY-MM-DD",
"lastAuditedBy": "claude/<context>"packages/engine/src/lib/feature-flags/grafts.tsexport type KnownGraftId =
| "fireside_mode"
| "scribe_mode"
| "meadow_access"
| "jxl_encoding"
| "jxl_kill_switch"
| "new_flag_id"; // Add new flaggit add .github/graft-inventory.json packages/engine/src/lib/feature-flags/grafts.ts
git commit -m "docs: update graft inventory
- Add <flag_id> to inventory
- Update total: X -> Y
- Update KnownGraftId type"# Count grafts in migrations
grep -c "INSERT OR IGNORE INTO feature_flags" packages/engine/migrations/*.sql | awk -F: '{sum+=$2} END {print sum}'
# List all flag IDs
grep -hoP "INSERT OR IGNORE INTO feature_flags.*?VALUES\s*\(\s*'\K[a-z_]+" packages/engine/migrations/*.sql | sort -u
# Count greenhouse-only grafts
npx wrangler d1 execute grove-engine-db --remote --command="SELECT COUNT(*) FROM feature_flags WHERE greenhouse_only = 1;"
# Full flag details from production
npx wrangler d1 execute grove-engine-db --remote --command="SELECT * FROM feature_flags ORDER BY id;"
# Check which migrations haven't been applied
# Compare migration file flag IDs vs production D1 flag IDspackages/engine/migrations/XXX_name.sqlnpx wrangler d1 execute grove-engine-db --remote --file=...KnownGraftIdgrafts.ts.github/graft-inventory.jsonlastUpdatedlastAuditedBy# Expected count
jq '.grafts.total' .github/graft-inventory.json
# Actual count in production
npx wrangler d1 execute grove-engine-db --remote --command="SELECT COUNT(*) as count FROM feature_flags;"# Apply a specific migration
npx wrangler d1 execute grove-engine-db --remote --file=packages/engine/migrations/XXX_name.sql.github/workflows/graft-inventory.ymlpackages/engine/migrations/*.sqlpackages/engine/src/lib/feature-flags/**totalflagsKnownGraftIdlastUpdatedtotal = platform + greenhouse