tpl

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

README

assets/tpl/

Sprintf-based format string templates that cannot currently be expressed in the YAML text system (commands/text/*.yaml).

Why these exist

The YAML short: / long: format supports single values looked up by key. These templates contain multi-line Markdown with fmt.Sprintf placeholders (%s, %d), which don't fit that model.

How they will be replaced

A Go text/template rendering pipeline (tracked in TASKS.md: "Migrate Sprintf-based templates (tpl_*.go) to Go text/template") will replace these constants with proper .tmpl files in the embedded assets. Once that pipeline exists:

  1. Each tpl_*.go constant moves to an embedded .tmpl file
  2. Callers use template.Execute() with typed data instead of fmt.Sprintf
  3. Templates become localizable alongside the YAML text entries
  4. This directory is deleted

Adding a new template

If you need a multi-line format string with placeholders, add it here with a comment explaining why it can't go to YAML (see tpl_obsidian.go for the pattern). Prefer this over scattering const blocks in CLI packages - at least they're collected in one place.

Documentation

Overview

Package tpl holds Sprintf-based format string constants that cannot yet be expressed in the YAML text system. These will migrate to Go text/template files when the template rendering pipeline is built.

Index

Constants

View Source
const (
	// Task formats a task checkbox line.
	// Args: content, priorityTag, timestamp.
	Task = "- [ ] %s%s #added:%s\n"

	// TaskPriority formats the inline priority tag.
	// Args: priority level.
	TaskPriority = " #priority:%s"

	// Learning formats a learning section with all ADR-style fields.
	// Args: timestamp, title, context, lesson, application.
	Learning = `## [%s] %s

**Context**: %s

**Lesson**: %s

**Application**: %s
`

	// Convention formats a convention list item.
	// Args: content.
	Convention = "- %s\n"

	// Decision formats a decision section with all ADR fields.
	// Args: timestamp, title, context, title (repeated), rationale, consequence.
	Decision = `## [%s] %s

**Status**: Accepted

**Context**: %s

**Decision**: %s

**Rationale**: %s

**Consequence**: %s
`
)

Markdown format templates for context entries.

These templates define the structure of entries written to .context/ files by the add command. Each uses fmt.Sprintf verbs for interpolation.

View Source
const (
	// TplJournalSiteReadme formats the README for the journal-site directory.
	// Args: journalDir.
	TplJournalSiteReadme = `# journal-site (generated)

This directory is generated by ` + "`ctx journal site`" + ` and is read-only.
Do not edit files here - changes will be overwritten on the next run.

## To update

1. Edit source entries in ` + "`%s/`" + `
2. Regenerate:

` + "```" + `
ctx journal site          # generate
ctx journal site --serve  # generate and preview
` + "```" + `
`

	// TplJournalIndexIntro is the introductory line on the journal index.
	TplJournalIndexIntro = "Browse your AI session history."

	// TplJournalIndexStats formats the session/suggestion count line.
	// Args: regular count, suggestion count.
	TplJournalIndexStats = "**Sessions**: %d | **Suggestions**: %d"

	// TplJournalSuggestionsNote is the description under the suggestions heading.
	TplJournalSuggestionsNote = "*Auto-generated suggestion prompts from Claude Code.*"

	// TplJournalMonthHeading formats a month section heading.
	// Args: month string (YYYY-MM).
	TplJournalMonthHeading = "## %s"

	// TplJournalIndexEntry formats a single entry in the journal index.
	// Args: timeStr, title, link, project, size.
	TplJournalIndexEntry = "- %s[%s](%s.md)%s `%s`"

	// TplJournalIndexSummary formats the summary line below an index entry.
	// Args: summary text. Indented to nest visually under the parent bullet.
	TplJournalIndexSummary = "    *%s*"

	// TplJournalSummaryAdmonition formats the summary as an abstract admonition
	// on individual journal entry pages.
	// Args: summary text.
	TplJournalSummaryAdmonition = "!!! abstract \"Summary\"\n    %s"

	// TplJournalSourceLink formats the "View source" link injected into entries.
	// Args: absPath, relPath, relPath.
	TplJournalSourceLink = `*[View source](file://%s) · <code>%s</code>*` +
		` <button onclick="navigator.clipboard.writeText('%s')" title="Copy path"` +
		` style="cursor:pointer;border:none;background:none;font-size:0.8em;vertical-align:middle">` +
		`&#x2398;</button>`

	// TplJournalTopicStats formats the topics index summary line.
	// Args: topic count, session count, popular count, longtail count.
	TplJournalTopicStats = "**%d topics** across **%d sessions** - **%d popular**, **%d long-tail**"

	// TplJournalTopicPageStats formats an individual topic page summary.
	// Args: session count.
	TplJournalTopicPageStats = "**%d sessions** with this topic."

	// TplJournalFileStats formats the key files index summary line.
	// Args: file count, session count, popular count, longtail count.
	TplJournalFileStats = "**%d files** across **%d sessions** - **%d popular**, **%d long-tail**"

	// TplJournalFilePageStats formats an individual key file page summary.
	// Args: session count.
	TplJournalFilePageStats = "**%d sessions** touching this file."

	// TplJournalTypeStats formats the session types index summary line.
	// Args: type count, session count.
	TplJournalTypeStats = "**%d types** across **%d sessions**"

	// TplJournalTypePageStats formats an individual type page summary.
	// Args: session count, type name.
	TplJournalTypePageStats = "**%d sessions** of type *%s*."

	// TplJournalPageHeading formats a Markdown heading for an index page.
	// Args: name.
	TplJournalPageHeading = "# %s"

	// TplJournalCodePageHeading formats a Markdown heading with code styling.
	// Args: path.
	TplJournalCodePageHeading = "# `%s`"

	// TplJournalSubpageEntry formats a session link on a subpage (topic, file, type).
	// Args: timeStr, title, linkPrefix, link.
	TplJournalSubpageEntry = "- %s[%s](%s%s.md)"

	// TplJournalLongtailEntry formats an inline longtail topic entry.
	// Args: name, title, link.
	TplJournalLongtailEntry = "- **%s** - [%s](../%s.md)"

	// TplJournalLongtailCodeEntry formats an inline longtail key file entry.
	// Args: path, title, link.
	TplJournalLongtailCodeEntry = "- `%s` - [%s](../%s.md)"

	// TplJournalNavItem formats a navigation item in zensical.toml.
	// Args: label, path.
	TplJournalNavItem = `  { "%s" = "%s" },`

	// TplJournalNavSection formats a navigation section opening.
	// Args: label.
	TplJournalNavSection = `  { "%s" = [`

	// TplJournalNavSessionItem formats a session entry in navigation.
	// Args: title, filename.
	TplJournalNavSessionItem = `    { "%s" = "%s" },`

	// TplZensicalProject is the [project] section of zensical.toml.
	TplZensicalProject = `` /* 594-byte string literal not displayed */

	// TplZensicalTheme is the theme and extras section of zensical.toml.
	TplZensicalTheme = `` /* 1653-byte string literal not displayed */

	// TplZensicalExtraCSS is the extra_css line for zensical.toml.
	// Must appear under [project] (after nav, before [project.theme]).
	TplZensicalExtraCSS = `extra_css = ["stylesheets/extra.css"]`
)

Journal site format templates.

These templates define the structure of generated journal site pages. Each uses fmt.Sprintf verbs for interpolation.

View Source
const (
	// LoadBudget formats the token budget summary line.
	// Args: budget, totalTokens.
	LoadBudget = "Token Budget: %d | Available: %d"

	// LoadTruncated formats the truncation notice for budget-limited output.
	// Args: fileName.
	LoadTruncated = "*[Truncated: %s and remaining files excluded due to token budget]*"

	// LoadSectionHeading formats a file section heading in assembled output.
	// Args: title.
	LoadSectionHeading = "## %s"

	// LoopScript is the bash script template for the Ralph Loop.
	// Args: promptFile, completionMsg, maxIterCheck, aiCommand, loopComplete, notifyCmd.
	LoopScript = `` /* 1090-byte string literal not displayed */

	// LoopMaxIter is the iteration-limit check block for the loop script.
	// Args: maxIterations, maxIterations, notifyCmd.
	LoopMaxIter = `` /* 142-byte string literal not displayed */

	// LoopNotify is the ctx notify call appended to loop completion points.
	LoopNotify = `ctx notify --event loop "Loop completed after $ITERATION iterations" 2>/dev/null || true`
)

Agent load and loop script templates.

View Source
const (
	// RecallFilename formats a journal entry filename.
	// Args: date, slug, shortID.
	RecallFilename = "%s-%s-%s.md"

	// RecallTokens formats the token stats line.
	// Args: total, in, out.
	RecallTokens = "**Tokens**: %s (in: %s, out: %s)" //nolint:gosec // G101: display template, not a credential

	// RecallPartOf formats the part indicator.
	// Args: part, totalParts.
	RecallPartOf = "**Part %d of %d**"

	// RecallConversationContinued formats the continued conversation heading.
	// Args: previous part number.
	RecallConversationContinued = "## Conversation (continued from part %d)"

	// RecallTurnHeader formats a conversation turn heading.
	// Args: msgNum, role, time.
	RecallTurnHeader = "### %d. %s (%s)"

	// RecallToolUse formats a tool use line.
	// Args: formatted tool name and args.
	RecallToolUse = "🔧 **%s**"

	// RecallToolCount formats a tool usage count line.
	// Args: name, count.
	RecallToolCount = "- %s: %d"

	// RecallSummaryPlaceholder is the placeholder text in the summary section.
	RecallSummaryPlaceholder = "[Add your summary of this session]"

	// RecallErrorMarker is the error indicator for tool results.
	RecallErrorMarker = "❌ Error"

	// RecallDetailsSummary formats the summary text for collapsible content.
	// Args: line count.
	RecallDetailsSummary = "%d lines"

	// RecallDetailsOpen formats the opening HTML for collapsible content.
	// Args: summary text. INVARIANT: the <summary> tag is always single-line
	// (<summary>N lines</summary>). Multi-line <summary> blocks (standalone
	// <summary> on its own line) are Claude Code context compaction artifacts
	// and are stripped by stripSystemReminders. This distinction is the basis
	// for safe disambiguation.
	RecallDetailsOpen = "<details>\n<summary>%s</summary>"

	// RecallDetailsClose is the closing HTML for collapsible content.
	RecallDetailsClose = "</details>"

	// RecallFencedBlock formats content inside code fences.
	// Args: fence, content, fence.
	RecallFencedBlock = "%s\n%s\n%s"

	// RecallNavPrev formats the previous part navigation link.
	// Args: filename.
	RecallNavPrev = "[← Previous](%s)"

	// RecallNavNext formats the next part navigation link.
	// Args: filename.
	RecallNavNext = "[Next →](%s)"

	// RecallPartFilename formats a multi-part filename.
	// Args: baseName, part.
	RecallPartFilename = "%s-p%d.md"

	// RecallListRow is the printf meta-format for recall list table rows.
	// Args: slugWidth, projectWidth. Produces a format string for 6 columns.
	RecallListRow = "  %%-%ds  %%-%ds  %%-17s  %%8s  %%5s  %%7s\n"

	// SessionMatch formats a session match line for ambiguous queries.
	// Args: slug, shortID, dateTime.
	SessionMatch = "%s (%s) - %s"

	// MetaDetailsOpen opens a collapsible details block with an HTML table.
	// Markdown tables don't render inside <details> in Zensical, so we use HTML.
	// Args: summary text.
	MetaDetailsOpen = "<details>\n<summary>%s</summary>\n<table>"

	// MetaDetailsClose closes a collapsible details block with HTML table.
	MetaDetailsClose = "</table>\n</details>"

	// MetaRow formats a single row in an HTML metadata table.
	// Args: label, value.
	MetaRow = "<tr><td><strong>%s</strong></td><td>%s</td></tr>"

	// FmQuoted formats a YAML frontmatter quoted string field.
	// Args: key, value.
	FmQuoted = "%s: %q"

	// FmString formats a YAML frontmatter bare string field.
	// Args: key, value.
	FmString = "%s: %s"

	// FmInt formats a YAML frontmatter integer field.
	// Args: key, value.
	FmInt = "%s: %d"

	// ToolDisplay formats a tool name with its key parameter.
	// Args: tool name, parameter value.
	ToolDisplay = "%s: %s"
)

Recall export format templates.

These templates define the structure of exported session transcripts. Each uses fmt.Sprintf verbs for interpolation.

View Source
const ObsidianReadme = `# journal-obsidian (generated)

This directory is generated by ` + "`ctx journal obsidian`" + ` and is read-only.
Do not edit files here - changes will be overwritten on the next run.

## To update

1. Edit source entries in ` + "`%s/`" + `
2. Regenerate:

` + "```" + `
ctx journal obsidian
` + "```" + `

## Usage

Open this directory as an Obsidian vault:

1. Open Obsidian
2. Choose "Open folder as vault"
3. Select this directory
`

ObsidianReadme is the README template for the generated Obsidian vault. Args: journal source directory path.

This template contains multi-line Markdown with fmt.Sprintf placeholders, which cannot be expressed in the YAML short/long text format. It should migrate to a Go text/template or an embedded template file when the template rendering pipeline is implemented (see TASKS.md).

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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