Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions internal/assets/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// / ctx: https://ctx.ist
// ,'`./ do you remember?
// `.,'\
// \ Copyright 2026-present Context contributors.
// SPDX-License-Identifier: Apache-2.0

// Package assets provides embedded assets for ctx including .context/
// templates and Claude Code plugin files.
package assets
7 changes: 4 additions & 3 deletions internal/assets/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package assets
import (
"embed"
"encoding/json"
"github.com/ActiveMemory/ctx/internal/config"
"strings"
"sync"
)
Expand Down Expand Up @@ -330,7 +331,7 @@ func ListHookVariants(hook string) ([]string, error) {
// - []byte: Document content from why/
// - error: Non-nil if the file is not found or read fails
func WhyDoc(name string) ([]byte, error) {
return FS.ReadFile("why/" + name + ".md")
return FS.ReadFile("why/" + name + config.ExtMarkdown)
}

// ListWhyDocs returns available "why" document names (without extension).
Expand All @@ -348,7 +349,7 @@ func ListWhyDocs() ([]string, error) {
for _, entry := range entries {
if !entry.IsDir() {
name := entry.Name()
if len(name) > 3 && name[len(name)-3:] == ".md" {
if len(name) > 3 && name[len(name)-3:] == config.ExtMarkdown {
names = append(names, name[:len(name)-3])
}
}
Expand Down Expand Up @@ -378,7 +379,7 @@ var (
// Lines are trimmed; empty lines and lines starting with '#' are skipped.
func parsePermissions(data []byte) []string {
var result []string
for _, line := range strings.Split(string(data), "\n") {
for _, line := range strings.Split(string(data), config.NewlineLF) {
line = strings.TrimSpace(line)
if line == "" || strings.HasPrefix(line, "#") {
continue
Expand Down
4 changes: 2 additions & 2 deletions internal/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/ActiveMemory/ctx/internal/cli/agent"
"github.com/ActiveMemory/ctx/internal/cli/changes"
"github.com/ActiveMemory/ctx/internal/cli/compact"
cliconfig "github.com/ActiveMemory/ctx/internal/cli/config"
"github.com/ActiveMemory/ctx/internal/cli/complete"
cliconfig "github.com/ActiveMemory/ctx/internal/cli/config"
"github.com/ActiveMemory/ctx/internal/cli/decision"
"github.com/ActiveMemory/ctx/internal/cli/deps"
"github.com/ActiveMemory/ctx/internal/cli/doctor"
Expand All @@ -38,8 +38,8 @@ import (
"github.com/ActiveMemory/ctx/internal/cli/notify"
"github.com/ActiveMemory/ctx/internal/cli/pad"
"github.com/ActiveMemory/ctx/internal/cli/pause"
"github.com/ActiveMemory/ctx/internal/cli/prompt"
"github.com/ActiveMemory/ctx/internal/cli/permissions"
"github.com/ActiveMemory/ctx/internal/cli/prompt"
"github.com/ActiveMemory/ctx/internal/cli/recall"
"github.com/ActiveMemory/ctx/internal/cli/reindex"
"github.com/ActiveMemory/ctx/internal/cli/remind"
Expand Down
9 changes: 9 additions & 0 deletions internal/bootstrap/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// / ctx: https://ctx.ist
// ,'`./ do you remember?
// `.,'\
// \ Copyright 2026-present Context contributors.
// SPDX-License-Identifier: Apache-2.0

// Package bootstrap initializes the ctx CLI application and registers
// all subcommands.
package bootstrap
3 changes: 2 additions & 1 deletion internal/cli/add/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package add

import (
"fmt"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -201,7 +202,7 @@ func runAdd(cmd *cobra.Command, args []string, flags addConfig) error {
}

green := color.New(color.FgGreen).SprintFunc()
cmd.Printf("%s Added to %s\n", green("✓"), fName)
cmd.Println(fmt.Sprintf("%s Added to %s", green("✓"), fName))

return nil
}
2 changes: 1 addition & 1 deletion internal/cli/changes/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func detectFromEvents() (time.Time, bool) {
return time.Time{}, false
}

lines := strings.Split(strings.TrimSpace(string(data)), "\n")
lines := strings.Split(strings.TrimSpace(string(data)), config.NewlineLF)
// Scan in reverse for last context-load-gate event.
for i := len(lines) - 1; i >= 0; i-- {
line := lines[i]
Expand Down
7 changes: 4 additions & 3 deletions internal/cli/changes/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package changes

import (
"fmt"
"github.com/ActiveMemory/ctx/internal/config"
"strings"
)

Expand All @@ -24,7 +25,7 @@ func RenderChanges(refLabel string, ctxChanges []ContextChange, code CodeSummary
b.WriteString(fmt.Sprintf("- `%s` — modified %s\n",
c.Name, c.ModTime.Format("2006-01-02 15:04")))
}
b.WriteString("\n")
b.WriteString(config.NewlineLF)
}

if code.CommitCount > 0 {
Expand All @@ -42,7 +43,7 @@ func RenderChanges(refLabel string, ctxChanges []ContextChange, code CodeSummary
b.WriteString(fmt.Sprintf("- **Authors**: %s\n",
strings.Join(code.Authors, ", ")))
}
b.WriteString("\n")
b.WriteString(config.NewlineLF)
}

if len(ctxChanges) == 0 && code.CommitCount == 0 {
Expand Down Expand Up @@ -77,5 +78,5 @@ func RenderChangesForHook(refLabel string, ctxChanges []ContextChange, code Code
return ""
}

return "Changes since last session: " + strings.Join(parts, ". ") + "\n"
return "Changes since last session: " + strings.Join(parts, ". ") + config.NewlineLF
}
9 changes: 5 additions & 4 deletions internal/cli/changes/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package changes

import (
"github.com/ActiveMemory/ctx/internal/config"
"os"
"os/exec"
"sort"
Expand Down Expand Up @@ -40,7 +41,7 @@ func FindContextChanges(refTime time.Time) ([]ContextChange, error) {

var changes []ContextChange
for _, e := range entries {
if e.IsDir() || !strings.HasSuffix(e.Name(), ".md") {
if e.IsDir() || !strings.HasSuffix(e.Name(), config.ExtMarkdown) {
continue
}
info, infoErr := e.Info()
Expand Down Expand Up @@ -78,7 +79,7 @@ func SummarizeCodeChanges(refTime time.Time) (CodeSummary, error) {
if lines == "" {
return summary, nil
}
commitLines := strings.Split(lines, "\n")
commitLines := strings.Split(lines, config.NewlineLF)
summary.CommitCount = len(commitLines)

// Latest commit message (first line of oneline output).
Expand Down Expand Up @@ -110,7 +111,7 @@ func SummarizeCodeChanges(refTime time.Time) (CodeSummary, error) {
// uniqueTopDirs extracts unique top-level directories from file paths.
func uniqueTopDirs(output string) []string {
seen := make(map[string]bool)
for _, line := range strings.Split(strings.TrimSpace(output), "\n") {
for _, line := range strings.Split(strings.TrimSpace(output), config.NewlineLF) {
line = strings.TrimSpace(line)
if line == "" {
continue
Expand All @@ -133,7 +134,7 @@ func uniqueTopDirs(output string) []string {
// uniqueLines returns unique non-empty lines from output.
func uniqueLines(output string) []string {
seen := make(map[string]bool)
for _, line := range strings.Split(strings.TrimSpace(output), "\n") {
for _, line := range strings.Split(strings.TrimSpace(output), config.NewlineLF) {
line = strings.TrimSpace(line)
if line != "" {
seen[line] = true
Expand Down
12 changes: 6 additions & 6 deletions internal/cli/config/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func statusCmd() *cobra.Command {
Use: "status",
Short: "Show active .ctxrc profile",
Annotations: map[string]string{internalConfig.AnnotationSkipInit: ""},
Args: cobra.NoArgs,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
root, rootErr := gitRoot()
if rootErr != nil {
Expand Down Expand Up @@ -99,7 +99,7 @@ func runSwitch(cmd *cobra.Command, root string, args []string) error {
func switchTo(cmd *cobra.Command, root, profile string) error {
current := detectProfile(root)
if current == profile {
cmd.Printf("already on %s profile\n", profile)
cmd.Println(fmt.Sprintf("already on %s profile", profile))
return nil
}

Expand All @@ -115,9 +115,9 @@ func switchTo(cmd *cobra.Command, root, profile string) error {
}

if current == "" {
cmd.Printf("created %s from %s profile\n", fileCtxRC, profile)
cmd.Println(fmt.Sprintf("created %s from %s profile", fileCtxRC, profile))
} else {
cmd.Printf("switched to %s profile\n", profile)
cmd.Println(fmt.Sprintf("switched to %s profile", profile))
}
return nil
}
Expand All @@ -130,7 +130,7 @@ func runStatus(cmd *cobra.Command, root string) error {
case profileBase:
cmd.Println("active: base (defaults)")
default:
cmd.Printf("active: none (%s does not exist)\n", fileCtxRC)
cmd.Println(fmt.Sprintf("active: none (%s does not exist)", fileCtxRC))
}
return nil
}
Expand All @@ -143,7 +143,7 @@ func detectProfile(root string) string {
return ""
}

for _, line := range strings.Split(string(data), "\n") {
for _, line := range strings.Split(string(data), internalConfig.NewlineLF) {
if strings.HasPrefix(strings.TrimSpace(line), "notify:") {
return profileDev
}
Expand Down
8 changes: 8 additions & 0 deletions internal/cli/decision/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// / ctx: https://ctx.ist
// ,'`./ do you remember?
// `.,'\
// \ Copyright 2026-present Context contributors.
// SPDX-License-Identifier: Apache-2.0

// Package decision manages DECISIONS.md file and its quick-reference index.
package decision
3 changes: 2 additions & 1 deletion internal/cli/deps/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package deps
import (
"encoding/json"
"fmt"
"github.com/ActiveMemory/ctx/internal/config"
"sort"
"strings"
)
Expand Down Expand Up @@ -57,7 +58,7 @@ func renderTable(graph map[string][]string) string {
// renderJSON produces a machine-readable JSON adjacency list.
func renderJSON(graph map[string][]string) string {
data, _ := json.MarshalIndent(graph, "", " ")
return string(data) + "\n"
return string(data) + config.NewlineLF
}

// sortedKeys returns the keys of a map sorted alphabetically.
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/deps/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package deps

import (
"bufio"
"github.com/ActiveMemory/ctx/internal/config"
"os"
"sort"
"strings"
Expand Down Expand Up @@ -148,7 +149,7 @@ func buildPyprojectGraph(includeDevDeps bool) (map[string][]string, error) {
// parsePyprojectDeps extracts dependency names from a TOML array section.
// Looks for [project.dependencies], [tool.poetry.dependencies], etc.
func parsePyprojectDeps(content string, sectionSuffix string) []string {
lines := strings.Split(content, "\n")
lines := strings.Split(content, config.NewlineLF)
var deps []string
inSection := false
inArray := false
Expand Down
6 changes: 4 additions & 2 deletions internal/cli/deps/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import (
"sort"
)

const rustEcosystem = "rust"

// rustBuilder implements GraphBuilder for Rust projects.
type rustBuilder struct{}

func (r *rustBuilder) Name() string { return "rust" }
func (r *rustBuilder) Name() string { return rustEcosystem }

func (r *rustBuilder) Detect() bool {
_, err := os.Stat("Cargo.toml")
Expand Down Expand Up @@ -49,7 +51,7 @@ type cargoPackage struct {

// cargoDep represents a dependency entry in cargo metadata.
type cargoDep struct {
Name string `json:"name"`
Name string `json:"name"`
Kind *string `json:"kind"`
}

Expand Down
9 changes: 9 additions & 0 deletions internal/cli/doctor/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// / ctx: https://ctx.ist
// ,'`./ do you remember?
// `.,'\
// \ Copyright 2026-present Context contributors.
// SPDX-License-Identifier: Apache-2.0

// Package doctor performs structural health checks for context, hooks,
// and configuration.
package doctor
4 changes: 2 additions & 2 deletions internal/cli/doctor/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,12 +635,12 @@ func outputDoctorHuman(cmd *cobra.Command, report *Report) error {
cmd.Println(cat)
for _, r := range results {
icon := statusIcon(r.Status)
cmd.Printf(" %s %s\n", icon, r.Message)
cmd.Println(fmt.Sprintf(" %s %s", icon, r.Message))
}
cmd.Println()
}

cmd.Printf("Summary: %d warnings, %d errors\n", report.Warnings, report.Errors)
cmd.Println(fmt.Sprintf("Summary: %d warnings, %d errors", report.Warnings, report.Errors))
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/cli/guide/guide_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestParseSkillFrontmatter(t *testing.T) {
wantErr bool
}{
{
name: "valid frontmatter",
name: "valid frontmatter",
input: "---\nname: ctx-test\ndescription: \"A test skill.\"\n---\nBody text.",
want: skillMeta{Name: "ctx-test", Description: "A test skill."},
},
Expand Down
5 changes: 3 additions & 2 deletions internal/cli/guide/skills.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package guide
import (
"bytes"
"fmt"
"github.com/ActiveMemory/ctx/internal/config"
"strings"

"github.com/spf13/cobra"
Expand All @@ -32,11 +33,11 @@ func parseSkillFrontmatter(content []byte) (skillMeta, error) {
const sep = "---"

text := string(content)
if !strings.HasPrefix(text, sep+"\n") {
if !strings.HasPrefix(text, sep+config.NewlineLF) {
return skillMeta{}, nil
}

end := strings.Index(text[4:], "\n"+sep)
end := strings.Index(text[4:], config.NewlineLF+sep)
if end < 0 {
return skillMeta{}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/hook/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ Run 'ctx agent' for AI-ready context packet.
cmd.Println(green("```"))

default:
cmd.Printf("Unknown tool: %s\n\n", tool)
cmd.Println(fmt.Sprintf("Unknown tool: %s\n", tool))
cmd.Println("Supported tools:")
cmd.Println(" claude-code - Anthropic's Claude Code CLI (use plugin instead)")
cmd.Println(" cursor - Cursor IDE")
Expand Down
Loading