Script Tools / Repo Quickscan
Source: examples/tools/script_tools/repo_quickscan.sh
Introduction
This script focuses on the practical so-what for tool integration: a deterministic, inspectable JSON contract for repository quickscan operations.
Technical Implementation
Read JSON input from
stdinand execute the quickscan workflow.Write report + trace artifacts under
artifacts/.Emit one JSON envelope on
stdoutwithok/result/artifacts/warnings/error.
flowchart LR
A["JSON input payload"] --> B["repo_quickscan.sh"]
B --> C["report.txt + trace artifact"]
C --> D["JSON envelope on stdout"]
1#!/usr/bin/env bash
2# # Script Tools / Repo Quickscan.
3#
4# ## Introduction
5# This script focuses on the practical so-what for tool integration: a deterministic, inspectable JSON
6# contract for repository quickscan operations.
7#
8# ## Technical Implementation
9# 1. Read JSON input from ``stdin`` and execute the quickscan workflow.
10# 2. Write report + trace artifacts under ``artifacts/``.
11# 3. Emit one JSON envelope on ``stdout`` with ``ok/result/artifacts/warnings/error``.
12#
13# ```mermaid
14# flowchart LR
15# A["JSON input payload"] --> B["repo_quickscan.sh"]
16# B --> C["report.txt + trace artifact"]
17# C --> D["JSON envelope on stdout"]
18# ```
19#
20# ## Expected Results
21# - Reads one JSON object from ``stdin``.
22# - Prints one JSON envelope containing ``ok/result/artifacts``.
23# - Writes artifacts under ``artifacts/repo_quickscan`` and ``artifacts/examples/traces``.
24
25set -euo pipefail
26
27artifact_dir="artifacts/repo_quickscan"
28mkdir -p "$artifact_dir"
29report_path="$artifact_dir/report.txt"
30
31ls -la > "$report_path"
32line_count=$(wc -l < "$report_path" | tr -d ' ')
33
34trace_dir="artifacts/examples/traces"
35mkdir -p "$trace_dir"
36request_id="example-script-repo-quickscan-001"
37timestamp=$(date -u +"%Y%m%dT%H%M%SZ")
38safe_request_id=$(printf '%s' "$request_id" | tr -c 'A-Za-z0-9_-' '_')
39trace_path="$trace_dir/run_${timestamp}_${safe_request_id}.jsonl"
40printf '{"event_type":"ScriptToolCompleted","run_id":"%s","attributes":{"line_count":%s}}\n' "$request_id" "$line_count" > "$trace_path"
41
42printf '{"ok":true,"result":{"line_count":%s,"trace_path":"%s"},"artifacts":[{"path":"%s","mime":"text/plain"},{"path":"%s","mime":"application/x-ndjson"}],"warnings":[],"error":null}\n' "$line_count" "$trace_path" "$report_path" "$trace_path"
Expected Results
Run Command
bash examples/tools/script_tools/repo_quickscan.sh
Reads one JSON object from
stdin.Prints one JSON envelope containing
ok/result/artifacts.Writes artifacts under
artifacts/repo_quickscanandartifacts/examples/traces.