-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-missing-groove.sh
More file actions
executable file
·88 lines (77 loc) · 2.76 KB
/
Copy pathfix-missing-groove.sh
File metadata and controls
executable file
·88 lines (77 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# SPDX-License-Identifier: MPL-2.0
#
# fix-missing-groove.sh — Add Groove manifest to repos that serve HTTP but lack one
#
# Fixes HYP-DOG-008 (HTTP server without Groove endpoint) by generating a
# .well-known/groove/manifest.json using the groove CLI tool.
#
# This script is dispatched by seambot when Hypatia detects DOG-08 findings.
#
# Usage: fix-missing-groove.sh <repo-path> <finding-json>
#
# Requires: groove CLI (installed via `cargo install --git https://github.com/hyperpolymath/groove-protocol --path cli`)
set -euo pipefail
REPO_PATH="${1:?Usage: $0 <repo-path> <finding-json>}"
FINDING_FILE="${2:?Missing finding JSON file}"
MANIFEST_DIR="$REPO_PATH/.well-known/groove"
MANIFEST_FILE="$MANIFEST_DIR/manifest.json"
echo "=== Missing Groove Manifest Fix ==="
echo " Repo: $REPO_PATH"
# Idempotency: skip if manifest already exists
if [[ -f "$MANIFEST_FILE" ]]; then
echo " SKIP: Groove manifest already exists"
exit 0
fi
# Try using the groove CLI if available
if command -v groove &>/dev/null; then
echo " Using groove CLI to generate manifest..."
groove init --path "$REPO_PATH" || {
echo " WARN: groove init failed — falling back to template"
}
fi
# If groove didn't create it (not installed or failed), use a minimal template
if [[ ! -f "$MANIFEST_FILE" ]]; then
echo " Generating minimal Groove manifest template..."
# Detect service name from repo directory or Cargo.toml
SERVICE_ID=""
if [[ -f "$REPO_PATH/Cargo.toml" ]]; then
SERVICE_ID=$(grep '^name\s*=' "$REPO_PATH/Cargo.toml" | head -1 | sed 's/.*"\(.*\)".*/\1/')
elif [[ -f "$REPO_PATH/mix.exs" ]]; then
SERVICE_ID=$(grep 'app:' "$REPO_PATH/mix.exs" | head -1 | sed 's/.*:\([a-z_]*\).*/\1/')
fi
SERVICE_ID="${SERVICE_ID:-$(basename "$REPO_PATH")}"
# Detect version
VERSION="0.1.0"
if [[ -f "$REPO_PATH/Cargo.toml" ]]; then
VERSION=$(grep '^version\s*=' "$REPO_PATH/Cargo.toml" | head -1 | sed 's/.*"\(.*\)".*/\1/')
fi
mkdir -p "$MANIFEST_DIR"
cat > "$MANIFEST_FILE" <<EOF
{
"groove_version": "1",
"service_id": "${SERVICE_ID}",
"service_version": "${VERSION}",
"capabilities": {
"custom": {
"type": "custom",
"description": "TODO: describe this service's primary capability",
"protocol": "http",
"endpoint": "/api",
"requires_auth": false,
"panel_compatible": true
}
},
"consumes": [],
"endpoints": {
"health": "/health"
},
"health": "/health",
"applicability": ["individual", "team"]
}
EOF
fi
echo " Created: $MANIFEST_FILE"
echo " NOTE: Review and customise the manifest — replace 'custom' capability"
echo " with the correct type from the Groove registry."
echo " Run 'groove validate --path $REPO_PATH' to check compliance."