Skip to content

mid refactoring#43

Merged
josealekhine merged 20 commits intomainfrom
feat/beaver
Mar 14, 2026
Merged

mid refactoring#43
josealekhine merged 20 commits intomainfrom
feat/beaver

Conversation

@josealekhine
Copy link
Member

merging changes to unblock @parlakisik and @CoderMungan

CODE MAY NOT BE STABLE!

josealekhine and others added 20 commits March 7, 2026 07:20
Complete the taxonomical symmetry: every single-command CLI package
now has Cmd() in cmd/root/cmd.go alongside Run(). Parent files are
thin re-exports: func Cmd() *cobra.Command { return root.Cmd() }.

20 packages updated. Special re-exports preserved:
- complete: CompleteTask
- initialize: PluginInstalled, PluginEnabledGlobally, PluginEnabledLocally

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move budget percentages, cooldown, tombstone prefix to config
- Move recency thresholds (7/30/90 days) and scores to config
- Move relevance match cap to config
- Move stopwords to assets YAML, loaded via assets.StopWords()
- Move agent instruction text to assets via TextDesc()
- Add assets.TextDesc() and assets.StopWords() to embed API
- Move date format, marker prefix, event name, JSON key to config
- Replace hand-rolled Itoa with strconv.Itoa
- Move HumanAgo time labels to assets for i18n
- Move changes error to internal/err (DetectReferenceTime)
- Reuse ctxerr.NotInitialized() in agent (was duplicate string)
- Fix DateTimeFormat usage in changes format.go
- Tasks added: configurable scoring, stopwords, isAlnum,
  HumanAgo/Pluralize extraction, format templates, compact write

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add doc.go to 21 cmd/root directories with meaningful package comments
- Move compact task output (moving/skipping/archived) to internal/write
- Move archive errors to internal/err (CreateArchiveDir, WriteArchive)
- Move archive filename template and date separator to config
- Eliminate compact/exports.go — consumers import compact/core directly
- Add TplArchiveFilename, ArchiveDateSep, PrefixCtxLoaded,
  EventContextLoadGate, JSONKeyTimestamp to config
- Task added: fix 19 doc.go quality issues from audit report

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move complete task errors to internal/err (TaskFileNotFound,
  TaskFileRead, TaskFileWrite, TaskMultipleMatches, TaskNotFound)
- Move complete output to write.InfoCompletedTask
- Move task completion regex replacement to config.TaskCompleteReplace
- Move schema read error to ctxerr.ReadEmbeddedSchema
- Move config status output to write (InfoConfigProfile{Dev,Base,None})
- Rename CompleteTask → complete.Task (avoids package stutter, document
  MCP as sole consumer)
- Fix 8 stuttery Run function names: RunStatus→Run, RunSwitch→Run,
  RunSetup→Run, RunRestore→Run, RunSnapshot→Run, RunList→Run,
  RunAdd→Run across config, notify, permissions, prompt, remind

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace nolint:gosec with validation.SafeReadFile in DetectProfile
  and CopyProfile
- Add exec.LookPath("git") check before git rev-parse in GitRoot
- Move profile constants (FileCtxRC, ProfileDev/Base/Prod) to
  internal/config — config/core aliases them
- Move ProfileDetectKey ("notify:") to config
- Move switchTo logic to core.SwitchTo (returns message, no cobra dep)
- Delete switchcmd/switch.go — cmd/root now only has cmd.go + run.go
- Add error constructors: UnknownProfile, ReadProfile, GitNotFound,
  NotInGitRepo, ReadEmbeddedSchema
- Task added: audit all git call sites for graceful degradation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Guard all exec.Command("git") call sites with exec.LookPath:
- changes/core/scan.go: gitLogSince returns error
- recall/parser/git.go: gitRemote returns "" (best-effort)
- system/cmd/checkmapstaleness: countModuleCommits returns 0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…deps

- Add 112 FlagDescKey* constants to assets/embed.go — all FlagDesc
  calls now use symbolic constants instead of string literals
- Move format constants (FormatMermaid, FormatTable) to config
- Move deps errors to ctxerr (UnknownFormat, UnknownProjectType)
- Move deps output to write (InfoDepsNoProject, InfoDepsNoDeps)
- Add config.AnnotationTrue for boolean cobra annotations
- Replace all AnnotationSkipInit: "true" with config.AnnotationTrue
- Task added: split deps/core builders into per-ecosystem packages

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move 19 DoctorCheck* name constants to config
- Move 8 DoctorCategory* category constants to config
- Move 4 Status* constants (ok/warning/error/info) to config
- Extract 30 doctor message strings to assets YAML
- Replace Go unicode escapes with UTF-8 characters in statusIcon
- Move format strings in output.go to assets
- Replace inline .notify.enc and reminders.json with config constants

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move NoCompletedTasks, NoTemplate, DriftViolations to internal/err
- Reuse existing ctxerr.TaskFileNotFound, NotInitialized, Mkdir,
  TaskFileWrite, FileWrite instead of drift-local duplicates
- Delete drift/core/err.go (per convention: no per-package err.go)
- Fix test assertion for changed error message
- Tasks added: drift fix/out/sanitize strings, guide text extraction

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move skillMeta struct to types.go per convention
- Replace "---" with config.Separator, "..." with config.Ellipsis
- Replace magic number 4 with len(config.Separator + config.NewlineLF)
- Move skills output to write (InfoSkillsHeader, InfoSkillLine)
- Remove unused bytes.Buffer and fmt.Fprintf

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Hook:
- Move CopilotInstructions to embedded asset file
- Move all tool integration text blocks to assets YAML
- Move output to write, errors to ctxerr
- Delete dead code (ToolConfigFiles)
- Add ctxerr.UnsupportedTool, config.CopilotMarker

Initialize run.go:
- Move 10 fmt.Errorf calls to ctxerr (ListTemplates, ReadTemplate,
  GenerateKey, SaveKey, MkdirKeyDir + reuse existing)
- Move 22 cmd.Println calls to 15 write.InfoInit* functions
- Replace literal "\n" with config.NewlineLF

Initialize core (10 files):
- Move ~102 inline strings to ctxerr + write across claude.go,
  dirs.go, fs.go, hook.go, makefile.go, plan.go, plugin.go,
  prompt.go, prompt_tpl.go, tpl.go
- Add ctxerr.HomeDir, ParseFile, MarshalPlugins, MarshalSettings
- Add write.InitPlugin{Skipped,AlreadyEnabled,Enabled} + others

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Rename runJournalObsidian → Run (align with codebase convention)
- Replace \u2713 and \u2192 with actual UTF-8 characters ✓ and →
- Move vault generation output to write.InfoObsidianGenerated
- Add tplObsidianGenerated and tplObsidianNextSteps to write/config

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add 73 CmdDescKey* symbolic constants for CommandDesc calls
- Add TextDescKey* and ExampleDescKey* constants (same pattern)
- Move extra.css from journal/cmd/site to internal/assets/journal/
- Add assets.JournalExtraCSS() accessor
- Move journal site output to write (generated, orphans, next steps)
- Move journal state error to ctxerr.LoadJournalStateErr
- Add config.DirStylesheets, config.FileExtraCSS
- Replace \u00d7 with × in consolidate.go

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move frontmatter struct to types.go per convention
- Move frontmatter field key constants to config (label.go)
- Fix unhandled fmt.Fprintf errors in section.go (_, _ = pattern)
- Replace \u00d7 with × in consolidate.go
- Add TextDescKey* constants for remaining TextDesc calls

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move loop errors to ctxerr (InvalidTool), output to write
- Add config.DefaultCompletionSignal for loop completion magic string
- Move load/core/out.go to internal/write/load.go (LoadRaw, LoadAssembled)
- Move load NotInitialized error to ctxerr
- Move mcp.serve Short/Long to assets, add CmdDescKeyMcpServe
- Fix mcp/cmd/root/cmd.go missing copyright header
- Remove 9 dead TextDescKey* constants from embed.go
- Add write templates for loop and journal site output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Not done yet.

Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Not done yet.

Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Not done yet.

Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Not done yet.

Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Not done yet.

Signed-off-by: Jose Alekhinne <jose@ctx.ist>
@josealekhine josealekhine self-assigned this Mar 14, 2026
@josealekhine josealekhine requested a review from bilersan as a code owner March 14, 2026 04:55
@cloudflare-workers-and-pages
Copy link

Deploying ctx with  Cloudflare Pages  Cloudflare Pages

Latest commit: f7ae9c8
Status: ✅  Deploy successful!
Preview URL: https://6606b6a0.ctx-bhl.pages.dev
Branch Preview URL: https://feat-beaver.ctx-bhl.pages.dev

View logs

@josealekhine josealekhine merged commit aad525f into main Mar 14, 2026
11 of 12 checks passed
@josealekhine josealekhine deleted the feat/beaver branch March 14, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant