Skip to content

Exp/smriti share#15

Open
ashu17706 wants to merge 2 commits intomainfrom
exp/smriti-share
Open

Exp/smriti share#15
ashu17706 wants to merge 2 commits intomainfrom
exp/smriti-share

Conversation

@ashu17706
Copy link
Contributor

#14

ashu17706 and others added 2 commits February 12, 2026 00:58
## Summary

Implement complete MVP of 3-stage knowledge unit segmentation pipeline
as outlined in the plan. Sessions are now transformed into modular,
independently-documentable knowledge units.

## Architecture

Stage 1 (Segmentation):
- LLM analyzes session, identifies distinct knowledge units
- Extracts topic, category, relevance score (0-10)
- Enriches prompt with operational metadata (tools, files, git ops, errors)
- Gracefully degrades to single unit if LLM unavailable

Stage 2 (Documentation):
- Applies 7 category-specific templates (bug, architecture, code, feature, topic, project, base)
- LLM synthesizes focused markdown per unit
- Generates YAML frontmatter with metadata
- Returns raw content if synthesis unavailable

Stage 3 (Deferred to Phase 2):
- Entity extraction, freshness detection, metadata enrichment

## Files Created (13)

Type System & Core Logic:
- src/team/types.ts - KnowledgeUnit, SegmentationResult, DocumentGenerationResult
- src/team/segment.ts - Stage 1 segmentation with metadata injection
- src/team/document.ts - Stage 2 documentation generation

Prompts (8 templates):
- src/team/prompts/stage1-segment.md - Segmentation with metadata injection
- src/team/prompts/stage2-*.md (7 category-specific templates)

Tests & Docs:
- test/team-segmented.test.ts - 14 unit tests (all passing)
- IMPLEMENTATION.md - Technical documentation
- QUICKSTART.md - User guide
- IMPLEMENTATION_CHECKLIST.md - Verification checklist
- DEMO_RESULTS.md - Live demo results

## Files Modified (3)

- src/db.ts - Extended smriti_shares table with unit_id, relevance_score, entities
- src/team/share.ts - Added shareSegmentedKnowledge() + routing logic
- src/index.ts - Added --segmented and --min-relevance CLI flags

## Key Features

✅ Graceful degradation at each stage
✅ Unit-level deduplication (content_hash + unit_id)
✅ Category validation against taxonomy
✅ Sequential processing (safe, monitorable)
✅ YAML frontmatter with unit metadata
✅ Auto-generated manifest and CLAUDE.md index
✅ Full backward compatibility (legacy pipeline unchanged)
✅ Database schema migration support

## Usage

# Basic usage
smriti share --project myapp --segmented

# With custom relevance threshold
smriti share --project myapp --segmented --min-relevance 7

# Share specific category
smriti share --category bug --segmented

## Testing

✅ 14 unit tests passing
✅ Code compiles without errors
✅ CLI working and documented
✅ Graceful degradation verified
✅ Backward compatibility confirmed

## Demo Results

- Cleared previous knowledge
- Successfully shared session e38f63e5
- Graceful degradation working (Ollama unavailable)
- Output created in .smriti/knowledge/uncategorized/
- Database migration successful
- CLAUDE.md auto-generated for discovery

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add gitleaks pre-commit hook to detect secrets before commits
- Configure .gitleaks.toml with allowlist for test tokens in knowledge base
- Add GitHub Actions CI pipeline for automated secret scanning
- Integrate detect-secrets as additional verification layer
- All hooks pass with no false positives after baseline configuration

Security improvements:
- Prevents accidental credential commits
- Scans full git history on each push
- Configured to ignore test/demo tokens in documentation

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
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

Comments