Critical bug fixes and code quality improvements from brutal-honest-review. ## Critical Fixes (9/10 completed, 1 deferred) 1. Fixed Agent Pattern Isolation (CRITICAL) - Added SwarmMemoryManager.queryPatternsByAgent() - SQL filtering by agent_id in metadata - Each agent now isolated 2. Fixed Async Method Cascade - Changed getPatterns() to async - Fixed 10 callers across 6 files - Build passes 3. Fixed Misleading Logging - Added isRealAgentDB() detection - Honest mock vs real reporting 4. Consolidated Embedding Generation - Created EmbeddingGenerator utility - Removed 50+ duplicate lines 5. Added AgentDB Initialization Checks - Empty DB detection - HNSW index verification 6. Integration Test Suite - 26 new test cases - Error path coverage 7. Repository Cleanup - Removed 19 temp test files 8. New QE Skill: sherlock-review - Evidence-based investigative review - 38 QE skills total 9. Deferred: Wire Up Real Test Execution - Deferred to v1.9.0 (documented) ## Statistics - Fixes: 9/10 (90%, 1 deferred) - Files Modified: 16 - Files Created: 3 - Files Deleted: 19 - Integration Tests: 26 - Build: PASSING ## Breaking Changes - getPatterns() now async - add await 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
6.7 KiB
Version Display Fix - Release 1.2.0
Date: 2025-10-21 Priority: P1-MEDIUM (BLOCKER #7) Status: ✅ RESOLVED
Problem Statement
Before
- CLI Version Display:
1.1.0(hardcoded) - package.json Version:
1.2.0(correct) - package-lock.json Version:
1.2.0(correct) - Mismatch: CLI showed old version despite package.json being updated
Root Cause
Hardcoded version string in /workspaces/agentic-qe-cf/src/cli/index.ts:
program
.name('agentic-qe')
.description('Agentic Quality Engineering Fleet - Autonomous testing and quality assurance')
.version('1.1.0'); // ❌ HARDCODED - not reading from package.json
Solution
Implementation
File: /workspaces/agentic-qe-cf/src/cli/index.ts
Change #1: Add package.json import
// Line 34 - Added import
import packageJson from '../../package.json';
Change #2: Use dynamic version
// Line 45 - Changed from hardcoded to dynamic
program
.name('agentic-qe')
.description('Agentic Quality Engineering Fleet - Autonomous testing and quality assurance')
.version(packageJson.version); // ✅ DYNAMIC - reads from package.json
Why This Works
-
resolveJsonModule: truealready intsconfig.json(Line 18)- Allows importing JSON files as modules
- TypeScript treats
package.jsonas a typed module
-
ES Module Import
import packageJson from '../../package.json'- TypeScript resolves path correctly relative to CLI entry point
-
Type Safety
- TypeScript infers
packageJson.versionasstring - No type casting needed with
resolveJsonModule
- TypeScript infers
Verification
Build Test ✅
npm run build
# Output:
# > agentic-qe@1.2.0 build
# > tsc
# (successful compilation - no errors)
Version Display Test ✅
node dist/cli/index.js --version
# Output: 1.2.0
# ✅ CORRECT - shows version from package.json
Alternative Test Methods
# Via npm script
npm start -- --version
# Output: 1.2.0
# Via binary (after npm link)
aqe --version
# Output: 1.2.0
# Via npx
npx aqe --version
# Output: 1.2.0
Alternative Approaches Considered
Option 1: require() instead of import ❌
const pkg = require('../../package.json');
program.version(pkg.version);
Rejected: Mixing CommonJS and ESM is not ideal; import is more modern
Option 2: fs.readFileSync() ❌
import fs from 'fs';
import path from 'path';
const pkgPath = path.join(__dirname, '../../package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
program.version(pkg.version);
Rejected: Overly complex; resolveJsonModule is simpler and type-safe
Option 3: Environment variable ❌
program.version(process.env.npm_package_version);
Rejected: Not reliable in all execution contexts; requires npm to set env vars
Option 4: Chosen - Direct JSON import ✅
import packageJson from '../../package.json';
program.version(packageJson.version);
Selected: Simple, type-safe, reliable, and works in all contexts
tsconfig.json Configuration
Existing Configuration (already correct):
{
"compilerOptions": {
"resolveJsonModule": true, // ✅ Required for JSON imports
"esModuleInterop": true, // ✅ Enables ES module interop
"moduleResolution": "node", // ✅ Node-style module resolution
"strict": true // ✅ Type safety
}
}
No changes to tsconfig.json were needed - configuration was already optimal.
Impact Analysis
Files Changed
- ✅
/workspaces/agentic-qe-cf/src/cli/index.ts(2 lines modified) - ✅
/workspaces/agentic-qe-cf/dist/cli/index.js(auto-generated by build)
Breaking Changes
- ❌ None - this is a bug fix
Backward Compatibility
- ✅ Fully compatible - no API changes
- ✅ Existing CLI commands work identically
- ✅ Only version display changes (from
1.1.0to1.2.0)
Side Effects
- ❌ None - no functional changes
- ✅ Better maintainability - version auto-updates from package.json
- ✅ Single source of truth for version number
Testing Coverage
Unit Tests (Future)
Consider adding test to verify version matches package.json:
// tests/cli/version.test.ts
import packageJson from '../../package.json';
import { execSync } from 'child_process';
describe('CLI Version Display', () => {
it('should display version from package.json', () => {
const output = execSync('node dist/cli/index.js --version').toString().trim();
expect(output).toBe(packageJson.version);
});
it('should not have hardcoded version', () => {
const cliSource = fs.readFileSync('src/cli/index.ts', 'utf8');
expect(cliSource).not.toMatch(/\.version\(['"]1\.\d+\.\d+['"]\)/);
expect(cliSource).toMatch(/\.version\(packageJson\.version\)/);
});
});
Manual Testing Completed ✅
- Build succeeds
- Version displays correctly (
1.2.0) - No errors in console
- Help command still works
- Other CLI commands unaffected
Deployment Checklist
Before releasing v1.2.0:
- Version updated in
package.json→1.2.0 - Version updated in
package-lock.json→1.2.0 - CLI reads version dynamically
- Build succeeds without errors
- Version display verified
- CHANGELOG.md updated with version fix
- Git commit created
- PR created for review
- CI/CD pipeline passes
Lessons Learned
What Went Well ✅
- Simple fix - only 2 lines changed
- No configuration changes -
tsconfig.jsonalready correct - Type-safe - TypeScript infers types correctly
- Future-proof - version auto-updates from package.json
What Could Improve 🔄
- Add automated test to catch version mismatches
- Add pre-commit hook to verify version consistency
- Document version management process in CONTRIBUTING.md
Prevention for Future
# Add to CI/CD pipeline:
- name: Verify version consistency
run: |
CLI_VERSION=$(node dist/cli/index.js --version)
PKG_VERSION=$(node -p "require('./package.json').version")
if [ "$CLI_VERSION" != "$PKG_VERSION" ]; then
echo "❌ Version mismatch: CLI=$CLI_VERSION, package.json=$PKG_VERSION"
exit 1
fi
echo "✅ Version consistent: $CLI_VERSION"
Related Issues
GitHub Issues
- Fixes version mismatch discovered during release 1.2.0 validation
- Part of BLOCKER #7 resolution
Pull Requests
- PR #XXX: "fix: Dynamic version from package.json for CLI"
Documentation Updates
- Added this fix documentation
- Updated release notes for v1.2.0
- Updated ESLint cleanup report
Fix Applied: 2025-10-21T09:45:00Z Verification: 2025-10-21T09:50:00Z Status: ✅ COMPLETE & VERIFIED Build Version: 1.2.0