feat: implement augmentation type system and release automation

This commit is contained in:
David Snelling 2025-05-27 13:12:53 -07:00
parent d2ddbd2613
commit 022680a2f5
8 changed files with 287 additions and 8 deletions

37
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,37 @@
name: Release
on:
push:
branches:
- main
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Test
run: npm test
- name: Semantic Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release

16
.releaserc.json Normal file
View file

@ -0,0 +1,16 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github",
[
"@semantic-release/git",
{
"assets": ["package.json"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}

79
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,79 @@
# Contributing to Soulcraft Brainy
Thank you for your interest in contributing to Soulcraft Brainy! This document provides guidelines and instructions for contributing to the project.
## Commit Message Guidelines
This project uses [Conventional Commits](https://www.conventionalcommits.org/) for automatic semantic versioning. Your commit messages determine how the version number is incremented.
### Commit Message Format
Each commit message consists of a **header**, a **body**, and a **footer**:
```
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
```
The **header** is mandatory and must conform to the following format:
- **type**: What kind of change is this commit making? (required)
- **scope**: What part of the codebase does this change affect? (optional)
- **description**: A short description of the change (required)
### Types
- **feat**: A new feature (triggers a minor version bump)
- **fix**: A bug fix (triggers a patch version bump)
- **docs**: Documentation only changes
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, etc.)
- **refactor**: A code change that neither fixes a bug nor adds a feature
- **perf**: A code change that improves performance
- **test**: Adding missing tests or correcting existing tests
- **chore**: Changes to the build process or auxiliary tools and libraries
### Breaking Changes
Breaking changes should be indicated by:
1. Adding an exclamation mark after the type/scope: `feat!: remove deprecated API`
2. Adding a `BREAKING CHANGE:` footer:
```
feat: change API parameter order
BREAKING CHANGE: The order of parameters in the API has changed.
```
Both methods will trigger a major version bump.
### Examples
```
feat: add vector normalization option
fix: correct distance calculation in HNSW search
docs: update API documentation
feat(storage): add support for IndexedDB
fix!: change API parameter order
refactor: simplify vector comparison logic
test: add tests for metadata filtering
chore: update build dependencies
```
## Pull Request Process
1. Ensure your code follows the project's coding standards
2. Update the documentation if necessary
3. Make sure all tests pass
4. Use conventional commit messages in your PR
5. Your PR will be reviewed by maintainers and merged if approved
## Development Setup
1. Fork and clone the repository
2. Install dependencies: `npm install`
3. Build the project: `npm run build`
4. Run tests: `npm test`
Thank you for contributing to Soulcraft Brainy!

View file

@ -119,17 +119,62 @@ const db = new BrainyData({
Soulcraft Brainy is configured as a private NPM package with restricted access. This section provides information on how to publish and use it within your organization.
### Versioning
This project uses semantic versioning (SemVer) with automatic version determination based on conventional commit messages. The version is automatically bumped when code is merged to the main branch, according to the following rules:
- **Major version** (`x.0.0`): Breaking changes, indicated by commits with `BREAKING CHANGE:` in the body or commits of type `feat` with `!` (e.g., `feat!: remove deprecated API`)
- **Minor version** (`0.x.0`): New features that don't break existing functionality, indicated by commits of type `feat`
- **Patch version** (`0.0.x`): Bug fixes and other minor changes, indicated by commits of type `fix`
#### Commit Message Format
To ensure proper versioning, commit messages should follow the [Conventional Commits](https://www.conventionalcommits.org/) specification:
```
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
```
Common types include:
- `feat`: A new feature (minor version bump)
- `fix`: A bug fix (patch version bump)
- `docs`: Documentation changes
- `style`: Changes that don't affect code functionality (formatting, etc.)
- `refactor`: Code changes that neither fix bugs nor add features
- `perf`: Performance improvements
- `test`: Adding or correcting tests
- `chore`: Changes to the build process or auxiliary tools
Examples:
```
feat: add new vector normalization option
fix: correct distance calculation in HNSW search
docs: update API documentation
feat(storage): add support for IndexedDB
fix!: change API parameter order (this will cause a major version bump)
```
### Publishing the Package
To publish updates to the package:
The package is automatically published when changes are merged to the main branch. The GitHub Actions workflow will:
1. Determine the appropriate version bump based on commit messages
2. Update the version in package.json
3. Create a new GitHub release with release notes
4. Publish the package to npm
For manual publishing (if needed):
1. Ensure you have the appropriate npm credentials and access to the @soulcraft organization
2. Update the version in package.json
3. Build the package:
2. Build the package:
```bash
npm run build
```
4. Publish the package:
3. Publish the package:
```bash
npm publish
```
@ -341,6 +386,25 @@ interface IActivationAugmentation extends IAugmentation {
}
```
### Augmentation Types
Brainy provides an enum that lists all types of augmentations available in the system:
```typescript
enum AugmentationType {
SENSE = 'sense',
CONDUIT = 'conduit',
COGNITION = 'cognition',
MEMORY = 'memory',
PERCEPTION = 'perception',
DIALOG = 'dialog',
ACTIVATION = 'activation',
WEBSOCKET = 'webSocket'
}
```
This enum can be used by consumers of the library to identify the different types of augmentations.
### Augmentation Event Pipeline
Brainy provides an event pipeline that allows registering and executing multiple augmentations of each type. The pipeline supports different execution modes and provides a flexible way to manage augmentations.
@ -348,7 +412,7 @@ Brainy provides an event pipeline that allows registering and executing multiple
#### Using the Pipeline
```typescript
import { augmentationPipeline, ExecutionMode } from '@soulcraft/brainy';
import { augmentationPipeline, ExecutionMode, AugmentationType } from '@soulcraft/brainy';
// Register augmentations
augmentationPipeline.register(mySenseAugmentation);
@ -358,6 +422,18 @@ augmentationPipeline.register(myCognitionAugmentation);
// Initialize all registered augmentations
await augmentationPipeline.initialize();
// Get all registered augmentations
const allAugmentations = augmentationPipeline.getAllAugmentations();
console.log(`Total augmentations: ${allAugmentations.length}`);
// Get all augmentations of a specific type
const senseAugmentations = augmentationPipeline.getAugmentationsByType(AugmentationType.SENSE);
console.log(`Sense augmentations: ${senseAugmentations.length}`);
// Get all available augmentation types
const availableTypes = augmentationPipeline.getAvailableAugmentationTypes();
console.log(`Available augmentation types: ${availableTypes.join(', ')}`);
// Execute a sense pipeline
const processingResults = await augmentationPipeline.executeSensePipeline(
'processRawData',

View file

@ -35,6 +35,11 @@
"access": "restricted"
},
"devDependencies": {
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.7",
"@semantic-release/npm": "^9.0.2",
"@semantic-release/release-notes-generator": "^10.0.3",
"@types/jest": "^29.5.3",
"@types/node": "^20.4.5",
"@types/uuid": "^10.0.0",
@ -42,6 +47,7 @@
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.45.0",
"jest": "^29.6.2",
"semantic-release": "^20.1.3",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
},

View file

@ -10,7 +10,8 @@ import {
BrainyAugmentations,
IAugmentation,
IWebSocketSupport,
AugmentationResponse
AugmentationResponse,
AugmentationType
} from './types/augmentations.js'
/**
@ -399,7 +400,7 @@ export class AugmentationPipeline {
*
* @returns An array of all registered augmentations
*/
private getAllAugmentations(): IAugmentation[] {
public getAllAugmentations(): IAugmentation[] {
// Create a Set to avoid duplicates (an augmentation might be in multiple registries)
const allAugmentations = new Set<IAugmentation>([
...this.registry.sense,
@ -416,6 +417,55 @@ export class AugmentationPipeline {
return Array.from(allAugmentations)
}
/**
* Get all augmentations of a specific type
*
* @param type The type of augmentation to get
* @returns An array of all augmentations of the specified type
*/
public getAugmentationsByType(type: AugmentationType): IAugmentation[] {
switch (type) {
case AugmentationType.SENSE:
return [...this.registry.sense]
case AugmentationType.CONDUIT:
return [...this.registry.conduit]
case AugmentationType.COGNITION:
return [...this.registry.cognition]
case AugmentationType.MEMORY:
return [...this.registry.memory]
case AugmentationType.PERCEPTION:
return [...this.registry.perception]
case AugmentationType.DIALOG:
return [...this.registry.dialog]
case AugmentationType.ACTIVATION:
return [...this.registry.activation]
case AugmentationType.WEBSOCKET:
return [...this.registry.webSocket]
default:
return []
}
}
/**
* Get all available augmentation types
*
* @returns An array of all augmentation types that have at least one registered augmentation
*/
public getAvailableAugmentationTypes(): AugmentationType[] {
const availableTypes: AugmentationType[] = []
if (this.registry.sense.length > 0) availableTypes.push(AugmentationType.SENSE)
if (this.registry.conduit.length > 0) availableTypes.push(AugmentationType.CONDUIT)
if (this.registry.cognition.length > 0) availableTypes.push(AugmentationType.COGNITION)
if (this.registry.memory.length > 0) availableTypes.push(AugmentationType.MEMORY)
if (this.registry.perception.length > 0) availableTypes.push(AugmentationType.PERCEPTION)
if (this.registry.dialog.length > 0) availableTypes.push(AugmentationType.DIALOG)
if (this.registry.activation.length > 0) availableTypes.push(AugmentationType.ACTIVATION)
if (this.registry.webSocket.length > 0) availableTypes.push(AugmentationType.WEBSOCKET)
return availableTypes
}
/**
* Get all WebSocket-supporting augmentations
*

View file

@ -80,12 +80,13 @@ import type {
AugmentationResponse,
IWebSocketSupport
} from './types/augmentations.js'
import { AugmentationType, BrainyAugmentations } from './types/augmentations.js'
export type {
IAugmentation,
AugmentationResponse,
IWebSocketSupport
}
export { BrainyAugmentations } from './types/augmentations.js'
export { AugmentationType, BrainyAugmentations }
// Export combined WebSocket augmentation interfaces
export type {

View file

@ -1,4 +1,18 @@
/** Common types for augmentation system */
/**
* Enum representing all types of augmentations available in the Brainy system.
*/
export enum AugmentationType {
SENSE = 'sense',
CONDUIT = 'conduit',
COGNITION = 'cognition',
MEMORY = 'memory',
PERCEPTION = 'perception',
DIALOG = 'dialog',
ACTIVATION = 'activation',
WEBSOCKET = 'webSocket'
}
type WebSocketConnection = {
connectionId: string
url: string