Below, you'll find a set of examples displaying how to use a certain Domain Specific…
- User
Below, you'll find a set of examples displaying how to use a certain Domain Specific Language. Your job is to work backwards from the examples, infer what the purpose of the DSL may be, define any additional functionality (with examples), and define a comprehensive PRD covering the DSL in question. It's a novel language so do not try to define it as any existing language.
Subsequently, define in pseudocode the language syntax / grammar.
Example 1: `>write path/to/my/file.ext <<EOF This is content from the file: path/to/my/file.ext
EOF`
EXAMPLE 2: `# Read from a file descriptor until EOF
read '/my/hand le/path' - MyVariableName
Write the value to a new prompt
prepare prompt as MyExamplePrompt << $MyVariableName
Associate the prompt with an agent (create a job)
assign MyExamplePrompt as MyExampleJob
Execute the job
execute $MyExampleJob`
- Assistant
Product Requirements Document (PRD)
Product Name: Agent Interaction Scripting Language (AISL)
Introduction
The Agent Interaction Scripting Language (AISL) is a domain-specific language designed to facilitate automation and interaction with software agents (such as AI models, services, or scripts). It provides a straightforward syntax for performing file operations, managing variables and prompts, assigning tasks to agents, and executing jobs. AISL enables users to script complex workflows involving the manipulation of files and data, preparation of dynamic prompts, and orchestration of agent activities in an efficient and readable manner.
Purpose and Scope
AISL is intended for users who need to automate tasks that involve:
- Reading from and writing to files.
- Managing variables and incorporating them into content.
- Preparing prompts or messages for agents.
- Assigning agents to perform jobs based on prepared prompts.
- Executing and managing jobs.
- Incorporating control flow mechanisms (conditions, loops, functions) into their scripts.
Features
-
File Operations
-
Write to a File
- Syntax:
> write [filepath] <<EOF ... EOF - Description: Writes the specified content into the file at the given path. If the file does not exist, it will be created.
- Example:
> write 'output.txt' <<EOF This is the output file content. EOF
- Syntax:
-
Read from a File
- Syntax:
> read [filepath] - [VariableName] - Description: Reads the content of the specified file into a variable.
- Example:
> read 'data/input.txt' - InputData
- Syntax:
-
Append to a File
- Syntax:
> append [filepath] <<EOF ... EOF - Description: Appends the specified content to the end of the file.
- Example:
> append 'log.txt' <<EOF New log entry at $Timestamp EOF
- Syntax:
-
Delete a File
- Syntax:
> delete [filepath] - Description: Deletes the specified file.
- Example:
> delete 'temp/output.tmp'
- Syntax:
-
Directory Operations
- Create a Directory
- Syntax:
> mkdir [directorypath] - Example:
> mkdir 'results/data'
- Syntax:
- List Directory Contents
- Syntax:
> ls [directorypath] - [VariableName] - Description: Lists the contents of the directory and stores them in a variable.
- Example:
> ls 'data/' - DataFiles
- Syntax:
- Create a Directory
-
-
Variable Management
-
Assigning Values
- Syntax:
> set [VariableName] = [Value] - Description: Assigns a value to a variable. Values can be strings, numbers, or the result of expressions.
- Example:
> set UserName = 'Alice' > set Counter = 0
- Syntax:
-
Referencing Variables
- Syntax: Use
$VariableNameto reference a variable's value. - Example:
> write 'greeting.txt' <<EOF Hello, $UserName! EOF
- Syntax: Use
-
Arithmetic Operations
- Syntax supports basic arithmetic operations.
- Example:
> set Counter = $Counter + 1
-
-
Prompt Management
- Prepare a Prompt
- Syntax:
> prepare prompt as [PromptName] <<EOF ... EOF - Description: Creates a prompt with the specified content and assigns it a name for later use.
- Example:
> prepare prompt as WelcomePrompt <<EOF Welcome, $UserName! How can I assist you today? EOF
- Syntax:
- Prepare a Prompt
-
Agent Management
- Assign an Agent and Prompt to Create a Job
- Syntax:
> assign $AgentName $PromptName as [JobName] - Description: Combines an agent and a prompt into a job, assigning a unique job name.
- Example:
> assign $CustomerServiceAgent $WelcomePrompt as WelcomeJob
- Syntax:
- Assign an Agent and Prompt to Create a Job
-
Job Execution
- Execute a Job
- Syntax:
> execute $JobName - Description: Executes the specified job.
- Example:
> execute $WelcomeJob
- Syntax:
- Execute a Job
-
Control Flow
-
Conditional Statements
- Syntax:
> if [Condition] > then [Commands] > else [Commands] > endif - Description: Executes commands based on a condition.
- Example:
> if $UserName == 'Admin' > then > set AccessLevel = 'Full' > else > set AccessLevel = 'Limited' > endif
- Syntax:
-
Loops
-
For Loop
- Syntax:
> for $Item in $ItemList > do [Commands] > done - Description: Iterates over items in a list variable.
- Example:
> for $File in $DataFiles > do > read 'data/$File' - FileContent > process $FileContent > done
- Syntax:
-
While Loop
- Syntax:
> while [Condition] > do [Commands] > done - Description: Repeats commands while a condition is true.
- Example:
> while $Counter < 10 > do > set Counter = $Counter + 1 > done
- Syntax:
-
-
-
Functions
-
Define a Function
- Syntax:
> function [FunctionName] [Parameters] > do [Commands] > endfunction - Description: Defines a reusable set of commands.
- Example:
> function greetUser $Name > do > write 'greeting.txt' <<EOF Hello, $Name! EOF > endfunction
- Syntax:
-
Call a Function
- Syntax:
> [FunctionName] [Arguments] - Example:
> greetUser 'Bob'
- Syntax:
-
-
Comments
- Single-Line Comments
- Syntax:
# Comment text - Description: Any text following
#is considered a comment and ignored during execution. - Example:
# This is a comment explaining the following command > set Counter = $Counter + 1
- Syntax:
- Single-Line Comments
Additional Functionality Examples
-
Appending to a File
> append 'notes.txt' <<EOF Remember to check the logs. EOF -
Deleting a File
> delete 'old_report.txt' -
Conditional Execution
> if $UserInput == 'yes' > then > execute $ConfirmationJob > endif -
Looping Over a List
> read 'users.txt' - UserList > for $User in $UserList > do > prepare prompt as UserPrompt <<EOF Dear $User, your account has been updated. EOF > assign $NotificationAgent $UserPrompt as NotificationJob > execute $NotificationJob > done -
Using Functions
> function logMessage $Message > do > append 'logfile.txt' <<EOF [$Timestamp] $Message EOF > endfunction > set Timestamp = '2023-10-01 12:00:00' > logMessage 'Job started' -
Error Handling (Try-Catch Block)
- Note: Error handling mechanisms can be designed as per the language capabilities.
> try > read 'critical_data.txt' - CriticalData > catch FileNotFoundError > write 'error.log' <<EOF Critical data file not found. EOF > endtry
Language Syntax / Grammar (Pseudocode)
Below is the pseudocode representation of the AISL syntax and grammar.
Tokens
COMMAND_PREFIX=>COMMENT_SYMBOL=#VARIABLE_PREFIX=$STRING_LITERAL='...'or"..."IDENTIFIER=[a-zA-Z_][a-zA-Z0-9_]*NUMBER=[0-9]+(\.[0-9]+)?NEWLINE= End of line characterEOF_MARKER=EOF
Grammar Rules
-
Script Structure
Script ::= (CommandLine | BlankLine | CommentLine)* CommandLine ::= COMMAND_PREFIX Command NEWLINE CommentLine ::= COMMENT_SYMBOL Text NEWLINE BlankLine ::= NEWLINE -
Commands
Command ::= FileCommand | VariableCommand | PromptCommand | AgentCommand | JobCommand | ControlFlowCommand | FunctionCommand | ExecutionCommand | OtherCommand -
File Commands
FileCommand ::= 'write' StringLiteral '<<' EOF_MARKER NEWLINE Content EOF_MARKER NEWLINE | 'read' StringLiteral '-' VariableName | 'append' StringLiteral '<<' EOF_MARKER NEWLINE Content EOF_MARKER NEWLINE | 'delete' StringLiteral | 'mkdir' StringLiteral | 'ls' StringLiteral '-' VariableName Content ::= (Text | VariableReference)* StringLiteral ::= STRING_LITERAL Text ::= Any sequence of characters excluding NEWLINE -
Variable Commands
VariableCommand ::= 'set' VariableName '=' Expression VariableName ::= IDENTIFIER VariableReference ::= VARIABLE_PREFIX VariableName Expression ::= StringLiteral | Number | VariableReference | Expression Operator Expression Operator ::= '+' | '-' | '*' | '/' | '%' -
Prompt Commands
PromptCommand ::= 'prepare' 'prompt' 'as' PromptName '<<' EOF_MARKER NEWLINE Content EOF_MARKER NEWLINE PromptName ::= IDENTIFIER -
Agent Commands
AgentCommand ::= 'assign' VariableReference PromptReference 'as' JobName PromptReference ::= VariableReference -
Job Commands
JobCommand ::= 'execute' VariableReference JobName ::= IDENTIFIER -
Control Flow Commands
ControlFlowCommand ::= IfStatement | ForLoop | WhileLoop IfStatement ::= 'if' Condition NEWLINE INDENT 'then' NEWLINE INDENT CommandBlock [INDENT 'else' NEWLINE INDENT CommandBlock] INDENT 'endif' ForLoop ::= 'for' VariableReference 'in' VariableReference NEWLINE INDENT 'do' NEWLINE INDENT CommandBlock INDENT 'done' WhileLoop ::= 'while' Condition NEWLINE INDENT 'do' NEWLINE INDENT CommandBlock INDENT 'done' Condition ::= Expression ComparisonOperator Expression ComparisonOperator ::= '==' | '!=' | '<' | '>' | '<=' | '>=' CommandBlock ::= (CommandLine | CommentLine | BlankLine)* INDENT ::= (Space or Tab characters) -
Function Commands
FunctionCommand ::= 'function' FunctionName [ParameterList] NEWLINE INDENT 'do' NEWLINE INDENT CommandBlock INDENT 'endfunction' ParameterList ::= ParameterName (',' ParameterName)* FunctionName ::= IDENTIFIER FunctionCall ::= FunctionName [ArgumentList] ArgumentList ::= Argument (',' Argument)* Argument ::= Expression -
Execution Commands
ExecutionCommand ::= FunctionCall | OtherCommand -
Other Commands
OtherCommand ::= Any command defined by extensions or custom implementations
Explanation of Syntax Elements
- Commands: Each command begins with
>and specifies an action. - Variables: Declared using
setand referenced with$VariableName. - Strings: Enclosed in single or double quotes.
- Comments: Start with
#and continue to the end of the line. - Control Structures: Use
if,for, andwhileblocks for flow control. - Functions: Defined using
functionand invoked by their names. - Indentation: Used for readability within blocks but not mandatory;
doanddonemark block boundaries.
Notes
- Variable Scope: Variables are global unless specifically managed within functions.
- Error Handling: Implementations can extend the language with error handling constructs such as
tryandcatch. - Extensibility: The language can be extended with additional commands and functionalities as needed.
Conclusion
The AISL provides a comprehensive set of commands and structures to enable users to script automated interactions with agents, manage files and variables, and control the execution flow of tasks. By offering a clear and consistent syntax, AISL simplifies the process of writing scripts for complex workflows involving agents and data manipulation.