# Task


Analyze the provided files and provide insights.
```

## Core Functions

[Section titled “Core Functions”](#core-functions)

### script() - Script Configuration

[Section titled “script() - Script Configuration”](#script---script-configuration)

```js
script({
  // Metadata
  title: "Script Name",
  description: "What it does",
  group: "category",


  // Model settings
  model: "openai:gpt-4o",
  temperature: 0.1,
  maxTokens: 4000,


  // File handling
  files: "**/*.md",
  accept: ".md,.txt,.js",
  ignore: "**/node_modules/**",


  // Tools & capabilities
  tools: ["fs_read_file", "web_search"],
  vision: true,
  cache: true,


  // Testing
  tests: [
    {
      files: "test.md",
      keywords: ["expected", "output"],
    },
  ],
});
```

### def() - Include Content

[Section titled “def() - Include Content”](#def---include-content)

```js
// Basic usage
def("VAR_NAME", content);


// With options
def("FILES", env.files, {
  lineNumbers: true, // Add line numbers
  maxTokens: 1000, // Limit token count
  language: "markdown", // Specify language
  glob: "**/*.md", // Filter files by pattern
  endsWith: ".js", // Filter by extension
  sliceHead: 100, // Take first N lines
  sliceTail: 50, // Take last N lines
});


// From file
def("CONFIG", await workspace.readText("config.json"));


// Multiple files
def(
  "DOCS",
  env.files.filter((f) => f.endsWith(".md")),
);
```

### $“ - Template Prompts

[Section titled “$“ - Template Prompts”](#---template-prompts)

```js
// Simple prompt
$`Write a summary of the content.`;


// Multi-line prompt
$`
You are an expert reviewer.
Analyze the FILES and:
1. Check for errors
2. Suggest improvements
3. Rate quality 1-10
`;


// With variables
const task = "summarize";
$`Please ${task} the provided content.`;
```

## `env`

[Section titled “env”](#env)

### env.files

[Section titled “env.files”](#envfiles)

```js
// Current selection/context files
def("FILES", env.files);


// Filter files
const mdFiles = env.files.filter((f) => f.endsWith(".md"));
const jsFiles = env.files.filter((f) =>
  f.filename.endsWith(".js"),
);
```

### Parameters

[Section titled “Parameters”](#parameters)

```js
script({
  parameters: {
    topic: {
      type: "string",
      description: "Topic to write about",
    },
    count: { type: "number", default: 5 },
  },
});


$`Write ${env.parameters.count} facts about ${env.parameters.topic}.`;
```

## Inline Prompts

[Section titled “Inline Prompts”](#inline-prompts)

```js
const summary = await runPrompt((_) => {
  _.def("FILE", file);
  _.$`Summarize FILE in one sentence.`;
});
def("SUMMARY", summary.text);
```

## File Operations

[Section titled “File Operations”](#file-operations)

### Reading Files

[Section titled “Reading Files”](#reading-files)

```js
// Read text file
const content = await workspace.readText("path/to/file.txt");


// Read JSON
const data = await workspace.readJSON("data.json");


// Search files
const { files } = await workspace.grep(/pattern/, {
  globs: "**/*.js",
});


// Find files
const matches = await workspace.findFiles("**/*.md", {
  maxFiles: 100,
});
```

## Data Handling

[Section titled “Data Handling”](#data-handling)

### Schemas & Validation

[Section titled “Schemas & Validation”](#schemas--validation)

```js
const schema = defSchema("DATA", {
  type: "object",
  properties: {
    name: { type: "string" },
    age: { type: "number" },
    skills: {
      type: "array",
      items: { type: "string" },
    },
  },
  required: ["name"],
});


$`Extract data using ${schema} format.`;
```

### File Parsers

[Section titled “File Parsers”](#file-parsers)

```js
// CSV - structured data
const rows = await parsers.CSV(file);
defData("TABLE", rows, { sliceHead: 10 });


// PDF - documents
const { pages } = await parsers.PDF(file);
def("CONTENT", pages.map((p) => p.content).join("\n"));


// DOCX - Word documents
const { content } = await parsers.DOCX(file);


// XLSX - spreadsheets
const { worksheets } = await parsers.XLSX(file);
const sheet1 = worksheets[0];


// JSON - structured config
const config = await parsers.JSON(file);


// YAML - configuration files
const settings = await parsers.YAML(file);


// XML - markup data
const { content } = await parsers.XML(file);
```

### Data Transformation

[Section titled “Data Transformation”](#data-transformation)

```js
// Filter and process data
const markdownFiles = env.files.filter((f) =>
  f.endsWith(".md"),
);
const recentFiles = env.files.filter(
  (f) => new Date(f.lastModified) > new Date("2024-01-01"),
);


// Transform data for context
defData("SUMMARY", {
  totalFiles: env.files.length,
  fileTypes: [...new Set(env.files.map((f) => f.extension))],
  totalSize: env.files.reduce((sum, f) => sum + f.size, 0),
});
```

## Tools & Agents

[Section titled “Tools & Agents”](#tools--agents)

### Built-in Tools

[Section titled “Built-in Tools”](#built-in-tools)

```js
script({
  tools: [
    "fs_read_file", // File system read
    "fs_find_files", // File search
    "web_search", // Web search
    "math_eval", // Math evaluation
    "python_code_interpreter", // Code execution
  ],
});
```

### Custom Tools

[Section titled “Custom Tools”](#custom-tools)

```js
defTool(
  "weather",
  "Get current weather",
  {
    city: { type: "string", description: "City name" },
  },
  async ({ city }) => {
    // Tool implementation
    return `Weather in ${city}: Sunny, 25°C`;
  },
);
```

### Agents

[Section titled “Agents”](#agents)

```js
script({ tools: "agent_fs" }); // File system agent
script({ tools: "agent_git" }); // Git operations agent
script({ tools: "agent_playwright" }); // Web automation agent


// Custom agent
defAgent("myagent", "Description", "You are helpful", {
  tools: ["fs_read_file", "web_search"],
});
```

## Images & Media

[Section titled “Images & Media”](#images--media)

### Images

[Section titled “Images”](#images)

```js
// Include images in prompt
defImages(
  env.files.filter((f) => f.endsWith(".png")),
  {
    autoCrop: true,
    details: "low", // or "high"
  },
);


// Generate images
const { image } = await generateImage("a cute cat");
```

### Videos

[Section titled “Videos”](#videos)

```js
// Extract frames
const frames = await ffmpeg.extractFrames(videoFile, {
  count: 5,
});
defImages(frames);


// Transcription
const transcript = await transcript(audioFile);
def("TRANSCRIPT", transcript.text);
```

## CLI Commands

[Section titled “CLI Commands”](#cli-commands)

### Running Scripts

[Section titled “Running Scripts”](#running-scripts)

```bash