Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 7 additions & 101 deletions extract-knowhow/templates/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h1>🏛️ OpenScientist</h1>
<div class="consent-details">Your name, institution, and role will be attached as contributor metadata. All skills are de-identified during extraction, but please verify no private information remains before submitting.</div>
</div>
<div class="submit-info">After agreeing above, click "Submit" on individual skills or submit all accepted skills at once.</div>
<button class="submit-btn" id="submit-all-btn" onclick="submitAll()" disabled>Submit All Accepted to GitHub</button>
<button class="submit-btn" id="submit-all-btn" onclick="submitAll()" disabled>Submit All Accepted</button>
<div class="output" id="output">
<p style="color:#3fb950;margin-bottom:.5rem" id="submit-msg"></p>
</div>
Expand Down Expand Up @@ -186,7 +186,7 @@ <h1>🏛️ OpenScientist</h1>
<div class="skill-desc">${mkEditable(sk.description, 'ed-desc')}</div>
<div class="skill-actions">
<button class="expand-btn" onclick="exp('${id}')" style="margin:0">▶ Show details</button>
<button class="gh-btn" onclick="openIssue(${pi},${si})" disabled>Submit to GitHub</button>
<button class="gh-btn" onclick="openIssue()" disabled>Submit</button>
</div>
<div class="detail" id="${id}-d">
<h4>Domain Knowledge</h4>${mkEditable(sk.domain_knowledge, 'ed-dk')}
Expand All @@ -208,116 +208,22 @@ <h4>Common Pitfalls</h4>${mkEditableList(sk.pitfalls, 'ed-pit')}
b.textContent=open?'▼ Hide details':'▶ Show details';
}

function readEditable(parent, cls){
const el=parent.querySelector('.'+cls);
return el?el.textContent.trim():'';
}
function readEditableList(parent, cls){
return Array.from(parent.querySelectorAll('.'+cls)).map(e=>e.textContent.trim()).filter(Boolean);
}

function buildIssueUrl(pi, si){
const proj = projects[pi];
const sk = proj.skills[si];
const id = `sk-${pi}-${si}`;
const wrap = document.getElementById(id+'-w');
const detail = document.getElementById(id+'-d');

const authorName = document.getElementById('author-name').value.trim() || 'Anonymous';
const authorInst = document.getElementById('author-inst').value.trim();
const authorRole = document.getElementById('author-role').value;
const author = authorName + (authorInst ? ' (' + authorInst + ')' : '');

// Read current (possibly edited) values from DOM
const title = readEditable(wrap, 'ed-title') || sk.title;
const desc = readEditable(wrap, 'ed-desc') || sk.description;
const dk = readEditable(detail, 'ed-dk') || sk.domain_knowledge || '';
const rs = readEditableList(detail, 'ed-rs');
const tools = readEditableList(detail, 'ed-tools');
const pit = readEditableList(detail, 'ed-pit');

const slug = title.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'');
const subLabel = [proj.domain, proj.subdomain].map(s=>s.split('-').map(w=>w.charAt(0).toUpperCase()+w.slice(1)).join(' ')).join(' / ');
const catLabel = CAT[sk.category] || sk.category;
const date = DATA.date || new Date().toISOString().slice(0,10);

const skillMd = `---
name: ${slug}
description: >
${desc}
domain: ${proj.domain}
subdomain: ${proj.subdomain}
category: ${sk.category}
author: "${author}"
expertise_level: intermediate
tags: []
dependencies: []
version: 1.0.0
status: draft
reviewed_by: []
---

## Purpose

${desc}

## Tools

${tools.length ? tools.map(t=>'- **'+t.split(' — ')[0]+'**'+(t.includes(' — ')?': '+t.split(' — ').slice(1).join(' — '):'')).join('\n') : '- N/A'}

## Domain Knowledge

### Key Concepts

${dk || 'N/A'}

## Reasoning Protocol

${rs.length ? rs.map((s,i)=>'Step '+(i+1)+': '+s).join('\n') : 'N/A'}

## Common Pitfalls

${pit.length ? pit.map(p=>'- '+p).join('\n') : '- N/A'}

## References

- Extracted by /extract-knowhow on ${date}
- Source project: ${proj.name}`;

const params = new URLSearchParams({
template: '01-submit-skill.yml',
title: 'Skill Submission: ' + slug,
english_name: authorName,
role: authorRole || '',
affiliation: authorInst || '',
subdomain: subLabel,
category: sk.category + ' — ' + catLabel,
skill_content: skillMd,
generation_method: 'Generated by /extract-knowhow, then reviewed by me',
notes: 'Confidence: ' + sk.confidence
});

return 'https://github.com/OpenScientists/OpenScientist/issues/new?' + params.toString();
}

function openIssue(pi, si){
function openIssue(){
if(!consentGiven){ alert('Please agree to the submission terms first.'); return; }
window.open(buildIssueUrl(pi, si), '_blank');
window.open('https://researchskills.ai/submit', '_blank');
}

function submitAll(){
if(!consentGiven){ alert('Please agree to the submission terms first.'); return; }
let count = 0;
projects.forEach((proj, pi) => {
proj.skills.forEach((sk, si) => {
const id = `sk-${pi}-${si}`;
if(!document.getElementById(id).checked) return;
window.open(buildIssueUrl(pi, si), '_blank');
count++;
if(document.getElementById(`sk-${pi}-${si}`).checked) count++;
});
});
if(count===0){alert('No skills selected.');return}
document.getElementById('submit-msg').textContent = '✓ Opened ' + count + ' GitHub issue tab(s). Review and submit each one.';
window.open('https://researchskills.ai/submit', '_blank');
document.getElementById('submit-msg').textContent = '✓ ' + count + ' skill(s) selected. Submit them at researchskills.ai.';
document.getElementById('output').style.display = 'block';
}
</script>
Expand Down