@author-today-tools/cli-core
v0.1.3
Published
Shared utilities for Author.Today CLI tools
Maintainers
Readme
@author-today-tools/cli-core
Shared utilities for Author.Today CLI and TUI packages.
Overview
This package provides common functionality used by both the CLI and TUI:
- Configuration Management - Profile-based configuration using
conf - Credential Storage - Secure credential storage using system keychain (keytar) with file-based fallback
- API Client Factory - Centralized API client creation with authentication
- Shared Types - TypeScript types for configuration and credentials
Installation
# This is typically installed as a workspace dependency
pnpm add @author-today-tools/cli-coreUsage
Configuration
import { config } from '@author-today-tools/cli-core';
// Set profile configuration
config.setProfile('default', {
apiUrl: 'https://api.author.today',
email: '[email protected]',
});
// Get profile configuration
const profile = config.getProfile('default');
// Get current profile name
const currentProfile = config.getCurrentProfile();Credentials
import { credentials } from '@author-today-tools/cli-core';
// Store credentials
await credentials.setCredentials({
token: 'your-auth-token',
expiresAt: Date.now() + 30 * 24 * 60 * 60 * 1000, // 30 days
}, 'default');
// Retrieve credentials
const creds = await credentials.getCredentials('default');
// Check if token is expired
const isExpired = await credentials.isTokenExpired('default');
// Delete credentials
await credentials.deleteCredentials('default');API Client Factory
import { createApiClient, requireAuth } from '@author-today-tools/cli-core';
// Ensure user is authenticated (throws if not)
await requireAuth('default');
// Create authenticated API client
const client = await createApiClient('default');
// Use the client
const library = await client.getUserLibrary();Architecture
Configuration Storage
Uses conf library for profile-based configuration:
- Location:
~/.config/at-cli/config.json - Profiles: Multiple profiles supported (e.g., personal, work)
- Preferences: UI preferences, keyboard shortcuts
Credential Storage
Primary: System keychain via keytar (macOS Keychain, Windows Credential Vault, Linux Secret Service)
Fallback: Encrypted file-based storage if keychain unavailable
Dependencies
- @author-today-tools/api - API client
- keytar - System keychain integration
- conf - Configuration management
- date-fns - Date utilities
License
MIT © Artyom Zakharov
