feat: implement AI-assisted rename prompting feature
- Added data model for AI-assisted renaming including structures for prompts, responses, and policies. - Created implementation plan detailing the integration of Google Genkit into the CLI for renaming tasks. - Developed quickstart guide for setting up and using the new AI rename functionality. - Documented research decisions regarding Genkit orchestration and prompt composition. - Established tasks for phased implementation, including setup, foundational work, and user stories. - Implemented contract tests to ensure AI rename policies and ledger metadata are correctly applied. - Developed integration tests for validating AI rename flows, including preview, apply, and undo functionalities. - Added tooling to pin Genkit dependency for consistent builds.
This commit is contained in:
61
scripts/smoke-test-ai.sh
Executable file
61
scripts/smoke-test-ai.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
BIN="go run"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
mkdir -p "$TMP_DIR"
|
||||
touch "$TMP_DIR/raw_demo 01.txt"
|
||||
touch "$TMP_DIR/raw_demo 02.txt"
|
||||
|
||||
PLAN_JSON="$TMP_DIR/ai-plan.json"
|
||||
|
||||
echo "Generating initial AI plan preview..."
|
||||
$BIN "$ROOT_DIR/main.go" ai --path "$TMP_DIR" --dry-run --export-plan "$PLAN_JSON" >/dev/null
|
||||
|
||||
if [[ ! -s "$PLAN_JSON" ]]; then
|
||||
echo "expected plan export at $PLAN_JSON" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Editing exported plan for deterministic names..."
|
||||
python3 - <<'PY'
|
||||
import json, pathlib
|
||||
path = pathlib.Path("$PLAN_JSON")
|
||||
plan = json.loads(path.read_text())
|
||||
for idx, item in enumerate(plan.get("items", []), start=1):
|
||||
item["proposed"] = f"{idx:03d}_final_demo.txt"
|
||||
plan["warnings"] = plan.get("warnings", []) + ["edited in smoke script"]
|
||||
path.write_text(json.dumps(plan, indent=2) + "\n")
|
||||
PY
|
||||
|
||||
echo "Validating edited plan (dry run)..."
|
||||
$BIN "$ROOT_DIR/main.go" ai --path "$TMP_DIR" --dry-run --import-plan "$PLAN_JSON" >/dev/null
|
||||
|
||||
echo "Applying edited plan..."
|
||||
$BIN "$ROOT_DIR/main.go" ai --path "$TMP_DIR" --import-plan "$PLAN_JSON" --yes >/dev/null
|
||||
|
||||
if [[ ! -f "$TMP_DIR/001_final_demo.txt" ]]; then
|
||||
echo "expected 001_final_demo.txt to exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f "$TMP_DIR/002_final_demo.txt" ]]; then
|
||||
echo "expected 002_final_demo.txt to exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Undoing AI plan application..."
|
||||
$BIN "$ROOT_DIR/main.go" undo --path "$TMP_DIR" >/dev/null
|
||||
|
||||
if [[ ! -f "$TMP_DIR/raw_demo 01.txt" ]]; then
|
||||
echo "undo failed to restore raw_demo 01.txt" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f "$TMP_DIR/raw_demo 02.txt" ]]; then
|
||||
echo "undo failed to restore raw_demo 02.txt" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "AI smoke test succeeded."
|
||||
Reference in New Issue
Block a user