qwai-tech_obsidian-plugin-i.../scripts/version.js
Leon Ward ecc5d1eca6 fix: agent reliability fixes + verification harness (bundles in-progress WIP)
This-session changes (reviewed, lint-clean, build+deploy verified):
- vector-store: fix misleading "no embedding" comment in search; count and
  warn on unembedded chunks (was silently scored 0); cache per-chunk vector
  norms to avoid recomputing cosine norms across queries; expose
  unembeddedChunkCount in stats.
- planner: add structured `expectsWriteProposal` signal so the forced
  write-proposal retry no longer depends on English prompt-string matching.
- chat.service: remove unreachable agent-mode branch (streamResponse only runs
  in chat mode) and the now-unused toolRegistry dependency; sync call sites.
- remove dead code: ChatState (superseded by ChatViewState) and
  AgentMemoryManager (superseded by agent-memory-service).
- docs: ADR-001 documenting the two-layer safety model (write-proposal gate vs
  policy budget) and why the vendored engine is intentionally permissive.
- tests: adverse-condition agent reliability (circuit breaker / maxSteps /
  abort / failure recovery), real builtin-tools E2E against an in-memory vault,
  and a live agent E2E (real model + real tools) that auto-skips without a key.

Also bundles pre-existing uncommitted WIP not authored in this session (per
explicit request to commit everything): LLM providers, web-search-service,
document-grader, rag-manager, rag-tab, and their tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 09:31:15 +08:00

168 lines
5 KiB
JavaScript

#!/usr/bin/env node
const { readFileSync, writeFileSync } = require('fs');
const { join } = require('path');
const logger = require('./utils/logger');
/**
* Version management script for bumping plugin versions
*/
class VersionManager {
constructor() {
this.sourceDir = process.cwd();
this.options = this.parseArgs();
// File paths
this.manifestPath = join(this.sourceDir, 'manifest.json');
this.versionsPath = join(this.sourceDir, 'versions.json');
this.packagePath = join(this.sourceDir, 'package.json');
}
parseArgs() {
const args = process.argv.slice(2);
const versionType = args[0] || 'patch';
return {
versionType,
showHelp: args.includes('--help') || args.includes('-h')
};
}
async bump() {
if (this.options.showHelp) {
this.showHelp();
return;
}
logger.section('🏷️ Version Management');
try {
// Step 1: Get current version from package.json
const currentVersion = this.getCurrentVersion();
logger.info(`Current version: ${currentVersion}`);
// Step 2: Calculate new version
const newVersion = this.calculateNewVersion(currentVersion, this.options.versionType);
logger.info(`New version: ${newVersion} (${this.options.versionType})`);
// Step 3: Update manifest.json
this.updateManifest(newVersion);
// Step 4: Update versions.json
this.updateVersions(newVersion);
// Step 5: Update package.json
this.updatePackage(newVersion);
logger.success(`✅ Version bumped to ${newVersion}`);
logger.info('💡 Remember to commit the changes');
} catch (error) {
logger.error(`Version bump failed: ${error.message}`);
process.exit(1);
}
}
getCurrentVersion() {
const packageJson = JSON.parse(readFileSync(this.packagePath, 'utf8'));
return packageJson.version;
}
calculateNewVersion(current, type) {
const parts = current.split('.').map(Number);
switch (type) {
case 'major':
return `${parts[0] + 1}.0.0`;
case 'minor':
return `${parts[0]}.${parts[1] + 1}.0`;
case 'patch':
default:
return `${parts[0]}.${parts[1]}.${parts[2] + 1}`;
}
}
updateManifest(newVersion) {
logger.step('1', 'Updating manifest.json');
const manifest = JSON.parse(readFileSync(this.manifestPath, 'utf8'));
const { minAppVersion } = manifest;
manifest.version = newVersion;
writeFileSync(this.manifestPath, JSON.stringify(manifest, null, '\t'));
logger.success(`manifest.json updated to ${newVersion}`);
}
updateVersions(newVersion) {
logger.step('2', 'Updating versions.json');
let versions;
try {
versions = JSON.parse(readFileSync(this.versionsPath, 'utf8'));
} catch (error) {
versions = {};
}
const manifest = JSON.parse(readFileSync(this.manifestPath, 'utf8'));
const { minAppVersion } = manifest;
versions[newVersion] = minAppVersion;
writeFileSync(this.versionsPath, JSON.stringify(versions, null, '\t'));
logger.success(`versions.json updated with ${newVersion} -> ${minAppVersion}`);
}
updatePackage(newVersion) {
logger.step('3', 'Updating package.json');
const packageJson = JSON.parse(readFileSync(this.packagePath, 'utf8'));
packageJson.version = newVersion;
writeFileSync(this.packagePath, JSON.stringify(packageJson, null, '\t'));
logger.success(`package.json updated to ${newVersion}`);
}
showHelp() {
console.log(`
🏷️ Version Management Tool
Usage: node version.js [type]
Types:
patch Increment patch version (1.0.1 -> 1.0.2) [default]
minor Increment minor version (1.0.1 -> 1.1.0)
major Increment major version (1.0.1 -> 2.0.0)
Examples:
node version.js # Bump patch version
node version.js patch # Bump patch version
node version.js minor # Bump minor version
node version.js major # Bump major version
Files updated:
- manifest.json (version field)
- versions.json (version -> minAppVersion mapping)
- package.json (version field)
Note:
This tool updates version files only; commit the changes separately.
`);
}
}
// Command line interface
async function main() {
const versionManager = new VersionManager();
await versionManager.bump();
}
// Run if called directly
if (require.main === module) {
main().catch(error => {
logger.error(`Unexpected error: ${error.message}`);
process.exit(1);
});
}
module.exports = VersionManager;