MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / usageDetails

Function usageDetails

atomic-cli/src/commands/query/graph_inspector.js:69–117  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

67 parent.appendChild(table);
68 }
69 function usageDetails(node) {
70 var usage = node.metadata && node.metadata.ai_usage;
71 var types = node.types || [node.kind];
72 var relevant = types.some(function(type) {
73 return /#(Change|View|WorkIntent|FeatureIntent|BugIntent|ReviewIntent|ManagedIntent)$/.test(type);
74 });
75 if (!usage) {
76 if (relevant) section('AI usage').appendChild(element('p', 'Usage was not included in this export. Regenerate it with a current Atomic CLI.', 'inspector-muted'));
77 return;
78 }
79 var result = section('AI usage');
80 result.classList.add('inspector-ai-usage');
81 var scope = {
82 change_provenance: 'This change’s recorded provenance.',
83 intent_implementation_and_recording_evidence_excluding_dependencies: 'Intent implementation and intent-artifact recording evidence; dependency-only changes excluded.',
84 view_effective_membership_including_ancestors_and_dependencies: 'Effective view membership, including ancestor views and dependencies.',
85 view_canonical_effective_membership_including_ancestors_and_dependencies: 'Effective view membership from canonical repository data, including ancestor views and dependencies.'
86 };
87 result.appendChild(element('p', scope[usage.basis] || usage.basis, 'inspector-muted'));
88 var coverage = usage.coverage;
89 result.appendChild(element('p', coverage.with_provenance + ' of ' + coverage.changes + ' unique changes have AI provenance; ' + coverage.without_provenance + ' without provenance, ' + coverage.unavailable + ' unavailable.', 'inspector-usage-coverage'));
90 if (!usage.scope_complete) result.appendChild(element('p', 'Incomplete membership scope: ' + (usage.scope_error || 'some ancestor views are unavailable') + '. These totals are not complete.', 'inspector-usage-warning'));
91 if (coverage.duplicate_usage_records) result.appendChild(element('p', coverage.duplicate_usage_records + ' duplicate usage record(s) counted once.', 'inspector-muted'));
92 if (coverage.conflicting_usage_records) result.appendChild(element('p', coverage.conflicting_usage_records + ' conflicting usage record(s) excluded from totals.', 'inspector-usage-warning'));
93 if (coverage.records_without_cost) result.appendChild(element('p', coverage.records_without_cost + ' usage record(s) have no usable cost. Amount below is a known subtotal.', 'inspector-usage-warning'));
94 if (coverage.records_without_tokens) result.appendChild(element('p', coverage.records_without_tokens + ' usage record(s) have no reported token counts. Token values below are known subtotals.', 'inspector-usage-warning'));
95 result.appendChild(element('div', usage.cost ? '$' + usage.cost.amount + ' ' + usage.cost.currency : 'Cost not recorded', 'inspector-usage-cost'));
96 tokenTable(result, usage.tokens);
97 result.appendChild(element('p', 'Cache and reasoning categories are provider-defined: they may overlap or be excluded from the recorded total.', 'inspector-muted'));
98 if (usage.contributors && usage.contributors.length) {
99 var attribution = section('Models, tools & vendors');
100 usage.contributors.forEach(function(profile) {
101 var card = element('div', undefined, 'inspector-attribution');
102 card.appendChild(element('h4', profile.model || '(model not recorded)'));
103 card.appendChild(element('p', 'Vendor: ' + (profile.vendor || '(not recorded)')));
104 card.appendChild(element('p', 'Tool: ' + (profile.tool || '(not recorded)')));
105 card.appendChild(element('p', profile.cost_usd === null ? 'Cost not recorded' : '$' + profile.cost_usd + ' USD'));
106 var breakdown = element('details');
107 breakdown.appendChild(element('summary', 'Token breakdown for this model/tool'));
108 tokenTable(breakdown, profile.tokens);
109 card.appendChild(breakdown);
110 attribution.appendChild(card);
111 });
112 }
113 var notes = element('details', undefined, 'inspector-usage-notes');
114 notes.appendChild(element('summary', 'How these totals are calculated'));
115 (usage.notes || []).forEach(function(note) { notes.appendChild(element('p', note, 'inspector-muted')); });
116 result.appendChild(notes);
117 }
118 function relationships(title, entries) {
119 var list = section(title + ' (' + entries.length + ')');
120 if (!entries.length) list.appendChild(element('p', 'None in this exported graph.', 'inspector-muted'));

Callers 1

selectFunction · 0.85

Calls 4

elementFunction · 0.85
tokenTableFunction · 0.85
sectionFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected