feat: add inspect-shz-logs skill for log inspection and monitoring
- Implemented a new skill to inspect and follow SHZ backend logs with bounded read-only commands. - Added scripts for viewing local and production logs, including options for following logs. - Created references for log locations and usage guidelines. feat: add query-shz-highgo skill for database querying - Introduced a skill to query the SHZ HighGo database through an SSH gateway using a read-only psql workflow. - Included scripts for executing SQL queries and schema discovery. - Added connection details and usage instructions. feat: add OutdoorFairBooth domain and mapper - Created OutdoorFairBooth domain model with relevant fields and annotations. - Implemented a mapper interface for physical deletion of records based on fair ID. feat: create SQL scripts for cms_outdoor_fair_booth - Added SQL script to create the cms_outdoor_fair_booth table and its associated sequence. - Included comments for clarity and compatibility with historical data. - Added a script to drop the cms_venue_booth table after migration confirmation.
This commit is contained in:
56
.codex/skills/inspect-shz-logs/SKILL.md
Normal file
56
.codex/skills/inspect-shz-logs/SKILL.md
Normal file
@@ -0,0 +1,56 @@
|
||||
---
|
||||
name: inspect-shz-logs
|
||||
description: Inspect and follow the SHZ backend's local and production logs through bounded, read-only commands. Use when Codex is working in the shz-backend project and needs to diagnose startup failures, exceptions, request behavior, scheduled jobs, or runtime incidents from local backend.log or the production backend, error, info, and user logs on the shz server.
|
||||
---
|
||||
|
||||
# Inspect SHZ Logs
|
||||
|
||||
Use the bundled script instead of assembling SSH commands manually. Keep every initial read bounded; follow logs only when the user explicitly asks to monitor live activity.
|
||||
|
||||
## Inspect local logs
|
||||
|
||||
Read the last 200 lines:
|
||||
|
||||
```bash
|
||||
.codex/skills/inspect-shz-logs/scripts/view.sh local 200
|
||||
```
|
||||
|
||||
Follow the local log interactively:
|
||||
|
||||
```bash
|
||||
.codex/skills/inspect-shz-logs/scripts/view.sh local 200 --follow
|
||||
```
|
||||
|
||||
## Inspect production logs
|
||||
|
||||
Read the main application log:
|
||||
|
||||
```bash
|
||||
.codex/skills/inspect-shz-logs/scripts/view.sh online backend 200
|
||||
```
|
||||
|
||||
Read the current error log:
|
||||
|
||||
```bash
|
||||
.codex/skills/inspect-shz-logs/scripts/view.sh online error 200
|
||||
```
|
||||
|
||||
Choose only one production log type: `backend`, `error`, `info`, or `user`. Add `--follow` as the final argument only for an explicit live-monitoring request.
|
||||
|
||||
For keyword analysis, fetch a bounded window and filter locally, for example:
|
||||
|
||||
```bash
|
||||
.codex/skills/inspect-shz-logs/scripts/view.sh online error 1000 | rg -i 'exception|error|failed'
|
||||
```
|
||||
|
||||
## Diagnose from logs
|
||||
|
||||
1. Establish whether the request concerns local or production behavior.
|
||||
2. Read 100–300 recent lines from the relevant log.
|
||||
3. Expand up to the script's 5,000-line cap only when timestamps or stack traces require more context.
|
||||
4. Correlate timestamps, thread names, exception causes, and nearby requests.
|
||||
5. Report the evidence and likely cause without exposing tokens, passwords, personal data, or unrelated log content.
|
||||
|
||||
Treat production access as read-only. Never restart services, edit files, deploy code, truncate logs, or run arbitrary remote commands through this skill.
|
||||
|
||||
Read [references/log-locations.md](references/log-locations.md) only when checking server identity, paths, or supported log types.
|
||||
4
.codex/skills/inspect-shz-logs/agents/openai.yaml
Normal file
4
.codex/skills/inspect-shz-logs/agents/openai.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
interface:
|
||||
display_name: "查看 SHZ 项目日志"
|
||||
short_description: "安全查看并跟踪 SHZ 项目的本地与线上运行日志内容"
|
||||
default_prompt: "Use $inspect-shz-logs to inspect recent local or production logs for the SHZ backend."
|
||||
19
.codex/skills/inspect-shz-logs/references/log-locations.md
Normal file
19
.codex/skills/inspect-shz-logs/references/log-locations.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Log locations
|
||||
|
||||
## Local
|
||||
|
||||
- Main log: `<project>/.local/logs/backend.log`
|
||||
- Producer: `<project>/local.sh`
|
||||
|
||||
## Production: shz
|
||||
|
||||
- SSH: `root@39.98.44.136:6022`
|
||||
- Application: `/opt/service/project/shz-backend/ruoyi-admin/target/ruoyi-admin.jar`
|
||||
- Profile: `dev`
|
||||
- HTTP port: `9091`
|
||||
- Main process log: `/opt/service/project/shz-backend/logs/backend.log`
|
||||
- Current error log: `/opt/service/project/shz-backend/logs/sys-error.log`
|
||||
- Current info log: `/opt/service/project/shz-backend/logs/sys-info.log`
|
||||
- Current user log: `/opt/service/project/shz-backend/logs/sys-user.log`
|
||||
|
||||
Use only the bundled read-only viewer. Rotated files use date suffixes but are intentionally not exposed by the default script.
|
||||
109
.codex/skills/inspect-shz-logs/scripts/view.sh
Executable file
109
.codex/skills/inspect-shz-logs/scripts/view.sh
Executable file
@@ -0,0 +1,109 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
skill_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
project_dir="$(cd "${skill_dir}/../../.." && pwd)"
|
||||
local_log="${project_dir}/.local/logs/backend.log"
|
||||
|
||||
ssh_host="root@39.98.44.136"
|
||||
ssh_port="6022"
|
||||
remote_log_dir="/opt/service/project/shz-backend/logs"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
view.sh local [lines] [--follow]
|
||||
view.sh online [backend|error|info|user] [lines] [--follow]
|
||||
|
||||
Examples:
|
||||
view.sh local 200
|
||||
view.sh local 100 --follow
|
||||
view.sh online backend 200
|
||||
view.sh online error 500 --follow
|
||||
EOF
|
||||
}
|
||||
|
||||
validate_lines() {
|
||||
local lines="$1"
|
||||
if [[ ! "${lines}" =~ ^[0-9]+$ ]] || (( lines < 1 || lines > 5000 )); then
|
||||
echo "Lines must be an integer between 1 and 5000: ${lines}" >&2
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
validate_follow() {
|
||||
local follow="${1:-}"
|
||||
if [[ -n "${follow}" && "${follow}" != "--follow" ]]; then
|
||||
echo "Unknown option: ${follow}" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
view_local() {
|
||||
local lines="${1:-200}"
|
||||
local follow="${2:-}"
|
||||
validate_lines "${lines}"
|
||||
validate_follow "${follow}"
|
||||
|
||||
if [[ ! -f "${local_log}" ]]; then
|
||||
echo "Local log does not exist: ${local_log}" >&2
|
||||
echo "Start the project first with: ./local.sh start" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "${follow}" == "--follow" ]]; then
|
||||
tail -n "${lines}" -F -- "${local_log}"
|
||||
else
|
||||
tail -n "${lines}" -- "${local_log}"
|
||||
fi
|
||||
}
|
||||
|
||||
view_online() {
|
||||
local kind="${1:-backend}"
|
||||
local lines="${2:-200}"
|
||||
local follow="${3:-}"
|
||||
local remote_file
|
||||
|
||||
case "${kind}" in
|
||||
backend) remote_file="${remote_log_dir}/backend.log" ;;
|
||||
error) remote_file="${remote_log_dir}/sys-error.log" ;;
|
||||
info) remote_file="${remote_log_dir}/sys-info.log" ;;
|
||||
user) remote_file="${remote_log_dir}/sys-user.log" ;;
|
||||
*)
|
||||
echo "Unknown online log type: ${kind}" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
validate_lines "${lines}"
|
||||
validate_follow "${follow}"
|
||||
|
||||
if [[ "${follow}" == "--follow" ]]; then
|
||||
ssh -p "${ssh_port}" -o BatchMode=yes -o ConnectTimeout=10 "${ssh_host}" \
|
||||
tail -n "${lines}" -F -- "${remote_file}"
|
||||
else
|
||||
ssh -p "${ssh_port}" -o BatchMode=yes -o ConnectTimeout=10 "${ssh_host}" \
|
||||
tail -n "${lines}" -- "${remote_file}"
|
||||
fi
|
||||
}
|
||||
|
||||
target="${1:-}"
|
||||
case "${target}" in
|
||||
local)
|
||||
[[ $# -le 3 ]] || { usage >&2; exit 2; }
|
||||
view_local "${2:-200}" "${3:-}"
|
||||
;;
|
||||
online)
|
||||
[[ $# -le 4 ]] || { usage >&2; exit 2; }
|
||||
view_online "${2:-backend}" "${3:-200}" "${4:-}"
|
||||
;;
|
||||
help|-h|--help)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
42
.codex/skills/query-shz-highgo/SKILL.md
Normal file
42
.codex/skills/query-shz-highgo/SKILL.md
Normal file
@@ -0,0 +1,42 @@
|
||||
---
|
||||
name: query-shz-highgo
|
||||
description: Query the SHZ HighGo Security Enterprise Edition database through its SSH gateway using a guarded read-only psql workflow. Use when Codex is working in the shz-backend project and needs to inspect database schemas, tables, columns, row counts, or application data; diagnose data-related behavior; or execute SELECT, WITH, SHOW, or EXPLAIN statements against the project's HighGo database.
|
||||
---
|
||||
|
||||
# Query SHZ HighGo
|
||||
|
||||
Use the bundled script to run read-only SQL through the configured SSH gateway.
|
||||
|
||||
## Query workflow
|
||||
|
||||
1. Form the narrowest useful query. Add a small `LIMIT` when inspecting rows.
|
||||
2. For unfamiliar tables, inspect `information_schema.columns` before selecting business data.
|
||||
3. Run:
|
||||
|
||||
```bash
|
||||
.codex/skills/query-shz-highgo/scripts/query.sh 'SELECT current_database(), current_user, current_schema()'
|
||||
```
|
||||
|
||||
4. Summarize the result and distinguish returned facts from inferences.
|
||||
|
||||
The script accepts only statements beginning with `SELECT`, `WITH`, `SHOW`, or `EXPLAIN`, rejects multiple statements, sets `search_path` to `shz,public`, enforces database-level read-only mode, and applies a 30-second timeout. Never bypass these controls or perform writes unless the user explicitly requests a separate write-capable workflow.
|
||||
|
||||
## Schema discovery
|
||||
|
||||
List user tables:
|
||||
|
||||
```bash
|
||||
.codex/skills/query-shz-highgo/scripts/query.sh "SELECT table_schema, table_name FROM information_schema.tables WHERE table_schema NOT IN ('pg_catalog', 'information_schema') ORDER BY 1, 2"
|
||||
```
|
||||
|
||||
Inspect columns:
|
||||
|
||||
```bash
|
||||
.codex/skills/query-shz-highgo/scripts/query.sh "SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_schema = 'shz' AND table_name = 'lowercase_table_name' ORDER BY ordinal_position"
|
||||
```
|
||||
|
||||
HighGo may expose unquoted identifiers in lowercase and quoted identifiers with exact case. Query `information_schema` first when the spelling is uncertain.
|
||||
|
||||
## Connection details
|
||||
|
||||
Read [references/connection.md](references/connection.md) only when troubleshooting connectivity or updating the endpoint. Do not print, quote, or expose the password file.
|
||||
4
.codex/skills/query-shz-highgo/agents/openai.yaml
Normal file
4
.codex/skills/query-shz-highgo/agents/openai.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
interface:
|
||||
display_name: "查询 SHZ 翰高数据库"
|
||||
short_description: "通过 SSH 网关安全执行本项目翰高数据库只读 SQL 查询"
|
||||
default_prompt: "Use $query-shz-highgo to run a read-only query against this project's SHZ HighGo database."
|
||||
12
.codex/skills/query-shz-highgo/references/connection.md
Normal file
12
.codex/skills/query-shz-highgo/references/connection.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Connection reference
|
||||
|
||||
- SSH gateway: `root@124.243.245.42`
|
||||
- HighGo client: `/opt/HighGo4.5.7-see/bin/psql`
|
||||
- Database endpoint: `39.98.44.136:6023`
|
||||
- Database: `highgo`
|
||||
- User: `sysdba`
|
||||
- Default schemas: `shz,public`
|
||||
- Detected server: HighGo Security Enterprise Edition Database System 4.5.10
|
||||
- Password source: `../.password`, mode `600`; override with `HIGHGO_PASSWORD_FILE`
|
||||
|
||||
The SSH gateway must be reachable with the workstation's existing SSH key. Keep credentials out of commands, logs, responses, and `SKILL.md`.
|
||||
43
.codex/skills/query-shz-highgo/scripts/query.sh
Executable file
43
.codex/skills/query-shz-highgo/scripts/query.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
skill_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
password_file="${HIGHGO_PASSWORD_FILE:-$skill_dir/.password}"
|
||||
|
||||
ssh_host="root@124.243.245.42"
|
||||
psql_path="/opt/HighGo4.5.7-see/bin/psql"
|
||||
db_host="39.98.44.136"
|
||||
db_port="6023"
|
||||
db_name="highgo"
|
||||
db_user="sysdba"
|
||||
|
||||
if [[ ! -r "$password_file" ]]; then
|
||||
echo "HighGo password file is missing or unreadable: $password_file" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Usage: $0 'SELECT ...'" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
sql="$*"
|
||||
if [[ ! "$sql" =~ ^[[:space:]]*(SELECT|select|WITH|with|SHOW|show|EXPLAIN|explain)([[:space:]]|$) ]]; then
|
||||
echo "Rejected: only SELECT, WITH, SHOW, and EXPLAIN queries are allowed." >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
sql_without_final_semicolon="${sql%;}"
|
||||
if [[ "$sql_without_final_semicolon" == *';'* ]]; then
|
||||
echo "Rejected: multiple SQL statements are not allowed." >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
password="$(<"$password_file")"
|
||||
sql_base64="$(printf '%s' "$sql" | base64 | tr -d '\n')"
|
||||
|
||||
{
|
||||
printf '%s\n' "$password"
|
||||
printf '%s\n' "$sql_base64"
|
||||
} | ssh -o BatchMode=yes -o ConnectTimeout=10 "$ssh_host" \
|
||||
"read -r PGPASSWORD; read -r SQL_BASE64; export PGPASSWORD; export PGOPTIONS='-c default_transaction_read_only=on -c search_path=shz,public -c statement_timeout=30000'; SQL=\$(printf '%s' \"\$SQL_BASE64\" | base64 -d); exec '$psql_path' -X --no-psqlrc -h '$db_host' -p '$db_port' -U '$db_user' -d '$db_name' -v ON_ERROR_STOP=1 -P pager=off -c \"\$SQL\""
|
||||
Reference in New Issue
Block a user