
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@astrotask/core
Advanced tools
A local-first, MCP-compatible task-navigation platform for humans + AI agents
The core library for Astrolabe, a local-first, MCP-compatible task-navigation platform for humans and AI agents.
@astrotask/core
provides the foundational components for building task management applications with offline-first capabilities. It includes database abstractions, task services, type-safe schemas, and utilities for logging and configuration.
pnpm add @astrotask/core
# Or with npm
npm install @astrotask/core
# Or with yarn
yarn add @astrotask/core
import { createDatabase, TaskService } from '@astrotask/core';
// Initialize database
const store = createDatabase({
path: './tasks.db',
encrypted: true
});
// Create task service
const taskService = new TaskService(store);
// Create a new task
const task = await taskService.createTask({
title: 'Fix login bug',
description: 'Users cannot login with special characters in password',
status: 'pending',
parentId: 'A' // Optional: make this a subtask
});
// List all tasks
const tasks = await taskService.listTasks();
// Get task with full context
const context = await taskService.getTaskContext('A', {
includeAncestors: true,
includeDescendants: true,
maxDepth: 3
});
console.log(context.task); // The main task
console.log(context.ancestors); // Parent tasks up the hierarchy
console.log(context.descendants); // Child tasks down the hierarchy
Tasks are the fundamental unit of work in Astrolabe. They support:
pending
, in-progress
, done
, cancelled
import type { Task, CreateTask, TaskStatus } from '@astrotask/core';
const newTask: CreateTask = {
title: 'Setup CI/CD pipeline',
description: 'Configure GitHub Actions for automated testing and deployment',
status: 'pending'
};
Context slices provide AI agents with relevant information bundles:
import type { ContextSlice, CreateContextSlice } from '@astrotask/core';
const context: CreateContextSlice = {
taskId: 'task_123',
content: 'Relevant code snippets, documentation, and context',
metadata: { source: 'codebase', lastUpdated: new Date() }
};
The primary service for task management operations.
createTask(data: CreateTask): Promise<Task>
Creates a new task with validation.
const task = await taskService.createTask({
title: 'Fix login bug',
description: 'Users cannot login with special characters in password',
status: 'pending',
parentId: 'A' // Optional: make this a subtask
});
updateTask(id: string, updates: Partial<Task>): Promise<Task>
Updates an existing task.
const updatedTask = await taskService.updateTask('A', {
status: 'done',
description: 'Updated description with solution details'
});
deleteTask(id: string, options?: { cascade?: boolean }): Promise<void>
Deletes a task, optionally including all subtasks.
// Delete just the task
await taskService.deleteTask('A');
// Delete task and all subtasks
await taskService.deleteTask('A', { cascade: true });
listTasks(filters?: ListTasksFilter): Promise<Task[]>
Lists tasks with optional filtering.
// Get all pending tasks
const pendingTasks = await taskService.listTasks({
status: 'pending'
});
// Get all subtasks of a parent
const subtasks = await taskService.listTasks({
parentId: 'A'
});
getTaskContext(id: string, options?: ContextOptions): Promise<TaskContext>
Retrieves a task with its full context including ancestors and descendants.
const context = await taskService.getTaskContext('A', {
includeAncestors: true,
includeDescendants: true,
maxDepth: 3
});
console.log(context.task); // The main task
console.log(context.ancestors); // Parent tasks up the hierarchy
console.log(context.descendants); // Child tasks down the hierarchy
createDatabase(options: DatabaseOptions): Store
Creates a new database store instance.
import { createDatabase } from '@astrotask/core';
// Basic SQLite database
const store = createDatabase({
path: './tasks.db'
});
// Encrypted database
const encryptedStore = createDatabase({
path: './tasks.db',
encrypted: true,
key: process.env.DB_ENCRYPTION_KEY
});
// In-memory database (for testing)
const memoryStore = createDatabase({
path: ':memory:'
});
All data types are validated using Zod schemas:
import {
taskSchema,
createTaskSchema,
updateTaskSchema,
contextSliceSchema
} from '@astrotask/core';
// Validate task data
const validTask = taskSchema.parse(taskData);
// Validate creation data
const validCreation = createTaskSchema.parse(newTaskData);
Structured logging with configurable levels:
import { createModuleLogger } from '@astrotask/core';
const logger = createModuleLogger('MyModule');
logger.info('Task created', { taskId: 'A' });
logger.error('Database error', { error: error.message });
logger.debug('Detailed debug info', { details: complexObject });
Astrotask Core uses environment variables for configuration. Create a .env
file in your project root:
# Database location (optional - will auto-detect if not set)
DATABASE_URI=./data/astrotask.db
# Enable debug logging
DB_VERBOSE=true
# Other configuration options...
LOG_LEVEL=debug
If DATABASE_URI
is not explicitly set, Astrotask will intelligently determine the database location:
{git_root}/data/astrotask.db
./data/astrotask.db
in the current directoryThis ensures that all parts of your project use the same database, regardless of which subdirectory you run commands from.
The library provides structured error handling:
import { DatabaseStore } from '@astrotask/core';
try {
const task = await taskService.createTask(newTaskData);
} catch (error) {
if (error instanceof ValidationError) {
console.log('Invalid task data:', error.issues);
} else if (error instanceof DatabaseError) {
console.log('Database operation failed:', error.message);
} else {
console.log('Unexpected error:', error);
}
}
The core library includes comprehensive test utilities:
import { createDatabase } from '@astrotask/core';
// Create test database
const testStore = createDatabase({ path: ':memory:' });
// Use in your tests
describe('Task operations', () => {
test('should create task', async () => {
const taskService = new TaskService(testStore);
const task = await taskService.createTask({
title: 'Test task',
status: 'pending'
});
expect(task.title).toBe('Test task');
expect(task.status).toBe('pending');
});
});
maxDepth
in context queries for better performancetodo
is now pending
contextDigest
fieldNewTask
type is deprecated, use CreateTask
insteadPrevious UUID format:
550e8400-e29b-41d4-a716-446655440000
New human-readable format:
ABCD
, XYZW
, QRST
)ABCD.1
, ABCD.2
, XYZW.1
ABCD.1.1
, ABCD.1.2
pnpm verify
to ensure qualityMIT License - see LICENSE for details.
@astrotask/mcp
- MCP server for AI agent integration@astrotask/cli
- Command-line interfaceFAQs
A local-first, MCP-compatible task-navigation platform for humans + AI agents
The npm package @astrotask/core receives a total of 10 weekly downloads. As such, @astrotask/core popularity was classified as not popular.
We found that @astrotask/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.