Skip to content

feat: Hermes Agent plugin v2 with full test coverage and zero TS errors#8

Merged
htafolla merged 12 commits into
masterfrom
feat/hermes-plugin-v2-tests
Mar 28, 2026
Merged

feat: Hermes Agent plugin v2 with full test coverage and zero TS errors#8
htafolla merged 12 commits into
masterfrom
feat/hermes-plugin-v2-tests

Conversation

@htafolla

Copy link
Copy Markdown
Owner

Summary

Upgrade the Hermes Agent native plugin to v2 with a bridge pipeline architecture, comprehensive tests, and fix all TypeScript errors across the codebase.

Changes

Plugin Features

  • Upgrade Hermes plugin to v2 with bridge pipeline architecture
  • Include hermes-agent plugin in npm package with auto-install via postinstall
  • List individual files in npm files array, exclude __pycache__

Test Fixes (48 tests unskipped, all passing)

  • Install missing test deps (express, ws, @modelcontextprotocol/sdk)
  • Fix version skew, duplicate imports, test logic failures
  • Unskip all 48 previously-skipped tests, fix underlying issues
  • Consolidate 15 identical agent-delegator tests into meaningful ones

Source Code Bug Fixes (7 bugs)

  • CircuitBreaker: Fix double-counting of successes/failures (counted in both executeWithTimeout and onSuccess/onFailure)
  • CircuitBreaker: Make onSuccess/onFailure/trip/reset async to properly await frameworkLogger.log()
  • processor-manager: Remove unreachable dead code after throw statement
  • kernel-patterns: Remove no-op inverted logic block
  • state-manager: Fix logging operationsProcessed before clearing queue (was always 0)
  • orchestrator: Fix getStatus() totalProcessed to use proper counter
  • strray-activation: Fix activateCodexInjection to actually push hook to globalThis

TypeScript Error Fixes (152 -> 0)

  • Fix wrong import paths across 15+ files (framework-logger, context-loader, job-correlation-manager, etc.)
  • Fix missing properties on test objects (AgentConfig, PostProcessorData)
  • Fix implicit any types in test callbacks and parameters
  • Fix LogStatus type mismatches (warn -> warning) in registry.ts
  • Fix await in non-async contexts (iac-validator, orchestration-flow-validator)
  • Fix constructor argument counts in test files
  • Add proper ws module declaration (vendor.d.ts)
  • Fix DOM WebSocket type collision
  • Add stub modules for missing imports

Test Results

  • 161 test files, 2359 tests, ALL PASSING
  • 0 TypeScript errors on full project compilation
  • TypeScript compilation: Clean (zero errors)

Files Changed

~47 files modified, 319 insertions, 117 deletions

htafolla added 12 commits March 27, 2026 18:13
…ive tests

Major changes:
- Add Node.js bridge (bridge.mjs) for real framework integration via JSON IPC
- Quality gate + pre/post processor pipeline on code-producing tools
- File logging to activity.log and plugin-tool-events.log
- Session stats tracking (quality gate runs, blocks, bridge calls/errors)
- Smart terminal nudges based on command patterns (grep, eslint, audit, etc.)
- Slash command /strray with status, stats, help subcommands
- Bridge-first tool execution with CLI fallback
- Project root detection (env var, node_modules/strray-ai, .opencode/strray)

Test coverage: 103 tests, 99% on tools.py, 100% on schemas.py
  - Bridge error paths (JSON decode, OS errors, timeouts, generic exceptions)
  - Pre/post hook bridge error resilience
  - All 5 code tools verified to trigger bridge
  - Partial processor failure handling
  - Edge cases (None args, non-dict results, empty paths, missing keys)
  - Slash command edge cases (unknown command, case insensitivity)
  - Log timestamp format verification
  - Live bridge integration tests (health, stats, quality gate, violations)

Files:
  __init__.py: 500 lines (hooks, bridge, slash cmd, file logging, session mgmt)
  bridge.mjs:  553 lines (Node.js IPC to StringRay framework components)
  tools.py:    207 lines (strray_validate, strray_codex_check, strray_health)
  test_plugin.py: 944 lines (103 tests, 23 test classes)
  schemas.py:   71 lines (tool parameter schemas)
  conftest.py:  14 lines (pytest config)
  after-install.md: 35 lines (post-install setup instructions)
  plugin.yaml:  11 lines (plugin manifest)
…postinstall

Two fixes for the Hermes plugin distribution pipeline:

1. Add src/integrations/hermes-agent/ to package.json files array
   - Previously the plugin source was not included in the npm tarball
   - The skill (src/skills/) was included but the plugin (src/integrations/) was not

2. Add plugin installation to postinstall.cjs
   - Detects ~/.hermes/ directory (Hermes Agent presence check)
   - Copies all 7 plugin files to ~/.hermes/plugins/strray-hermes/
   - Uses mtime comparison to skip if already up to date
   - Copies: __init__.py, tools.py, schemas.py, plugin.yaml, bridge.mjs, conftest.py, after-install.md
   - Graceful error handling — never blocks npm install

Flow after fix:
  npm install strray-ai
    -> postinstall detects ~/.hermes/
    -> copies skill to ~/.hermes/skills/hermes-agent/SKILL.md
    -> copies plugin to ~/.hermes/plugins/strray-hermes/ (7 files)
    -> Hermes restart picks up the plugin automatically
- Change files array from directory glob to explicit file list
  This prevents __pycache__ and .pytest_cache from being packaged
- Add test_plugin.py to both files array and postinstall copy list
- Add .npmignore as defense-in-depth for any future src/ additions

npm pack --dry-run verification:
  - 8 hermes-agent files included
  - 0 __pycache__ files
  - Total tarball size clean
- Sync all version refs from 1.15.1 -> 1.15.6 (1 ahead of npm 1.15.5)
- Fix duplicate imports in model-router.test.ts and test-auto-creation-processor.test.ts
- Fix AGENTS.md currency test: 31 days could round to 30, use 40 days
- Add system prompt to DEFAULT_AGENT_CONFIG in agent-resolver.ts

Test results: 151 passed / 9 failed (down from 145 passed / 15 failed)
Remaining 9 failures are pre-existing missing npm deps (express, ws, @modelcontextprotocol/sdk)
- Add express, ws, @modelcontextprotocol/sdk as devDependencies
- Resolves all 9 remaining test failures

Test results: 160 passed / 0 failed (2311 tests)
- Install missing deps: express, ws, @modelcontextprotocol/sdk
- Fix agent-delegator.test.ts: rewrite 20 tests to match current API
- Fix orchestrator.test.ts: add missing mocks, fix assertion shapes
- Fix consent-manager.test.ts: unique temp dirs per test for isolation
- Fix consent-manager.ts: handle absolute paths correctly
- Fix processor-activation.test.ts: explicit mock return for codexCompliance
- Fix state-manager-persistence.test.ts: mock fs.statSync
- Fix SuccessHandler.test.ts: clear console spy between tests
- Fix performance-system-orchestrator.ts: set monitoringActive before async ops
- Fix framework-enforcement-integration.test.ts: import path, assertions
- Fix architect.test.ts: unskip integration points describe
- Fix codex-enforcement-e2e.test.ts: rule ID mismatches, assertion counts
- Fix e2e-orchestration-flow.test.ts: rewrite to match BootOrchestrator API
- Fix rule-enforcer.ts: resolve-all-errors -> error-resolution, loop-safety IDs

Test results: 161 passed / 0 failed / 0 skipped (2359 tests)
- CircuitBreaker: fix double-counting of successes/failures (counted in both
  executeWithTimeout and onSuccess/onFailure)
- CircuitBreaker: make onSuccess/onFailure/trip/reset async to properly await
  frameworkLogger.log() calls (was using await in non-async context)
- CircuitBreaker: clean up mangled log event names
- processor-manager: remove unreachable dead code after throw statement
- kernel-patterns: remove no-op inverted logic block that did nothing
- state-manager: fix logging operationsProcessed before clearing queue (was
  always 0)
- orchestrator: fix getStatus() totalProcessed to use proper counter instead
  of queue+active (which returned pending count, not processed count)
- strray-activation: fix activateCodexInjection to actually push hook to
  globalThis.strRayHooks (was created and discarded)

All 161 test files / 2359 tests passing.
- Fix wrong import paths (framework-logger.js, context-loader.js, job-correlation-manager.js, orchestrator.js, PostProcessor.js)
- Fix missing properties on AgentConfig objects in tests (capabilities, maxComplexity, enabled)
- Fix missing 'operation' property on PostProcessorData objects
- Fix implicit 'any' types in test callbacks and parameters
- Fix LogStatus type mismatches ('warn' -> 'warning') in registry.ts
- Fix Record<LogLevel> index type in Integration.ts
- Fix await in non-async contexts (iac-validator.ts, orchestration-flow-validator.ts)
- Fix constructor argument counts in test files (MCPClientManager, MonitoringEngine, ProcessorManager)
- Fix inputSchema missing required 'type' property in tool-cache tests
- Fix mock type casting in tool-discovery and tool-executor tests
- Fix ws module declaration (vendor.d.ts) - proper WebSocket class with static constants
- Fix WebSocket imports to avoid DOM type collision (use named import from 'ws' module)
- Add null-safe assertions (!) for WebSocket operations after construction
- Add stub modules for missing imports (predictive-analytics, live-metrics-collector, marketplace-service, ml/core/types)
- Export missing interfaces from integration.ts (TaskContext, AgentConfig, IntegrationResult)
- Fix processor-activation.test.ts wrong ProcessorResult import
- Fix rule-enforcer.test.ts mock path
- Clean up unused vendor.d.ts test file

Result: 0 TypeScript errors on full project compilation (was 152)
All 161 test files / 2359 tests still passing.
- Added eslint-plugin-vitest dependency for processor test linting
- Converted processor-mock-validator.ts to processor-mock-validator.js
  to avoid ts-node ESM issues in CI
- Updated CI workflow to use node instead of npx ts-node
- Renamed processor-mock-validator.js to .cjs (ES module compatibility)
- Removed vitest plugin from processor-test-rules.js to fix circular JSON error
  (vitest/globals and plugin:vitest/recommended caused issues)
@htafolla htafolla merged commit 562e7d4 into master Mar 28, 2026
14 checks passed
@htafolla htafolla deleted the feat/hermes-plugin-v2-tests branch March 31, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant