@aiyiran/myclaw 1.1.201 → 1.1.203
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/assets/myclaw-artifacts.js +316 -9
- package/assets/myclaw-inject.js +110 -9
- package/create_agent.js +15 -11
- package/index.js +8 -0
- package/package.json +1 -1
- package/publish.sh +6 -1
- package/server/sync_workspace.py +12 -5
- package/skills/yiran-playground-template-use/SKILL.md +5 -4
- package/skills/yiran-playground-template-use/prompts/single-html-handoff.txt +23 -0
- package/skills/yiran-playground-template-use/scripts/deploy_to_workspace.py +62 -10
- package/skills/yiran-playground-template-use/scripts/start_tui_handoff.py +22 -4
- package/skills/yiran-course-template-pipeline/README.md +0 -132
- package/skills/yiran-course-template-pipeline/SKILL.md +0 -74
- package/skills/yiran-course-template-pipeline/assets/a100-teacher.example.html +0 -66
- package/skills/yiran-course-template-pipeline/assets/student-template.html +0 -77
- package/skills/yiran-course-template-pipeline/assets/teacher-portrait-demo.html +0 -105
- package/skills/yiran-course-template-pipeline/assets/teacher-task-view.html +0 -110
- package/skills/yiran-course-template-pipeline/prompts//350/257/204/344/273/267/347/202/271/345/255/220.md +0 -107
- package/skills/yiran-course-template-pipeline/prompts//351/230/266/346/256/2651-demo/347/224/237/346/210/220.md +0 -121
- package/skills/yiran-course-template-pipeline/prompts//351/230/266/346/256/2652-student/347/224/237/346/210/220.md +0 -115
- package/skills/yiran-course-template-pipeline/prompts//351/230/266/346/256/2653-teacher/347/224/237/346/210/220.md +0 -144
- package/skills/yiran-course-template-pipeline/prompts//351/230/266/346/256/2654-/346/211/223/345/214/205/350/220/275/347/233/230.md +0 -130
- package/skills/yiran-course-template-pipeline/references/student-example.json +0 -38
- package/skills/yiran-course-template-pipeline/references/student-fields.md +0 -195
- package/skills/yiran-course-template-pipeline/references/student-scaffold.json +0 -34
- package/skills/yiran-course-template-pipeline/references/teacher-fields.md +0 -271
- package/skills/yiran-course-template-pipeline/references/teacher-scaffold.json +0 -25
- package/skills/yiran-course-template-pipeline/scripts/build_template_index.py +0 -150
- package/skills/yiran-course-template-pipeline/scripts/build_template_views.py +0 -132
- package/skills/yiran-course-template-pipeline/scripts/identify_template.py +0 -174
- package/skills/yiran-course-template-pipeline/scripts/migrate_templates.py +0 -104
- package/skills/yiran-course-template-pipeline/scripts/move_template_task.py +0 -107
- package/skills/yiran-course-template-pipeline/scripts/publish_template.py +0 -131
- package/skills/yiran-course-template-pipeline/scripts/release_template.py +0 -84
- package/skills/yiran-course-template-pipeline/scripts/render_student_page.py +0 -66
- package/skills/yiran-course-template-pipeline/scripts/render_teacher_view.py +0 -108
- package/skills/yiran-course-template-pipeline/template-index.json +0 -671
- package/skills/yiran-course-template-pipeline/template-index.md +0 -246
- package/skills/yiran-course-template-pipeline//344/270/232/345/212/241/350/203/214/346/231/257.md +0 -81
- package/skills/yiran-course-template-pipeline//345/272/237/345/274/203/rewrite_html_refs.py +0 -102
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
btn.id = 'myclaw-artifacts-btn';
|
|
106
106
|
btn.style.cssText = [
|
|
107
107
|
'position: fixed',
|
|
108
|
-
'top:
|
|
108
|
+
'top: 0',
|
|
109
109
|
'right: 0',
|
|
110
110
|
'padding: 3px 10px',
|
|
111
111
|
'background: rgba(100, 100, 100, 0.7)',
|
|
@@ -143,19 +143,19 @@
|
|
|
143
143
|
panelVisible = true;
|
|
144
144
|
|
|
145
145
|
var btn = document.querySelector('#myclaw-artifacts-btn');
|
|
146
|
-
if (btn) btn.style.
|
|
146
|
+
if (btn) btn.style.display = 'none';
|
|
147
147
|
|
|
148
148
|
// 面板
|
|
149
149
|
var panel = document.createElement('div');
|
|
150
150
|
panel.id = 'myclaw-artifacts-panel';
|
|
151
151
|
panel.style.cssText = [
|
|
152
152
|
'position: fixed',
|
|
153
|
-
'top:
|
|
153
|
+
'top: 0',
|
|
154
154
|
'right: 0',
|
|
155
155
|
'width: 380px',
|
|
156
|
-
'height:
|
|
156
|
+
'height: calc(100vh - 50px)',
|
|
157
157
|
'background: #1e1e2e',
|
|
158
|
-
'border-radius:
|
|
158
|
+
'border-radius: 0 0 0 8px',
|
|
159
159
|
'overflow: hidden',
|
|
160
160
|
'display: flex',
|
|
161
161
|
'flex-direction: column',
|
|
@@ -314,6 +314,7 @@
|
|
|
314
314
|
panel.appendChild(header);
|
|
315
315
|
panel.appendChild(content);
|
|
316
316
|
panel.appendChild(panelFooter);
|
|
317
|
+
panel.appendChild(createTrainingCard(null));
|
|
317
318
|
document.body.appendChild(panel);
|
|
318
319
|
|
|
319
320
|
// 立即拉一次,后续由轮询更新
|
|
@@ -323,11 +324,20 @@
|
|
|
323
324
|
// ═══ 关闭右侧面板 ═══
|
|
324
325
|
function closeArtifactsPanel() {
|
|
325
326
|
var panel = document.querySelector('#myclaw-artifacts-panel');
|
|
326
|
-
if (panel)
|
|
327
|
+
if (panel) {
|
|
328
|
+
var trainingCard = panel.querySelector('.myclaw-training-card');
|
|
329
|
+
if (trainingCard && typeof trainingCard._destroyVoiceInputs === 'function') {
|
|
330
|
+
try { trainingCard._destroyVoiceInputs(); } catch (e) {}
|
|
331
|
+
}
|
|
332
|
+
panel.remove();
|
|
333
|
+
}
|
|
327
334
|
panelVisible = false;
|
|
328
335
|
|
|
329
336
|
var btn = document.querySelector('#myclaw-artifacts-btn');
|
|
330
|
-
if (btn)
|
|
337
|
+
if (btn) {
|
|
338
|
+
btn.style.display = '';
|
|
339
|
+
btn.style.background = 'rgba(100, 100, 100, 0.7)';
|
|
340
|
+
}
|
|
331
341
|
}
|
|
332
342
|
|
|
333
343
|
// ═══ 请求数据 ═══
|
|
@@ -674,6 +684,246 @@
|
|
|
674
684
|
return asset.type && IMAGE_TYPES.indexOf(asset.type.toLowerCase()) !== -1;
|
|
675
685
|
}
|
|
676
686
|
|
|
687
|
+
var TRAINING_CARD_STORAGE_PREFIX = 'myclaw-training-card-records-v1:';
|
|
688
|
+
var TRAINING_CARD_STORAGE_LIMIT = 200;
|
|
689
|
+
|
|
690
|
+
function buildTrainingCardPrompt(values) {
|
|
691
|
+
return [
|
|
692
|
+
'我当前最想解决的问题是:',
|
|
693
|
+
values.problem,
|
|
694
|
+
'',
|
|
695
|
+
'我想达成的目标是:',
|
|
696
|
+
values.goal,
|
|
697
|
+
'',
|
|
698
|
+
'为了达到这个目标,我选择的方案是:',
|
|
699
|
+
values.plan,
|
|
700
|
+
'',
|
|
701
|
+
'请只围绕这个问题、目标和方案帮助我,不要顺便修改其他内容。'
|
|
702
|
+
].join('\n');
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function createTrainingRecord(asset, values) {
|
|
706
|
+
var now = new Date();
|
|
707
|
+
return {
|
|
708
|
+
version: 1,
|
|
709
|
+
recordId: 'training-' + now.getTime() + '-' + Math.random().toString(36).slice(2, 8),
|
|
710
|
+
submittedAt: now.toISOString(),
|
|
711
|
+
claw: lastKnownClawName || '',
|
|
712
|
+
workspace: getWorkspaceId(),
|
|
713
|
+
studentAgent: getAgentName(),
|
|
714
|
+
asset: asset ? {
|
|
715
|
+
name: asset.name || '',
|
|
716
|
+
path: asset.path || ''
|
|
717
|
+
} : null,
|
|
718
|
+
problem: values.problem,
|
|
719
|
+
goal: values.goal,
|
|
720
|
+
plan: values.plan
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
function archiveTrainingRecordLocally(record) {
|
|
725
|
+
var key = TRAINING_CARD_STORAGE_PREFIX + record.workspace;
|
|
726
|
+
var records = [];
|
|
727
|
+
try {
|
|
728
|
+
var stored = JSON.parse(localStorage.getItem(key) || '[]');
|
|
729
|
+
if (Array.isArray(stored)) records = stored;
|
|
730
|
+
} catch (e) {
|
|
731
|
+
records = [];
|
|
732
|
+
}
|
|
733
|
+
records.push(record);
|
|
734
|
+
if (records.length > TRAINING_CARD_STORAGE_LIMIT) {
|
|
735
|
+
records = records.slice(records.length - TRAINING_CARD_STORAGE_LIMIT);
|
|
736
|
+
}
|
|
737
|
+
localStorage.setItem(key, JSON.stringify(records));
|
|
738
|
+
return record;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function createTrainingCard(asset) {
|
|
742
|
+
var section = document.createElement('section');
|
|
743
|
+
section.className = 'myclaw-training-card';
|
|
744
|
+
var voiceDestroyers = [];
|
|
745
|
+
|
|
746
|
+
var heading = document.createElement('div');
|
|
747
|
+
heading.className = 'myclaw-training-card__heading';
|
|
748
|
+
var headingText = document.createElement('div');
|
|
749
|
+
var title = document.createElement('h2');
|
|
750
|
+
title.textContent = '这一轮想做什么?';
|
|
751
|
+
var intro = document.createElement('p');
|
|
752
|
+
intro.textContent = '三句话就够了,简单写。';
|
|
753
|
+
headingText.appendChild(title);
|
|
754
|
+
headingText.appendChild(intro);
|
|
755
|
+
|
|
756
|
+
var step = document.createElement('div');
|
|
757
|
+
step.className = 'myclaw-training-card__step';
|
|
758
|
+
step.textContent = '问题 → 目标 → 方案';
|
|
759
|
+
heading.appendChild(headingText);
|
|
760
|
+
heading.appendChild(step);
|
|
761
|
+
section.appendChild(heading);
|
|
762
|
+
|
|
763
|
+
var fields = document.createElement('div');
|
|
764
|
+
fields.className = 'myclaw-training-card__fields';
|
|
765
|
+
|
|
766
|
+
function makeField(number, label, prompt, placeholder) {
|
|
767
|
+
var field = document.createElement('label');
|
|
768
|
+
field.className = 'myclaw-training-card__field';
|
|
769
|
+
var fieldTitle = document.createElement('span');
|
|
770
|
+
fieldTitle.className = 'myclaw-training-card__field-title';
|
|
771
|
+
fieldTitle.textContent = number + '、' + label;
|
|
772
|
+
var fieldPrompt = document.createElement('span');
|
|
773
|
+
fieldPrompt.className = 'myclaw-training-card__field-prompt';
|
|
774
|
+
fieldPrompt.textContent = prompt;
|
|
775
|
+
var input = document.createElement('textarea');
|
|
776
|
+
input.rows = 2;
|
|
777
|
+
input.maxLength = 1000;
|
|
778
|
+
input.placeholder = placeholder;
|
|
779
|
+
input.setAttribute('aria-label', label);
|
|
780
|
+
|
|
781
|
+
var inputWrap = document.createElement('span');
|
|
782
|
+
inputWrap.className = 'myclaw-training-card__input-wrap';
|
|
783
|
+
var micBtn = document.createElement('button');
|
|
784
|
+
micBtn.type = 'button';
|
|
785
|
+
micBtn.className = 'myclaw-training-card__mic';
|
|
786
|
+
micBtn.title = '语音输入';
|
|
787
|
+
micBtn.setAttribute('aria-label', label + '语音输入');
|
|
788
|
+
micBtn.innerHTML = [
|
|
789
|
+
'<svg width="14" height="14" viewBox="0 0 24 24" fill="none"',
|
|
790
|
+
' stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">',
|
|
791
|
+
' <path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/>',
|
|
792
|
+
' <path d="M19 10v2a7 7 0 0 1-14 0v-2"/>',
|
|
793
|
+
' <line x1="12" x2="12" y1="19" y2="22"/>',
|
|
794
|
+
'</svg>'
|
|
795
|
+
].join('');
|
|
796
|
+
inputWrap.appendChild(input);
|
|
797
|
+
inputWrap.appendChild(micBtn);
|
|
798
|
+
field.appendChild(fieldTitle);
|
|
799
|
+
field.appendChild(fieldPrompt);
|
|
800
|
+
field.appendChild(inputWrap);
|
|
801
|
+
fields.appendChild(field);
|
|
802
|
+
|
|
803
|
+
if (typeof window.myclawBindVoiceInput === 'function') {
|
|
804
|
+
voiceDestroyers.push(window.myclawBindVoiceInput(input, micBtn));
|
|
805
|
+
} else {
|
|
806
|
+
micBtn.disabled = true;
|
|
807
|
+
micBtn.title = '语音输入暂不可用,请刷新页面';
|
|
808
|
+
}
|
|
809
|
+
return input;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
var problemInput = makeField(
|
|
813
|
+
'1', '问题',
|
|
814
|
+
'这一轮,我当前最想解决的问题是什么?',
|
|
815
|
+
'现在最想解决什么?'
|
|
816
|
+
);
|
|
817
|
+
var goalInput = makeField(
|
|
818
|
+
'2', '目标',
|
|
819
|
+
'我想让它变成什么样?做到什么样才算解决?',
|
|
820
|
+
'做到什么样就算解决?'
|
|
821
|
+
);
|
|
822
|
+
var planInput = makeField(
|
|
823
|
+
'3', '方案',
|
|
824
|
+
'为了达到这个目标,我选择哪个方案?',
|
|
825
|
+
'这一轮准备选哪个方案?'
|
|
826
|
+
);
|
|
827
|
+
section.appendChild(fields);
|
|
828
|
+
|
|
829
|
+
var footer = document.createElement('div');
|
|
830
|
+
footer.className = 'myclaw-training-card__footer';
|
|
831
|
+
var status = document.createElement('div');
|
|
832
|
+
status.className = 'myclaw-training-card__status';
|
|
833
|
+
status.setAttribute('role', 'status');
|
|
834
|
+
status.setAttribute('aria-live', 'polite');
|
|
835
|
+
var actions = document.createElement('div');
|
|
836
|
+
actions.className = 'myclaw-training-card__actions';
|
|
837
|
+
var aiBtn = document.createElement('button');
|
|
838
|
+
aiBtn.type = 'button';
|
|
839
|
+
aiBtn.className = 'myclaw-training-card__button myclaw-training-card__button--ai';
|
|
840
|
+
aiBtn.textContent = '提交 AI';
|
|
841
|
+
var teacherBtn = document.createElement('button');
|
|
842
|
+
teacherBtn.type = 'button';
|
|
843
|
+
teacherBtn.className = 'myclaw-training-card__button myclaw-training-card__button--teacher';
|
|
844
|
+
teacherBtn.textContent = '提交老师';
|
|
845
|
+
actions.appendChild(aiBtn);
|
|
846
|
+
actions.appendChild(teacherBtn);
|
|
847
|
+
footer.appendChild(status);
|
|
848
|
+
footer.appendChild(actions);
|
|
849
|
+
section.appendChild(footer);
|
|
850
|
+
|
|
851
|
+
var lastTeacherFingerprint = '';
|
|
852
|
+
|
|
853
|
+
function readValues() {
|
|
854
|
+
return {
|
|
855
|
+
problem: problemInput.value.trim(),
|
|
856
|
+
goal: goalInput.value.trim(),
|
|
857
|
+
plan: planInput.value.trim()
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
function validate(values) {
|
|
862
|
+
var missing = [];
|
|
863
|
+
if (!values.problem) missing.push('问题');
|
|
864
|
+
if (!values.goal) missing.push('目标');
|
|
865
|
+
if (!values.plan) missing.push('方案');
|
|
866
|
+
if (missing.length) {
|
|
867
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--error';
|
|
868
|
+
status.textContent = '请先填写:' + missing.join('、');
|
|
869
|
+
return false;
|
|
870
|
+
}
|
|
871
|
+
return true;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
aiBtn.addEventListener('click', function () {
|
|
875
|
+
var values = readValues();
|
|
876
|
+
if (!validate(values)) return;
|
|
877
|
+
if (typeof window.myclawSendPrompt !== 'function') {
|
|
878
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--error';
|
|
879
|
+
status.textContent = 'AI 提交功能还没有准备好,请刷新页面后重试。';
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
aiBtn.disabled = true;
|
|
883
|
+
var sent = window.myclawSendPrompt(buildTrainingCardPrompt(values));
|
|
884
|
+
aiBtn.disabled = false;
|
|
885
|
+
if (sent) {
|
|
886
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--success';
|
|
887
|
+
status.textContent = '已提交 AI。可以关闭作品窗口查看回复。';
|
|
888
|
+
} else {
|
|
889
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--error';
|
|
890
|
+
status.textContent = '暂时无法发送。请确认 AI 没有正在回复,然后重试。';
|
|
891
|
+
}
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
teacherBtn.addEventListener('click', function () {
|
|
895
|
+
var values = readValues();
|
|
896
|
+
if (!validate(values)) return;
|
|
897
|
+
var fingerprint = [values.problem, values.goal, values.plan].join('\n---\n');
|
|
898
|
+
if (fingerprint === lastTeacherFingerprint) {
|
|
899
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--success';
|
|
900
|
+
status.textContent = '这份内容已经提交老师。';
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
teacherBtn.disabled = true;
|
|
904
|
+
try {
|
|
905
|
+
var record = createTrainingRecord(asset, values);
|
|
906
|
+
archiveTrainingRecordLocally(record);
|
|
907
|
+
lastTeacherFingerprint = fingerprint;
|
|
908
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--success';
|
|
909
|
+
status.textContent = '已提交老师,并暂存在这台电脑。';
|
|
910
|
+
} catch (e) {
|
|
911
|
+
console.error('[myclaw-training-card] 本地归档失败:', e);
|
|
912
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--error';
|
|
913
|
+
status.textContent = '提交失败,填写内容仍然保留,请重试。';
|
|
914
|
+
}
|
|
915
|
+
teacherBtn.disabled = false;
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
section._destroyVoiceInputs = function () {
|
|
919
|
+
voiceDestroyers.forEach(function (destroy) {
|
|
920
|
+
try { destroy(); } catch (e) {}
|
|
921
|
+
});
|
|
922
|
+
voiceDestroyers = [];
|
|
923
|
+
};
|
|
924
|
+
return section;
|
|
925
|
+
}
|
|
926
|
+
|
|
677
927
|
function openPreviewModal(data, asset) {
|
|
678
928
|
if (document.querySelector('#myclaw-artifacts-preview')) return;
|
|
679
929
|
|
|
@@ -2905,7 +3155,8 @@
|
|
|
2905
3155
|
|
|
2906
3156
|
rightHeader.appendChild(infoSpan);
|
|
2907
3157
|
rightHeader.appendChild(openNewBtn);
|
|
2908
|
-
|
|
3158
|
+
var previewFile = tpl['预览文件'] || (tpl['模板格式'] === 'single-html' ? 'index.html' : '__student-view__.html');
|
|
3159
|
+
previewIframe.src = TEMPLATE_CDN_BASE + '/' + encodeURIComponent(tpl['文件夹名']) + '/' + (tpl['version'] || 'v1') + '/' + encodeURIComponent(previewFile);
|
|
2909
3160
|
}
|
|
2910
3161
|
|
|
2911
3162
|
row.onclick = setActive;
|
|
@@ -3073,6 +3324,61 @@
|
|
|
3073
3324
|
' from { transform: rotate(0deg); }',
|
|
3074
3325
|
' to { transform: rotate(360deg); }',
|
|
3075
3326
|
'}',
|
|
3327
|
+
'.myclaw-training-card {',
|
|
3328
|
+
' box-sizing: border-box; width: 100%; padding: 10px 12px;',
|
|
3329
|
+
' color: #e5e7eb; background: #191927; border-top: 1px solid #35354d;',
|
|
3330
|
+
' font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;',
|
|
3331
|
+
'}',
|
|
3332
|
+
'#myclaw-artifacts-panel > .myclaw-training-card { flex-shrink: 0; }',
|
|
3333
|
+
'.myclaw-training-card__heading {',
|
|
3334
|
+
' margin: 0 0 8px; display: flex; align-items: baseline; gap: 9px;',
|
|
3335
|
+
'}',
|
|
3336
|
+
'.myclaw-training-card__heading h2 { margin: 0; font-size: 15px; line-height: 1.2; color: #f4f4f5; }',
|
|
3337
|
+
'.myclaw-training-card__heading p { margin: 0; font-size: 11px; color: #8f90a5; }',
|
|
3338
|
+
'.myclaw-training-card__step { display: none; }',
|
|
3339
|
+
'.myclaw-training-card__fields {',
|
|
3340
|
+
' display: grid; grid-template-columns: 1fr; gap: 6px;',
|
|
3341
|
+
'}',
|
|
3342
|
+
'.myclaw-training-card__field {',
|
|
3343
|
+
' min-width: 0; display: grid; grid-template-columns: 58px minmax(0, 1fr);',
|
|
3344
|
+
' align-items: center; gap: 8px;',
|
|
3345
|
+
'}',
|
|
3346
|
+
'.myclaw-training-card__field-title { font-size: 12px; font-weight: 700; color: #c9c9d7; }',
|
|
3347
|
+
'.myclaw-training-card__field-prompt { display: none; }',
|
|
3348
|
+
'.myclaw-training-card__input-wrap {',
|
|
3349
|
+
' min-width: 0; display: flex; align-items: center; gap: 6px;',
|
|
3350
|
+
'}',
|
|
3351
|
+
'.myclaw-training-card__field textarea {',
|
|
3352
|
+
' box-sizing: border-box; flex: 1; min-width: 0; width: auto; height: 52px; min-height: 52px; max-height: 76px;',
|
|
3353
|
+
' resize: vertical; padding: 7px 9px; border: 1px solid #3d3d55; border-radius: 7px;',
|
|
3354
|
+
' outline: none; color: #f4f4f5; background: #232334;',
|
|
3355
|
+
' font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;',
|
|
3356
|
+
'}',
|
|
3357
|
+
'.myclaw-training-card__field textarea::placeholder { color: #77788d; }',
|
|
3358
|
+
'.myclaw-training-card__field textarea:focus { border-color: #8b5cf6; background: #27273a; }',
|
|
3359
|
+
'.myclaw-training-card__mic {',
|
|
3360
|
+
' width: 32px; height: 32px; flex: 0 0 32px; padding: 0; border-radius: 50%;',
|
|
3361
|
+
' border: 1px solid #45455f; background: #232334; color: #9a9bad; cursor: pointer;',
|
|
3362
|
+
' display: inline-flex; align-items: center; justify-content: center; transition: all .15s ease;',
|
|
3363
|
+
'}',
|
|
3364
|
+
'.myclaw-training-card__mic:hover { color: #ddd6fe; border-color: #7c3aed; background: #292940; }',
|
|
3365
|
+
'.myclaw-training-card__mic:disabled { cursor: not-allowed; opacity: .4; }',
|
|
3366
|
+
'.myclaw-training-card__footer {',
|
|
3367
|
+
' margin: 8px 0 0; display: flex; flex-direction: column; gap: 5px;',
|
|
3368
|
+
'}',
|
|
3369
|
+
'.myclaw-training-card__status { min-height: 15px; color: #9ca3af; font-size: 11px; }',
|
|
3370
|
+
'.myclaw-training-card__status--success { color: #6ee7b7; }',
|
|
3371
|
+
'.myclaw-training-card__status--error { color: #fca5a5; }',
|
|
3372
|
+
'.myclaw-training-card__actions { display: flex; gap: 8px; width: 100%; }',
|
|
3373
|
+
'.myclaw-training-card__button {',
|
|
3374
|
+
' flex: 1; min-width: 0; padding: 7px 10px; border: 0; border-radius: 7px; cursor: pointer;',
|
|
3375
|
+
' color: #fff; font-size: 12px; font-weight: 700;',
|
|
3376
|
+
' transition: transform .15s ease, opacity .15s ease, filter .15s ease;',
|
|
3377
|
+
'}',
|
|
3378
|
+
'.myclaw-training-card__button:hover { transform: translateY(-1px); filter: brightness(1.08); }',
|
|
3379
|
+
'.myclaw-training-card__button:disabled { cursor: wait; opacity: .55; transform: none; }',
|
|
3380
|
+
'.myclaw-training-card__button--ai { background: #7c3aed; }',
|
|
3381
|
+
'.myclaw-training-card__button--teacher { background: #2563eb; }',
|
|
3076
3382
|
].join('\n');
|
|
3077
3383
|
document.head.appendChild(style);
|
|
3078
3384
|
}
|
|
@@ -3082,8 +3388,9 @@
|
|
|
3082
3388
|
injectStyles();
|
|
3083
3389
|
createArtifactsButton();
|
|
3084
3390
|
var templateFloatBtn = document.createElement('div');
|
|
3391
|
+
templateFloatBtn.id = 'myclaw-template-btn';
|
|
3085
3392
|
templateFloatBtn.textContent = '📋 模板';
|
|
3086
|
-
templateFloatBtn.style.cssText = 'position:fixed;right:
|
|
3393
|
+
templateFloatBtn.style.cssText = 'position:fixed;right:5px;bottom:8px;z-index:99999;cursor:pointer;padding:3px 10px;border-radius:4px;font-size:11px;font-weight:bold;font-family:monospace;color:#cdd6f4;background:rgba(37,37,54,0.92);border:1px solid #3d3d5c;text-align:center;transition:all 0.2s;letter-spacing:0.5px;';
|
|
3087
3394
|
templateFloatBtn.onmouseenter = function () { templateFloatBtn.style.background = 'rgba(255,255,255,0.14)'; };
|
|
3088
3395
|
templateFloatBtn.onmouseleave = function () { templateFloatBtn.style.background = 'rgba(37,37,54,0.92)'; };
|
|
3089
3396
|
templateFloatBtn.onclick = function () { openTemplateModal(); };
|
package/assets/myclaw-inject.js
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
var suppressNextClipboardCopy = false;
|
|
32
32
|
var VOICE_STOP_WAIT_MS = 1500;
|
|
33
33
|
var VOICE_STOP_WAIT_SECONDS = VOICE_STOP_WAIT_MS / 1000;
|
|
34
|
+
var activeBoundVoiceStop = null;
|
|
34
35
|
|
|
35
36
|
// ═══ 1. 右下角版本入口(打开快捷命令) ═══
|
|
36
37
|
function createVersionBar() {
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
bar.style.cssText = [
|
|
42
43
|
"position: fixed",
|
|
43
44
|
"bottom: 8px",
|
|
44
|
-
"right:
|
|
45
|
+
"right: 75px",
|
|
45
46
|
"padding: 3px 10px",
|
|
46
47
|
"background: rgba(59, 130, 246, 0.85)",
|
|
47
48
|
"color: #fff",
|
|
@@ -85,7 +86,7 @@
|
|
|
85
86
|
btn.style.cssText = [
|
|
86
87
|
"position: fixed",
|
|
87
88
|
"bottom: 8px",
|
|
88
|
-
"right:
|
|
89
|
+
"right: 175px",
|
|
89
90
|
"padding: 3px 10px",
|
|
90
91
|
"background: rgba(120, 120, 120, 0.18)",
|
|
91
92
|
"color: rgba(170, 170, 170, 0.9)",
|
|
@@ -235,24 +236,32 @@
|
|
|
235
236
|
*/
|
|
236
237
|
function setTextareaValue(fullText) {
|
|
237
238
|
var ta = document.querySelector(".agent-chat__input textarea");
|
|
238
|
-
if (!ta) return;
|
|
239
|
+
if (!ta) return false;
|
|
239
240
|
|
|
240
241
|
var setter = Object.getOwnPropertyDescriptor(
|
|
241
242
|
HTMLTextAreaElement.prototype, "value"
|
|
242
243
|
).set;
|
|
243
244
|
setter.call(ta, fullText);
|
|
244
245
|
ta.dispatchEvent(new Event("input", { bubbles: true }));
|
|
246
|
+
return true;
|
|
245
247
|
}
|
|
246
248
|
|
|
247
249
|
function sendGeneratedPrompt(text) {
|
|
250
|
+
if (!setTextareaValue(text)) {
|
|
251
|
+
console.warn("[myclaw-send] 找不到聊天输入框");
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
248
254
|
suppressNextClipboardCopy = true;
|
|
249
|
-
|
|
250
|
-
trySend();
|
|
255
|
+
var sent = trySend();
|
|
251
256
|
setTimeout(function () {
|
|
252
257
|
suppressNextClipboardCopy = false;
|
|
253
258
|
}, 3000);
|
|
259
|
+
return sent;
|
|
254
260
|
}
|
|
255
261
|
|
|
262
|
+
// 给其他 MyClaw 前端模块复用统一的聊天发送能力。
|
|
263
|
+
window.myclawSendPrompt = sendGeneratedPrompt;
|
|
264
|
+
|
|
256
265
|
/**
|
|
257
266
|
* 获取 textarea 当前值
|
|
258
267
|
*/
|
|
@@ -524,6 +533,97 @@
|
|
|
524
533
|
};
|
|
525
534
|
}
|
|
526
535
|
|
|
536
|
+
// 为其他 MyClaw 模块已有的 textarea 绑定一枚独立语音按钮。
|
|
537
|
+
function bindVoiceInput(input, micBtn) {
|
|
538
|
+
if (!input || !micBtn) return function () {};
|
|
539
|
+
|
|
540
|
+
var localVoice = null;
|
|
541
|
+
var localRecording = false;
|
|
542
|
+
var localStopping = false;
|
|
543
|
+
|
|
544
|
+
function setMicUI(isRecording) {
|
|
545
|
+
if (isRecording) {
|
|
546
|
+
micBtn.style.background = "#ef4444";
|
|
547
|
+
micBtn.style.borderColor = "#ef4444";
|
|
548
|
+
micBtn.style.color = "#fff";
|
|
549
|
+
micBtn.title = "停止录音";
|
|
550
|
+
input.style.borderColor = "#ef4444";
|
|
551
|
+
} else {
|
|
552
|
+
micBtn.style.background = "#232334";
|
|
553
|
+
micBtn.style.borderColor = "#45455f";
|
|
554
|
+
micBtn.style.color = "#9a9bad";
|
|
555
|
+
micBtn.title = "语音输入";
|
|
556
|
+
input.style.borderColor = "";
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function initVoiceForField() {
|
|
561
|
+
if (typeof window.VoiceInput === "undefined") return false;
|
|
562
|
+
localVoice = new window.VoiceInput({
|
|
563
|
+
onResult: function (text) {
|
|
564
|
+
if (!localRecording && !localStopping) return;
|
|
565
|
+
input.value = String(text || "").slice(0, input.maxLength || 1000);
|
|
566
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
567
|
+
},
|
|
568
|
+
onStatusChange: function (oldStatus, newStatus) {
|
|
569
|
+
if (newStatus === "idle" && localRecording && !localStopping) {
|
|
570
|
+
setTimeout(function () {
|
|
571
|
+
if (localRecording && localVoice) localVoice.start();
|
|
572
|
+
}, 300);
|
|
573
|
+
}
|
|
574
|
+
},
|
|
575
|
+
onError: function (err) {
|
|
576
|
+
console.error("[myclaw-training-card] voice error:", err);
|
|
577
|
+
localRecording = false;
|
|
578
|
+
localStopping = false;
|
|
579
|
+
if (activeBoundVoiceStop === stopVoiceForField) activeBoundVoiceStop = null;
|
|
580
|
+
setMicUI(false);
|
|
581
|
+
},
|
|
582
|
+
});
|
|
583
|
+
return true;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function startVoiceForField() {
|
|
587
|
+
if (!localVoice && !initVoiceForField()) {
|
|
588
|
+
console.warn("[myclaw-training-card] VoiceInput SDK 未加载");
|
|
589
|
+
micBtn.title = "语音输入暂不可用";
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
if (activeBoundVoiceStop && activeBoundVoiceStop !== stopVoiceForField) {
|
|
593
|
+
activeBoundVoiceStop();
|
|
594
|
+
}
|
|
595
|
+
activeBoundVoiceStop = stopVoiceForField;
|
|
596
|
+
localStopping = false;
|
|
597
|
+
localRecording = true;
|
|
598
|
+
setMicUI(true);
|
|
599
|
+
localVoice.start();
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function stopVoiceForField() {
|
|
603
|
+
if (!localRecording && !localStopping) return;
|
|
604
|
+
localStopping = true;
|
|
605
|
+
localRecording = false;
|
|
606
|
+
setMicUI(false);
|
|
607
|
+
setTimeout(function () {
|
|
608
|
+
localStopping = false;
|
|
609
|
+
if (localVoice) localVoice.stop();
|
|
610
|
+
if (activeBoundVoiceStop === stopVoiceForField) activeBoundVoiceStop = null;
|
|
611
|
+
}, VOICE_STOP_WAIT_MS);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
micBtn.addEventListener("click", function () {
|
|
615
|
+
if (localRecording) stopVoiceForField();
|
|
616
|
+
else if (!localStopping) startVoiceForField();
|
|
617
|
+
});
|
|
618
|
+
setMicUI(false);
|
|
619
|
+
|
|
620
|
+
return function destroyVoiceBinding() {
|
|
621
|
+
stopVoiceForField();
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
window.myclawBindVoiceInput = bindVoiceInput;
|
|
626
|
+
|
|
527
627
|
function showDebugModal() {
|
|
528
628
|
if (document.getElementById("myclaw-debug-modal")) return;
|
|
529
629
|
|
|
@@ -1207,13 +1307,14 @@ btn.addEventListener("click", function () {
|
|
|
1207
1307
|
var btn = document.querySelector("button.chat-send-btn");
|
|
1208
1308
|
if (!btn) {
|
|
1209
1309
|
console.log("[myclaw-send] 找不到发送按钮");
|
|
1210
|
-
return;
|
|
1310
|
+
return false;
|
|
1211
1311
|
}
|
|
1212
1312
|
if (btn.classList.contains("chat-send-btn--stop")) {
|
|
1213
1313
|
console.log("[myclaw-send] AI 生成中,禁止发送");
|
|
1214
|
-
return;
|
|
1314
|
+
return false;
|
|
1215
1315
|
}
|
|
1216
1316
|
btn.click();
|
|
1317
|
+
return true;
|
|
1217
1318
|
}
|
|
1218
1319
|
|
|
1219
1320
|
/**
|
|
@@ -1769,7 +1870,7 @@ btn.addEventListener("click", function () {
|
|
|
1769
1870
|
btn.style.cssText = [
|
|
1770
1871
|
"position: fixed",
|
|
1771
1872
|
"bottom: 8px",
|
|
1772
|
-
"right:
|
|
1873
|
+
"right: 260px",
|
|
1773
1874
|
"padding: 3px 10px",
|
|
1774
1875
|
"background: rgba(139, 92, 246, 0.85)",
|
|
1775
1876
|
"color: #fff",
|
|
@@ -1804,7 +1905,7 @@ btn.addEventListener("click", function () {
|
|
|
1804
1905
|
btn.style.cssText = [
|
|
1805
1906
|
"position: fixed",
|
|
1806
1907
|
"bottom: 8px",
|
|
1807
|
-
"right:
|
|
1908
|
+
"right: 355px",
|
|
1808
1909
|
"padding: 3px 10px",
|
|
1809
1910
|
"background: rgba(59, 130, 246, 0.85)",
|
|
1810
1911
|
"color: #fff",
|
package/create_agent.js
CHANGED
|
@@ -278,20 +278,23 @@ function createAgent(rawName, opts) {
|
|
|
278
278
|
fail('配置文件写入失败: ' + err.message + '\n备份文件: ' + normalizePath(backupPath));
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
//
|
|
281
|
+
// 发送首条消息:普通 mc new 保持生日初始化逻辑;
|
|
282
|
+
// 模板部署可传 skipFirstMessage,等文件就绪后再发模板提示词。
|
|
282
283
|
const birthMessage = opts.firstMessage || buildBirthMessage();
|
|
283
284
|
let firstMessageSent = false;
|
|
284
285
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
286
|
+
if (!opts.skipFirstMessage) {
|
|
287
|
+
try {
|
|
288
|
+
const { spawn } = require('child_process');
|
|
289
|
+
spawn('openclaw', ['agent', '--agent', agentId, '--message', birthMessage, '--json'], {
|
|
290
|
+
detached: true,
|
|
291
|
+
stdio: 'ignore',
|
|
292
|
+
shell: true,
|
|
293
|
+
}).unref();
|
|
294
|
+
firstMessageSent = true;
|
|
295
|
+
} catch (err) {
|
|
296
|
+
firstMessageSent = false;
|
|
297
|
+
}
|
|
295
298
|
}
|
|
296
299
|
|
|
297
300
|
// 返回结果
|
|
@@ -305,6 +308,7 @@ function createAgent(rawName, opts) {
|
|
|
305
308
|
configBackup: normalizePath(backupPath),
|
|
306
309
|
birthMessage: birthMessage,
|
|
307
310
|
firstMessageSent: firstMessageSent,
|
|
311
|
+
firstMessageSkipped: !!opts.skipFirstMessage,
|
|
308
312
|
};
|
|
309
313
|
}
|
|
310
314
|
|
package/index.js
CHANGED
|
@@ -319,9 +319,16 @@ function runNew() {
|
|
|
319
319
|
// mc new → 交互输入名字
|
|
320
320
|
// mc new <name> → 直接使用传入的名字
|
|
321
321
|
// mc new <name> --first-message "..." → 自定义首条消息
|
|
322
|
+
// mc new <name> --no-first-message → 仅创建,不发送首条消息(供模板部署使用)
|
|
322
323
|
const rawName = args[1];
|
|
323
324
|
const firstMessageIdx = args.indexOf('--first-message');
|
|
324
325
|
const customFirstMessage = firstMessageIdx !== -1 ? args[firstMessageIdx + 1] : null;
|
|
326
|
+
const skipFirstMessage = args.includes('--no-first-message');
|
|
327
|
+
|
|
328
|
+
if (customFirstMessage && skipFirstMessage) {
|
|
329
|
+
console.error(R + '--first-message 和 --no-first-message 不能同时使用。' + NC);
|
|
330
|
+
process.exit(1);
|
|
331
|
+
}
|
|
325
332
|
|
|
326
333
|
if (rawName) {
|
|
327
334
|
doCreate(rawName);
|
|
@@ -402,6 +409,7 @@ function runNew() {
|
|
|
402
409
|
var result;
|
|
403
410
|
try {
|
|
404
411
|
const createOpts = customFirstMessage ? { firstMessage: customFirstMessage } : {};
|
|
412
|
+
createOpts.skipFirstMessage = skipFirstMessage;
|
|
405
413
|
createOpts.agentId = agentId;
|
|
406
414
|
createOpts.displayName = displayName;
|
|
407
415
|
result = require('./create_agent').createAgent(input, createOpts);
|
package/package.json
CHANGED
package/publish.sh
CHANGED
|
@@ -28,7 +28,12 @@ fi
|
|
|
28
28
|
|
|
29
29
|
# 3. 自动更新最小版本号 (npm version patch 会自动再做一个改 package.json 的 commit 并且打上 Tag)
|
|
30
30
|
echo "📈 增加 Patch 版本号..."
|
|
31
|
-
|
|
31
|
+
if [ "$GIT_MODE" = true ]; then
|
|
32
|
+
npm version patch
|
|
33
|
+
else
|
|
34
|
+
# 普通发布不提交、不打 Git Tag,也允许当前工作区保留待提交修改。
|
|
35
|
+
npm version patch --no-git-tag-version
|
|
36
|
+
fi
|
|
32
37
|
|
|
33
38
|
# 4. 发布到 npm
|
|
34
39
|
echo "🚀 优先发布到 npm 仓库..."
|