service

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultNoteTypes = map[string]*coreconfig.NoteTypeConfig{
	"inbox": {
		Icon:          theme.IconNoteInbox,
		IconColor:     "orange",
		DefaultExpand: false,
		SortOrder:     10,
		Description:   "Default location for new notes.",
	},
	"issues": {
		Icon:          theme.IconNoteIssues,
		IconColor:     "red",
		DefaultExpand: false,
		SortOrder:     11,
		Description:   "Notes related to bugs or issues.",
	},
	"plans": {
		Icon:          theme.IconPlan,
		IconColor:     "blue",
		DefaultExpand: true,
		SortOrder:     13,
		Description:   "Directory for structured project plans.",
	},
	"skills": {
		Icon:        theme.IconBuild,
		IconColor:   "orange",
		SortOrder:   15,
		Description: "Agent skills for automation and integration.",
	},
	"in_progress": {
		Icon:          theme.IconNoteInProgress,
		IconColor:     "blue",
		DefaultExpand: true,
		SortOrder:     20,
		Description:   "Notes for tasks currently being worked on.",
	},
	"review": {
		Icon:          theme.IconNoteReview,
		IconColor:     "pink",
		DefaultExpand: false,
		SortOrder:     30,
		Description:   "Notes or PRs ready for review.",
	},
	"completed": {
		Icon:          theme.IconNoteCompleted,
		IconColor:     "green",
		DefaultExpand: false,
		SortOrder:     999,
		Description:   "Completed work and historical notes.",
	},
	"docs": {
		Icon:        theme.IconDocs,
		IconColor:   "orange",
		SortOrder:   40,
		Description: "Documentation and reference materials.",
	},
	"learn": {
		Icon:        theme.IconSchool,
		IconColor:   "orange",
		SortOrder:   50,
		Description: "Learning materials and educational content.",
	},
	"daily": {
		Icon:        theme.IconCalendar,
		SortOrder:   5,
		Description: "Daily notes and journal entries.",
	},
	"github-issues": {
		Icon:        theme.IconIssueOpened,
		IconColor:   "red",
		SortOrder:   12,
		Description: "GitHub issues.",
	},
	"github-prs": {
		Icon:        theme.IconPullRequest,
		IconColor:   "pink",
		SortOrder:   31,
		Description: "GitHub pull requests.",
	},
	".archive": {
		Icon:        theme.IconArchive,
		Description: "Archived items.",
	},
	".closed": {
		Icon:        theme.IconArchive,
		Description: "Closed items.",
	},
	".artifacts": {
		Icon:        theme.IconDocs,
		Description: "Generated artifacts and outputs.",
	},
	"quick": {
		Icon:        theme.IconClockFast,
		Description: "Quick notes and scratch space.",
	},
	"prompts": {
		Icon:        theme.IconLightbulb,
		Description: "AI prompts and templates.",
	},
	"blog": {
		Icon:        theme.IconRss,
		Description: "Blog posts and articles.",
	},
	"architecture": {
		Icon:        theme.IconArchitecture,
		Description: "Architecture documentation and design.",
	},
	"todos": {
		Icon:        theme.IconChecklist,
		Description: "Task lists and todos.",
	},
	"concepts": {
		Icon:          theme.IconLightbulb,
		IconColor:     "cyan",
		SortOrder:     60,
		DefaultExpand: true,
		Description:   "Project concepts and architectural memory.",
	},
}

DefaultNoteTypes provides the built-in configuration for "special" note types. User configurations in grove.yml can override these settings.

Functions

func CreateNoteContent

func CreateNoteContent(noteType models.NoteType, title, workspace, branch, worktree, currentWorkspaceName string, template string, noteTypeConfig *coreconfig.NoteTypeConfig) string

CreateNoteContent generates initial note content based on type and template If noteTypeConfig is provided with a TemplatePath, it reads from that file. Otherwise, it falls back to generating default content.

func GenerateFilename

func GenerateFilename(suffix string) string

GenerateFilename creates a timestamped filename

func GenerateNoteID

func GenerateNoteID(suffix string) string

GenerateNoteID creates an ID from filename (without .md extension)

func GetFileStatus

func GetFileStatus(repoPath string) (map[string]string, error)

GetFileStatus runs `git status --porcelain=v1` and returns a map of absolute, normalized file paths to their status codes.

func GetNoteMetadata

func GetNoteMetadata(path string) (workspaceIdentifier, branch, noteType string)

GetNoteMetadata extracts metadata from note path

func ParseArtifact

func ParseArtifact(path string) (*models.Note, error)

ParseArtifact reads and parses an artifact file (e.g., briefing.xml)

func ParseGenericFile

func ParseGenericFile(path string) (*models.Note, error)

ParseGenericFile creates a Note model for a non-Markdown file.

func ParseNote

func ParseNote(path string) (*models.Note, error)

ParseNote reads and parses a note file

func SanitizeFilename

func SanitizeFilename(s string) string

SanitizeFilename removes invalid characters from filename

Types

type ConceptInfo

type ConceptInfo struct {
	ID        string `json:"id"`
	Title     string `json:"title"`
	Path      string `json:"path"`
	Workspace string `json:"workspace"`
}

ConceptInfo represents metadata about a concept

type ConceptSearchMatch

type ConceptSearchMatch struct {
	LineNumber int    `json:"line"`
	Text       string `json:"text"`
}

ConceptSearchMatch represents a single line match within a file

type ConceptSearchResult

type ConceptSearchResult struct {
	ConceptID string               `json:"concept_id"`
	Workspace string               `json:"workspace"`
	FilePath  string               `json:"file_path"`
	Matches   []ConceptSearchMatch `json:"matches"`
}

ConceptSearchResult represents search matches grouped by file

type Config

type Config struct {
	DataDir     string
	Editor      string
	Templates   map[string]string
	DefaultType models.NoteType
}

Config holds service configuration

type CreateOption

type CreateOption func(*createOptions)

func InGlobalWorkspace

func InGlobalWorkspace() CreateOption

func WithoutEditor

func WithoutEditor() CreateOption

type GitStatusResult

type GitStatusResult struct {
	FileStatus   map[string]string // path -> status code
	DeletedFiles []string          // paths of deleted files (don't exist on disk)
}

GitStatusResult contains the parsed git status information

func GetFileStatusExtended

func GetFileStatusExtended(repoPath string) (*GitStatusResult, error)

GetFileStatusExtended runs `git status --porcelain=v1` and returns extended info including deleted files that don't exist on disk.

type NoteContentGenerator

type NoteContentGenerator func(title, workspace, branch string, tags []string, now time.Time, timestampStr string) string

NoteContentGenerator defines the function signature for note content generators

type SearchOption

type SearchOption func(*searchOptions)

func AllWorkspaces

func AllWorkspaces() SearchOption

func OfType

func OfType(t models.NoteType) SearchOption

func WithLimit

func WithLimit(limit int) SearchOption

type Service

type Service struct {
	Config     *Config
	CoreConfig *coreconfig.Config
	Logger     *logrus.Entry
	NoteTypes  map[string]*coreconfig.NoteTypeConfig
	// contains filtered or unexported fields
}

Service is the core note service

func New

func New(config *Config, provider *coreworkspace.Provider, coreCfg *coreconfig.Config, logger *logrus.Entry) (*Service, error)

New creates a new note service

func (*Service) ArchiveNotes

func (s *Service) ArchiveNotes(ctx *WorkspaceContext, paths []string) error

ArchiveNotes moves notes to a .archive subdirectory within their current directory.

func (*Service) BuildNotePath

func (s *Service) BuildNotePath(workspaceName, branch, noteType, filename string) (string, error)

BuildNotePath constructs a path for a note in the specified workspace/branch/type Note: branch parameter is accepted for API compatibility but always uses "main"

func (*Service) Close

func (s *Service) Close() error

Close closes the service

func (*Service) CopyNotes

func (s *Service) CopyNotes(sourcePaths []string, destWorkspace *coreworkspace.WorkspaceNode, destGroup string) ([]string, error)

CopyNotes copies notes to a new workspace and group.

func (*Service) CreateConcept

func (s *Service) CreateConcept(ctx *WorkspaceContext, title string, options ...CreateOption) (*models.Note, error)

CreateConcept creates the directory structure for a new concept.

func (*Service) CreateNote

func (s *Service) CreateNote(ctx *WorkspaceContext, noteType models.NoteType, title string, options ...CreateOption) (*models.Note, error)

CreateNote creates a new note in the specified workspace context

func (*Service) CreateNoteWithContent

func (s *Service) CreateNoteWithContent(
	ctx *WorkspaceContext,
	noteType models.NoteType,
	title string,
	fm *frontmatter.Frontmatter,
	body string,
) (*models.Note, error)

CreateNoteWithContent creates a new note programmatically without opening an editor. This is used by the sync system to create notes for synced items.

func (*Service) DeleteNotes

func (s *Service) DeleteNotes(paths []string) error

DeleteNotes removes note files from the filesystem.

func (*Service) GetBranches

func (s *Service) GetBranches(ws *coreworkspace.WorkspaceNode) ([]string, error)

GetBranches returns all branches for a git workspace

func (*Service) GetConceptPath

func (s *Service) GetConceptPath(ctx *WorkspaceContext, conceptID string) (string, error)

GetConceptPath returns the absolute path to a concept's directory

func (*Service) GetConceptsDir

func (s *Service) GetConceptsDir(ctx *WorkspaceContext) (string, error)

GetConceptsDir returns the absolute path to the concepts directory for the current workspace

func (*Service) GetNotebookLocator

func (s *Service) GetNotebookLocator() *coreworkspace.NotebookLocator

GetNotebookLocator returns the notebook locator

func (*Service) GetWorkspaceContext

func (s *Service) GetWorkspaceContext(startPath string) (*WorkspaceContext, error)

GetWorkspaceContext returns current workspace context. If startPath is provided, it's used as the basis for context detection. If startPath is "global", it forces the global context.

func (*Service) GetWorkspaceProvider

func (s *Service) GetWorkspaceProvider() *coreworkspace.Provider

GetWorkspaceProvider returns the workspace provider

func (*Service) LinkConceptToConcept

func (s *Service) LinkConceptToConcept(ctx *WorkspaceContext, sourceID, targetID string) error

LinkConceptToConcept adds a concept-to-concept reference

func (*Service) LinkNoteToConcept

func (s *Service) LinkNoteToConcept(ctx *WorkspaceContext, conceptID, noteAlias string) error

LinkNoteToConcept adds a note reference to a concept's manifest

func (*Service) LinkPlanToConcept

func (s *Service) LinkPlanToConcept(ctx *WorkspaceContext, conceptID, planAlias string) error

LinkPlanToConcept adds a plan reference to a concept's manifest

func (*Service) LinkSkillToConcept

func (s *Service) LinkSkillToConcept(ctx *WorkspaceContext, conceptID, skillName string) error

LinkSkillToConcept adds a skill reference to a concept's manifest

func (*Service) ListAllConcepts

func (s *Service) ListAllConcepts() ([]ConceptInfo, error)

ListAllConcepts lists concepts across all workspaces in the ecosystem

func (*Service) ListAllGlobalItems

func (s *Service) ListAllGlobalItems(includeArchived bool, includeArtifacts bool) ([]*tree.Item, error)

ListAllGlobalItems lists all items in the global workspace (all directories)

func (*Service) ListAllGlobalNotes

func (s *Service) ListAllGlobalNotes(includeArchived bool, includeArtifacts bool) ([]*models.Note, error)

ListAllGlobalNotes lists all notes in the global workspace (all directories)

func (*Service) ListAllItems

func (s *Service) ListAllItems(ctx *WorkspaceContext, includeArchived bool, includeArtifacts bool) ([]*tree.Item, error)

ListAllItems lists all files as generic Items in the specified workspace context.

func (*Service) ListAllNotes

func (s *Service) ListAllNotes(ctx *WorkspaceContext, includeArchived bool, includeArtifacts bool) ([]*models.Note, error)

ListAllNotes lists all notes in the specified workspace context (all directories)

func (*Service) ListAllNotesInWorkspace

func (s *Service) ListAllNotesInWorkspace(ws *coreworkspace.WorkspaceNode) ([]*models.Note, error)

ListAllNotesInWorkspace lists all notes in a given workspace, across all branches.

func (*Service) ListConcepts

func (s *Service) ListConcepts(ctx *WorkspaceContext) ([]ConceptInfo, error)

ListConcepts lists all concepts in the workspace

func (*Service) ListEcosystemConcepts

func (s *Service) ListEcosystemConcepts(ctx *WorkspaceContext) ([]ConceptInfo, error)

ListEcosystemConcepts lists concepts from all workspaces within the current ecosystem

func (*Service) ListGlobalNotes

func (s *Service) ListGlobalNotes(noteType models.NoteType) ([]*models.Note, error)

ListGlobalNotes lists notes in the global workspace

func (*Service) ListItemsFromAllWorkspaces

func (s *Service) ListItemsFromAllWorkspaces(includeArchived bool, includeArtifacts bool) ([]*tree.Item, error)

ListItemsFromAllWorkspaces returns generic items from all registered workspaces

func (*Service) ListNoteTypes

func (s *Service) ListNoteTypes(notebookContext *coreworkspace.WorkspaceNode) ([]models.NoteType, error)

ListNoteTypes discovers note types by scanning directories within the notes path. It ensures 'inbox' is always included as the default.

func (*Service) ListNotes

func (s *Service) ListNotes(ctx *WorkspaceContext, noteType models.NoteType) ([]*models.Note, error)

ListNotes lists notes in the current workspace

func (*Service) ListNotesFromAllWorkspaces

func (s *Service) ListNotesFromAllWorkspaces(includeArchived bool, includeArtifacts bool) ([]*models.Note, error)

ListNotesFromAllWorkspaces returns notes from all registered workspaces

func (*Service) MoveNotes

func (s *Service) MoveNotes(sourcePaths []string, destWorkspace *coreworkspace.WorkspaceNode, destGroup string) ([]string, error)

MoveNotes moves notes to a new workspace and group.

func (*Service) RenameNote

func (s *Service) RenameNote(oldPath, newTitle string) (string, error)

RenameNote renames a note by updating its filename, ID, title, and first heading

func (*Service) SearchConcepts

func (s *Service) SearchConcepts(query string) ([]ConceptSearchResult, error)

SearchConcepts searches for a query string across all concept files in the ecosystem

func (*Service) SearchEcosystemConcepts

func (s *Service) SearchEcosystemConcepts(ctx *WorkspaceContext, query string) ([]ConceptSearchResult, error)

SearchEcosystemConcepts searches for a query within concepts in the current ecosystem only

func (*Service) SearchNotes

func (s *Service) SearchNotes(ctx *WorkspaceContext, query string, options ...SearchOption) ([]*models.Note, error)

SearchNotes searches for notes matching the query using filesystem tools.

func (*Service) UpdateNoteContent

func (s *Service) UpdateNoteContent(path string, content string) error

UpdateNoteContent updates the content of an existing note

func (*Service) UpdateNoteWithContent

func (s *Service) UpdateNoteWithContent(
	notePath string,
	fm *frontmatter.Frontmatter,
	body string,
) error

UpdateNoteWithContent updates an existing note's content programmatically. This is used by the sync system to update notes when remote items change.

type WorkspaceContext

type WorkspaceContext struct {
	CurrentWorkspace         *coreworkspace.WorkspaceNode
	NotebookContextWorkspace *coreworkspace.WorkspaceNode
	Branch                   string
	Paths                    map[string]string
}

WorkspaceContext holds current workspace information

Jump to

Keyboard shortcuts

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