# READ CAREFULLY THEN REMOVE Remove bullet points that are not relevant. PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI. - Pull requests that do not follow these guidelines will be closed without review or comment. - If you use AI to write your PR description your pr will be close without review or comment. - If you are unsure about anything, feel free to ask for clarification. ## Description Please provide a clear description of your changes. --- ## Type of Change Please delete options that are not relevant. - [ ] 🐛 Bug fix (non-breaking change which fixes an issue) - [ ] ✨ New feature (non-breaking change which adds functionality) - [ ] 💥 Breaking change (fix or feature with breaking changes) - [ ] 📝 Documentation update - [ ] 🎨 UI/UX improvement - [ ] 🔒 Security enhancement - [ ] ⚡ Performance improvement ## Areas Affected Please check all that apply: - [ ] Email Integration (Gmail, IMAP, etc.) - [ ] User Interface/Experience - [ ] Authentication/Authorization - [ ] Data Storage/Management - [ ] API Endpoints - [ ] Documentation - [ ] Testing Infrastructure - [ ] Development Workflow - [ ] Deployment/Infrastructure ## Testing Done Describe the tests you've done: - [ ] Unit tests added/updated - [ ] Integration tests added/updated - [ ] Manual testing performed - [ ] Cross-browser testing (if UI changes) - [ ] Mobile responsiveness verified (if UI changes) ## Security Considerations For changes involving data or authentication: - [ ] No sensitive data is exposed - [ ] Authentication checks are in place - [ ] Input validation is implemented - [ ] Rate limiting is considered (if applicable) ## Checklist - [ ] I have read the [CONTRIBUTING](https://github.com/Mail-0/Zero/blob/staging/.github/CONTRIBUTING.md) document - [ ] My code follows the project's style guidelines - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in complex areas - [ ] I have updated the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix/feature works - [ ] All tests pass locally - [ ] Any dependent changes are merged and published ## Additional Notes Add any other context about the pull request here. ## Screenshots/Recordings Add screenshots or recordings here if applicable. --- _By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._ <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Commented out unused constants in prompts and voice provider files, and set a default server URL in the ElevenLabs tools script. <!-- End of auto-generated description by cubic. -->
Scripts
This folder contains utility scripts for the Zero email application. These scripts are designed to help with development, testing, and maintenance tasks that are not part of the main application flow.
Overview
The scripts system in Zero is built using cmd-ts, a TypeScript library for building type-safe command-line applications. This provides a structured way to create, organize, and run utility scripts with proper command-line argument handling, help text, and more.
How to Run Scripts
Scripts can be run using the scripts command from the project root:
# Run a script from the project root
pnpm scripts <script-name> [options]
# Example: Run the seed-style script
pnpm scripts seed-style
This command is defined in the root package.json and executes the script runner in the mail app:
"scripts": "dotenv -- pnpm run --cwd apps/mail --silent --elide-lines=0 scripts"
Available Scripts
seed-style
Seeds the writing style matrix for a given connection with sample emails of different styles. This is useful for testing and developing the writing style features of the application.
Usage:
# Interactive mode (will prompt for options)
pnpm scripts seed-style
# With command-line options
pnpm scripts seed-style seed --connection-id <id> --style <style> --size <number> [--reset]
# Or reset the style matrix
pnpm scripts seed-style reset --connection-id <id>
Options:
--connection-id, -c: The connection ID to seed the style matrix for--style, -s: The style to use (professional, persuasive, genz, concise, friendly)--size, -n: Number of emails to seed (default: 10)--reset, -r: Reset the style matrix before seeding
Subcommands:
seed: Seeds the style matrix with sample emailsreset: Resets the style matrix for a connection
How to Add New Scripts
To add a new script to the system:
- Create a new script file in the
apps/mail/scriptsdirectory or a subdirectory - Export a command object using the cmd-ts library
- Register the command in
apps/mail/scripts/run.ts
Step 1: Create a new script file
Create a new TypeScript file for your script. For example, apps/mail/scripts/my-script.ts:
import { command, option, string as stringType } from 'cmd-ts';
export const myScriptCommand = command({
name: 'my-script',
description: 'Description of what my script does',
args: {
// Define command-line arguments
param1: option({
type: stringType,
long: 'param1',
short: 'p',
description: 'Description of param1',
}),
},
handler: async (inputs) => {
// Script implementation
console.log(`Running my script with param1: ${inputs.param1}`);
// Do something useful here
},
});
Step 2: Register the command
Update apps/mail/scripts/run.ts to include your new command:
import { seedStyleCommand } from '@zero/mail/scripts/seed-style/seeder';
import { myScriptCommand } from '@zero/mail/scripts/my-script';
import { subcommands, run } from 'cmd-ts';
const app = subcommands({
name: 'scripts',
cmds: {
'seed-style': seedStyleCommand,
'my-script': myScriptCommand, // Add your new command here
},
});
await run(app, process.argv.slice(2));
process.exit(0);
Step 3: Run your script
You can now run your script using:
pnpm scripts my-script --param1 value
Best Practices
When creating scripts:
- Use cmd-ts features: Take advantage of the cmd-ts library for argument parsing, validation, and help text
- Interactive mode: Consider supporting both interactive mode (using prompts) and command-line options
- Error handling: Implement proper error handling and provide useful error messages
- Documentation: Document your script's purpose, usage, and options in this README
- Modularity: Break complex scripts into smaller, reusable functions
- Testing: Consider adding tests for critical script functionality
Dependencies
The scripts system uses several key dependencies:
- cmd-ts: Command-line parsing and execution
- @inquirer/prompts: Interactive command-line prompts
- p-all: Run promises in parallel with limited concurrency
- p-retry: Retry failed promises