![]() |
VOOZH | about |
dotnet add package FsAgent --version 0.3.1
NuGet\Install-Package FsAgent -Version 0.3.1
<PackageReference Include="FsAgent" Version="0.3.1" />
<PackageVersion Include="FsAgent" Version="0.3.1" />Directory.Packages.props
<PackageReference Include="FsAgent" />Project file
paket add FsAgent --version 0.3.1
#r "nuget: FsAgent, 0.3.1"
#:package FsAgent@0.3.1
#addin nuget:?package=FsAgent&version=0.3.1Install as a Cake Addin
#tool nuget:?package=FsAgent&version=0.3.1Install as a Cake Tool
A small DSL and library for generating custom agent files for popular agent tools
prompt { ... } builder{{{variable}}} syntax)open FsAgent.Prompts
let assistantPrompt = prompt {
role "You are a helpful coding assistant"
objective "Help users with F# development tasks"
instructions "Provide clear, concise code examples"
examples [
Prompt.example "How to build?" "Run `dotnet build` from the project root"
Prompt.example "How to test?" "Run `dotnet test` to execute all tests"
]
}
open FsAgent.Agents
open FsAgent.Writers
open FsAgent.Tools
let codingAgent = agent {
name "FSharp-Assistant"
description "An AI assistant for F# development"
model "gpt-4"
temperature 0.7
tools [Read; Custom "search"; Edit]
prompt assistantPrompt // Reference the prompt
}
let markdown = MarkdownWriter.writeAgent codingAgent (fun _ -> ())
open FsAgent.Prompts
open FsAgent.Writers
let greetingPrompt = prompt {
role "You are a friendly greeter"
template "Hello {{{userName}}}, welcome to {{{appName}}}!"
}
let output = MarkdownWriter.writePrompt greetingPrompt (fun opts ->
opts.TemplateVariables <- Map.ofList [
("userName", "Alice" :> obj)
("appName", "FsAgent" :> obj)
])
// Output: Hello Alice, welcome to FsAgent!
For lower-level usage using the AST directly, see .
Create reusable prompt content:
prompt {
// Metadata (stored but not output)
name "my-prompt"
description "A helpful prompt"
author "Your Name"
// Content sections
role "You are..."
objective "Your goal is..."
instructions "Follow these steps..."
context "In this scenario..."
output "Format responses as..."
// Templates
template "Dynamic content: {{{variable}}}"
templateFile "path/to/template.txt"
// Imports
import "config.json" // Wrapped in code block
importRaw "inline.txt" // Raw content
// Custom sections
section "custom-section" "Custom content"
}
Build agents referencing prompts:
agent {
// Metadata (output in frontmatter)
name "my-agent"
description "Agent description"
model "gpt-4"
temperature 0.7
maxTokens 2000.0
// Tool configuration
tools [Write; Edit; Read] // Type-safe tool list
disallowedTools [Bash; Write] // Disable specific tools
// Reference prompts
prompt myPrompt1
prompt myPrompt2 // Sections are merged
// Direct sections
section "notes" "Additional information"
import "data.yaml"
// Or use meta builder for complex frontmatter
meta (meta {
kv "key" "value"
kvList "items" ["a"; "b"; "c"]
})
}
OutputFormat: Opencode (default) or CopilotOutputType: Md (default), Json, or YamlTemplateVariables: Map of variable name → value for template renderingDisableCodeBlockWrapping: Force raw output even for import (default false)RenameMap: Map for renaming section headingsHeadingFormatter: Optional function to format headingsGeneratedFooter: Optional function to generate footer contentIncludeFrontmatter: Whether to include frontmatter (default true)CustomWriter: Optional custom writer functionSee knowledge/import-data.md for an example of generated output with imported data rules from knowledge/import-data.rules.json.
FsAgent supports type-safe tool configuration with automatic harness-specific name mapping. Tools are always output as a list, with disabled tools omitted from the output.
open FsAgent.Tools
let agent = agent {
name "my-agent"
tools [Glob; Bash; Read]
}
let markdown = MarkdownWriter.writeAgent agent (fun _ -> ())
// Output (Opencode):
// tools:
// - grep
// - bash
// - read
Use disallowedTools to exclude specific tools from the output:
open FsAgent.Tools
let agent = agent {
name "my-agent"
tools [Glob; Bash; Read; Edit]
disallowedTools [Bash; Write] // These tools won't appear in output
}
let markdown = MarkdownWriter.writeAgent agent (fun _ -> ())
// Output:
// tools:
// - grep
// - read
// - edit
// (bash and write are omitted because they're disabled)
The DSL provides two operations for importing external files:
import "path" - Wraps content in a fenced code block (e.g., ```json ... ```)importRaw "path" - Embeds content directly without wrappinglet agent = agent {
role "Data processor"
import "config.json" // Wraps in ```json ... ```
importRaw "inline.txt" // Embeds directly
}
// Default: imports are resolved with code blocks respected
let markdown = MarkdownWriter.writeMarkdown agent (fun _ -> ())
// Force all imports to raw (no code blocks)
let rawMarkdown = MarkdownWriter.writeMarkdown agent (fun opts ->
opts.DisableCodeBlockWrapping <- true)
The script examples/toon.fsx demonstrates the prompt-first approach:
MarkdownWriter.writeAgent// 1. Define reusable prompt
let toonPrompt = prompt {
role "You are a narrative strategist for animated missions"
objective "Map each catalog character to a mission brief"
instructions "Use the imported TOON catalog..."
import "examples/toon-data.toon"
}
// 2. Create agent with configuration
let toonAgent = agent {
name "toon-importer"
model "gpt-4.1"
tools [Read; Custom "search"]
prompt toonPrompt
}
// 3. Write to file
let markdown = MarkdownWriter.writeAgent toonAgent (fun _ -> ())
This shows how prompts can be defined once and reused across multiple agents while keeping configuration separate from content.
Existing code using open FsAgent.DSL continues to work via re-exports in Library.fs. However, the new modular approach with separate Prompt and Agent types is recommended for new code:
Old style (still works):
open FsAgent.DSL
// Uses backward compatibility layer
New style (recommended):
open FsAgent.Prompts
open FsAgent.Agents
open FsAgent.Writers
See for detailed migration instructions from v0.1.0 to v0.2.0.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
**Opencode tool output format**: Tools now output in struct/map format with boolean values (e.g., `bash: true`, `write: false`) instead of list format; **Opencode shows disabled tools**: Disabled tools now appear with `false` value in Opencode output, providing explicit visibility of all tool states; **Alphabetical tool ordering**: Opencode tools are now sorted alphabetically for deterministic output; Fixed malformed YAML output when Copilot/ClaudeCode agents have only `disallowedTools` with no enabled tools - now correctly omits the tools section instead of outputting `tools: \n - `; 4 new unit tests covering harness-specific tool output format scenarios (alphabetical sorting, empty tools, only disallowedTools for Copilot/ClaudeCode); OpenSpec requirement documentation for harness-specific tools output format in `openspec/specs/markdown-writer/spec.md`