← Browse

@tooluse/tool-use-ai

C

Tool-Use Repository Development Guidelines

rulescursor

Install

agr install @tooluse/tool-use-ai --target cursor

Writes 1 file into .cursor/rules/, pinned to git-9308ccfb.

  • .cursorrules

Document

Tool-Use Repository Development Guidelines

Creating a New Script

To add a new script to the tool-use repository, you need to modify several files:

  1. Create a new script file in src/tool_use/scripts/:

Example: src/tool_use/scripts/my_script.py from ..utils.ai_service import AIService from ..config_manager import config_manager def main(args): config_values = config_manager.get_tool_config("script_name") # Your script implementation pass if name == "main": try: main() except KeyboardInterrupt: console.print("\n[yellow]Operation cancelled by user.[/yellow]") sys.exit(0) except Exception as e: console.print(f"\n[red]An unexpected error occurred: {e}[/red]") sys.exit(1)

  1. Add dependencies to src/tool_use/scripts/_script_dependencies.py:

SCRIPT_DEPENDENCIES = {

... existing dependencies ...

"my-script": ["required-package1", "required-package2"] }

  1. Add configuration in src/tool_use/utils/config_wizard.py: SCRIPT_INFO = {

... existing scripts ...

"my-script": { "name": "My Script", "description": "What your script does", "config_keys": [ { "key": "my_config_key", "prompt": "Enter configuration value:", "description": "What this config value does", "required": True } ] } }

  1. Update src/tool_use/cli.py:
  • Add to all_scripts dictionary
  • Add to script_modules mapping
  1. Add script to README.md

Using AIService

The AIService utility (src/tool_use/utils/ai_service.py) provides a standardized way to interact with AI models. Example usage from prioritize.py:

from ..utils.ai_service import AIService

Initialize the service

ai = AIService()

Simple completion

response = ai.query("Your prompt here")

#Structured output

class Example(BaseModel): example: str = Field(description="example")

class StructuredOutput(BaseModel): """Example description for the structured output, keys can be any pydantic supported field""" field1: str = Field(description="First field for the output") field2: List[Example] = Field(description="List of examples")

Structured outputs only supported by openai

ai_service = AIService(service_type="openai") response = ai_service.query_structured(prompt, StructuredOutput, system_prompt)

field1, field2 = response

Script Best Practices

  1. Use config_manager for settings:

from ..config_manager import config_manager config_values = config_manager.get_tool_config("script_name")

  1. Handle arguments properly: def main(args): print("Usage: tool-use my-script [args]") return

  2. Provide clear error messages and user feedback

  3. Follow existing patterns for consistency:

  • Use relative imports
  • Handle dependencies through SCRIPT_DEPENDENCIES
  • Provide configuration through config_wizard
  • Document usage in script's docstring

Error Handling

Make sure to handle errors gracefully and provide clear error messages to the user.

Formatting

  • Use Rich when possible to display print statements in a visually appealing way

Common Patterns

  1. AI Integration:

    • Use AIService for AI interactions
    • Structure prompts clearly
    • Handle API errors gracefully
  2. Configuration:

    • Use config_wizard for user settings
    • Validate config values
    • Provide clear configuration prompts
  3. CLI Integration:

    • Follow existing argument patterns
    • Provide help text
    • Handle invalid inputs gracefully

Trustgrade C

  • passBody integrity

    Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.

  • passType matchnot applicable to this artifact type

    Whether the artifact is really the kind of thing its metadata claims it is.

  • warnFreshnessstale (>1y)

    How long since the source repository was last pushed to.

  • passPrompt injection

    Scans the artifact's own text for instructions aimed at your agent rather than at you.

  • warnLicenseno SPDX license detected

    Whether the source repository declares an SPDX license permissive enough to redistribute.

How the grade is calculated

Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:

  • Aevery check passed
  • Bone warning
  • Ctwo warnings
  • Dprompt injection or body integrity failed, or three warnings
  • Fone of those failed, and something else is wrong

These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged — not that the artifact is safe.

Versions

  • git-9308ccfb90a12026-08-06