Skip to content

Comments

refactor(infrastructure): consolidate skills service factories (LISA-58)#212

Merged
TonyCasey merged 1 commit intomainfrom
lisa-58
Feb 12, 2026
Merged

refactor(infrastructure): consolidate skills service factories (LISA-58)#212
TonyCasey merged 1 commit intomainfrom
lisa-58

Conversation

@TonyCasey
Copy link
Owner

@TonyCasey TonyCasey commented Feb 12, 2026

Summary

  • Consolidate skill service factories (MemoryService, TaskService, PromptService) into infrastructure layer
  • Create shared GitMemFactory with lazy singleton pattern
  • Eliminate duplicate code between skills and infrastructure
  • Maintain backwards compatibility through re-exports

Changes

Created (in infrastructure)

  • infrastructure/git-mem/GitMemFactory.ts - Shared lazy singleton factory
  • infrastructure/services/skill-interfaces/ - Skill service interfaces
  • infrastructure/services/SkillMemoryService.ts - Rich memory service for CLI
  • infrastructure/services/SkillTaskService.ts - Rich task service for CLI
  • infrastructure/services/SkillPromptService.ts - Prompt capture service

Modified

  • bootstrap.ts - Uses shared getGitMemInstance() instead of inline creation
  • Skills re-export from infrastructure for backwards compatibility

Deleted (6 files, -1341 lines)

  • skills/shared/clients/GitMemFactory.ts
  • skills/shared/services/MemoryService.ts
  • skills/shared/services/TaskService.ts
  • skills/shared/services/PromptService.ts
  • skills/shared/services/interfaces/IMemoryService.ts
  • skills/shared/services/interfaces/ITaskService.ts

Test plan

  • npm run build succeeds
  • npm test passes (1456 tests)
  • npm run lint passes (only pre-existing warning)
  • Manual verification: lisa memory load works
  • Manual verification: lisa tasks list works

Closes LISA-58

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved internal service organization and naming conventions for consistency.
    • Consolidated memory service management to enhance code reuse and prevent duplication.
    • Reorganized and centralized service factory exports through infrastructure modules for better maintainability.

Move skill service factories (MemoryService, TaskService, PromptService)
from skills/shared to infrastructure layer. This eliminates duplicate
code between skills and infrastructure while maintaining backwards
compatibility through re-exports.

Changes:
- Create shared GitMemFactory with lazy singleton pattern
- Move skill services to infrastructure/services/
- Move skill interfaces to infrastructure/services/skill-interfaces/
- Update bootstrap.ts to use shared git-mem instance
- Re-export from skills/shared for backwards compatibility
- Delete 6 duplicate files (-1341 lines)

Skills entry points continue to work unchanged via re-exports.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

This PR consolidates the git-mem factory into a shared singleton pattern at the infrastructure level, renames service interfaces and factories to skill-specific variants (e.g., IMemoryService → ISkillMemoryService), introduces a centralized skill-interfaces module, and updates the DI bootstrap to reuse the shared git-mem singleton instance.

Changes

Cohort / File(s) Summary
Git-mem Singleton Factory
src/lib/infrastructure/git-mem/GitMemFactory.ts, src/lib/infrastructure/git-mem/index.ts
New lazy-initialized singleton factory with getGitMemInstance() for shared git-mem access, createGitMem() for test isolation, and resetGitMemInstance() for test cleanup.
Skill-specific Service Interfaces
src/lib/infrastructure/services/skill-interfaces/ISkillMemoryService.ts, src/lib/infrastructure/services/skill-interfaces/ISkillTaskService.ts, src/lib/infrastructure/services/skill-interfaces/ISkillPromptService.ts, src/lib/infrastructure/services/skill-interfaces/index.ts
New centralized module for rich CLI skill service interfaces; renames IMemoryService→ISkillMemoryService, ITaskService→ISkillTaskService, ITask→ISkillTask; introduces ISkillPromptService with fingerprint and addPrompt methods; provides backward-compatible legacy aliases.
Service Factory Renames
src/lib/infrastructure/services/SkillMemoryService.ts, src/lib/infrastructure/services/SkillPromptService.ts, src/lib/infrastructure/services/SkillTaskService.ts
Renames factories to skill-specific versions: createMemoryService→createSkillMemoryService, createPromptService→createSkillPromptService, createTaskService→createSkillTaskService; updates parameter and return types to ISkill\* variants; relocates imports to skill-interfaces module.
DI Bootstrap Updates
src/lib/infrastructure/di/bootstrap.ts
Replaces inline git-mem wiring with shared singleton via getGitMemInstance(); reuses singleton when constructing skillTaskService in GitHub sync path.
Export Consolidation
src/lib/infrastructure/services/index.ts, src/lib/skills/shared/clients/index.ts, src/lib/skills/shared/services/index.ts, src/lib/skills/shared/services/interfaces/index.ts
Centralizes service and client exports from infrastructure; moves createGitMem export to infrastructure/git-mem; re-exports skill service factories and interfaces from infrastructure with backward-compatible aliases; consolidates interface exports to single skill-interfaces source.
Removed/Deleted
src/lib/skills/shared/clients/GitMemFactory.ts
Deletes local createGitMem factory; functionality consolidated into centralized infrastructure factory.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Possibly related PRs

Suggested labels

nate

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: consolidating skills service factories into the infrastructure layer, which is the primary change across the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch lisa-58

No actionable comments were generated in the recent review. 🎉


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot added the nate Nate Plan: Memory improvement features label Feb 12, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0db0b2f26e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const memoryRepo = new MemoryRepository(notesService);
const gitMemService = new GitMemService(memoryRepo);
// Use shared git-mem instance from GitMemFactory
const gitMemService = getGitMemInstance();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Scope git-mem instance per project bootstrap

bootstrapContainer now always takes the process-wide getGitMemInstance() path, which means all later container bootstraps reuse the first git-mem backend created in this process. Since that singleton is not keyed by projectRoot, any multi-repo usage in one process (e.g., repeated bootstrap calls in adapters/tests or long-lived hosts) can persist/read memory and tasks against the wrong repository state; this is a data-isolation regression compared to constructing a fresh instance per bootstrap.

Useful? React with 👍 / 👎.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed analysis! Let me explain why this is safe in Lisa's architecture:

git-mem is stateless regarding cwd:

  • NotesService.read/write/list() takes cwd as a parameter on each method call
  • MemoryRepository.create/query/delete() passes cwd through to NotesService
  • The singleton stores no repo state - it just holds the wired service instances

Lisa's usage pattern:

  • CLI commands are short-lived processes (one command = one process)
  • Hooks run per-session in the context of a single project
  • There's no multi-repo handling within a single process

For tests:

  • We export resetGitMemInstance() which tests can call between bootstrap invocations
  • This clears the singleton when needed

Fallback behavior:
When cwd is not passed (as in Lisa's services), git-mem defaults to process.cwd() at execution time - which is correct for our CLI/hook pattern since they're always invoked from the project root.

If we need multi-repo support in the future, we could add explicit cwd passing to the skill services, but for current usage the singleton is safe.

@TonyCasey TonyCasey merged commit 1c34a01 into main Feb 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nate Nate Plan: Memory improvement features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant