refactor(scopes): simplify scopes.json structure

This commit is contained in:
Prad Nukala 2024-12-26 19:20:32 +00:00
parent 92df0375dd
commit 75adb6200d
2 changed files with 598 additions and 614 deletions

267
.github/scopes.json vendored
View File

@ -1,7 +1,106 @@
[
{
"name": "core-chain",
{
"scopes": [
"core-chain",
"core-ibc",
"crypto-mpc",
"crypto-ucan",
"crypto-zkp",
"sonr-hway",
"sonr-orm",
"sonr-motr",
"sonr-chat",
"x-did",
"x-dwn",
"x-svc",
"ci-cd",
"dev-ops",
"wasm-worker"
],
"docs": [
{
"keywords": [
"github",
"actions",
"workflows",
"syntax"
],
"url": "https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions"
},
{
"keywords": [
"cosmos",
"tooling",
"cosmovisor"
],
"url": "https://docs.cosmos.network/v0.50/build/tooling/cosmovisor"
},
{
"keywords": [
"process-compose",
"configuration"
],
"url": "https://f1bonacc1.github.io/process-compose/configuration/"
},
{
"keywords": [
"taskfile",
"cli",
"reference"
],
"url": "https://taskfile.dev/reference/cli"
},
{
"keywords": [],
"url": "https://taskfile.dev/reference/schema"
},
{
"keywords": [
"taskfile",
"templating",
"reference"
],
"url": "https://taskfile.dev/reference/templating/"
},
{
"keywords": [
"mkdocs",
"material",
"reference"
],
"url": "https://squidfunk.github.io/mkdocs-material/reference/"
},
{
"keywords": [
"pkl",
"language",
"reference"
],
"url": "https://pkl-lang.org/main/current/language-reference/index.html"
},
{
"keywords": [
"pwa",
"service-workers",
"web"
],
"url": "https://web.dev/learn/pwa/service-workers/"
},
{
"keywords": [
"service-workers",
"web",
"api"
],
"url": "https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API"
},
{
"keywords": [
"web-authentication",
"web",
"api"
],
"url": "https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API"
},
{
"keywords": [
"sdk",
@ -49,12 +148,7 @@
"sdk"
],
"url": "https://docs.cosmos.network/v0.50/build/building-modules/depinject"
}
]
},
{
"name": "core-ibc",
"docs": [
{
"keywords": [
"ibc",
@ -136,12 +230,7 @@
"assets"
],
"url": "https://docs.nomic.io/nbtc"
}
]
},
{
"name": "crypto-mpc",
"docs": [
{
"keywords": [
"mpc",
@ -151,12 +240,7 @@
"invokation"
],
"url": "https://csrc.nist.gov/CSRC/media/Events/NTCW19/papers/paper-DKLS.pdf"
}
]
},
{
"name": "crypto-ucan",
"docs": [
{
"keywords": [
"ucan",
@ -165,12 +249,7 @@
"authorization"
],
"url": "https://raw.githubusercontent.com/ucan-wg/spec/refs/heads/main/README.md"
}
]
},
{
"name": "crypto-zkp",
"docs": [
{
"keywords": [
"zero-knowledge",
@ -179,17 +258,12 @@
"privacy"
],
"url": "https://eprint.iacr.org/2021/1672.pdf"
}
]
},
{
"name": "sonr-hway",
"docs": [
{
"keywords": [
"gateway",
"http",
"sse",
"sse"
],
"url": "https://echo.labstack.com/docs/cookbook/sse"
},
@ -197,7 +271,7 @@
"keywords": [
"gateway",
"http",
"websocket",
"websocket"
],
"url": "https://echo.labstack.com/docs/cookbook/websocket"
},
@ -205,15 +279,10 @@
"keywords": [
"gateway",
"http",
"subdomain",
"subdomain"
],
"url": "https://echo.labstack.com/docs/cookbook/subdomain"
}
]
},
{
"name": "sonr-orm",
"docs": [
{
"keywords": [
"tigerbeetle",
@ -302,12 +371,7 @@
"injective"
],
"url": "https://docs.substreams.dev/tutorials/cosmos/injective/foundational"
}
]
},
{
"name": "sonr-motr",
"docs": [
{
"keywords": [
"worker",
@ -333,12 +397,7 @@
"api"
],
"url": "https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API"
}
]
},
{
"name": "sonr-chat",
"docs": [
{
"keywords": [
"synapse",
@ -347,12 +406,7 @@
"usage"
],
"url": "https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html"
}
]
},
{
"name": "x-did",
"docs": [
{
"keywords": [
"cosmos",
@ -379,12 +433,7 @@
"bank"
],
"url": "https://docs.cosmos.network/v0.50/build/modules/bank"
}
]
},
{
"name": "x-dwn",
"docs": [
{
"keywords": [
"cosmos",
@ -420,12 +469,7 @@
"sdk"
],
"url": "https://docs.cosmos.network/v0.50/build/modules/staking"
}
]
},
{
"name": "x-svc",
"docs": [
{
"keywords": [
"cosmos",
@ -454,103 +498,4 @@
"url": "https://docs.cosmos.network/v0.50/build/modules/nft"
}
]
},
{
"name": "ci-cd",
"docs": [
{
"keywords": [
"github",
"actions",
"workflows",
"syntax"
],
"url": "https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions"
},
{
"keywords": [
"cosmos",
"tooling",
"cosmovisor"
],
"url": "https://docs.cosmos.network/v0.50/build/tooling/cosmovisor"
},
{
"keywords": [
"process-compose",
"configuration"
],
"url": "https://f1bonacc1.github.io/process-compose/configuration/"
},
{
"keywords": [
"taskfile",
"cli",
"reference"
],
"url": "https://taskfile.dev/reference/cli"
},
{
"keywords": [],
"url": "https://taskfile.dev/reference/schema"
},
{
"keywords": [
"taskfile",
"templating",
"reference"
],
"url": "https://taskfile.dev/reference/templating/"
}
]
},
{
"name": "dev-ops",
"docs": [
{
"keywords": [
"mkdocs",
"material",
"reference"
],
"url": "https://squidfunk.github.io/mkdocs-material/reference/"
},
{
"keywords": [
"pkl",
"language",
"reference"
],
"url": "https://pkl-lang.org/main/current/language-reference/index.html"
}
]
},
{
"name": "wasm-worker",
"docs": [
{
"keywords": [
"pwa",
"service-workers",
"web"
],
"url": "https://web.dev/learn/pwa/service-workers/"
},
{
"keywords": [
"service-workers",
"web",
"api"
],
"url": "https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API"
},
{
"keywords": [
"web-authentication",
"web",
"api"
],
"url": "https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API"
]
}
]
}

View File

@ -1,70 +1,109 @@
#!/bin/bash
set -e
#!/bin/sh
ROOT_DIR=$(git rev-parse --show-toplevel)
# Extract scope name and path using jq, and pass it to fzf for selection
SCOPE=$(cat "$ROOT_DIR/.github/scopes.json" | jq -r '.[] | "\(.name)"' | fzf --prompt "Select scope:")
DOCS=$(cat "$ROOT_DIR/.github/scopes.json" | jq -r ".[] | select(.name == \"$SCOPE\") | .docs[].url")
select_scope() {
cat "$ROOT_DIR/.github/scopes.json" | jq -r '.scopes[]' | fzf --prompt "Select scope:"
}
# Write Title
TITLE=$(gum input --placeholder "Issue Title...")
get_title() {
gum input --placeholder "Issue Title..."
}
# Write Goal
GOAL=$(mods --role "determine-issue-goal" "$SCOPE $TITLE")
add_requirement() {
requirement=$(gum input --placeholder "Add a requirement...")
if [ -n "$requirement" ]; then
REQUIREMENTS="$REQUIREMENTS
$requirement"
return 0
fi
return 1
}
# Input Requirements
REQUIREMENTS=()
while true; do
if [ ${#REQUIREMENTS[@]} -ge 2 ]; then
if ! gum confirm "Do you want to add another requirement?"; then
collect_requirements() {
REQUIREMENTS=""
req_count=0
while true; do
if add_requirement; then
req_count=$((req_count + 1))
if [ $req_count -ge 2 ] && ! gum confirm "Do you want to add another requirement?"; then
break
fi
fi
REQUIREMENT=$(gum input --placeholder "Add a requirement...")
if [ -n "$REQUIREMENT" ]; then
REQUIREMENTS+=("$REQUIREMENT")
else
if [ $req_count -ge 2 ]; then
break
else
echo "Requirement cannot be empty. Please enter a valid requirement."
fi
done
create_body() {
echo "### Goal(s):"
echo "$GOAL"
echo "### Requirements:"
for i in "${!REQUIREMENTS[@]}"; do
echo "$(($i + 1)). ${REQUIREMENTS[$i]}"
fi
done
echo "### Resources:"
while IFS= read -r doc; do
echo "- $doc"
done <<< "$DOCS"
}
ISSUE_BODY=$(create_body)
get_docs() {
docs=$(cat "$ROOT_DIR/.github/scopes.json" | jq -c '.docs')
mods --role "determine-issue-docs" "$SCOPE" "$TITLE" "$docs"
}
# Function to collect output
preview_output() {
get_goal() {
mods --role "determine-issue-goal" "$SCOPE $TITLE"
}
format_requirements() {
i=1
echo "$REQUIREMENTS" | while IFS= read -r req; do
if [ -n "$req" ]; then
echo "$i. $req"
i=$((i + 1))
fi
done
}
create_body() {
goal=$(get_goal)
docs=$(get_docs)
echo "### Goal(s):"
echo "$goal"
echo
echo "### Requirements:"
format_requirements
echo
echo "### Resources:"
echo "$docs"
}
preview_issue() {
echo "# ($SCOPE) $TITLE"
echo "$ISSUE_BODY"
}
# Display the formatted output
preview_output | gum format
# Confirm to create a GitHub issue
if gum confirm "Do you want to create a new GitHub issue with this information?"; then
# Ask if this should be a draft issue
if gum confirm "Create as draft issue?"; then
# Create a draft GitHub issue
gh issue create --repo onsonr/sonr --title "($SCOPE) $TITLE" --body "$ISSUE_BODY"
else
# Create a regular GitHub issue
gh issue create --repo onsonr/sonr --title "($SCOPE) $TITLE" --body "$ISSUE_BODY" -a @me
create_github_issue() {
draft_flag=""
if gum confirm "Assign this issue to yourself?"; then
draft_flag="-a @me"
fi
else
exit 1
fi
gh issue create \
--repo onsonr/sonr \
--title "[$SCOPE] $TITLE" \
--body "$ISSUE_BODY" \
$draft_flag
}
main() {
SCOPE=$(select_scope)
TITLE=$(get_title)
collect_requirements
ISSUE_BODY=$(create_body)
preview_issue | gum format
if gum confirm "Do you want to create a new GitHub issue with this information?"; then
create_github_issue
else
exit 1
fi
}
main