@aiyiran/myclaw 1.1.203 → 1.1.205
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 +341 -104
- package/package.json +1 -1
|
@@ -311,9 +311,12 @@
|
|
|
311
311
|
panelFooter.appendChild(historyFooterBtn);
|
|
312
312
|
panelFooter.appendChild(forkPanelBtn);
|
|
313
313
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
314
|
+
var workSection = document.createElement('section');
|
|
315
|
+
workSection.className = 'myclaw-artifacts-work-section';
|
|
316
|
+
workSection.appendChild(header);
|
|
317
|
+
workSection.appendChild(content);
|
|
318
|
+
workSection.appendChild(panelFooter);
|
|
319
|
+
panel.appendChild(workSection);
|
|
317
320
|
panel.appendChild(createTrainingCard(null));
|
|
318
321
|
document.body.appendChild(panel);
|
|
319
322
|
|
|
@@ -688,18 +691,17 @@
|
|
|
688
691
|
var TRAINING_CARD_STORAGE_LIMIT = 200;
|
|
689
692
|
|
|
690
693
|
function buildTrainingCardPrompt(values) {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
''
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
].join('\n');
|
|
694
|
+
var sections = [];
|
|
695
|
+
function addSection(title, value) {
|
|
696
|
+
if (!value) return;
|
|
697
|
+
sections.push(title, value, '');
|
|
698
|
+
}
|
|
699
|
+
addSection('我最想解决的一个问题是:', values.problem);
|
|
700
|
+
addSection('我想在 10 分钟后达成的目标是:', values.goal);
|
|
701
|
+
addSection('我选择的方案是:', values.plan);
|
|
702
|
+
addSection('我验收的结果是:', values.acceptance);
|
|
703
|
+
sections.push('请只围绕我填写的内容帮助我,不要顺便修改其他内容。');
|
|
704
|
+
return sections.join('\n');
|
|
703
705
|
}
|
|
704
706
|
|
|
705
707
|
function createTrainingRecord(asset, values) {
|
|
@@ -717,12 +719,15 @@
|
|
|
717
719
|
} : null,
|
|
718
720
|
problem: values.problem,
|
|
719
721
|
goal: values.goal,
|
|
720
|
-
plan: values.plan
|
|
722
|
+
plan: values.plan,
|
|
723
|
+
acceptance: values.acceptance,
|
|
724
|
+
acceptanceChoice: values.acceptanceChoice,
|
|
725
|
+
acceptanceNote: values.acceptanceNote
|
|
721
726
|
};
|
|
722
727
|
}
|
|
723
728
|
|
|
724
|
-
function
|
|
725
|
-
var key = TRAINING_CARD_STORAGE_PREFIX +
|
|
729
|
+
function loadTrainingRecords(workspace) {
|
|
730
|
+
var key = TRAINING_CARD_STORAGE_PREFIX + workspace;
|
|
726
731
|
var records = [];
|
|
727
732
|
try {
|
|
728
733
|
var stored = JSON.parse(localStorage.getItem(key) || '[]');
|
|
@@ -730,12 +735,69 @@
|
|
|
730
735
|
} catch (e) {
|
|
731
736
|
records = [];
|
|
732
737
|
}
|
|
733
|
-
records
|
|
738
|
+
return records;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function saveTrainingRecordLocally(asset, values, recordId) {
|
|
742
|
+
var workspace = getWorkspaceId();
|
|
743
|
+
var key = TRAINING_CARD_STORAGE_PREFIX + workspace;
|
|
744
|
+
var records = loadTrainingRecords(workspace);
|
|
745
|
+
var recordIndex = -1;
|
|
746
|
+
if (recordId) {
|
|
747
|
+
recordIndex = records.findIndex(function (item) {
|
|
748
|
+
return item && item.recordId === recordId;
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
var isUpdate = recordIndex !== -1;
|
|
753
|
+
var record;
|
|
754
|
+
if (isUpdate) {
|
|
755
|
+
record = Object.assign({}, records[recordIndex], {
|
|
756
|
+
updatedAt: new Date().toISOString(),
|
|
757
|
+
claw: lastKnownClawName || '',
|
|
758
|
+
studentAgent: getAgentName(),
|
|
759
|
+
asset: asset ? {
|
|
760
|
+
name: asset.name || '',
|
|
761
|
+
path: asset.path || ''
|
|
762
|
+
} : null,
|
|
763
|
+
problem: values.problem,
|
|
764
|
+
goal: values.goal,
|
|
765
|
+
plan: values.plan,
|
|
766
|
+
acceptance: values.acceptance,
|
|
767
|
+
acceptanceChoice: values.acceptanceChoice,
|
|
768
|
+
acceptanceNote: values.acceptanceNote
|
|
769
|
+
});
|
|
770
|
+
records[recordIndex] = record;
|
|
771
|
+
} else {
|
|
772
|
+
record = createTrainingRecord(asset, values);
|
|
773
|
+
records.push(record);
|
|
774
|
+
recordIndex = records.length - 1;
|
|
775
|
+
}
|
|
776
|
+
|
|
734
777
|
if (records.length > TRAINING_CARD_STORAGE_LIMIT) {
|
|
735
778
|
records = records.slice(records.length - TRAINING_CARD_STORAGE_LIMIT);
|
|
779
|
+
recordIndex = records.findIndex(function (item) {
|
|
780
|
+
return item && item.recordId === record.recordId;
|
|
781
|
+
});
|
|
736
782
|
}
|
|
737
783
|
localStorage.setItem(key, JSON.stringify(records));
|
|
738
|
-
return
|
|
784
|
+
return {
|
|
785
|
+
record: record,
|
|
786
|
+
index: recordIndex,
|
|
787
|
+
isUpdate: isUpdate
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
function formatTrainingCardNumber(index) {
|
|
792
|
+
var number = index + 1;
|
|
793
|
+
var digits = ['', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
|
|
794
|
+
if (number <= 9) return digits[number];
|
|
795
|
+
if (number === 10) return '十';
|
|
796
|
+
if (number < 20) return '十' + digits[number % 10];
|
|
797
|
+
if (number < 100) {
|
|
798
|
+
return digits[Math.floor(number / 10)] + '十' + digits[number % 10];
|
|
799
|
+
}
|
|
800
|
+
return String(number);
|
|
739
801
|
}
|
|
740
802
|
|
|
741
803
|
function createTrainingCard(asset) {
|
|
@@ -743,39 +805,31 @@
|
|
|
743
805
|
section.className = 'myclaw-training-card';
|
|
744
806
|
var voiceDestroyers = [];
|
|
745
807
|
|
|
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
808
|
var fields = document.createElement('div');
|
|
764
809
|
fields.className = 'myclaw-training-card__fields';
|
|
765
810
|
|
|
766
|
-
function makeField(number, label, prompt,
|
|
811
|
+
function makeField(number, label, prompt, hints, target) {
|
|
767
812
|
var field = document.createElement('label');
|
|
768
813
|
field.className = 'myclaw-training-card__field';
|
|
814
|
+
var fieldHeader = document.createElement('span');
|
|
815
|
+
fieldHeader.className = 'myclaw-training-card__field-header';
|
|
769
816
|
var fieldTitle = document.createElement('span');
|
|
770
817
|
fieldTitle.className = 'myclaw-training-card__field-title';
|
|
771
|
-
fieldTitle.textContent = number + '、' +
|
|
772
|
-
var
|
|
773
|
-
|
|
774
|
-
|
|
818
|
+
fieldTitle.textContent = number + '、' + prompt;
|
|
819
|
+
var hintRow = null;
|
|
820
|
+
if (hints && hints.length) {
|
|
821
|
+
hintRow = document.createElement('span');
|
|
822
|
+
hintRow.className = 'myclaw-training-card__hints';
|
|
823
|
+
hints.forEach(function (hint) {
|
|
824
|
+
var hintTag = document.createElement('span');
|
|
825
|
+
hintTag.className = 'myclaw-training-card__hint';
|
|
826
|
+
hintTag.textContent = hint;
|
|
827
|
+
hintRow.appendChild(hintTag);
|
|
828
|
+
});
|
|
829
|
+
}
|
|
775
830
|
var input = document.createElement('textarea');
|
|
776
831
|
input.rows = 2;
|
|
777
832
|
input.maxLength = 1000;
|
|
778
|
-
input.placeholder = placeholder;
|
|
779
833
|
input.setAttribute('aria-label', label);
|
|
780
834
|
|
|
781
835
|
var inputWrap = document.createElement('span');
|
|
@@ -795,10 +849,11 @@
|
|
|
795
849
|
].join('');
|
|
796
850
|
inputWrap.appendChild(input);
|
|
797
851
|
inputWrap.appendChild(micBtn);
|
|
798
|
-
|
|
799
|
-
|
|
852
|
+
fieldHeader.appendChild(fieldTitle);
|
|
853
|
+
if (hintRow) fieldHeader.appendChild(hintRow);
|
|
854
|
+
field.appendChild(fieldHeader);
|
|
800
855
|
field.appendChild(inputWrap);
|
|
801
|
-
fields.appendChild(field);
|
|
856
|
+
(target || fields).appendChild(field);
|
|
802
857
|
|
|
803
858
|
if (typeof window.myclawBindVoiceInput === 'function') {
|
|
804
859
|
voiceDestroyers.push(window.myclawBindVoiceInput(input, micBtn));
|
|
@@ -811,58 +866,106 @@
|
|
|
811
866
|
|
|
812
867
|
var problemInput = makeField(
|
|
813
868
|
'1', '问题',
|
|
814
|
-
'
|
|
815
|
-
'
|
|
869
|
+
'我最想解决的一个问题是:',
|
|
870
|
+
['一个', '具体', '够小']
|
|
816
871
|
);
|
|
817
872
|
var goalInput = makeField(
|
|
818
873
|
'2', '目标',
|
|
819
|
-
'
|
|
820
|
-
'
|
|
874
|
+
'我想在 10 分钟后达成的目标是:',
|
|
875
|
+
['10分钟', '很清楚', '能检查']
|
|
821
876
|
);
|
|
822
877
|
var planInput = makeField(
|
|
823
878
|
'3', '方案',
|
|
824
|
-
'
|
|
825
|
-
'
|
|
879
|
+
'我选择的方案是:',
|
|
880
|
+
['为什么喜欢这个 / 其他的为什么不好']
|
|
826
881
|
);
|
|
827
882
|
section.appendChild(fields);
|
|
828
883
|
|
|
829
884
|
var footer = document.createElement('div');
|
|
830
885
|
footer.className = 'myclaw-training-card__footer';
|
|
886
|
+
var metaRow = document.createElement('div');
|
|
887
|
+
metaRow.className = 'myclaw-training-card__meta-row';
|
|
831
888
|
var status = document.createElement('div');
|
|
832
889
|
status.className = 'myclaw-training-card__status';
|
|
833
890
|
status.setAttribute('role', 'status');
|
|
834
891
|
status.setAttribute('aria-live', 'polite');
|
|
835
892
|
var actions = document.createElement('div');
|
|
836
893
|
actions.className = 'myclaw-training-card__actions';
|
|
894
|
+
var cardActions = document.createElement('div');
|
|
895
|
+
cardActions.className = 'myclaw-training-card__actions myclaw-training-card__card-actions';
|
|
837
896
|
var aiBtn = document.createElement('button');
|
|
838
897
|
aiBtn.type = 'button';
|
|
839
898
|
aiBtn.className = 'myclaw-training-card__button myclaw-training-card__button--ai';
|
|
840
899
|
aiBtn.textContent = '提交 AI';
|
|
841
|
-
var
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
900
|
+
var cardBtn = document.createElement('button');
|
|
901
|
+
cardBtn.type = 'button';
|
|
902
|
+
cardBtn.className = 'myclaw-training-card__button myclaw-training-card__button--teacher';
|
|
903
|
+
cardBtn.textContent = '提交卡片';
|
|
845
904
|
actions.appendChild(aiBtn);
|
|
846
|
-
|
|
847
|
-
|
|
905
|
+
cardActions.appendChild(cardBtn);
|
|
906
|
+
|
|
907
|
+
var history = document.createElement('div');
|
|
908
|
+
history.className = 'myclaw-training-card__history';
|
|
909
|
+
var historyList = document.createElement('div');
|
|
910
|
+
historyList.className = 'myclaw-training-card__history-list';
|
|
911
|
+
history.appendChild(historyList);
|
|
912
|
+
metaRow.appendChild(status);
|
|
913
|
+
footer.appendChild(metaRow);
|
|
848
914
|
footer.appendChild(actions);
|
|
849
915
|
section.appendChild(footer);
|
|
850
916
|
|
|
851
|
-
var
|
|
917
|
+
var acceptanceFields = document.createElement('div');
|
|
918
|
+
acceptanceFields.className = 'myclaw-training-card__fields myclaw-training-card__acceptance';
|
|
919
|
+
var acceptanceChoice = '';
|
|
920
|
+
var acceptanceChoiceButtons = [];
|
|
921
|
+
var acceptanceInput = makeField(
|
|
922
|
+
'4', '验收',
|
|
923
|
+
'验收',
|
|
924
|
+
null,
|
|
925
|
+
acceptanceFields
|
|
926
|
+
);
|
|
927
|
+
var acceptanceHeader = acceptanceFields.querySelector('.myclaw-training-card__field-header');
|
|
928
|
+
var acceptanceChoices = document.createElement('span');
|
|
929
|
+
acceptanceChoices.className = 'myclaw-training-card__acceptance-choices';
|
|
930
|
+
['符合预期', '一部分符合', '不符合预期'].forEach(function (choice) {
|
|
931
|
+
var choiceBtn = document.createElement('button');
|
|
932
|
+
choiceBtn.type = 'button';
|
|
933
|
+
choiceBtn.className = 'myclaw-training-card__choice';
|
|
934
|
+
choiceBtn.textContent = choice;
|
|
935
|
+
choiceBtn.setAttribute('aria-label', choice);
|
|
936
|
+
choiceBtn.setAttribute('aria-pressed', 'false');
|
|
937
|
+
choiceBtn.addEventListener('click', function () {
|
|
938
|
+
setAcceptanceChoice(choice);
|
|
939
|
+
updateActionButtonStates();
|
|
940
|
+
});
|
|
941
|
+
acceptanceChoiceButtons.push(choiceBtn);
|
|
942
|
+
acceptanceChoices.appendChild(choiceBtn);
|
|
943
|
+
});
|
|
944
|
+
acceptanceHeader.appendChild(acceptanceChoices);
|
|
945
|
+
section.appendChild(acceptanceFields);
|
|
946
|
+
section.appendChild(cardActions);
|
|
947
|
+
section.appendChild(history);
|
|
948
|
+
|
|
949
|
+
var editingRecordId = '';
|
|
852
950
|
|
|
853
951
|
function readValues() {
|
|
952
|
+
var acceptanceNote = acceptanceInput.value.trim();
|
|
854
953
|
return {
|
|
855
954
|
problem: problemInput.value.trim(),
|
|
856
955
|
goal: goalInput.value.trim(),
|
|
857
|
-
plan: planInput.value.trim()
|
|
956
|
+
plan: planInput.value.trim(),
|
|
957
|
+
acceptance: [acceptanceChoice, acceptanceNote].filter(Boolean).join(';'),
|
|
958
|
+
acceptanceChoice: acceptanceChoice,
|
|
959
|
+
acceptanceNote: acceptanceNote
|
|
858
960
|
};
|
|
859
961
|
}
|
|
860
962
|
|
|
861
|
-
function validate(values) {
|
|
963
|
+
function validate(values, includeAcceptance) {
|
|
862
964
|
var missing = [];
|
|
863
965
|
if (!values.problem) missing.push('问题');
|
|
864
966
|
if (!values.goal) missing.push('目标');
|
|
865
967
|
if (!values.plan) missing.push('方案');
|
|
968
|
+
if (includeAcceptance && !values.acceptance) missing.push('验收');
|
|
866
969
|
if (missing.length) {
|
|
867
970
|
status.className = 'myclaw-training-card__status myclaw-training-card__status--error';
|
|
868
971
|
status.textContent = '请先填写:' + missing.join('、');
|
|
@@ -871,9 +974,87 @@
|
|
|
871
974
|
return true;
|
|
872
975
|
}
|
|
873
976
|
|
|
977
|
+
function setAcceptanceChoice(choice) {
|
|
978
|
+
acceptanceChoice = choice || '';
|
|
979
|
+
acceptanceChoiceButtons.forEach(function (button) {
|
|
980
|
+
var selected = button.textContent === acceptanceChoice;
|
|
981
|
+
button.classList.toggle('myclaw-training-card__choice--active', selected);
|
|
982
|
+
button.setAttribute('aria-pressed', selected ? 'true' : 'false');
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
function updateActionButtonStates() {
|
|
987
|
+
var values = readValues();
|
|
988
|
+
var aiReady = !!(values.problem && values.goal);
|
|
989
|
+
var cardReady = !!(values.problem && values.goal && values.plan && values.acceptance);
|
|
990
|
+
aiBtn.disabled = !aiReady;
|
|
991
|
+
aiBtn.title = aiReady ? '把已填写的内容提交给 AI' : '填写问题和目标后即可提交 AI';
|
|
992
|
+
cardBtn.disabled = !cardReady;
|
|
993
|
+
cardBtn.title = cardReady ? '保存这张卡片' : '填写问题、目标、方案,并完成验收后即可提交';
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
function clearInputs() {
|
|
997
|
+
problemInput.value = '';
|
|
998
|
+
goalInput.value = '';
|
|
999
|
+
planInput.value = '';
|
|
1000
|
+
acceptanceInput.value = '';
|
|
1001
|
+
setAcceptanceChoice('');
|
|
1002
|
+
editingRecordId = '';
|
|
1003
|
+
updateActionButtonStates();
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
function renderHistory() {
|
|
1007
|
+
var records = loadTrainingRecords(getWorkspaceId());
|
|
1008
|
+
historyList.textContent = '';
|
|
1009
|
+
history.hidden = records.length === 0;
|
|
1010
|
+
records.forEach(function (record, index) {
|
|
1011
|
+
if (!record) return;
|
|
1012
|
+
var cardName = '卡片' + formatTrainingCardNumber(index);
|
|
1013
|
+
var item = document.createElement('button');
|
|
1014
|
+
item.type = 'button';
|
|
1015
|
+
item.className = 'myclaw-training-card__history-item';
|
|
1016
|
+
if (record.recordId === editingRecordId) {
|
|
1017
|
+
item.classList.add('myclaw-training-card__history-item--active');
|
|
1018
|
+
}
|
|
1019
|
+
item.setAttribute('aria-label', '打开' + cardName);
|
|
1020
|
+
|
|
1021
|
+
var name = document.createElement('span');
|
|
1022
|
+
name.className = 'myclaw-training-card__history-name';
|
|
1023
|
+
name.textContent = cardName;
|
|
1024
|
+
var preview = document.createElement('span');
|
|
1025
|
+
preview.className = 'myclaw-training-card__history-preview';
|
|
1026
|
+
preview.textContent = record.problem || '未填写问题';
|
|
1027
|
+
item.appendChild(name);
|
|
1028
|
+
item.appendChild(preview);
|
|
1029
|
+
|
|
1030
|
+
item.addEventListener('click', function () {
|
|
1031
|
+
problemInput.value = record.problem || '';
|
|
1032
|
+
goalInput.value = record.goal || '';
|
|
1033
|
+
planInput.value = record.plan || '';
|
|
1034
|
+
acceptanceInput.value = record.acceptanceNote != null
|
|
1035
|
+
? record.acceptanceNote
|
|
1036
|
+
: (record.acceptance || '');
|
|
1037
|
+
setAcceptanceChoice(record.acceptanceChoice || '');
|
|
1038
|
+
editingRecordId = record.recordId || '';
|
|
1039
|
+
status.className = 'myclaw-training-card__status';
|
|
1040
|
+
status.textContent = record.acceptance
|
|
1041
|
+
? '正在编辑' + cardName + ',再次提交会更新原卡片。'
|
|
1042
|
+
: '正在编辑' + cardName + ',请补充验收后更新。';
|
|
1043
|
+
renderHistory();
|
|
1044
|
+
updateActionButtonStates();
|
|
1045
|
+
problemInput.focus();
|
|
1046
|
+
});
|
|
1047
|
+
historyList.appendChild(item);
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
|
|
874
1051
|
aiBtn.addEventListener('click', function () {
|
|
875
1052
|
var values = readValues();
|
|
876
|
-
if (!
|
|
1053
|
+
if (!(values.problem && values.goal)) {
|
|
1054
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--error';
|
|
1055
|
+
status.textContent = '请先填写问题和目标。';
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
877
1058
|
if (typeof window.myclawSendPrompt !== 'function') {
|
|
878
1059
|
status.className = 'myclaw-training-card__status myclaw-training-card__status--error';
|
|
879
1060
|
status.textContent = 'AI 提交功能还没有准备好,请刷新页面后重试。';
|
|
@@ -881,7 +1062,7 @@
|
|
|
881
1062
|
}
|
|
882
1063
|
aiBtn.disabled = true;
|
|
883
1064
|
var sent = window.myclawSendPrompt(buildTrainingCardPrompt(values));
|
|
884
|
-
|
|
1065
|
+
updateActionButtonStates();
|
|
885
1066
|
if (sent) {
|
|
886
1067
|
status.className = 'myclaw-training-card__status myclaw-training-card__status--success';
|
|
887
1068
|
status.textContent = '已提交 AI。可以关闭作品窗口查看回复。';
|
|
@@ -891,30 +1072,31 @@
|
|
|
891
1072
|
}
|
|
892
1073
|
});
|
|
893
1074
|
|
|
894
|
-
|
|
1075
|
+
cardBtn.addEventListener('click', function () {
|
|
895
1076
|
var values = readValues();
|
|
896
|
-
if (!validate(values)) return;
|
|
897
|
-
|
|
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;
|
|
1077
|
+
if (!validate(values, true)) return;
|
|
1078
|
+
cardBtn.disabled = true;
|
|
904
1079
|
try {
|
|
905
|
-
var
|
|
906
|
-
|
|
907
|
-
|
|
1080
|
+
var saved = saveTrainingRecordLocally(asset, values, editingRecordId);
|
|
1081
|
+
var cardName = '卡片' + formatTrainingCardNumber(saved.index);
|
|
1082
|
+
clearInputs();
|
|
1083
|
+
renderHistory();
|
|
908
1084
|
status.className = 'myclaw-training-card__status myclaw-training-card__status--success';
|
|
909
|
-
status.textContent = '
|
|
1085
|
+
status.textContent = cardName + (saved.isUpdate ? '已更新' : '已保存') + ',输入框已清空。';
|
|
910
1086
|
} catch (e) {
|
|
911
1087
|
console.error('[myclaw-training-card] 本地归档失败:', e);
|
|
912
1088
|
status.className = 'myclaw-training-card__status myclaw-training-card__status--error';
|
|
913
1089
|
status.textContent = '提交失败,填写内容仍然保留,请重试。';
|
|
914
1090
|
}
|
|
915
|
-
|
|
1091
|
+
updateActionButtonStates();
|
|
916
1092
|
});
|
|
917
1093
|
|
|
1094
|
+
[problemInput, goalInput, planInput, acceptanceInput].forEach(function (input) {
|
|
1095
|
+
input.addEventListener('input', updateActionButtonStates);
|
|
1096
|
+
});
|
|
1097
|
+
updateActionButtonStates();
|
|
1098
|
+
renderHistory();
|
|
1099
|
+
|
|
918
1100
|
section._destroyVoiceInputs = function () {
|
|
919
1101
|
voiceDestroyers.forEach(function (destroy) {
|
|
920
1102
|
try { destroy(); } catch (e) {}
|
|
@@ -3325,60 +3507,115 @@
|
|
|
3325
3507
|
' to { transform: rotate(360deg); }',
|
|
3326
3508
|
'}',
|
|
3327
3509
|
'.myclaw-training-card {',
|
|
3328
|
-
' box-sizing: border-box; width: 100%; padding: 10px
|
|
3329
|
-
' color: #
|
|
3510
|
+
' box-sizing: border-box; width: 100%; padding: 5px 10px;',
|
|
3511
|
+
' color: #eceaf3; background: linear-gradient(180deg, #2b2942 0%, #242238 100%);',
|
|
3512
|
+
' border-top: 2px solid #74629a; border-radius: 10px 0 0 0;',
|
|
3513
|
+
' box-shadow: inset 0 1px 0 rgba(255,255,255,.05);',
|
|
3330
3514
|
' font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;',
|
|
3331
3515
|
'}',
|
|
3332
|
-
'
|
|
3333
|
-
'
|
|
3334
|
-
'
|
|
3516
|
+
'.myclaw-artifacts-work-section {',
|
|
3517
|
+
' box-sizing: border-box; min-height: 0; flex: 1 1 0;',
|
|
3518
|
+
' display: flex; flex-direction: column; overflow: hidden; background: #1b1b29;',
|
|
3519
|
+
'}',
|
|
3520
|
+
'.myclaw-artifacts-work-section > #myclaw-artifacts-content { min-height: 0; }',
|
|
3521
|
+
'#myclaw-artifacts-panel > .myclaw-training-card {',
|
|
3522
|
+
' min-height: 0; flex: 1 1 0; overflow: hidden;',
|
|
3335
3523
|
'}',
|
|
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
3524
|
'.myclaw-training-card__fields {',
|
|
3340
|
-
' display: grid; grid-template-columns: 1fr; gap:
|
|
3525
|
+
' display: grid; grid-template-columns: 1fr; gap: 7px;',
|
|
3341
3526
|
'}',
|
|
3342
3527
|
'.myclaw-training-card__field {',
|
|
3343
|
-
' min-width: 0; display:
|
|
3344
|
-
'
|
|
3528
|
+
' min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 3px;',
|
|
3529
|
+
'}',
|
|
3530
|
+
'.myclaw-training-card__field-header {',
|
|
3531
|
+
' min-width: 0; display: flex; align-items: center; justify-content: flex-start; gap: 6px;',
|
|
3532
|
+
'}',
|
|
3533
|
+
'.myclaw-training-card__field-title {',
|
|
3534
|
+
' min-width: 0; font-size: 12px; line-height: 1.3; font-weight: 700; color: #f2eff8;',
|
|
3535
|
+
' white-space: nowrap;',
|
|
3536
|
+
'}',
|
|
3537
|
+
'.myclaw-training-card__hints { display: flex; align-items: center; gap: 3px; flex: 0 0 auto; }',
|
|
3538
|
+
'.myclaw-training-card__hint {',
|
|
3539
|
+
' padding: 0 5px; border: 1px solid #67558f; border-radius: 999px;',
|
|
3540
|
+
' color: #e9ddff; background: rgba(124, 58, 237, 0.22); font-size: 10px; font-weight: 650;',
|
|
3541
|
+
' line-height: 1.35; white-space: nowrap;',
|
|
3542
|
+
'}',
|
|
3543
|
+
'.myclaw-training-card__acceptance {',
|
|
3544
|
+
' margin-top: 4px; padding-top: 4px; border-top: 1px solid #4a4663;',
|
|
3545
|
+
'}',
|
|
3546
|
+
'.myclaw-training-card__acceptance-choices { display: flex; align-items: center; gap: 3px; }',
|
|
3547
|
+
'.myclaw-training-card__choice {',
|
|
3548
|
+
' padding: 1px 5px; border: 1px solid #55556f; border-radius: 999px;',
|
|
3549
|
+
' color: #d0cddd; background: rgba(255,255,255,.045); font-size: 9px; font-weight: 650;',
|
|
3550
|
+
' line-height: 1.25; white-space: nowrap; cursor: pointer;',
|
|
3551
|
+
'}',
|
|
3552
|
+
'.myclaw-training-card__choice:hover { color: #eee8ff; border-color: #8066b3; }',
|
|
3553
|
+
'.myclaw-training-card__choice--active {',
|
|
3554
|
+
' color: #fff; border-color: #8b5cf6; background: #6d3bd1;',
|
|
3345
3555
|
'}',
|
|
3346
|
-
'.myclaw-training-card__field-title { font-size: 12px; font-weight: 700; color: #c9c9d7; }',
|
|
3347
|
-
'.myclaw-training-card__field-prompt { display: none; }',
|
|
3348
3556
|
'.myclaw-training-card__input-wrap {',
|
|
3349
|
-
' min-width: 0; display: flex; align-items: center; gap: 6px;',
|
|
3557
|
+
' min-width: 0; width: 100%; display: flex; align-items: center; gap: 6px;',
|
|
3350
3558
|
'}',
|
|
3351
3559
|
'.myclaw-training-card__field textarea {',
|
|
3352
|
-
' box-sizing: border-box; flex: 1; min-width: 0; width: auto; height:
|
|
3353
|
-
' resize:
|
|
3354
|
-
' outline: none; color: #
|
|
3355
|
-
'
|
|
3560
|
+
' box-sizing: border-box; flex: 1; min-width: 0; width: auto; height: 32px; min-height: 32px; max-height: 32px;',
|
|
3561
|
+
' resize: none; padding: 3px 7px; border: 1px solid #565171; border-radius: 6px;',
|
|
3562
|
+
' outline: none; color: #faf9ff; background: #343149;',
|
|
3563
|
+
' overflow-y: auto; scrollbar-width: none;',
|
|
3564
|
+
' font: 13px/1.25 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;',
|
|
3356
3565
|
'}',
|
|
3357
|
-
'.myclaw-training-card__field textarea
|
|
3358
|
-
'.myclaw-training-card__field textarea:focus { border-color: #
|
|
3566
|
+
'.myclaw-training-card__field textarea::-webkit-scrollbar { display: none; }',
|
|
3567
|
+
'.myclaw-training-card__field textarea:focus { border-color: #a78bfa; background: #3a3652; }',
|
|
3359
3568
|
'.myclaw-training-card__mic {',
|
|
3360
|
-
' width:
|
|
3361
|
-
' border: 1px solid #
|
|
3569
|
+
' width: 28px; height: 28px; flex: 0 0 28px; padding: 0; border-radius: 50%;',
|
|
3570
|
+
' border: 1px solid #5c5778; background: #343149; color: #bbb6cc; cursor: pointer;',
|
|
3362
3571
|
' display: inline-flex; align-items: center; justify-content: center; transition: all .15s ease;',
|
|
3363
3572
|
'}',
|
|
3364
|
-
'.myclaw-training-card__mic:hover { color: #
|
|
3573
|
+
'.myclaw-training-card__mic:hover { color: #fff; border-color: #a78bfa; background: #403a5d; }',
|
|
3365
3574
|
'.myclaw-training-card__mic:disabled { cursor: not-allowed; opacity: .4; }',
|
|
3366
3575
|
'.myclaw-training-card__footer {',
|
|
3367
|
-
' margin:
|
|
3576
|
+
' margin: 4px 0 0; display: flex; flex-direction: column; gap: 2px;',
|
|
3368
3577
|
'}',
|
|
3369
|
-
'.myclaw-training-
|
|
3578
|
+
'.myclaw-training-card__meta-row { min-width: 0; display: flex; align-items: center; gap: 6px; }',
|
|
3579
|
+
'.myclaw-training-card__status {',
|
|
3580
|
+
' min-width: 0; max-width: 44%; overflow: hidden; color: #9ca3af; font-size: 10px;',
|
|
3581
|
+
' white-space: nowrap; text-overflow: ellipsis; flex: 0 1 auto;',
|
|
3582
|
+
'}',
|
|
3583
|
+
'.myclaw-training-card__status:empty { display: none; }',
|
|
3370
3584
|
'.myclaw-training-card__status--success { color: #6ee7b7; }',
|
|
3371
3585
|
'.myclaw-training-card__status--error { color: #fca5a5; }',
|
|
3372
3586
|
'.myclaw-training-card__actions { display: flex; gap: 8px; width: 100%; }',
|
|
3587
|
+
'.myclaw-training-card__card-actions { margin-top: 4px; }',
|
|
3373
3588
|
'.myclaw-training-card__button {',
|
|
3374
|
-
' flex: 1; min-width: 0; padding:
|
|
3589
|
+
' flex: 1; min-width: 0; padding: 6px 9px; border: 0; border-radius: 6px; cursor: pointer;',
|
|
3375
3590
|
' color: #fff; font-size: 12px; font-weight: 700;',
|
|
3376
3591
|
' transition: transform .15s ease, opacity .15s ease, filter .15s ease;',
|
|
3377
3592
|
'}',
|
|
3378
3593
|
'.myclaw-training-card__button:hover { transform: translateY(-1px); filter: brightness(1.08); }',
|
|
3379
|
-
'.myclaw-training-card__button:disabled { cursor:
|
|
3594
|
+
'.myclaw-training-card__button:disabled { cursor: not-allowed; opacity: .55; transform: none; }',
|
|
3380
3595
|
'.myclaw-training-card__button--ai { background: #7c3aed; }',
|
|
3381
3596
|
'.myclaw-training-card__button--teacher { background: #2563eb; }',
|
|
3597
|
+
'.myclaw-training-card__history {',
|
|
3598
|
+
' min-width: 0; margin-top: 4px; padding-top: 4px; border-top: 1px solid #4a4663;',
|
|
3599
|
+
'}',
|
|
3600
|
+
'.myclaw-training-card__history[hidden] { display: none; }',
|
|
3601
|
+
'.myclaw-training-card__history-list {',
|
|
3602
|
+
' min-width: 0; max-height: 48px; display: flex; flex-flow: row wrap; align-content: flex-start;',
|
|
3603
|
+
' gap: 4px; overflow-x: hidden; overflow-y: auto;',
|
|
3604
|
+
' scrollbar-width: thin; scrollbar-color: #4b4b65 transparent;',
|
|
3605
|
+
'}',
|
|
3606
|
+
'.myclaw-training-card__history-item {',
|
|
3607
|
+
' box-sizing: border-box; min-width: 78px; max-width: 155px; flex: 0 0 auto;',
|
|
3608
|
+
' display: flex; align-items: center; gap: 6px;',
|
|
3609
|
+
' padding: 3px 7px; border: 1px solid #514c6c; border-radius: 6px;',
|
|
3610
|
+
' color: #e4e1ec; background: #302d45; cursor: pointer; text-align: left;',
|
|
3611
|
+
'}',
|
|
3612
|
+
'.myclaw-training-card__history-item:hover { border-color: #8976b0; background: #3a3552; }',
|
|
3613
|
+
'.myclaw-training-card__history-item--active { border-color: #a78bfa; background: #43375f; }',
|
|
3614
|
+
'.myclaw-training-card__history-name { color: #c4b5fd; font-size: 11px; font-weight: 700; }',
|
|
3615
|
+
'.myclaw-training-card__history-preview {',
|
|
3616
|
+
' min-width: 0; flex: 1; overflow: hidden; color: #9293a7; font-size: 10px;',
|
|
3617
|
+
' white-space: nowrap; text-overflow: ellipsis;',
|
|
3618
|
+
'}',
|
|
3382
3619
|
].join('\n');
|
|
3383
3620
|
document.head.appendChild(style);
|
|
3384
3621
|
}
|