@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 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 xưng gì? (ví dụ: em, mình, tôi, con - Enter=em): ', (firstAnswer) => {
1035
- let firstPerson = firstAnswer.trim();
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
- // Validate: không rỗng và chỉ chứa chữ cái tiếng Việt
1038
- if (!firstPerson || firstPerson.length === 0 || /[^a-zA-ZÀ-ỹ\s]/.test(firstPerson)) {
1039
- if (firstAnswer.trim().length > 0) {
1040
- console.log(' ⚠ Xưng hô không hợp lệ, dùng mặc định: em');
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
- rl.question('AI hô user là gì? (ví dụ: anh, bạn, thầy - Enter=anh): ', (secondAnswer) => {
1046
- let secondPerson = secondAnswer.trim();
1047
-
1048
- // Validate: không rỗng và chỉ chứa chữ cái tiếng Việt
1049
- if (!secondPerson || secondPerson.length === 0 || /[^a-zA-ZÀ-ỹ\s]/.test(secondPerson)) {
1050
- if (secondAnswer.trim().length > 0) {
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
- resolve({
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
- const targets = platforms
1074
- .filter(key => PLATFORMS[key])
1075
- .map(key => PLATFORMS[key].folder);
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
- // Helper function to safely capitalize
1082
- function capitalize(str) {
1083
- if (!str || str.length === 0) return str;
1084
- return str.charAt(0).toUpperCase() + str.slice(1);
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 firstPersonCap = capitalize(addressingConfig.firstPerson);
1088
- const secondPersonCap = capitalize(addressingConfig.secondPerson);
1063
+ const userAddress = addressingConfig.userAddress;
1089
1064
 
1090
- for (const folder of targets) {
1091
- try {
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
- Khi giao tiếp bằng tiếng Việt:
1106
- - Luôn xưng "${addressingConfig.firstPerson}" (bản thân AI)
1107
- - Luôn hô "${addressingConfig.secondPerson}" (người dùng)
1108
- - Duy trì xưng hô nhất quán trong toàn bộ conversation
1068
+ if (!fs.existsSync(claudeMdFile)) {
1069
+ console.log(' ⚠ CLAUDE.md not found at project root');
1070
+ return;
1071
+ }
1109
1072
 
1110
- **Ví dụ:** "${firstPersonCap} đã đọc file này và ${addressingConfig.firstPerson} thấy ${addressingConfig.secondPerson} cần sửa dòng 45."
1073
+ let content = fs.readFileSync(claudeMdFile, 'utf8');
1111
1074
 
1112
- **⚠️ Context Overflow Detection:**
1113
- 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:
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
- **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.`;
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
- // Match from ## Xưng hô to the end of section (including any trailing newlines)
1119
- // This regex matches the entire section including the final newline after "Lưu ý:" paragraph
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
- if (regex.test(content)) {
1123
- // Replace existing section
1124
- content = content.replace(regex, addressingSection);
1125
- } else {
1126
- // Append at the end
1127
- if (!content.endsWith('\n')) {
1128
- content += '\n';
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
- fs.writeFileSync(claudeMdFile, content, 'utf8');
1134
-
1135
- if (addressingConfig.enabled) {
1136
- console.log(` ✓ Xưng hô configured in CLAUDE.md: ${addressingConfig.firstPerson}/${addressingConfig.secondPerson}`);
1137
- } else {
1138
- console.log(` ✓ Xưng hô disabled in CLAUDE.md`);
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.4",
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",
@@ -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
- Khi giao tiếp bằng tiếng Việt:
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`.