Documentation
¶
Overview ¶
Package add provides the "ctx add" command for appending entries to context files.
It supports adding decisions, tasks, learnings, and conventions to their respective files in the .context/ directory. Content can be provided via command argument, --file flag, or stdin pipe.
Supported entry types (defined in config.FileType):
- decision/decisions: Appends to DECISIONS.md
- task/tasks: Inserts into TASKS.md under a section header
- learning/learnings: Appends to LEARNINGS.md
- convention/conventions: Appends to CONVENTIONS.md
Example usage:
ctx add decision "Use PostgreSQL for primary database" ctx add task "Implement auth" --priority high --section "Next Up" ctx add learning --file notes.md echo "Use camelCase" | ctx add convention
Index ¶
- func AppendEntry(existing []byte, entry string, fileType string, section string) []byte
- func Cmd() *cobra.Command
- func FormatConvention(content string) string
- func FormatDecision(content string) string
- func FormatLearning(content string) string
- func FormatTask(content string, priority string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendEntry ¶
AppendEntry inserts a formatted entry into existing file content.
For task entries, the function locates the target section header and inserts the entry immediately after it. For all other entry types, the entry is appended to the end of the file with appropriate newline handling.
Parameters:
- existing: Current file content as bytes
- entry: Pre-formatted entry text to insert
- fileType: Entry type (e.g., "task", "decision", "learning", "convention")
- section: Target section header for tasks; defaults to "## Next Up" if empty; a "## " prefix is added automatically if missing
Returns:
- []byte: Modified file content with the entry inserted
func Cmd ¶
Cmd returns the "ctx add" command for appending entries to context files.
Supported types are defined in config.FileType (both singular and plural forms accepted, e.g., "decision" or "decisions"). Content can be provided via command argument, --file flag, or stdin pipe.
Flags:
- --priority, -p: Priority level for tasks (high, medium, low)
- --section, -s: Target section within the file
- --file, -f: Read content from a file instead of argument
Returns:
- *cobra.Command: Configured add command with flags registered
func FormatConvention ¶
FormatConvention formats a convention entry as a simple markdown list item.
Format: "- content"
Parameters:
- content: Convention description text
Returns:
- string: Formatted convention line with trailing newline
func FormatDecision ¶
FormatDecision formats a decision entry as a structured Markdown section.
The output includes a timestamped heading, status, and placeholder sections for context, rationale, and consequences of the ADR format.
Parameters:
- content: Decision title/summary text
Returns:
- string: Formatted decision section with placeholders for details
func FormatLearning ¶
FormatLearning formats a learning entry as a timestamped markdown list item.
Format: "- **[YYYY-MM-DD-HHMMSS]** content"
Parameters:
- content: Learning description text
Returns:
- string: Formatted learning line with trailing newline
func FormatTask ¶
FormatTask formats a task entry as a markdown checkbox item.
The output includes a timestamp tag for session correlation and an optional priority tag. Format: "- [ ] content #priority:level #added:YYYY-MM-DD-HHMMSS"
Parameters:
- content: Task description text
- priority: Priority level (high, medium, low); empty string omits the tag
Returns:
- string: Formatted task line with trailing newline
Types ¶
This section is empty.