version: "3"
vars:
NODE_VERSION: "22"
DOCKER_IMAGE: "knowledgegraph-mcp"
DOCKER_TAG: "latest"
dotenv: [".env"]
tasks:
# Development Tasks
install:
desc: Install dependencies
cmds:
- npm install
clean:
desc: Clean build artifacts and node_modules
cmds:
- rm -rf dist/
- rm -rf coverage/
- rm -rf node_modules/
- rm -rf benchmark-reports/
build:
desc: Build TypeScript to JavaScript
deps: [install]
cmds:
- npm run build
sources:
- "**/*.ts"
- "tsconfig.json"
generates:
- "dist/**/*.js"
- "dist/**/*.d.ts"
watch:
desc: Watch and rebuild on changes
deps: [install]
cmds:
- npm run watch
dev:
desc: Start development server with auto-reload
deps: [build]
cmds:
- node dist/index.js
# Testing Tasks
test:
desc: Run comprehensive multi-backend test suite
deps: [build]
cmds:
- npm run test:comprehensive
test:watch:
desc: Run tests in watch mode
deps: [install]
cmds:
- npm run test:watch
test:coverage:
desc: Run tests with coverage report
deps: [build]
cmds:
- npm run test:coverage
test:performance:
desc: Run performance tests
deps: [build]
cmds:
- npm run test:performance
test:unit:
desc: Run unit tests only (excluding performance and multi-backend tests)
deps: [build]
cmds:
- npx jest --testPathIgnorePatterns=performance --testPathIgnorePatterns=multi-backend
test:original:
desc: Run original test suite only (without multi-backend tests)
deps: [build]
cmds:
- npx jest --testPathIgnorePatterns=multi-backend
test:integration:
desc: Run integration tests
deps: [build]
cmds:
- npx jest tests/storage-providers.test.ts tests/knowledge-graph-manager.test.ts
test:search:
desc: Run search-related tests
deps: [build]
cmds:
- npx jest tests/search/
test:multi-backend:
desc: Run multi-backend tests against both SQLite and PostgreSQL
deps: [build]
cmds:
- npm run test:multi-backend
test:all-backends:
desc: Run all tests including multi-backend tests
deps: [build]
cmds:
- npm run test:all-backends
test:comprehensive:
desc: Run comprehensive multi-backend test suite with detailed reporting
deps: [build]
cmds:
- npm run test:comprehensive
# Benchmarking Tasks
benchmark:
desc: Run all benchmarks
deps: [build]
cmds:
- npm run benchmark
benchmark:search:
desc: Run search performance benchmarks
deps: [build]
cmds:
- npm run benchmark:search
benchmark:database:
desc: Run database performance benchmarks
deps: [build]
cmds:
- npm run benchmark:database
benchmark:load:
desc: Run load testing benchmarks
deps: [build]
cmds:
- npm run benchmark:load
# Database Tasks
db:setup:
desc: Setup PostgreSQL database
cmds:
- |
echo "Creating PostgreSQL database..."
psql -h localhost -p 5432 -U postgres -c "CREATE DATABASE knowledgegraph;" || echo "Database may already exist"
echo "Database setup complete"
db:drop:
desc: Drop PostgreSQL database
cmds:
- |
echo "Dropping PostgreSQL database..."
psql -h localhost -p 5432 -U postgres -c "DROP DATABASE IF EXISTS knowledgegraph;"
echo "Database dropped"
db:reset:
desc: Reset PostgreSQL database (drop and recreate)
cmds:
- task: db:drop
- task: db:setup
db:migrate:
desc: Run database migrations
deps: [build]
cmds:
- node dist/scripts/migrate-to-text.js
# Docker Tasks
docker:build:
desc: Build Docker image
cmds:
- docker build -t {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}} .
docker:run:
desc: Run Docker container
deps: [docker:build]
cmds:
- |
docker run -it --rm \
-e KNOWLEDGEGRAPH_STORAGE_TYPE="$KNOWLEDGEGRAPH_STORAGE_TYPE" \
-e KNOWLEDGEGRAPH_CONNECTION_STRING="$KNOWLEDGEGRAPH_CONNECTION_STRING" \
-e KNOWLEDGEGRAPH_PROJECT="$KNOWLEDGEGRAPH_PROJECT" \
--network host \
{{.DOCKER_IMAGE}}:{{.DOCKER_TAG}}
docker:run:sqlite:
desc: Run Docker container with SQLite backend
deps: [docker:build]
cmds:
- |
docker run -it --rm \
-e KNOWLEDGEGRAPH_STORAGE_TYPE=sqlite \
-e KNOWLEDGEGRAPH_CONNECTION_STRING="sqlite://./knowledgegraph.db" \
-e KNOWLEDGEGRAPH_PROJECT="$KNOWLEDGEGRAPH_PROJECT" \
-v $(pwd)/data:/app/data \
{{.DOCKER_IMAGE}}:{{.DOCKER_TAG}}
docker:test:
desc: Run tests in Docker container
deps: [docker:build]
cmds:
- |
docker run --rm \
-e KNOWLEDGEGRAPH_STORAGE_TYPE=sqlite \
-e KNOWLEDGEGRAPH_CONNECTION_STRING="sqlite://:memory:" \
{{.DOCKER_IMAGE}}:{{.DOCKER_TAG}} npm test
docker:clean:
desc: Clean Docker images and containers
cmds:
- docker rmi {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}} || true
- docker system prune -f
# Linting and Code Quality
lint:
desc: Run TypeScript compiler check
deps: [install]
cmds:
- npx tsc --noEmit
lint:fix:
desc: Fix TypeScript issues where possible
deps: [install]
cmds:
- npx tsc --noEmit --pretty
# Utility Tasks
check:
desc: Run all checks (lint, test, build)
cmds:
- task: lint
- task: test
- task: build
ci:
desc: Run CI pipeline (install, lint, test, build)
cmds:
- task: install
- task: lint
- task: test:coverage
- task: build
# Demo and Examples
demo:sqlite:
desc: Run SQLite demo
deps: [build]
env:
KNOWLEDGEGRAPH_STORAGE_TYPE: sqlite
KNOWLEDGEGRAPH_CONNECTION_STRING: "sqlite://./demo-data/memory.db"
cmds:
- node dist/examples/sqlite-demo.js
demo:storage:
desc: Run storage demo
deps: [build]
cmds:
- node dist/examples/storage-demo.js
demo:tags:
desc: Run tag system demo
deps: [build]
cmds:
- node dist/examples/tag-system-demo.js
# Health and Status
health:
desc: Check service health
deps: [build]
cmds:
- node scripts/health-check.js
# Package and Release
package:
desc: Prepare package for distribution
deps: [clean, install, lint, test, build]
cmds:
- npm pack
# Publishing and Version Management
publish:check:
desc: Check if ready to publish (run all validations)
cmds:
- task: lint
- task: test
- task: build
- npm pack --dry-run
- echo "✅ Ready to publish"
publish:patch:
desc: Publish new patch version (x.x.X)
deps: [publish:check]
cmds:
- task: git:sync-tags
- npm version patch --no-git-tag-version
- task: git:commit-version
- task: git:create-tag
- task: git:push-all
- npm publish
- echo "✅ Published patch version successfully"
publish:minor:
desc: Publish new minor version (x.X.0)
deps: [publish:check]
cmds:
- task: git:sync-tags
- npm version minor --no-git-tag-version
- task: git:commit-version
- task: git:create-tag
- task: git:push-all
- npm publish
- echo "✅ Published minor version successfully"
publish:major:
desc: Publish new major version (X.0.0)
deps: [publish:check]
cmds:
- task: git:sync-tags
- npm version major --no-git-tag-version
- task: git:commit-version
- task: git:create-tag
- task: git:push-all
- npm publish
- echo "✅ Published major version successfully"
publish:dry-run:
desc: Test publishing without actually publishing
deps: [publish:check]
cmds:
- npm publish --dry-run
- echo "✅ Dry run completed successfully"
# Git Tag Management
git:sync-tags:
desc: Sync local tags with remote (fetch and clean up conflicts)
cmds:
- git fetch --tags
- echo "✅ Tags synced from remote"
git:list-tags:
desc: List all git tags (local and remote)
cmds:
- echo "📋 Local tags:"
- git tag -l | sort -V
- echo ""
- echo "📋 Remote tags:"
- git ls-remote --tags origin | cut -d/ -f3 | sort -V
git:delete-tag:
desc: Delete a specific tag locally and remotely
cmds:
- |
if [ -z "{{.TAG}}" ]; then
echo "❌ Error: TAG variable is required"
echo "Usage: task git:delete-tag TAG=v1.0.0"
exit 1
fi
echo "🗑️ Deleting tag {{.TAG}}..."
git tag -d {{.TAG}} || echo "Tag {{.TAG}} not found locally"
git push origin :refs/tags/{{.TAG}} || echo "Tag {{.TAG}} not found on remote"
echo "✅ Tag {{.TAG}} deleted"
git:clean-tags:
desc: Clean up local tags that don't exist on remote
cmds:
- |
echo "🧹 Cleaning up local tags..."
git fetch --prune origin "+refs/tags/*:refs/tags/*"
echo "✅ Local tags cleaned up"
git:force-sync-tags:
desc: Force sync tags (delete all local tags and re-fetch from remote)
cmds:
- |
echo "⚠️ Force syncing tags (this will delete all local tags)..."
git tag -l | xargs git tag -d
git fetch --tags
echo "✅ Tags force synced from remote"
git:commit-version:
desc: Commit version changes
cmds:
- |
VERSION=$(node -p "require('./package.json').version")
git add package.json package-lock.json
git commit -m "chore: bump version to v$VERSION"
echo "✅ Version v$VERSION committed"
git:create-tag:
desc: Create and annotate git tag for current version
cmds:
- |
VERSION=$(node -p "require('./package.json').version")
git tag -a "v$VERSION" -m "Release v$VERSION"
echo "✅ Tag v$VERSION created"
git:push-all:
desc: Push commits and tags to remote
cmds:
- git push origin main
- git push origin --tags
- echo "✅ Pushed commits and tags to remote"
# Version Management
version:current:
desc: Show current version
cmds:
- |
VERSION=$(node -p "require('./package.json').version")
echo "📦 Current version: v$VERSION"
version:next:
desc: Show what the next versions would be
cmds:
- |
CURRENT=$(node -p "require('./package.json').version")
echo "📦 Current version: v$CURRENT"
echo "📦 Next patch: v$(npm version patch --dry-run | sed 's/v//')"
echo "📦 Next minor: v$(npm version minor --dry-run | sed 's/v//')"
echo "📦 Next major: v$(npm version major --dry-run | sed 's/v//')"
# NPM Management
npm:check-auth:
desc: Check npm authentication status
cmds:
- |
if npm whoami > /dev/null 2>&1; then
echo "✅ Logged in as: $(npm whoami)"
else
echo "❌ Not logged in to npm"
echo "Run: npm login"
exit 1
fi
npm:view-package:
desc: View published package information
cmds:
- npm view knowledgegraph-mcp
npm:unpublish:
desc: Unpublish a specific version
cmds:
- |
if [ -z "{{.VERSION}}" ]; then
echo "❌ Error: VERSION variable is required"
echo "Usage: task npm:unpublish VERSION=0.6.7"
exit 1
fi
echo "⚠️ Unpublishing knowledgegraph-mcp@{{.VERSION}}..."
npm unpublish knowledgegraph-mcp@{{.VERSION}}
echo "✅ Version {{.VERSION}} unpublished"
npm:deprecate:
desc: Deprecate a specific version
cmds:
- |
if [ -z "{{.VERSION}}" ]; then
echo "❌ Error: VERSION variable is required"
echo "Usage: task npm:deprecate VERSION=0.6.7 MESSAGE=\"Use latest version\""
exit 1
fi
MESSAGE="{{.MESSAGE}}"
if [ -z "$MESSAGE" ]; then
MESSAGE="This version is deprecated. Please use the latest version."
fi
echo "⚠️ Deprecating knowledgegraph-mcp@{{.VERSION}}..."
npm deprecate knowledgegraph-mcp@{{.VERSION}} "$MESSAGE"
echo "✅ Version {{.VERSION}} deprecated"
# Environment Setup
env:setup:
desc: Setup development environment
cmds:
- task: install
- task: db:setup
- task: build
- echo "✅ Development environment setup complete"
env:setup:sqlite:
desc: Setup development environment with SQLite (uses default home directory path)
env:
KNOWLEDGEGRAPH_STORAGE_TYPE: sqlite
cmds:
- task: install
- task: build
- echo "✅ SQLite development environment setup complete"
- echo "📁 Database will be created at ~/.knowledge-graph/knowledgegraph.db"
# Performance and Monitoring
perf:profile:
desc: Profile application performance
deps: [build]
cmds:
- node --prof dist/index.js &
- sleep 10
- pkill -f "node --prof"
- node --prof-process isolate-*.log > profile.txt
- echo "Profile saved to profile.txt"
perf:memory:
desc: Check memory usage
deps: [build]
cmds:
- node --inspect dist/index.js &
- sleep 5
- echo "Memory profiling available at chrome://inspect"
- pkill -f "node --inspect"
# Security and Validation
security:audit:
desc: Run security audit
cmds:
- npm audit
- npm audit --audit-level high
security:fix:
desc: Fix security vulnerabilities
cmds:
- npm audit fix
# Documentation
docs:generate:
desc: Generate API documentation
deps: [build]
cmds:
- echo "📚 Generating documentation..."
- npx typedoc --out docs/api src/
- echo "✅ Documentation generated in docs/api/"
docs:serve:
desc: Serve documentation locally
cmds:
- ./scripts/serve-docs.sh
# Backup and Restore
backup:data:
desc: Backup database data
cmds:
- ./scripts/backup-data.sh
restore:data:
desc: Show available backups for restore
cmds:
- ./scripts/list-backups.sh
# Maintenance
maintenance:cleanup:
desc: Cleanup old files and logs
cmds:
- rm -f *.log
- rm -f isolate-*.log
- rm -f profile.txt
- rm -rf .nyc_output/
- find . -name "*.tmp" -delete
- echo "Cleanup complete"
maintenance:update:
desc: Update dependencies
cmds:
- npm update
- npm audit fix
- echo "Dependencies updated"
# Help
help:
desc: Show available tasks
cmds:
- task --list
help:detailed:
desc: Show detailed task descriptions
cmds:
- ./scripts/show-help.sh
default:
desc: Default task - show help
cmds:
- task: help:detailed