harvester-ui-extension/scripts/generate-agent-and-persona-mds.sh
Andy Lee 67bb6dfbd5
docs: add AGENTS.md for AI agent guidance (#837)
* feat: add AGENNTS.md

Signed-off-by: Andy Lee <andy.lee@suse.com>

* refactor: update based on copilot feedback

Signed-off-by: Andy Lee <andy.lee@suse.com>

* refactor: update AGENTS.md

Signed-off-by: Andy Lee <andy.lee@suse.com>

* refactor: update based on AI suggestion

Signed-off-by: Andy Lee <andy.lee@suse.com>

* refactor: based on comments

Signed-off-by: Andy Lee <andy.lee@suse.com>

* refactor: some files

Signed-off-by: Andy Lee <andy.lee@suse.com>

* refactor: boundaries.md

Signed-off-by: Andy Lee <andy.lee@suse.com>

---------

Signed-off-by: Andy Lee <andy.lee@suse.com>
2026-04-29 16:05:51 +08:00

45 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -e
# Get the directory of the script
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Project root is one level up from scripts/
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
# Source files
TEMPLATE_FILE="${PROJECT_ROOT}/docs/agents.md/template_agents.md"
AGENTS_DIR="${PROJECT_ROOT}/docs/agents.md/agents"
CONTRIBUTORS_DIR="${PROJECT_ROOT}/docs/agents.md/contributors"
PERSONAS_DIR="${PROJECT_ROOT}/docs/agents.md/personas"
# Destination file
OUTPUT_FILE="${PROJECT_ROOT}/AGENTS.md"
insert_directory_contents() {
local dir="$1"
if [ -d "$dir" ]; then
for file in "$dir"/*; do
if [ -f "$file" ]; then
cat "$file"
echo ""
fi
done
fi
}
echo "Generating ${OUTPUT_FILE}..."
while IFS= read -r line || [ -n "$line" ]; do
if [[ "$line" == *"<agents>"* ]]; then
insert_directory_contents "${AGENTS_DIR}"
elif [[ "$line" == *"<contributors>"* ]]; then
insert_directory_contents "${CONTRIBUTORS_DIR}"
elif [[ "$line" == *"<personas>"* ]]; then
insert_directory_contents "${PERSONAS_DIR}"
else
echo "$line"
fi
done < "${TEMPLATE_FILE}" > "${OUTPUT_FILE}"
echo "Done."