Documentation
¶
Index ¶
- Constants
- Variables
- func ClaudeRuleToCommandPattern(rule string) string
- func Claw(ctx context.Context, args ClawArgs) (int, error)
- func ComputeSourceDigest(agent, sourceRoot string) string
- func DetectAgents() []string
- func DetectGrokBot() string
- func ExtractMarkdownEntries(text string) []string
- func FindExportFiles(source string) []string
- func FindOpenBotUserData(source string) string
- func ImportAgent(ctx context.Context, args Args) (int, error)
- func IsSecretKey(key string) bool
- func LoadSyncManifest(targetRoot string) *jsonutil.Object
- func ManagedSkills(entry any) map[string]any
- func MergeBots(bots []*jsonutil.Object) []*jsonutil.Object
- func NormalizeText(text string) string
- func ParseExport(text string) ([]*jsonutil.Object, error)
- func RedactSecrets(value any) (any, int)
- func RegisterOpenClaw(i OpenClawImporter)
- func SanitizeMCPEnv(env any) (*jsonutil.Object, []string)
- func SaveSyncManifest(ctx context.Context, targetRoot string, manifest *jsonutil.Object) error
- func ScheduleToCron(schedule *jsonutil.Object, timezone string) (string, bool)
- func SkillTreeDigest(skillDir string) string
- func StripFrontmatter(text string) string
- func SyncManifestPath(targetRoot string) string
- func UpdateSyncManifest(ctx context.Context, agent, sourceRoot, targetRoot string, overwrite bool, ...) error
- type AgentImporter
- type Args
- type BotImporter
- type BotOptions
- type ClawArgs
- type ConfigReadError
- type ExportFormatError
- type GrokBotCache
- type Item
- type OpenBotData
- type OpenClawArgs
- type OpenClawCleanupArgs
- type OpenClawImporter
- type Report
Constants ¶
const EntryDelimiter = memory.EntryDelimiter
EntryDelimiter separates entries of the memory store files
const ExportPrompt = "I'm moving to another assistant and need a complete, machine-readable copy of your setup. Do not " +
"change, pause or delete anything.\n" +
"\n" +
"Write one JSON document with exactly this shape, then save it as grok-bot-export-<your name>.json " +
"(your name in lowercase, spaces as hyphens): in my Downloads folder if you can write to my computer, " +
"otherwise in your workspace, and attach it to your reply. If you cannot attach files, put the whole " +
"document in a single ```json code block instead.\n" +
"\n" +
"{\n" +
" \"format\": \"grok-bot-export\",\n" +
" \"version\": 1,\n" +
" \"bots\": [\n" +
" {\n" +
" \"name\": \"your name\",\n" +
" \"title\": \"your label/job title, or empty\",\n" +
" \"instructions\": \"your full role, job description and lasting rules, verbatim where you can\",\n" +
" \"memories\": [\"each thing you remember about the work, one string per fact\"],\n" +
" \"user_facts\": [\"each fact you know about me (name, time zone, preferences), one per string\"],\n" +
" \"skills\": [\n" +
" {\"name\": \"skill name\", \"description\": \"when to use it\",\n" +
" \"instructions\": \"the COMPLETE skill text, every step, rule and output format, verbatim\"}\n" +
" ],\n" +
" \"routines\": [\n" +
" {\"name\": \"routine name\",\n" +
" \"instruction\": \"the COMPLETE instruction the routine runs, verbatim\",\n" +
" \"trigger\": \"schedule | slack | github | linear | sentry | pagerduty | email | webhook | other\",\n" +
" \"schedule_cron\": \"5-field cron expression in the routine's time zone, e.g. 0 8 * * 1-5 " +
"(empty when not on a schedule)\",\n" +
" \"schedule_text\": \"When to run, in words, as the app shows it\",\n" +
" \"timezone\": \"IANA time zone, e.g. America/New_York\",\n" +
" \"paused\": false,\n" +
" \"skills\": [\"names of skills this routine uses\"],\n" +
" \"trigger_details\": \"for event triggers: channel, repository, phrase, senders, etc.\"}\n" +
" ],\n" +
" \"apps\": [{\"name\": \"connected app or MCP server name\", \"mcp_url\": \"remote MCP URL if any, else empty\"}]\n" +
" }\n" +
" ]\n" +
"}\n" +
"\n" +
"Rules: include EVERY routine you own (paused ones too) and EVERY skill enabled for you, with full " +
"text, not summaries. If you cannot read something (a routine's schedule, a skill's text), leave " +
"it out and tell me in your reply what you left out; never guess or fill it in from memory. Never include passwords, API keys, tokens, webhook keys, cookies or card " +
"numbers: leave those out entirely. Output valid JSON only (no comments).\n" +
"If it is too long for one message or file, split it: send several documents, each complete and " +
"valid in this same shape with the same bot name, each holding the part the others do not. They " +
"are imported together.\n"
ExportPrompt is the message a user pastes into a Grok Bot chat so the Bot writes its own export
const MemoryCharLimit = 20_000
MemoryCharLimit is the character budget of a merged memory file
const Pasted = "<pasted export>"
Pasted stands for the export read from standard input, the text riding on the importer
const SyncManifestName = "import-sync.json"
SyncManifestName is the per profile file listing every imported source
Variables ¶
var AgentChoices = []string{agentOpenClaw, "claude-code", "codex", "cursor", agentGrokBot, agentOpenBot}
AgentChoices are the agent names import-agent accepts in command line order
var AgentDefaultDirs = map[string]string{"claude-code": ".claude", "codex": ".codex", "cursor": ".cursor"}
AgentDefaultDirs maps each supported agent to its config dir under the user home
var ErrOpenClawMissing = errors.New("the OpenClaw importer (pkg/agentimport/openclaw) is not linked into this binary")
ErrOpenClawMissing reports that no OpenClaw importer is linked into the binary
var SupportedAgents = []string{"claude-code", "codex", "cursor"}
SupportedAgents are the coding agents the directory importer reads
Functions ¶
func ClaudeRuleToCommandPattern ¶
ClaudeRuleToCommandPattern maps a Bash rule to its command pattern, a trailing prefix marker becoming a star, else empty
func Claw ¶
Claw handles icebath claw, migrate and cleanup going to the registered OpenClaw importer
func ComputeSourceDigest ¶
ComputeSourceDigest is the content digest of everything the importer would read from the source
func DetectAgents ¶
func DetectAgents() []string
DetectAgents lists the supported agents whose default dir exists
func DetectGrokBot ¶
func DetectGrokBot() string
DetectGrokBot is the Grok Bot app dir or an export file found on this computer, empty when none
func ExtractMarkdownEntries ¶
ExtractMarkdownEntries splits markdown into memory entries with headings as context prefixes, code and tables skipped
func FindExportFiles ¶
FindExportFiles lists the exports to read, the source file, the export files in a source dir, or those in ~/Downloads
func FindOpenBotUserData ¶
FindOpenBotUserData is the folder holding openbot.db, from the source folder or file else the OS default
func ImportAgent ¶
ImportAgent handles icebath import-agent, preview first, then confirm and apply
func IsSecretKey ¶
IsSecretKey reports whether an env var name looks like a credential
func LoadSyncManifest ¶
LoadSyncManifest reads the manifest, a missing, unreadable or malformed file giving an empty one
func ManagedSkills ¶
ManagedSkills reads imported_skills as name to digest at import, a pre digest list mapping to nil
func MergeBots ¶
MergeBots makes one bot per name, lists unioned and scalars keeping the last non empty value
func NormalizeText ¶
NormalizeText collapses whitespace runs to one space and lowercases
func ParseExport ¶
ParseExport returns the bots of an export document or of every json block in a pasted reply, merged per bot
func RedactSecrets ¶
RedactSecrets replaces token shaped strings with [redacted] and counts them
func RegisterOpenClaw ¶
func RegisterOpenClaw(i OpenClawImporter)
RegisterOpenClaw installs the OpenClaw importer
func SanitizeMCPEnv ¶
SanitizeMCPEnv splits an MCP env mapping into kept values and the stripped secret names
func SaveSyncManifest ¶
SaveSyncManifest writes the manifest as sorted indented JSON
func ScheduleToCron ¶
ScheduleToCron maps an OpenBot routine schedule to a cron schedule firing at the same instants, false when none fits
func SkillTreeDigest ¶
SkillTreeDigest is the content digest of an installed skill dir, relative path and bytes of every file
func StripFrontmatter ¶
StripFrontmatter drops a leading YAML frontmatter block holding routing metadata
func SyncManifestPath ¶
SyncManifestPath is the sync manifest of a home
Types ¶
type AgentImporter ¶
type AgentImporter struct {
// contains filtered or unexported fields
}
AgentImporter plans and applies the import of one Claude Code, Codex or Cursor tree
func NewAgentImporter ¶
func NewAgentImporter(ctx context.Context, agent, sourceRoot, targetRoot string, execute, overwrite bool, syncSkills map[string]any) (*AgentImporter, error)
NewAgentImporter builds the importer of a supported agent, syncSkills naming skills an earlier import wrote with their digest
func (*AgentImporter) Run ¶
func (a *AgentImporter) Run() (*Report, error)
Run plans every item, applying them when executing, and returns the report
type Args ¶
type Args struct {
Console *cliui.Console
Agent string
Source string
DryRun bool
Overwrite bool
Yes bool
Sync bool
FromSetup bool
Preset string
MigrateSecrets bool
NoBackup bool
WorkspaceTarget string
SkillConflict string
ActivateRoutines bool
Bot []string
Include []string
Exclude []string
OutputDir string
JSON bool
// contains filtered or unexported fields
}
Args are the import-agent flags as the command line parsed them, empty meaning not passed
type BotImporter ¶
type BotImporter struct {
// contains filtered or unexported fields
}
BotImporter plans and applies normalized bots into one home, the shared core of the Grok Bot and OpenBot importers
func NewGrokBotImporter ¶
func NewGrokBotImporter(ctx context.Context, exportFiles []string, targetRoot string, o BotOptions, pasted *string) *BotImporter
NewGrokBotImporter builds the importer of Grok Bot export files, pasted holding a reply read from standard input
func NewOpenBotImporter ¶
func NewOpenBotImporter(ctx context.Context, userData, targetRoot string, o BotOptions) *BotImporter
NewOpenBotImporter builds the importer of the OpenBot agents under a user data folder
func (*BotImporter) Run ¶
func (g *BotImporter) Run() (*Report, error)
Run imports every bot the sources hold, only those --bot names when given
type BotOptions ¶
BotOptions are the settings of a Grok Bot or OpenBot import
type ClawArgs ¶
type ClawArgs struct {
Console *cliui.Console
Action string
Source string
DryRun bool
Overwrite bool
Yes bool
Preset string
MigrateSecrets bool
NoBackup bool
WorkspaceTarget string
SkillConflict string
FromSetup bool
Include []string
Exclude []string
OutputDir string
JSON bool
}
ClawArgs are the flags of icebath claw with the subcommand word under Action
type ConfigReadError ¶
type ConfigReadError struct{ Err error }
ConfigReadError is an existing config.yaml that cannot be read or parsed, so a merge must not replace it
func (*ConfigReadError) Error ¶
func (e *ConfigReadError) Error() string
func (*ConfigReadError) Unwrap ¶
func (e *ConfigReadError) Unwrap() error
type ExportFormatError ¶
type ExportFormatError struct{ Msg string }
ExportFormatError is a document that is not a Grok Bot export this importer can read
func (*ExportFormatError) Error ¶
func (e *ExportFormatError) Error() string
type GrokBotCache ¶
GrokBotCache holds Bot names in roster order and per Bot the routine names its cached chat created
func ReadGrokBotCache ¶
func ReadGrokBotCache() GrokBotCache
ReadGrokBotCache reads the cached roster and routine names under the user home, empty when the app is not installed
type Item ¶
type Item struct {
Kind string
Source string
Destination string
Status string
Reason string
Details map[string]any
}
Item is one planned or applied change of an import
type OpenBotData ¶
type OpenBotData struct {
Agents []*jsonutil.Object
MCPServers *jsonutil.Object
PassthroughFor []string
Passthrough map[string][]string
Problems []string
}
OpenBotData holds the agents as normalized bots, the machine wide MCP servers, their env passthrough names and unreadable rows
func ReadOpenBotAgents ¶
func ReadOpenBotAgents(ctx context.Context, userData, scratchParent string) (*OpenBotData, error)
ReadOpenBotAgents reads every agent and the MCP servers, one unreadable agent reported and a foreign database refused
type OpenClawArgs ¶
type OpenClawArgs struct {
Console *cliui.Console
Source string
DryRun bool
Overwrite bool
Yes bool
Preset string
MigrateSecrets bool
NoBackup bool
WorkspaceTarget string
SkillConflict string
FromSetup bool
Include []string
Exclude []string
OutputDir string
JSON bool
}
OpenClawArgs are the flags of an OpenClaw import as the command line parsed them, empty meaning not passed
type OpenClawCleanupArgs ¶
OpenClawCleanupArgs are the flags of claw cleanup
type OpenClawImporter ¶
type OpenClawImporter struct {
FindDirs func() []string
Migrate func(ctx context.Context, args OpenClawArgs) (int, error)
Cleanup func(ctx context.Context, args OpenClawCleanupArgs) (int, error)
}
OpenClawImporter is the OpenClaw half of the importer, installed by its package when the binary links it