agentimport

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 46 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const EntryDelimiter = memory.EntryDelimiter

EntryDelimiter separates entries of the memory store files

View Source
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

View Source
const MemoryCharLimit = 20_000

MemoryCharLimit is the character budget of a merged memory file

View Source
const Pasted = "<pasted export>"

Pasted stands for the export read from standard input, the text riding on the importer

View Source
const SyncManifestName = "import-sync.json"

SyncManifestName is the per profile file listing every imported source

Variables

View Source
var AgentChoices = []string{agentOpenClaw, "claude-code", "codex", "cursor", agentGrokBot, agentOpenBot}

AgentChoices are the agent names import-agent accepts in command line order

View Source
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

View Source
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

View Source
var SupportedAgents = []string{"claude-code", "codex", "cursor"}

SupportedAgents are the coding agents the directory importer reads

Functions

func ClaudeRuleToCommandPattern

func ClaudeRuleToCommandPattern(rule string) string

ClaudeRuleToCommandPattern maps a Bash rule to its command pattern, a trailing prefix marker becoming a star, else empty

func Claw

func Claw(ctx context.Context, args ClawArgs) (int, error)

Claw handles icebath claw, migrate and cleanup going to the registered OpenClaw importer

func ComputeSourceDigest

func ComputeSourceDigest(agent, sourceRoot string) string

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

func ExtractMarkdownEntries(text string) []string

ExtractMarkdownEntries splits markdown into memory entries with headings as context prefixes, code and tables skipped

func FindExportFiles

func FindExportFiles(source string) []string

FindExportFiles lists the exports to read, the source file, the export files in a source dir, or those in ~/Downloads

func FindOpenBotUserData

func FindOpenBotUserData(source string) string

FindOpenBotUserData is the folder holding openbot.db, from the source folder or file else the OS default

func ImportAgent

func ImportAgent(ctx context.Context, args Args) (int, error)

ImportAgent handles icebath import-agent, preview first, then confirm and apply

func IsSecretKey

func IsSecretKey(key string) bool

IsSecretKey reports whether an env var name looks like a credential

func LoadSyncManifest

func LoadSyncManifest(targetRoot string) *pyjson.Object

LoadSyncManifest reads the manifest, a missing, unreadable or malformed file giving an empty one

func ManagedSkills

func ManagedSkills(entry any) map[string]any

ManagedSkills reads imported_skills as name to digest at import, a pre digest list mapping to nil

func MergeBots

func MergeBots(bots []*pyjson.Object) []*pyjson.Object

MergeBots makes one bot per name, lists unioned and scalars keeping the last non empty value

func NormalizeText

func NormalizeText(text string) string

NormalizeText collapses whitespace runs to one space and lowercases

func ParseExport

func ParseExport(text string) ([]*pyjson.Object, error)

ParseExport returns the bots of an export document or of every json block in a pasted reply, merged per bot

func RedactSecrets

func RedactSecrets(value any) (any, int)

RedactSecrets replaces token shaped strings with [redacted] and counts them

func RegisterOpenClaw

func RegisterOpenClaw(i OpenClawImporter)

RegisterOpenClaw installs the OpenClaw importer

func SanitizeMCPEnv

func SanitizeMCPEnv(env any) (*pyjson.Object, []string)

SanitizeMCPEnv splits an MCP env mapping into kept values and the stripped secret names

func SaveSyncManifest

func SaveSyncManifest(ctx context.Context, targetRoot string, manifest *pyjson.Object) error

SaveSyncManifest writes the manifest as sorted indented JSON

func ScheduleToCron

func ScheduleToCron(schedule *pyjson.Object, timezone string) (string, bool)

ScheduleToCron maps an OpenBot routine schedule to a cron schedule firing at the same instants, false when none fits

func SkillTreeDigest

func SkillTreeDigest(skillDir string) string

SkillTreeDigest is the content digest of an installed skill dir, relative path and bytes of every file

func StripFrontmatter

func StripFrontmatter(text string) string

StripFrontmatter drops a leading YAML frontmatter block holding routing metadata

func SyncManifestPath

func SyncManifestPath(targetRoot string) string

SyncManifestPath is the sync manifest of a home

func UpdateSyncManifest

func UpdateSyncManifest(ctx context.Context, agent, sourceRoot, targetRoot string, overwrite bool, report *Report, refreshDigest bool) error

UpdateSyncManifest records a real import with every skill digest it wrote, refreshDigest false keeping the old source digest

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

type BotOptions struct {
	Execute          bool
	Overwrite        bool
	ActivateRoutines bool
	BotNames         []string
}

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

type GrokBotCache struct {
	Bots        []string
	RoutineBots []string
	Routines    map[string][]string
}

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         []*pyjson.Object
	MCPServers     *pyjson.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

type OpenClawCleanupArgs struct {
	Console *cliui.Console
	Source  string
	DryRun  bool
	Yes     bool
}

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

type Report

type Report struct {
	Agent           string
	Source          string
	Target          string
	DryRun          bool
	Items           []Item
	Summary         map[string]int
	StrippedSecrets []string
}

Report is the outcome of one importer run

Directories

Path Synopsis
Package openclaw ports the OpenClaw migration engine and the import-agent openclaw and claw commands
Package openclaw ports the OpenClaw migration engine and the import-agent openclaw and claw commands

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL