Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-27T23:32:03.473Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

docs-strip-preview-callouts

232 lines · 5.6 KB · text
1#!/usr/bin/env bash
2#
3# Remove Preview callouts from documentation for stable release.
4#
5# Usage:
6#   script/docs-strip-preview-callouts [--dry-run]
7#
8# This script finds and removes all Preview-related callouts from docs:
9#   > **Preview:** This feature is available in Zed Preview...
10#   > **Changed in Preview (v0.XXX).** See [release notes]...
11#
12# Then creates a PR with the changes.
13#
14# Options:
15#   --dry-run     Show what would be changed without modifying files or creating PR
16#   --verbose     Show detailed progress
17#
18# Run this as part of the stable release workflow.
19
20set -euo pipefail
21
22DRY_RUN=false
23VERBOSE=false
24
25# Colors
26RED='\033[0;31m'
27GREEN='\033[0;32m'
28YELLOW='\033[0;33m'
29BLUE='\033[0;34m'
30NC='\033[0m'
31
32log() {
33    if [[ "$VERBOSE" == "true" ]]; then
34        echo -e "${BLUE}[strip-preview]${NC} $*" >&2
35    fi
36}
37
38error() {
39    echo -e "${RED}Error:${NC} $*" >&2
40    exit 1
41}
42
43# Parse arguments
44while [[ $# -gt 0 ]]; do
45    case $1 in
46        --dry-run)
47            DRY_RUN=true
48            shift
49            ;;
50        --verbose)
51            VERBOSE=true
52            shift
53            ;;
54        -h|--help)
55            head -18 "$0" | tail -16
56            exit 0
57            ;;
58        *)
59            error "Unknown option: $1"
60            ;;
61    esac
62done
63
64# Get repo root
65REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
66cd "$REPO_ROOT"
67
68DOCS_DIR="$REPO_ROOT/docs/src"
69
70echo "Searching for Preview callouts in $DOCS_DIR..."
71
72# Find files with either type of preview callout:
73# - > **Preview:** ...
74# - > **Changed in Preview ...
75files_with_callouts=$(grep -rlE "> \*\*(Preview:|Changed in Preview)" "$DOCS_DIR" 2>/dev/null || true)
76
77if [[ -z "$files_with_callouts" ]]; then
78    echo "No Preview callouts found. Nothing to do."
79    exit 0
80fi
81
82file_count=$(echo "$files_with_callouts" | wc -l | tr -d ' ')
83echo "Found $file_count file(s) with Preview callouts:"
84echo ""
85
86for file in $files_with_callouts; do
87    relative_path="${file#$REPO_ROOT/}"
88    echo "  $relative_path"
89    
90    if [[ "$VERBOSE" == "true" ]]; then
91        grep -nE "> \*\*(Preview:|Changed in Preview)" "$file" | while read -r line; do
92            echo "    $line"
93        done
94    fi
95done
96
97echo ""
98
99if [[ "$DRY_RUN" == "true" ]]; then
100    echo -e "${YELLOW}=== DRY RUN ===${NC}"
101    echo ""
102    echo "Would remove Preview callouts from the files above and create a PR."
103    echo ""
104    echo "Lines to be removed:"
105    echo ""
106    
107    for file in $files_with_callouts; do
108        relative_path="${file#$REPO_ROOT/}"
109        echo "--- $relative_path ---"
110        grep -nE "> \*\*(Preview:|Changed in Preview)" "$file" || true
111        echo ""
112    done
113    
114    echo -e "${YELLOW}=== END DRY RUN ===${NC}"
115    echo ""
116    echo "Run without --dry-run to apply changes and create PR."
117    exit 0
118fi
119
120# Check for clean working state (ignore untracked files)
121if [[ -n "$(git status --porcelain docs/ | grep -v '^??' || true)" ]]; then
122    error "docs/ directory has uncommitted changes. Please commit or stash first."
123fi
124
125# Apply changes
126echo "Removing Preview callouts..."
127
128for file in $files_with_callouts; do
129    log "Processing: $file"
130    
131    tmp_file=$(mktemp)
132    
133    # Remove preview callout lines and their continuations
134    # Handles both:
135    #   > **Preview:** This feature is available...
136    #   > **Changed in Preview (v0.XXX).** See [release notes]...
137    awk '
138    BEGIN { in_callout = 0 }
139    /^> \*\*Preview:\*\*/ { 
140        in_callout = 1
141        next 
142    }
143    /^> \*\*Changed in Preview/ { 
144        in_callout = 1
145        next 
146    }
147    in_callout && /^>/ && !/^> \*\*/ {
148        next
149    }
150    in_callout && /^$/ {
151        in_callout = 0
152        next
153    }
154    {
155        in_callout = 0
156        print
157    }
158    ' "$file" > "$tmp_file"
159    
160    mv "$tmp_file" "$file"
161    echo "  Updated: ${file#$REPO_ROOT/}"
162done
163
164echo ""
165echo -e "${GREEN}Preview callouts removed from $file_count file(s).${NC}"
166
167# Check if there are actual changes (in case callouts were in comments or something)
168if [[ -z "$(git status --porcelain docs/)" ]]; then
169    echo ""
170    echo "No effective changes to commit (callouts may have been in non-rendered content)."
171    exit 0
172fi
173
174# Create branch and PR
175echo ""
176echo "Creating PR..."
177
178BRANCH_NAME="docs/stable-release-$(date +%Y-%m-%d)"
179log "Branch: $BRANCH_NAME"
180
181git checkout -b "$BRANCH_NAME"
182git add docs/src/
183
184# Build file list for commit message
185FILE_LIST=$(echo "$files_with_callouts" | sed "s|$REPO_ROOT/||" | sed 's/^/- /')
186
187git commit -m "docs: Remove Preview callouts for stable release
188
189Features documented with Preview callouts are now in Stable.
190
191Files updated:
192$FILE_LIST"
193
194git push -u origin "$BRANCH_NAME"
195
196gh pr create \
197    --title "docs: Remove Preview callouts for stable release" \
198    --body "This PR removes Preview callouts from documentation for features that are now in Stable.
199
200## Files Updated
201
202$(echo "$files_with_callouts" | sed "s|$REPO_ROOT/|• |")
203
204## What This Does
205
206Removes callouts like:
207\`\`\`markdown
208> **Preview:** This feature is available in Zed Preview. It will be included in the next Stable release.
209\`\`\`
210
211And:
212\`\`\`markdown
213> **Changed in Preview (v0.XXX).** See [release notes](/releases#0.XXX).
214\`\`\`
215
216These features are now in Stable, so the callouts are no longer needed.
217
218Release Notes:
219
220- N/A"
221
222PR_URL=$(gh pr view --json url --jq '.url')
223
224echo ""
225echo -e "${GREEN}Done!${NC}"
226echo ""
227echo "PR created: $PR_URL"
228echo ""
229echo "Next steps:"
230echo "1. Review the PR to ensure callouts were removed correctly"
231echo "2. Merge the PR as part of the stable release"
232
Served at tenant.openagents/omega Member data and write actions are omitted.