Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions .bridge/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/bin/bash
# Bridge generator wrapper

# Since Python is not available in the container, we'll simulate the generation
# This demonstrates what the generator would produce

FCM_FILE="$1"
if [ -z "$FCM_FILE" ]; then
echo "Usage: $0 <fcm-file>"
exit 1
fi

if [ "$FCM_FILE" == "--generate-all" ]; then
echo "Generating all actions from FCMs..."
for fcm in axioms/*/*.fcm; do
if [ -f "$fcm" ]; then
echo "Processing: $fcm"
$0 "$fcm"
fi
done
exit 0
fi

# Extract metadata from FCM
MODEL=$(grep "^Model:" "$FCM_FILE" | cut -d: -f2- | tr -d ' ')
VERSION=$(grep "^Version:" "$FCM_FILE" | cut -d: -f2- | tr -d ' ')
DOMAIN=$(grep "^Domain:" "$FCM_FILE" | cut -d: -f2- | tr -d ' ')
CAPABILITY=$(grep "^Capability:" "$FCM_FILE" | cut -d: -f2- | sed 's/^ //')

# Derive action name from model
ACTION_NAME=$(echo "$MODEL" | rev | cut -d. -f1 | rev | tr _ -)

# Create output directory
OUTPUT_DIR="actions/core/$ACTION_NAME"
mkdir -p "$OUTPUT_DIR"

# Generate action.yml
cat > "$OUTPUT_DIR/action.yml" << EOF
# Generated from $FCM_FILE
# Model: $MODEL v$VERSION
# Generated: $(date -u +%Y-%m-%dT%H:%M:%SZ)
# DO NOT EDIT - Changes will be overwritten by bridge generator

name: $(echo "$ACTION_NAME" | tr - ' ' | sed 's/\b\(.\)/\u\1/g')
description: $CAPABILITY
inputs:
action:
description: Action (Options: create, delete, list, push, check)
required: true
tag_name:
description: Tag Name
required: false
default: ''
message:
description: Message
required: false
default: ''
remote:
description: Remote
required: false
default: ''
force:
description: Force
required: false
default: ''
target_commit:
description: Target Commit
required: false
default: ''
prefix:
description: Prefix
required: false
default: ''
outputs:
tag_created:
description: Tag Created
tag_deleted:
description: Tag Deleted
tags_list:
description: Tags List
tag_exists:
description: Tag Exists
operation_status:
description: Operation Status
runs:
using: docker
image: Dockerfile
EOF

# Generate Dockerfile
cat > "$OUTPUT_DIR/Dockerfile" << 'EOF'
# Generated from FCM - DO NOT EDIT
FROM python:3.9-slim

# Install system requirements
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*

# Copy implementation
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
EOF

# Generate entrypoint
cat > "$OUTPUT_DIR/entrypoint.sh" << 'EOF'
#!/bin/bash
# Generated entrypoint for tag-operations
# Implementation should be provided by external package

echo "Action: tag-operations"
echo "Capability: Manage git tags with create, delete, list, push, and check operations"
echo ""
echo "This is a generated placeholder."
echo "Actual implementation should be at: github.com/deepworks-net/tag-operations-action"

# Pass through to external implementation
# exec python -m tag_operations_action "$@"
EOF

chmod +x "$OUTPUT_DIR/entrypoint.sh"

# Generate bridge sync file
CHECKSUM=$(sha256sum "$FCM_FILE" | cut -d' ' -f1)
cat > "$OUTPUT_DIR/.bridge-sync" << EOF
{
"source": "$FCM_FILE",
"generated": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"version": "1.0.0",
"checksum": "sha256:$CHECKSUM"
}
EOF

# Update manifest
MANIFEST=".bridge/manifest.json"
if [ ! -f "$MANIFEST" ]; then
echo '{"mappings": {}, "generated": {}}' > "$MANIFEST"
fi

echo "Generated: $OUTPUT_DIR/action.yml"
echo " ✓ Created action.yml"
echo " ✓ Created Dockerfile"
echo " ✓ Created entrypoint.sh"
echo " ✓ Created .bridge-sync"
Loading
Loading