agentleFS
XueHua-sXueHua-s/ouchn-learn/.agents/skills/ai-exam-tool-architecture/SKILL.md

ai-exam-tool-architecture

Skill16 starsChanged 7 months agoMITView on GitHub

Design or review the OUCHN AI exam answer-tool architecture. Use when planning provider tool calling, tool-envelope fallback, DOM answer execution tools, error feedback, or refactoring AIResponse-driven answer filling into browser-safe tool execution.

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. About 0 are common, 12 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈12

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when working on the OUCHN AI automatic exam-answering architecture, especially when converting provider output into …

    line 8
  2. Very specific:

    Do not port Node.js APIs, React/TUI rendering, MCP, filesystem state caches, permission dialogs, or heavy telemetry.

    line 18
  3. Distinctive:

    Default DOM-writing tools to non-concurrency-safe.

    line 24
  4. Distinctive:

    Avoid shallow tools. A tool should own meaningful validation, execution, and result mapping.

    line 28
  5. Distinctive:

    Keep provider inference concurrency separate from DOM execution concurrency.

    line 29
  6. Distinctive:

    Use a compact local interface.

    line 33
  7. Very specific:

    Add a buildExamTool helper with defaults:

    line 51
  8. Distinctive:

    Start with the smallest tool set that creates a real boundary:

    line 59
  9. Very specific:

    If these would only delegate without owning validation, prefer one deeper answer_question tool first and split later.

    line 67
  10. Distinctive:

    Use typed error codes that can drive stats, retry, and debugging:

    line 71
  11. Distinctive:

    Do the migration incrementally:

    line 89
  12. Distinctive:

    Keep existing JSON answer prompts working.

    line 91
  13. Distinctive:

    Add JSON tool-envelope fallback for models without native tool calling:

    line 93
  14. Distinctive:

    Add native OpenAI/Claude tool mapping only after the internal executor contract is stable.

    line 103
  15. Distinctive:

    Before changing behavior, inspect and preserve these modules:

    line 108

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

AI Exam Tool Architecture Skill

Use this skill when working on the OUCHN AI automatic exam-answering architecture, especially when converting provider output into controlled tools that execute DOM writes in a Tampermonkey userscript.

Core Rule

Adopt the reference project's tool lifecycle, not its runtime stack. The browser userscript should have a small, deep tool layer:

provider tool intent -> registry lookup -> input validation -> semantic validation -> serial DOM execution -> typed result/error -> stats and feedback

Do not port Node.js APIs, React/TUI rendering, MCP, filesystem state caches, permission dialogs, or heavy telemetry. The target runtime is browser + Tampermonkey IIFE.

Design Principles

  • Tools must hide DOM and OUCHN compatibility details from providers.
  • Tool names are stable provider-visible contracts.
  • Default DOM-writing tools to non-concurrency-safe.
  • Validate model input shape before semantic/page validation.
  • Return typed results and typed errors; do not collapse failures into generic false.
  • Preserve current business behavior by wrapping existing fill/match/write logic first.
  • Avoid shallow tools. A tool should own meaningful validation, execution, and result mapping.
  • Keep provider inference concurrency separate from DOM execution concurrency.

Browser-Safe Tool Shape

Use a compact local interface. Avoid adding a schema library unless the implementation task explicitly accepts the dependency.

type ExamToolResult =
  | { ok: true; tool: string; questionIndex: number; filledCount?: number; detail?: string }
  | { ok: false; tool: string; questionIndex?: number; code: ExamToolErrorCode; message: string; retryable: boolean };

type ExamTool<Input> = {
  name: string;
  description: string;
  inputSchema: (input: unknown) => input is Input;
  validateInput?: (input: Input, context: ExamToolContext) => ExamToolResult | null;
  isConcurrencySafe?: (input: Input) => boolean;
  isReadOnly?: (input: Input) => boolean;
  execute: (input: Input, context: ExamToolContext) => Promise<ExamToolResult>;
};

Add a buildExamTool helper with defaults:

  • isConcurrencySafe: false
  • isReadOnly: false
  • validateInput: no extra semantic error

Recommended Tools

Start with the smallest tool set that creates a real boundary:

  • answer_choice: single selection and true/false.
  • answer_multiple_choice: multiple selection.
  • answer_blank: fill-in-blank.
  • answer_essay: short answer and unknown fallback.
  • answer_matching: matching/pairing questions.

If these would only delegate without owning validation, prefer one deeper answer_question tool first and split later.

Error Codes

Use typed error codes that can drive stats, retry, and debugging:

  • unknown_tool
  • invalid_tool_input
  • question_not_found
  • invalid_answer_shape
  • unknown_option_label
  • blank_count_mismatch
  • matching_pair_unresolved
  • dom_write_failed
  • unsupported_question_type
  • provider_parse_failed
  • tool_execution_cancelled

Each failure should include retryable. Provider-correctable input errors are retryable. Missing DOM/page-state failures usually are not retryable without re-extraction.

Provider Migration

Do the migration incrementally:

  1. Keep existing JSON answer prompts working.
  2. Convert parsed AIResponse into internal ExamToolUse[] before DOM writing.
  3. Add JSON tool-envelope fallback for models without native tool calling:
{
  "toolUses": [
    { "tool": "answer_choice", "input": { "questionIndex": 1, "answer": "C" } }
  ]
}
  1. Add native OpenAI/Claude tool mapping only after the internal executor contract is stable.
  2. Preserve per-question provider concurrency; execute DOM-writing tools serially.

Existing Code To Preserve

Before changing behavior, inspect and preserve these modules:

  • src/modules/exam/ai-provider.ts: per-question provider calls, vision handling, internal-index trust.
  • src/modules/exam/answer-fill.ts: answer filling, choice fallbacks, blank/editor logic, essay fallback sync.
  • src/modules/exam/answer-match.ts: matching answer parsing and multi-stage DOM/Angular fallbacks.
  • src/modules/exam/answer-write.ts: editor write and verification behavior.
  • src/modules/exam/question-extract.ts: authoritative Question metadata and DOM lookup.
  • src/types/exam.ts: Question, AnswerValue, AIResponse, ExamStats, integer sub-question index rules.

Review Checklist

  • Does the design reduce provider-to-DOM format leakage?
  • Are DOM-writing tools serial by default?
  • Are existing matching, blank, image, sub-question, and editor-sync protections preserved?
  • Are tool errors specific enough for stats and retry?
  • Is native tool calling optional, with JSON-envelope fallback?
  • Does the implementation avoid Node.js-only APIs and new runtime dependencies unless explicitly accepted?
  • Are tool abstractions deep enough to justify their module boundaries?

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.