@nerviq/cli 1.6.5 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +86 -1
- package/package.json +1 -1
- package/src/benchmark.js +3 -1
package/bin/cli.js
CHANGED
|
@@ -26,7 +26,7 @@ const COMMAND_ALIASES = {
|
|
|
26
26
|
gov: 'governance',
|
|
27
27
|
outcome: 'feedback',
|
|
28
28
|
};
|
|
29
|
-
const KNOWN_COMMANDS = ['audit', 'org', 'setup', 'augment', 'suggest-only', 'plan', 'apply', 'fix', 'governance', 'benchmark', 'deep-review', 'interactive', 'watch', 'badge', 'insights', 'history', 'compare', 'trend', 'scan', 'feedback', 'doctor', 'convert', 'migrate', 'catalog', 'certify', 'serve', 'check-health', 'harmony-audit', 'harmony-sync', 'harmony-drift', 'harmony-advise', 'harmony-watch', 'harmony-governance', 'harmony-add', 'synergy-report', 'anti-patterns', 'rules-export', 'freshness', 'help', 'version'];
|
|
29
|
+
const KNOWN_COMMANDS = ['audit', 'org', 'setup', 'augment', 'suggest-only', 'plan', 'apply', 'fix', 'rollback', 'governance', 'benchmark', 'deep-review', 'interactive', 'watch', 'badge', 'insights', 'history', 'compare', 'trend', 'scan', 'feedback', 'doctor', 'convert', 'migrate', 'catalog', 'certify', 'serve', 'check-health', 'harmony-audit', 'harmony-sync', 'harmony-drift', 'harmony-advise', 'harmony-watch', 'harmony-governance', 'harmony-add', 'synergy-report', 'anti-patterns', 'rules-export', 'freshness', 'help', 'version'];
|
|
30
30
|
|
|
31
31
|
function levenshtein(a, b) {
|
|
32
32
|
const matrix = Array.from({ length: a.length + 1 }, () => Array(b.length + 1).fill(0));
|
|
@@ -313,6 +313,9 @@ const HELP = `
|
|
|
313
313
|
nerviq fix <key> Auto-fix a specific check (with score impact)
|
|
314
314
|
nerviq fix --all-critical Fix all critical issues at once
|
|
315
315
|
nerviq fix --dry-run Preview fixes without writing
|
|
316
|
+
nerviq rollback Undo the most recent apply (delete created files)
|
|
317
|
+
nerviq rollback --list Show available rollback points
|
|
318
|
+
nerviq rollback --dry-run Preview what would be deleted
|
|
316
319
|
|
|
317
320
|
IMPROVE
|
|
318
321
|
nerviq augment Improvement plan (no writes)
|
|
@@ -784,6 +787,88 @@ async function main() {
|
|
|
784
787
|
}
|
|
785
788
|
console.log('');
|
|
786
789
|
}
|
|
790
|
+
} else if (normalizedCommand === 'rollback') {
|
|
791
|
+
const fsMod = require('fs');
|
|
792
|
+
const pathMod = require('path');
|
|
793
|
+
const rollbackDir = pathMod.join(options.dir, '.nerviq', 'rollbacks');
|
|
794
|
+
|
|
795
|
+
if (!fsMod.existsSync(rollbackDir)) {
|
|
796
|
+
console.log('\n No rollback artifacts found. Run `nerviq apply` first to create rollback data.\n');
|
|
797
|
+
process.exit(0);
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
const rollbackFiles = fsMod.readdirSync(rollbackDir)
|
|
801
|
+
.filter(f => f.endsWith('.json'))
|
|
802
|
+
.sort()
|
|
803
|
+
.reverse();
|
|
804
|
+
|
|
805
|
+
if (rollbackFiles.length === 0) {
|
|
806
|
+
console.log('\n No rollback artifacts found.\n');
|
|
807
|
+
process.exit(0);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// --list mode
|
|
811
|
+
if (flags.includes('--list')) {
|
|
812
|
+
console.log(`\n Rollback points (${rollbackFiles.length}):\n`);
|
|
813
|
+
for (const f of rollbackFiles) {
|
|
814
|
+
try {
|
|
815
|
+
const data = JSON.parse(fsMod.readFileSync(pathMod.join(rollbackDir, f), 'utf8'));
|
|
816
|
+
const created = (data.createdFiles || []).length;
|
|
817
|
+
const patched = (data.patchedFiles || []).length;
|
|
818
|
+
console.log(` ${f.replace('.json', '')} (${created} created, ${patched} patched)`);
|
|
819
|
+
} catch {
|
|
820
|
+
console.log(` ${f} (unreadable)`);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
console.log(`\n Run \`nerviq rollback\` to undo the most recent.\n`);
|
|
824
|
+
process.exit(0);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// Execute rollback of most recent
|
|
828
|
+
const latestFile = rollbackFiles[0];
|
|
829
|
+
const latestPath = pathMod.join(rollbackDir, latestFile);
|
|
830
|
+
let rollbackData;
|
|
831
|
+
try {
|
|
832
|
+
rollbackData = JSON.parse(fsMod.readFileSync(latestPath, 'utf8'));
|
|
833
|
+
} catch (e) {
|
|
834
|
+
console.error(`\n Error: Cannot parse rollback file: ${e.message}\n`);
|
|
835
|
+
process.exit(1);
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
const createdFiles = rollbackData.createdFiles || [];
|
|
839
|
+
if (createdFiles.length === 0) {
|
|
840
|
+
console.log('\n Rollback artifact has no files to remove.\n');
|
|
841
|
+
process.exit(0);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
if (options.dryRun) {
|
|
845
|
+
console.log(`\n [dry-run] Would delete ${createdFiles.length} files:\n`);
|
|
846
|
+
for (const f of createdFiles) {
|
|
847
|
+
console.log(` - ${f}`);
|
|
848
|
+
}
|
|
849
|
+
console.log('');
|
|
850
|
+
process.exit(0);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
let deleted = 0;
|
|
854
|
+
let missing = 0;
|
|
855
|
+
console.log('');
|
|
856
|
+
for (const relPath of createdFiles) {
|
|
857
|
+
const fullPath = pathMod.join(options.dir, relPath);
|
|
858
|
+
if (fsMod.existsSync(fullPath)) {
|
|
859
|
+
fsMod.unlinkSync(fullPath);
|
|
860
|
+
console.log(` 🗑️ Deleted: ${relPath}`);
|
|
861
|
+
deleted++;
|
|
862
|
+
} else {
|
|
863
|
+
missing++;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// Remove rollback artifact after use
|
|
868
|
+
fsMod.unlinkSync(latestPath);
|
|
869
|
+
|
|
870
|
+
console.log(`\n Rollback complete: ${deleted} files deleted${missing > 0 ? `, ${missing} already missing` : ''}.\n`);
|
|
871
|
+
|
|
787
872
|
} else if (normalizedCommand === 'apply') {
|
|
788
873
|
if (flags.includes('--rollback')) {
|
|
789
874
|
console.error('\n Error: --rollback is not yet supported as a flag.');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nerviq/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "The intelligent nervous system for AI coding agents — 2,431 checks across 8 platforms, 10 languages, and 62 domain packs. Audit, align, and amplify.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
package/src/benchmark.js
CHANGED
|
@@ -145,7 +145,9 @@ function buildExecutiveSummary(before, after, workflowEvidence) {
|
|
|
145
145
|
const scoreDelta = after.score - before.score;
|
|
146
146
|
const organicDelta = after.organicScore - before.organicScore;
|
|
147
147
|
const workflowCoverage = workflowEvidence.summary.coverageScore;
|
|
148
|
-
let headline =
|
|
148
|
+
let headline = before.score >= 60
|
|
149
|
+
? 'Setup is already applied — benchmark shows no additional improvement. Run benchmark on a project before running setup to see the full delta.'
|
|
150
|
+
: 'Benchmark did not improve the score in this run.';
|
|
149
151
|
|
|
150
152
|
if (scoreDelta < 0) {
|
|
151
153
|
headline = `Warning: score decreased by ${Math.abs(scoreDelta)} points. Setup may have introduced a regression.`;
|