feat(core): Add debounced tasks and step-based progress tracking; upgrade deps and improve dashboard and scheduling
This commit is contained in:
Binary file not shown.
@@ -1,35 +0,0 @@
|
||||
# Code Style and Conventions for TaskBuffer
|
||||
|
||||
## File Structure
|
||||
- Source code in `ts/` directory
|
||||
- Tests in `test/` directory
|
||||
- Compiled output in `dist_ts/`
|
||||
- All filenames must be lowercase
|
||||
|
||||
## Naming Conventions
|
||||
- **Interfaces**: Prefix with `I` (e.g., `ITaskFunction`)
|
||||
- **Types**: Prefix with `T` (e.g., `TPreOrAfterTaskFunction`)
|
||||
- **Classes**: PascalCase (e.g., `TaskManager`)
|
||||
- **Files**: `taskbuffer.classes.{classname}.ts` pattern
|
||||
- **Test files**: `test.{number}.{feature}.ts` pattern
|
||||
|
||||
## TypeScript Conventions
|
||||
- Use ES modules (import/export)
|
||||
- Avoid ENums when possible
|
||||
- Import dependencies through `plugins.ts`
|
||||
- Reference with full path: `plugins.myModule.myClass()`
|
||||
- Use async/await patterns consistently
|
||||
- Strong typing throughout
|
||||
|
||||
## Testing Conventions
|
||||
- Import expect from `@git.zone/tstest/tapbundle`
|
||||
- Test files end with `export default tap.start()`
|
||||
- Use descriptive test names with tap.test()
|
||||
- Test both browser and node when applicable
|
||||
|
||||
## Code Quality
|
||||
- Make focused, goal-oriented changes
|
||||
- Preserve necessary complexity
|
||||
- Keep code elegant and maintainable
|
||||
- No inline documentation unless requested
|
||||
- Complete implementations only (no partial work)
|
||||
@@ -1,27 +0,0 @@
|
||||
# TaskBuffer Project Overview
|
||||
|
||||
## Purpose
|
||||
@push.rocks/taskbuffer is a powerful TypeScript-first task management library for orchestrating asynchronous operations. It provides flexible task execution patterns including buffered execution, task chains, parallel execution, scheduling, debouncing, and one-time execution.
|
||||
|
||||
## Tech Stack
|
||||
- **Language**: TypeScript (ES modules)
|
||||
- **Runtime**: Node.js
|
||||
- **Build Tool**: tsbuild, tsbundle
|
||||
- **Test Framework**: @git.zone/tstest (tapbundle)
|
||||
- **Package Manager**: pnpm
|
||||
- **Module System**: ES modules (type: "module")
|
||||
|
||||
## Key Features
|
||||
- Task: Basic unit of work with async function wrapping
|
||||
- Taskchain: Sequential task execution with result passing
|
||||
- Taskparallel: Parallel task execution
|
||||
- TaskManager: Cron-based task scheduling
|
||||
- TaskDebounced: Debounced execution pattern
|
||||
- TaskOnce: Singleton execution pattern
|
||||
- TaskRunner: Distributed task execution
|
||||
- BufferRunner: Smart concurrent execution control
|
||||
|
||||
## Main Entry Points
|
||||
- Main export: `ts/index.ts`
|
||||
- Compiled output: `dist_ts/index.js`
|
||||
- All classes exported from index for clean API
|
||||
@@ -1,67 +0,0 @@
|
||||
# Suggested Commands for TaskBuffer Development
|
||||
|
||||
## Build and Test Commands
|
||||
```bash
|
||||
# Build the project
|
||||
pnpm run build
|
||||
|
||||
# Run tests
|
||||
pnpm test
|
||||
|
||||
# Type checking
|
||||
tsbuild check test/**/* --skiplibcheck
|
||||
|
||||
# Build documentation
|
||||
pnpm run buildDocs
|
||||
```
|
||||
|
||||
## Development Workflow
|
||||
```bash
|
||||
# Install dependencies
|
||||
pnpm install
|
||||
|
||||
# Add development dependency
|
||||
pnpm install --save-dev <package>
|
||||
|
||||
# Add production dependency
|
||||
pnpm add <package>
|
||||
|
||||
# Run specific test
|
||||
tstest test/test.some.ts --verbose
|
||||
|
||||
# Run tests with logging
|
||||
tstest test/test.some.ts --logfile
|
||||
```
|
||||
|
||||
## Git Commands
|
||||
```bash
|
||||
# View status
|
||||
git status
|
||||
|
||||
# Stage changes
|
||||
git add .
|
||||
|
||||
# Commit with message
|
||||
git commit -m "message"
|
||||
|
||||
# Use git mv for file operations to preserve history
|
||||
git mv oldfile newfile
|
||||
```
|
||||
|
||||
## System Commands (Linux)
|
||||
```bash
|
||||
# List files
|
||||
ls -la
|
||||
|
||||
# Find files
|
||||
find . -name "*.ts"
|
||||
|
||||
# Search in files
|
||||
rg "pattern" # Use ripgrep instead of grep
|
||||
|
||||
# View file
|
||||
cat filename
|
||||
|
||||
# Create directory
|
||||
mkdir -p path/to/dir
|
||||
```
|
||||
@@ -1,37 +0,0 @@
|
||||
# Task Completion Checklist for TaskBuffer
|
||||
|
||||
## Before Marking Any Task Complete
|
||||
|
||||
### 1. Code Quality Checks
|
||||
- [ ] Run build to ensure TypeScript compiles: `pnpm run build`
|
||||
- [ ] Run tests to ensure nothing breaks: `pnpm test`
|
||||
- [ ] Type check test files: `tsbuild check test/**/* --skiplibcheck`
|
||||
|
||||
### 2. Code Review
|
||||
- [ ] All changes are focused and purposeful
|
||||
- [ ] No unnecessary modifications made
|
||||
- [ ] Code follows project naming conventions
|
||||
- [ ] Imports use the plugins.ts pattern where applicable
|
||||
- [ ] All async operations use proper async/await
|
||||
|
||||
### 3. Testing
|
||||
- [ ] New features have corresponding tests
|
||||
- [ ] Existing tests still pass
|
||||
- [ ] Test files end with `export default tap.start()`
|
||||
- [ ] Tests use proper expect from tapbundle
|
||||
|
||||
### 4. Documentation
|
||||
- [ ] readme.md updated if new features added
|
||||
- [ ] Code is self-explanatory (no comments unless requested)
|
||||
- [ ] API changes documented
|
||||
|
||||
### 5. Git Hygiene
|
||||
- [ ] Changes are staged appropriately
|
||||
- [ ] Commit message is clear and focused
|
||||
- [ ] NO commits made without explicit user approval
|
||||
|
||||
## Common Issues to Check
|
||||
- No uppercase filenames
|
||||
- No direct npm usage (use pnpm)
|
||||
- No guessing APIs (always check documentation)
|
||||
- No partial implementations
|
||||
@@ -1,68 +0,0 @@
|
||||
# language of the project (csharp, python, rust, java, typescript, go, cpp, or ruby)
|
||||
# * For C, use cpp
|
||||
# * For JavaScript, use typescript
|
||||
# Special requirements:
|
||||
# * csharp: Requires the presence of a .sln file in the project folder.
|
||||
language: typescript
|
||||
|
||||
# whether to use the project's gitignore file to ignore files
|
||||
# Added on 2025-04-07
|
||||
ignore_all_files_in_gitignore: true
|
||||
# list of additional paths to ignore
|
||||
# same syntax as gitignore, so you can use * and **
|
||||
# Was previously called `ignored_dirs`, please update your config if you are using that.
|
||||
# Added (renamed) on 2025-04-07
|
||||
ignored_paths: []
|
||||
|
||||
# whether the project is in read-only mode
|
||||
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
|
||||
# Added on 2025-04-18
|
||||
read_only: false
|
||||
|
||||
|
||||
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
|
||||
# Below is the complete list of tools for convenience.
|
||||
# To make sure you have the latest list of tools, and to view their descriptions,
|
||||
# execute `uv run scripts/print_tool_overview.py`.
|
||||
#
|
||||
# * `activate_project`: Activates a project by name.
|
||||
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
|
||||
# * `create_text_file`: Creates/overwrites a file in the project directory.
|
||||
# * `delete_lines`: Deletes a range of lines within a file.
|
||||
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
|
||||
# * `execute_shell_command`: Executes a shell command.
|
||||
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
|
||||
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
|
||||
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
|
||||
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
|
||||
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
|
||||
# * `initial_instructions`: Gets the initial instructions for the current project.
|
||||
# Should only be used in settings where the system prompt cannot be set,
|
||||
# e.g. in clients you have no control over, like Claude Desktop.
|
||||
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
|
||||
# * `insert_at_line`: Inserts content at a given line in a file.
|
||||
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
|
||||
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
|
||||
# * `list_memories`: Lists memories in Serena's project-specific memory store.
|
||||
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
|
||||
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
|
||||
# * `read_file`: Reads a file within the project directory.
|
||||
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
|
||||
# * `remove_project`: Removes a project from the Serena configuration.
|
||||
# * `replace_lines`: Replaces a range of lines within a file with new content.
|
||||
# * `replace_symbol_body`: Replaces the full definition of a symbol.
|
||||
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
|
||||
# * `search_for_pattern`: Performs a search for a pattern in the project.
|
||||
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
|
||||
# * `switch_modes`: Activates modes by providing a list of their names
|
||||
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
|
||||
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
|
||||
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
|
||||
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
|
||||
excluded_tools: []
|
||||
|
||||
# initial prompt for the project. It will always be given to the LLM upon activating the project
|
||||
# (contrary to the memories, which are loaded on demand).
|
||||
initial_prompt: ""
|
||||
|
||||
project_name: "taskbuffer"
|
||||
13
changelog.md
13
changelog.md
@@ -1,5 +1,18 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-12-04 - 3.5.0 - feat(core)
|
||||
Add debounced tasks and step-based progress tracking; upgrade deps and improve dashboard and scheduling
|
||||
|
||||
- Add TaskDebounced class to coalesce rapid triggers into a single execution (debounce behavior).
|
||||
- Introduce step tracking and progress reporting on Task via TaskStep, getProgress(), getStepsMetadata(), getMetadata(), resetSteps(), and completeAllSteps().
|
||||
- Enhance buffered execution flow: BufferRunner and CycleCounter improvements to better coordinate buffered runs and cycle promises.
|
||||
- Standardize concurrent runner naming (Taskparallel) and update related exports/usages (ts/index.ts, readme examples).
|
||||
- Enhance TaskManager scheduling/metadata: getScheduledTasks now returns schedule and nextRun, addExecuteRemoveTask collects execution report metadata and cleans up after execution, distributed coordination hooks retained.
|
||||
- Add/upgrade web dashboard UI, demos and refresh logic to surface task metadata, scheduled tasks and progress.
|
||||
- Bump runtime and dev dependencies (multiple @push.rocks packages and @git.zone tooling).
|
||||
- Update tests: reduce iteration threshold and tighten schedule interval in test/test.4.taskmanager.ts.
|
||||
- Remove several .serena memory files (project overview, style guides and suggested commands) as cleanup.
|
||||
|
||||
## 2025-09-07 - 3.4.0 - feat(taskbuffer-dashboard)
|
||||
Add TaskBuffer dashboard web component, demo and browser tests; add HTML entry and update dependencies
|
||||
|
||||
|
||||
24
package.json
24
package.json
@@ -34,21 +34,21 @@
|
||||
},
|
||||
"homepage": "https://code.foss.global/push.rocks/taskbuffer#readme",
|
||||
"dependencies": {
|
||||
"@design.estate/dees-element": "^2.1.2",
|
||||
"@push.rocks/lik": "^6.0.5",
|
||||
"@design.estate/dees-element": "^2.1.3",
|
||||
"@push.rocks/lik": "^6.2.2",
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartlog": "^3.1.9",
|
||||
"@push.rocks/smartpromise": "^4.0.3",
|
||||
"@push.rocks/smartrx": "^3.0.6",
|
||||
"@push.rocks/smarttime": "^4.0.6",
|
||||
"@push.rocks/smartunique": "^3.0.6"
|
||||
"@push.rocks/smartlog": "^3.1.10",
|
||||
"@push.rocks/smartpromise": "^4.2.3",
|
||||
"@push.rocks/smartrx": "^3.0.10",
|
||||
"@push.rocks/smarttime": "^4.1.1",
|
||||
"@push.rocks/smartunique": "^3.0.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.6.8",
|
||||
"@git.zone/tsbundle": "^2.0.8",
|
||||
"@git.zone/tsrun": "^1.2.44",
|
||||
"@git.zone/tstest": "^2.3.6",
|
||||
"@types/node": "^20.8.7"
|
||||
"@git.zone/tsbuild": "^3.1.2",
|
||||
"@git.zone/tsbundle": "^2.6.3",
|
||||
"@git.zone/tsrun": "^2.0.0",
|
||||
"@git.zone/tstest": "^3.1.3",
|
||||
"@types/node": "^24.10.1"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
|
||||
3263
pnpm-lock.yaml
generated
3263
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
33
readme.md
33
readme.md
@@ -162,9 +162,9 @@ console.log(`Saved ${savedCount} items`);
|
||||
Execute multiple tasks simultaneously:
|
||||
|
||||
```typescript
|
||||
import { TaskParallel } from '@push.rocks/taskbuffer';
|
||||
import { Taskparallel } from '@push.rocks/taskbuffer';
|
||||
|
||||
const parallel = new TaskParallel({
|
||||
const parallel = new Taskparallel({
|
||||
name: 'ParallelProcessor',
|
||||
tasks: [
|
||||
emailTask,
|
||||
@@ -179,6 +179,29 @@ const results = await parallel.trigger(notificationData);
|
||||
// results = [emailResult, smsResult, pushResult, webhookResult]
|
||||
```
|
||||
|
||||
### Debounced Tasks - Smart Trigger Coalescing
|
||||
|
||||
Coalesce rapid triggers into a single execution after a quiet period:
|
||||
|
||||
```typescript
|
||||
import { TaskDebounced } from '@push.rocks/taskbuffer';
|
||||
|
||||
const searchTask = new TaskDebounced({
|
||||
name: 'SearchQuery',
|
||||
debounceTimeInMillis: 300, // Wait 300ms after last trigger
|
||||
taskFunction: async (query) => {
|
||||
const results = await searchAPI(query);
|
||||
return results;
|
||||
}
|
||||
});
|
||||
|
||||
// Rapid typing - only the last query executes
|
||||
searchTask.trigger('h');
|
||||
searchTask.trigger('he');
|
||||
searchTask.trigger('hel');
|
||||
searchTask.trigger('hello'); // Only this one executes after 300ms pause
|
||||
```
|
||||
|
||||
### TaskManager - Centralized Orchestration
|
||||
|
||||
Manage all your tasks from a single point:
|
||||
@@ -559,9 +582,11 @@ logger.level = 'debug';
|
||||
- **`Task<T, TSteps>`** - Basic task unit with optional step tracking
|
||||
- **`TaskManager`** - Central orchestrator for task management
|
||||
- **`Taskchain`** - Sequential task executor
|
||||
- **`TaskParallel`** - Concurrent task executor
|
||||
- **`Taskparallel`** - Concurrent task executor
|
||||
- **`TaskOnce`** - Single-execution task
|
||||
- **`TaskLoop`** - Repeating task with conditions
|
||||
- **`TaskDebounced`** - Debounced task that waits for a pause in triggers
|
||||
- **`TaskRunner`** - Sequential task runner with scheduling support
|
||||
- **`distributedCoordination`** - Namespace for distributed task coordination
|
||||
|
||||
### Key Methods
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ tap.test('should run the task as expected', async () => {
|
||||
console.log('Task "myTask" executed!');
|
||||
referenceBoolean = true;
|
||||
taskRunCounter++;
|
||||
if (taskRunCounter === 10) {
|
||||
if (taskRunCounter === 3) {
|
||||
taskDone.resolve();
|
||||
}
|
||||
},
|
||||
@@ -38,7 +38,7 @@ tap.test('should run the task as expected', async () => {
|
||||
});
|
||||
|
||||
tap.test('should schedule task', async () => {
|
||||
myTaskManager.scheduleTaskByName('myTask', '*/10 * * * * *');
|
||||
myTaskManager.scheduleTaskByName('myTask', '*/5 * * * * *');
|
||||
await taskDone.promise;
|
||||
myTaskManager.descheduleTaskByName('myTask');
|
||||
});
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/taskbuffer',
|
||||
version: '3.4.0',
|
||||
version: '3.5.0',
|
||||
description: 'A flexible task management library supporting TypeScript, allowing for task buffering, scheduling, and execution with dependency management.'
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/taskbuffer',
|
||||
version: '3.4.0',
|
||||
version: '3.5.0',
|
||||
description: 'A flexible task management library supporting TypeScript, allowing for task buffering, scheduling, and execution with dependency management.'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user