@haposoft/cafekit 0.9.4 → 0.9.6
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/bin/install.js +51 -96
- package/package.json +1 -1
- package/src/claude/CLAUDE.md +1 -12
package/bin/install.js
CHANGED
|
@@ -1024,125 +1024,80 @@ async function promptAddressingConfig() {
|
|
|
1024
1024
|
output: process.stdout
|
|
1025
1025
|
});
|
|
1026
1026
|
|
|
1027
|
-
console.log('\n🎯 Xưng hô (Addressing Configuration)');
|
|
1028
|
-
console.log(' CafeKit có thể cấu hình cách AI xưng hô khi giao tiếp tiếng Việt');
|
|
1029
|
-
console.log(' • Mục đích: Phát hiện context overflow (khi AI đột nhiên đổi cách xưng hô)');
|
|
1030
|
-
console.log(' • Để trống = dùng mặc định (em/anh)');
|
|
1031
|
-
console.log();
|
|
1032
|
-
|
|
1033
1027
|
return new Promise((resolve) => {
|
|
1034
|
-
rl.question('AI
|
|
1035
|
-
|
|
1028
|
+
rl.question('\nHow should the AI address you? (e.g. boss, sir, master - Enter to skip): ', (answer) => {
|
|
1029
|
+
rl.close();
|
|
1030
|
+
const userAddress = answer.trim();
|
|
1036
1031
|
|
|
1037
|
-
//
|
|
1038
|
-
if (!
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
}
|
|
1042
|
-
firstPerson = 'em';
|
|
1032
|
+
// Blank = skip, no addressing configured
|
|
1033
|
+
if (!userAddress || userAddress.length === 0) {
|
|
1034
|
+
resolve({ enabled: false, userAddress: '' });
|
|
1035
|
+
return;
|
|
1043
1036
|
}
|
|
1044
1037
|
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
console.log(' ⚠ Xưng hô không hợp lệ, dùng mặc định: anh');
|
|
1052
|
-
}
|
|
1053
|
-
secondPerson = 'anh';
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
rl.question('Bật xưng hô? (Y/n, Enter=Y): ', (enableAnswer) => {
|
|
1057
|
-
rl.close();
|
|
1058
|
-
const enabled = enableAnswer.trim().toLowerCase();
|
|
1059
|
-
const isEnabled = enabled === '' || enabled === 'y' || enabled === 'yes';
|
|
1038
|
+
// Validate: letters and spaces only
|
|
1039
|
+
if (/[^a-zA-ZÀ-ỹ\s]/.test(userAddress)) {
|
|
1040
|
+
console.log(' ⚠ Invalid input (letters only), skipping addressing setup');
|
|
1041
|
+
resolve({ enabled: false, userAddress: '' });
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1060
1044
|
|
|
1061
|
-
|
|
1062
|
-
enabled: isEnabled,
|
|
1063
|
-
firstPerson: firstPerson,
|
|
1064
|
-
secondPerson: secondPerson
|
|
1065
|
-
});
|
|
1066
|
-
});
|
|
1067
|
-
});
|
|
1045
|
+
resolve({ enabled: true, userAddress: userAddress });
|
|
1068
1046
|
});
|
|
1069
1047
|
});
|
|
1070
1048
|
}
|
|
1071
1049
|
|
|
1072
1050
|
function configureAddressing(addressingConfig, platforms = ['claude']) {
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
if (targets.length === 0) {
|
|
1078
|
-
targets.push('.claude');
|
|
1051
|
+
// CLAUDE.md is installed at the project root (see copyClaudeMdFile),
|
|
1052
|
+
// and only the Claude platform ships it. Skip if Claude isn't installed.
|
|
1053
|
+
if (!platforms.includes('claude')) {
|
|
1054
|
+
return;
|
|
1079
1055
|
}
|
|
1080
1056
|
|
|
1081
|
-
//
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
return
|
|
1057
|
+
// Skip if addressing not enabled (user left blank or invalid input)
|
|
1058
|
+
if (!addressingConfig.enabled || !addressingConfig.userAddress) {
|
|
1059
|
+
console.log(' → Bỏ qua thiết lập xưng hô');
|
|
1060
|
+
return;
|
|
1085
1061
|
}
|
|
1086
1062
|
|
|
1087
|
-
const
|
|
1088
|
-
const secondPersonCap = capitalize(addressingConfig.secondPerson);
|
|
1063
|
+
const userAddress = addressingConfig.userAddress;
|
|
1089
1064
|
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
const targetDir = path.join(process.cwd(), folder);
|
|
1093
|
-
const claudeMdFile = path.join(targetDir, 'CLAUDE.md');
|
|
1094
|
-
|
|
1095
|
-
if (!fs.existsSync(claudeMdFile)) {
|
|
1096
|
-
console.log(` ⚠ CLAUDE.md not found in ${folder}/`);
|
|
1097
|
-
continue;
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
let content = fs.readFileSync(claudeMdFile, 'utf8');
|
|
1101
|
-
|
|
1102
|
-
// Build the addressing section
|
|
1103
|
-
const addressingSection = `## Xưng hô (Addressing - Context Overflow Indicator)
|
|
1065
|
+
try {
|
|
1066
|
+
const claudeMdFile = path.join(process.cwd(), 'CLAUDE.md');
|
|
1104
1067
|
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1068
|
+
if (!fs.existsSync(claudeMdFile)) {
|
|
1069
|
+
console.log(' ⚠ CLAUDE.md not found at project root');
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1109
1072
|
|
|
1110
|
-
|
|
1073
|
+
let content = fs.readFileSync(claudeMdFile, 'utf8');
|
|
1111
1074
|
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
"${firstPersonCap} nhận thấy context có thể đã bị compact. ${secondPersonCap} có thể cần /clear để reset session."
|
|
1075
|
+
// Build the addressing section (short instruction + user-chosen term)
|
|
1076
|
+
const addressingSection = `## Xưng hô (Addressing - Context Overflow Indicator)
|
|
1115
1077
|
|
|
1116
|
-
|
|
1078
|
+
AI luôn gọi người dùng là "${userAddress}" trong suốt conversation. Nếu AI ngừng gọi như vậy, đó là dấu hiệu context đã bị compact — hãy báo người dùng cân nhắc \`/clear\`.`;
|
|
1117
1079
|
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
const regex = /## Xưng hô \(Addressing - Context Overflow Indicator\)[\s\S]*?(?=\n##|\n*$)/;
|
|
1080
|
+
// Match from ## Xưng hô to the next ## header or end of file
|
|
1081
|
+
const regex = /## Xưng hô \(Addressing - Context Overflow Indicator\)[\s\S]*?(?=\n##|\n*$)/;
|
|
1121
1082
|
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
}
|
|
1130
|
-
content += '\n' + addressingSection + '\n';
|
|
1083
|
+
if (regex.test(content)) {
|
|
1084
|
+
// Replace existing section
|
|
1085
|
+
content = content.replace(regex, addressingSection);
|
|
1086
|
+
} else {
|
|
1087
|
+
// Append at the end
|
|
1088
|
+
if (!content.endsWith('\n')) {
|
|
1089
|
+
content += '\n';
|
|
1131
1090
|
}
|
|
1091
|
+
content += '\n' + addressingSection + '\n';
|
|
1092
|
+
}
|
|
1132
1093
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
} catch (error) {
|
|
1141
|
-
console.error(` ✗ Failed to configure addressing in ${folder}/CLAUDE.md`);
|
|
1142
|
-
console.error(` Error: ${error.message}`);
|
|
1143
|
-
if (process.env.DEBUG) {
|
|
1144
|
-
console.error(error.stack);
|
|
1145
|
-
}
|
|
1094
|
+
fs.writeFileSync(claudeMdFile, content, 'utf8');
|
|
1095
|
+
console.log(` ✓ Xưng hô configured in CLAUDE.md: AI gọi user là "${userAddress}"`);
|
|
1096
|
+
} catch (error) {
|
|
1097
|
+
console.error(' ✗ Failed to configure addressing in CLAUDE.md');
|
|
1098
|
+
console.error(` Error: ${error.message}`);
|
|
1099
|
+
if (process.env.DEBUG) {
|
|
1100
|
+
console.error(error.stack);
|
|
1146
1101
|
}
|
|
1147
1102
|
}
|
|
1148
1103
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haposoft/cafekit",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"description": "Claude Code-first spec-driven workflow for AI coding assistants. Bundles CafeKit hapo: skills, runtime hooks, agents, and installer scaffolding.",
|
|
5
5
|
"author": "Haposoft <nghialt@haposoft.com>",
|
|
6
6
|
"license": "MIT",
|
package/src/claude/CLAUDE.md
CHANGED
|
@@ -129,15 +129,4 @@ When generating specs or structured project output, use the user's preferred lan
|
|
|
129
129
|
|
|
130
130
|
## Xưng hô (Addressing - Context Overflow Indicator)
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
- Luôn xưng "em" (bản thân AI)
|
|
134
|
-
- Luôn hô "anh" (người dùng)
|
|
135
|
-
- Duy trì xưng hô nhất quán trong toàn bộ conversation
|
|
136
|
-
|
|
137
|
-
**Ví dụ:** "Em đã đọc file này và em thấy anh cần sửa dòng 45."
|
|
138
|
-
|
|
139
|
-
**⚠️ Context Overflow Detection:**
|
|
140
|
-
Nếu bạn (AI) đột nhiên không thể nhớ hoặc tuân thủ quy tắc xưng hô này, đây là dấu hiệu context window đã bị compact/truncate. Hãy thông báo ngay:
|
|
141
|
-
"Em nhận thấy context có thể đã bị compact. Anh có thể cần /clear để reset session."
|
|
142
|
-
|
|
143
|
-
**Lưu ý:** Xưng hô được thiết lập khi cài đặt CafeKit và lưu trực tiếp trong file CLAUDE.md này. Để thay đổi, chỉnh sửa section này hoặc chạy lại installer.
|
|
132
|
+
AI luôn gọi người dùng là "anh" trong suốt conversation. Nếu AI ngừng gọi như vậy, đó là dấu hiệu context đã bị compact — hãy báo người dùng cân nhắc `/clear`.
|