feat(pc-audit): AI 相談用プロンプトコピーボタンを追加

チェック項目カラムに「AI 相談用にコピー」ボタンを追加。
PC情報(名前・管理者権限・UAC)+注意/情報チェック項目を
Claude に貼り付けるだけで対処手順を聞けるプロンプトを生成する。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
posimai 2026-04-21 17:52:58 +09:00
parent 04483c8744
commit 6d7f2a4ed4
1 changed files with 96 additions and 1 deletions

View File

@ -148,8 +148,24 @@
.filter-row {
flex-shrink: 0;
display: flex; gap: 0.4rem; margin-bottom: 0.6rem; flex-wrap: wrap;
align-items: center;
}
/* ── AI prompt copy button ── */
.copy-prompt-btn {
margin-left: auto;
font-size: 0.68rem; font-weight: 600;
padding: 0.2rem 0.65rem;
border-radius: 99px;
border: 1px solid var(--border);
background: transparent; color: var(--text3);
cursor: pointer;
transition: border-color 0.12s, color 0.12s, background 0.12s;
white-space: nowrap;
}
.copy-prompt-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-prompt-btn.copied { border-color: var(--ok-color); color: var(--ok-color); }
/* ── Scrollable area inside each column ── */
.scroll-pane {
flex: 1;
@ -323,7 +339,9 @@
<!-- Col 2: Guidance -->
<div class="grid-col">
<div class="col-label">チェック項目</div>
<div class="filter-row" id="guidance-filter-row"></div>
<div class="filter-row" id="guidance-filter-row">
<button id="copy-prompt-btn" class="copy-prompt-btn">AI 相談用にコピー</button>
</div>
<div class="scroll-pane" id="guidance"></div>
</div>
@ -638,6 +656,7 @@
/* Load data */
/* ------------------------------------------------------------------ */
function loadData(data) {
currentData = data;
document.getElementById("upload-wrap").style.display = "none";
document.getElementById("alt-file-btn").style.display = "";
document.getElementById("output").style.display = "flex";
@ -648,6 +667,82 @@
document.getElementById("raw").textContent = JSON.stringify(data, null, 2);
}
/* ------------------------------------------------------------------ */
/* AI prompt generation */
/* ------------------------------------------------------------------ */
var currentData = null;
function buildAiPrompt(data) {
var uc = data.userContext || {};
var m = data.machine || {};
var uac = data.uac || {};
var shareSafe = data.meta && data.meta.shareSafe;
var items = allGuidanceItems.filter(function(i) {
return (i.Level||'').toLowerCase() !== 'ok';
});
var lines = [];
lines.push("以下は PC 監査ツールPosimai PC Auditの実行結果です。");
lines.push("各チェック項目について、Windows での具体的な対処手順をコマンドや設定画面の操作手順を含めて教えてください。");
lines.push("");
lines.push("## PC 情報");
lines.push("- PC 名: " + (m.Name || "不明"));
lines.push("- ユーザー: " + (uc.UserName || "不明"));
lines.push("- 管理者権限: " + (uc.IsAdmin === true ? "あり" : "なし"));
lines.push("- UAC (EnableLUA): " + (uac.EnableLUA != null ? String(uac.EnableLUA) : "不明"));
if (shareSafe) lines.push("- モード: ShareSafe機微情報は省略済み");
lines.push("");
if (items.length === 0) {
lines.push("## チェック結果");
lines.push("注意・情報レベルの指摘はありませんでした。");
} else {
lines.push("## チェック結果(" + items.length + " 件)");
items.forEach(function(item, idx) {
var level = (item.Level||'info').toLowerCase();
var tag = level === 'warn' ? '[注意]' : '[情報]';
lines.push("");
lines.push("### " + (idx + 1) + ". " + tag + " " + (item.Title || ""));
if (item.Body) lines.push((item.Body || "").replace(/\n/g, " "));
if (item.ActionJa) lines.push("推奨対処: " + item.ActionJa);
});
}
lines.push("");
lines.push("---");
lines.push("それぞれについて Windows での具体的な対処手順PowerShell コマンドや設定画面の操作など)を教えてください。");
return lines.join("\n");
}
document.addEventListener("DOMContentLoaded", function () {
var btn = document.getElementById("copy-prompt-btn");
btn.addEventListener("click", function () {
if (!currentData) return;
var text = buildAiPrompt(currentData);
navigator.clipboard.writeText(text).then(function () {
btn.textContent = "コピーしました";
btn.classList.add("copied");
setTimeout(function () {
btn.textContent = "AI 相談用にコピー";
btn.classList.remove("copied");
}, 2000);
}).catch(function () {
var ta = document.createElement("textarea");
ta.value = text;
ta.style.position = "fixed"; ta.style.opacity = "0";
document.body.appendChild(ta);
ta.select(); document.execCommand("copy");
document.body.removeChild(ta);
btn.textContent = "コピーしました";
btn.classList.add("copied");
setTimeout(function () {
btn.textContent = "AI 相談用にコピー";
btn.classList.remove("copied");
}, 2000);
});
});
});
/* ------------------------------------------------------------------ */
/* Auto-load */
/* ------------------------------------------------------------------ */