refactor(vscode): extract TemplateService from Configuration (R1) #198 - #223
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ctor (#199) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…uture fields Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rtup call site
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ar dep Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add getEntryFilePatternRaw, getNotesFilePatternRaw, getWeeklyNotesFilePatternRaw, getWeekFilePatternRaw, getWeekOrEntryPathPatternRaw so TemplateService can read pattern strings without touching vscode.WorkspaceConfiguration directly. Rename private getInlineTemplate → public loadInlineTemplate to satisfy the IRawConfigProvider interface that TemplateService will depend on. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
) Add src/vscode/template-service.ts exporting: - IRawConfigProvider: narrow interface Configuration implements - TemplateService: holds all resolution logic, zero vscode imports Configuration now implements IRawConfigProvider and holds a private TemplateService instance (tpl). getTplTime() added to satisfy the interface. Template-service.ts never imports conf.ts — no circular dep. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
) All template-resolution methods now delegate to this.tpl (TemplateService). conf.ts contains zero resolution logic — only raw config accessors and one-line wrappers. Remove unused replaceVariableValue / resolveDate imports and dead getInlineTemplateCached + patterns Map. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Brooks-Lint ReviewMode: PR Review This is an exemplary "Extract Class" refactor. It strictly adheres to the approved implementation plan, successfully decoupling complex template resolution logic from VS Code integration while maintaining full backward compatibility. Findings🟢 SuggestionAccidental Complexity — Minor Interface Inconsistency SummaryThe PR achieves a significant architectural win by isolating the template resolution engine into a leaf module ( Verdict: Approved. |
Align with getWeeksPathPatternRaw naming convention. Method is not on IConfiguration so rename is safe. Only 3 call sites (declaration, IRawConfigProvider, TemplateService.getResolvedWeeklyNotesPath). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
src/vscode/conf.tsinto a newTemplateServiceclass (src/vscode/template-service.ts)IRawConfigProviderinterface soTemplateServicehas zerovscodeimports and no circular dependency onconf.tsConfigurationdelegates all resolution methods to an internalTemplateServiceinstance —IConfigurationand all callers unchangedChanges
New file:
src/vscode/template-service.tsIRawConfigProvider(14-method interface, no VS Code types)TemplateService(all moved resolution logic)Modified:
src/vscode/conf.tsConfigurationnow implementsIRawConfigProvidergetEntryFilePatternRaw,getNotesFilePatternRaw,getWeeklyNotesFilePatternRaw,getWeekFilePatternRaw,getWeekOrEntryPathPatternRaw)getTplTime()added to satisfy interfacegetInlineTemplaterenamed → publicloadInlineTemplatereturn this.tpl.xxx(...)wrappersconf.ts: 945 → 709 lines (−236 net; −326 gross resolution logic)Test Plan
grep vscode src/vscode/template-service.ts→ zero resultsgrep "from.*conf" src/vscode/template-service.ts→ zero resultsgit diff develop -- src/model/interfaces.ts→ emptynpm run compile→ cleannpm test→ 159/159 passingCloses #198
Related spec: docs/specs/2026-05-18-198-extract-template-service.md
Related plan: docs/plans/2026-05-18-198-extract-template-service.md
🤖 Generated with Claude Code