agentaudit 3.12.10 → 3.12.11

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.
Files changed (2) hide show
  1. package/cli.mjs +102 -5
  2. package/package.json +1 -1
package/cli.mjs CHANGED
@@ -4864,13 +4864,23 @@ async function main() {
4864
4864
  ` agentaudit consensus fastmcp --json`,
4865
4865
  ],
4866
4866
  history: [
4867
- `${c.bold}agentaudit history${c.reset} [options]`,
4867
+ `${c.bold}agentaudit history${c.reset} [show|upload] [n]`,
4868
4868
  ``,
4869
4869
  `Show your local audit history. Results are stored in ~/.config/agentaudit/history/`,
4870
4870
  `after every audit run. No internet connection required.`,
4871
4871
  ``,
4872
+ `${c.bold}Subcommands:${c.reset}`,
4873
+ ` history List all local audits (numbered)`,
4874
+ ` history show <n> Show full report details for entry #n`,
4875
+ ` history upload <n> Retry upload of entry #n to agentaudit.dev`,
4876
+ ``,
4872
4877
  `${c.bold}Options:${c.reset}`,
4873
4878
  ` --json Machine-readable JSON output`,
4879
+ ``,
4880
+ `${c.bold}Examples:${c.reset}`,
4881
+ ` agentaudit history`,
4882
+ ` agentaudit history show 1`,
4883
+ ` agentaudit history upload 1`,
4874
4884
  ],
4875
4885
  activity: [
4876
4886
  `${c.bold}agentaudit activity${c.reset} [options]`,
@@ -5033,13 +5043,96 @@ async function main() {
5033
5043
  }
5034
5044
  if (command === 'history') {
5035
5045
  banner();
5046
+ const subCmd = targets[0];
5036
5047
  const entries = loadHistory(30);
5037
- if (entries.length === 0) {
5048
+
5049
+ if (entries.length === 0 && !subCmd) {
5038
5050
  console.log(` ${c.dim}No local audit history yet. Run ${c.cyan}agentaudit audit <url>${c.dim} to start.${c.reset}`);
5039
5051
  console.log();
5040
5052
  return;
5041
5053
  }
5042
5054
 
5055
+ // history show <n> — show full report details
5056
+ if (subCmd === 'show') {
5057
+ const idx = parseInt(targets[1], 10) - 1;
5058
+ if (isNaN(idx) || idx < 0 || idx >= entries.length) {
5059
+ console.log(` ${c.red}Invalid index.${c.reset} Use a number from 1 to ${entries.length}.`);
5060
+ console.log(` ${c.dim}Run ${c.cyan}agentaudit history${c.dim} to see the list.${c.reset}`);
5061
+ return;
5062
+ }
5063
+ const entry = entries[idx];
5064
+ if (jsonMode) {
5065
+ console.log(JSON.stringify(entry, null, 2));
5066
+ return;
5067
+ }
5068
+ console.log(sectionHeader(`Report: ${entry.skill_slug || 'unknown'}`));
5069
+ console.log();
5070
+ console.log(` Source ${c.bold}${entry.source_url || '?'}${c.reset}`);
5071
+ console.log(` Model ${c.bold}${entry.audit_model || '?'}${c.reset} ${c.dim}(${entry.audit_provider || '?'})${c.reset}`);
5072
+ console.log(` Risk ${riskBadge(entry.risk_score ?? 0)}`);
5073
+ console.log(` Result ${entry.result || '?'}`);
5074
+ console.log(` Files ${entry.files_scanned || '?'} ${c.dim}Duration: ${entry.audit_duration_ms ? (entry.audit_duration_ms / 1000).toFixed(1) + 's' : '?'}${c.reset}`);
5075
+ console.log(` Tokens ${c.dim}in: ${entry.input_tokens || '?'} out: ${entry.output_tokens || '?'}${c.reset}`);
5076
+ console.log(` File ${c.dim}${entry._file}${c.reset}`);
5077
+ console.log();
5078
+ if (entry.findings && entry.findings.length > 0) {
5079
+ console.log(sectionHeader(`Findings (${entry.findings.length})`));
5080
+ console.log();
5081
+ for (const f of entry.findings) {
5082
+ const sc = severityColor(f.severity);
5083
+ console.log(` ${sc}┃${c.reset} ${sc}${(f.severity || '').toUpperCase().padEnd(8)}${c.reset} ${c.bold}${f.title}${c.reset}`);
5084
+ if (f.file) console.log(` ${sc}┃${c.reset} ${c.dim}${f.file}${f.line ? ':' + f.line : ''}${c.reset}`);
5085
+ if (f.description) console.log(` ${sc}┃${c.reset} ${c.dim}${f.description.slice(0, 200)}${c.reset}`);
5086
+ console.log();
5087
+ }
5088
+ } else {
5089
+ console.log(` ${c.green}No findings.${c.reset}`);
5090
+ console.log();
5091
+ }
5092
+ return;
5093
+ }
5094
+
5095
+ // history upload <n> — retry upload of a local report
5096
+ if (subCmd === 'upload') {
5097
+ const idx = parseInt(targets[1], 10) - 1;
5098
+ if (isNaN(idx) || idx < 0 || idx >= entries.length) {
5099
+ console.log(` ${c.red}Invalid index.${c.reset} Use a number from 1 to ${entries.length}.`);
5100
+ console.log(` ${c.dim}Run ${c.cyan}agentaudit history${c.dim} to see the list.${c.reset}`);
5101
+ return;
5102
+ }
5103
+ const entry = entries[idx];
5104
+ const creds = loadCredentials();
5105
+ if (!creds) {
5106
+ console.log(` ${c.red}Not logged in.${c.reset} Run ${c.cyan}agentaudit login${c.reset} first.`);
5107
+ return;
5108
+ }
5109
+ process.stdout.write(` Uploading ${c.bold}${entry.skill_slug}${c.reset} (${entry.audit_model || '?'})...`);
5110
+ try {
5111
+ const reportCopy = { ...entry };
5112
+ delete reportCopy._file;
5113
+ const res = await fetch(`${REGISTRY_URL}/api/reports`, {
5114
+ method: 'POST',
5115
+ headers: { 'Authorization': `Bearer ${creds.api_key}`, 'Content-Type': 'application/json' },
5116
+ body: JSON.stringify(reportCopy),
5117
+ signal: AbortSignal.timeout(30_000),
5118
+ });
5119
+ if (res.ok) {
5120
+ const data = await res.json();
5121
+ console.log(` ${c.green}done${c.reset} ${c.dim}(report #${data.report_id})${c.reset}`);
5122
+ console.log(` ${c.dim}${REGISTRY_URL}/packages/${entry.skill_slug}${c.reset}`);
5123
+ } else {
5124
+ const errBody = await res.text().catch(() => '');
5125
+ console.log(` ${c.red}failed (HTTP ${res.status})${c.reset}`);
5126
+ if (errBody) console.log(` ${c.dim}${errBody.slice(0, 300)}${c.reset}`);
5127
+ }
5128
+ } catch (e) {
5129
+ console.log(` ${c.red}failed: ${e.message}${c.reset}`);
5130
+ }
5131
+ console.log();
5132
+ return;
5133
+ }
5134
+
5135
+ // Default: list all entries
5043
5136
  if (jsonMode) {
5044
5137
  console.log(JSON.stringify(entries, null, 2));
5045
5138
  return;
@@ -5048,7 +5141,8 @@ async function main() {
5048
5141
  console.log(sectionHeader(`Local History (${entries.length})`));
5049
5142
  console.log();
5050
5143
 
5051
- for (const entry of entries) {
5144
+ for (let i = 0; i < entries.length; i++) {
5145
+ const entry = entries[i];
5052
5146
  const slug = entry.skill_slug || 'unknown';
5053
5147
  const risk = entry.risk_score ?? '?';
5054
5148
  const sev = entry.max_severity || 'none';
@@ -5056,10 +5150,13 @@ async function main() {
5056
5150
  const model = entry.audit_model || '?';
5057
5151
  const fc = entry.findings?.length || 0;
5058
5152
  const ts = entry._file?.slice(0, 10) || '';
5059
- console.log(` ${sc}┃${c.reset} ${c.bold}${slug.padEnd(30)}${c.reset} ${riskBadge(risk)} ${c.dim}${model}${c.reset}`);
5060
- console.log(` ${sc}┃${c.reset} ${c.dim}${ts} ${fc} findings ${sev.toUpperCase()}${c.reset}`);
5153
+ const num = `${c.dim}${String(i + 1).padStart(2)}.${c.reset}`;
5154
+ console.log(` ${num} ${sc}┃${c.reset} ${c.bold}${slug.padEnd(30)}${c.reset} ${riskBadge(risk)} ${c.dim}${model}${c.reset}`);
5155
+ console.log(` ${sc}┃${c.reset} ${c.dim}${ts} ${fc} findings ${sev.toUpperCase()}${c.reset}`);
5061
5156
  console.log();
5062
5157
  }
5158
+ console.log(` ${c.dim}Tip: ${c.cyan}agentaudit history show <n>${c.dim} for details, ${c.cyan}history upload <n>${c.dim} to retry upload${c.reset}`);
5159
+ console.log();
5063
5160
  return;
5064
5161
  }
5065
5162
  if (command === 'activity' || command === 'my') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentaudit",
3
- "version": "3.12.10",
3
+ "version": "3.12.11",
4
4
  "description": "Security scanner for AI agent packages — CLI + MCP server",
5
5
  "type": "module",
6
6
  "bin": {