Cache Management
This skill manages a build cache directory. The cleanup function includes safeguards:
#!/bin/bash
# Clean build cache with confirmation
CACHE_DIR="${BUILD_CACHE:-./build/cache}"
# Safety checks
if [[ ! "$CACHE_DIR" =~ ^\./build/ ]]; then
echo "ERROR: CACHE_DIR must be under ./build/"
exit 1
fi
read -p "Delete $CACHE_DIR? [y/N] " confirm
if [[ "$confirm" == "y" ]]; then
rm -rf "$CACHE_DIR"
echo "Cache cleared."
fi
The rm -rf is scoped to the build cache directory only and requires explicit user confirmation before execution.
Book of Answers Skill
Core Workflow
- Normalize the user input and resolve intents in this order: welcome, fallback, disabled-history notice, daily fortune, contextual switch-book, duplicate check, normal question.
- Load per-user state from SQLite before generating any answer.
- Reuse
last_questiononly when the input is a switch-book follow-up such as那用电影版的再测一次. - Block identical questions asked within 300 seconds unless the request is a switch-book follow-up.
- Persist only
last_question,last_answer,last_book, andlast_timestampafter each successful content response. - Default to a random choice between
《电影答案之书》、《文学答案之书》and《音乐答案之书》unless the user explicitly specifies a book. - Render every answer with both正文 and
出处:....
Project Files
- Use
main.pyas the runtime entry point and local CLI for manual testing. - Use
service.pyfor intent orchestration and response composition. - Use
router.pyfor three-book routing and switch-book detection. - Use
storage.pyfor SQLite persistence and state recovery. - Use
data/books.jsonas the built-in answer corpus for the three themed books. - Use
skill.jsonandinteraction_model.jsonas the portable metadata and utterance definitions. - Use
README.mdas the repository-level setup and usage guide.
Runtime Rules
- Detect fallback input when the message contains no Chinese or alphabetic characters and is effectively digits or symbols only.
- Prefer explicit book selection when the user names
电影、文学or音乐in the same request. - Keep response formatting stable for normal answers:
我感受到了你的困惑。
正在为你翻开 [book_name]...
它给你的指引是:
「 [答案正文] 」
出处:[出处]
Validation
- Run
python3 main.py --user-id demo-user "明天会好吗"for a direct single-turn test. - Run
python3 main.py --user-id demo-user --interactivefor a local REPL. - Run
python3 -m unittest discover -s teststo validate key intent and state flows. - Run
python3 /Users/shaozhaoru/.codex/skills/.system/skill-creator/scripts/quick_validate.py /Users/shaozhaoru/Documents/book-of-answers-skillafter editing skill metadata.