-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Overview
This branch implements a 3-stage prompt architecture for the smriti share command that intelligently segments sessions into distinct knowledge units, generates category-specific documentation, and exports team knowledge to .smriti/ directories.
Architecture Stages
Stage 1: Segment
- Purpose: Analyze sessions and extract distinct knowledge units
- Process: LLM analyzes session content, identifies topics, categories, and relevance scores
- Metadata Injection: Tool usage, files modified, git operations, and errors are extracted and injected into prompts for better context
- Output:
KnowledgeUnit[]with categories, relevance (1-10), and entity tags
Stage 2: Document
- Purpose: Generate polished markdown documentation for each unit
- Process: Select category-specific templates and apply unit content
- Categories Supported:
bug/*- Symptoms → Root Cause → Investigation → Fix → Preventionarchitecture/*/decision/*- Context → Options → Decision → Consequencescode/*- Implementation → Key Decisions → Gotchasfeature/*- Requirements → Design → Implementation Notestopic/*- Concept → Relevance → Examples → Resourcesproject/*- What Changed → Why → Steps → Verification
- Output: Markdown files organized in
.smriti/knowledge/<category>/
Stage 3: Defer
- Purpose: Metadata enrichment (phase 2)
- Future: Entity extraction, freshness detection, version tracking
Key Design Patterns
- Graceful Degradation: Stage 1 fails → fallback to single unit → Stage 2 still generates docs
- Category Validation: LLM suggestions validated against
smriti_categoriestable - Unit-Level Deduplication: Hash(content + category + entities) prevents re-sharing
- Sequential Processing: Units processed one-by-one (safety) not in parallel
- Template Flexibility: Checks
.smriti/prompts/first before using built-in templates
Implementation Details
Files Created
src/team/types.ts- Type definitionssrc/team/segment.ts- Stage 1 segmentation logicsrc/team/document.ts- Stage 2 documentation generationsrc/team/prompts/stage1-segment.md- Segmentation promptsrc/team/prompts/stage2-*.md(7 templates) - Category-specific templatestest/team-segmented.test.ts- Comprehensive test suite (14 tests)
Files Modified
src/db.ts- Extendedsmriti_sharestable withunit_id,relevance_score,entitiessrc/team/share.ts- AddedshareSegmentedKnowledge()function + flag routingsrc/index.ts- Added CLI flags:--segmented,--min-relevance
Usage
# Legacy (unchanged)
smriti share --project myapp
# New 3-stage pipeline
smriti share --project myapp --segmented
# With custom relevance threshold (default: 6/10)
smriti share --project myapp --segmented --min-relevance 7Testing
- 14 unit tests covering:
- Graceful fallback logic
- Unit validation and filtering
- Relevance thresholding
- Edge cases
- All tests passing
- Uses in-memory DB (no external dependencies)
Backward Compatibility
✅ No breaking changes - legacy smriti share behavior unchanged. New flags are optional.
Future Phases
- Phase 2: Entity extraction, freshness detection, tech version tracking
- Phase 3: Relationship graphs, contradiction detection,
smriti conflictscommand
Related Issues
Related to discussion of knowledge organization and team sharing workflows.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels