@haposoft/cafekit 0.9.3 → 0.9.5
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 +109 -0
- package/package.json +1 -1
- package/src/claude/CLAUDE.md +13 -0
package/bin/install.js
CHANGED
|
@@ -1018,6 +1018,111 @@ function configureGeminiKey(apiKey, platforms = ['claude']) {
|
|
|
1018
1018
|
return success;
|
|
1019
1019
|
}
|
|
1020
1020
|
|
|
1021
|
+
async function promptAddressingConfig() {
|
|
1022
|
+
const rl = readline.createInterface({
|
|
1023
|
+
input: process.stdin,
|
|
1024
|
+
output: process.stdout
|
|
1025
|
+
});
|
|
1026
|
+
|
|
1027
|
+
return new Promise((resolve) => {
|
|
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();
|
|
1031
|
+
|
|
1032
|
+
// Blank = skip, no addressing configured
|
|
1033
|
+
if (!userAddress || userAddress.length === 0) {
|
|
1034
|
+
resolve({ enabled: false, userAddress: '' });
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
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
|
+
}
|
|
1044
|
+
|
|
1045
|
+
resolve({ enabled: true, userAddress: userAddress });
|
|
1046
|
+
});
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
function configureAddressing(addressingConfig, platforms = ['claude']) {
|
|
1051
|
+
const targets = platforms
|
|
1052
|
+
.filter(key => PLATFORMS[key])
|
|
1053
|
+
.map(key => PLATFORMS[key].folder);
|
|
1054
|
+
|
|
1055
|
+
if (targets.length === 0) {
|
|
1056
|
+
targets.push('.claude');
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
// Helper function to safely capitalize first letter
|
|
1060
|
+
function capitalize(str) {
|
|
1061
|
+
if (!str || str.length === 0) return str;
|
|
1062
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
// Skip if addressing not enabled (user left blank or invalid input)
|
|
1066
|
+
if (!addressingConfig.enabled || !addressingConfig.userAddress) {
|
|
1067
|
+
console.log(' → Bỏ qua thiết lập xưng hô');
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
const userAddress = addressingConfig.userAddress;
|
|
1072
|
+
const userAddressCap = capitalize(userAddress);
|
|
1073
|
+
|
|
1074
|
+
for (const folder of targets) {
|
|
1075
|
+
try {
|
|
1076
|
+
const targetDir = path.join(process.cwd(), folder);
|
|
1077
|
+
const claudeMdFile = path.join(targetDir, 'CLAUDE.md');
|
|
1078
|
+
|
|
1079
|
+
if (!fs.existsSync(claudeMdFile)) {
|
|
1080
|
+
console.log(` ⚠ CLAUDE.md not found in ${folder}/`);
|
|
1081
|
+
continue;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
let content = fs.readFileSync(claudeMdFile, 'utf8');
|
|
1085
|
+
|
|
1086
|
+
// Build the addressing section
|
|
1087
|
+
const addressingSection = `## Xưng hô (Addressing - Context Overflow Indicator)
|
|
1088
|
+
|
|
1089
|
+
Khi giao tiếp bằng tiếng Việt, AI luôn gọi người dùng là "${userAddress}".
|
|
1090
|
+
Duy trì cách gọi này nhất quán trong toàn bộ conversation.
|
|
1091
|
+
|
|
1092
|
+
**Ví dụ:** "${userAddressCap} cần sửa dòng 45 trong file này."
|
|
1093
|
+
|
|
1094
|
+
**⚠️ Context Overflow Detection:**
|
|
1095
|
+
Nếu AI đột nhiên không còn gọi người dùng là "${userAddress}", đây là dấu hiệu context window đã bị compact/truncate. Hãy thông báo ngay:
|
|
1096
|
+
"Context có thể đã bị compact. ${userAddressCap} có thể cần /clear để reset session."
|
|
1097
|
+
|
|
1098
|
+
**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.`;
|
|
1099
|
+
|
|
1100
|
+
// Match from ## Xưng hô to the next ## header or end of file
|
|
1101
|
+
const regex = /## Xưng hô \(Addressing - Context Overflow Indicator\)[\s\S]*?(?=\n##|\n*$)/;
|
|
1102
|
+
|
|
1103
|
+
if (regex.test(content)) {
|
|
1104
|
+
// Replace existing section
|
|
1105
|
+
content = content.replace(regex, addressingSection);
|
|
1106
|
+
} else {
|
|
1107
|
+
// Append at the end
|
|
1108
|
+
if (!content.endsWith('\n')) {
|
|
1109
|
+
content += '\n';
|
|
1110
|
+
}
|
|
1111
|
+
content += '\n' + addressingSection + '\n';
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
fs.writeFileSync(claudeMdFile, content, 'utf8');
|
|
1115
|
+
console.log(` ✓ Xưng hô configured in CLAUDE.md: AI gọi user là "${userAddress}"`);
|
|
1116
|
+
} catch (error) {
|
|
1117
|
+
console.error(` ✗ Failed to configure addressing in ${folder}/CLAUDE.md`);
|
|
1118
|
+
console.error(` Error: ${error.message}`);
|
|
1119
|
+
if (process.env.DEBUG) {
|
|
1120
|
+
console.error(error.stack);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1021
1126
|
async function setupGeminiCLI(platforms) {
|
|
1022
1127
|
const hasGemini = checkGeminiCLI();
|
|
1023
1128
|
|
|
@@ -1147,6 +1252,10 @@ async function main() {
|
|
|
1147
1252
|
await setupOpenCodeModel(platforms, results);
|
|
1148
1253
|
await setupGeminiCLI(platforms);
|
|
1149
1254
|
|
|
1255
|
+
// Setup addressing configuration
|
|
1256
|
+
const addressingConfig = await promptAddressingConfig();
|
|
1257
|
+
configureAddressing(addressingConfig, platforms);
|
|
1258
|
+
|
|
1150
1259
|
// Summary
|
|
1151
1260
|
console.log('╔════════════════════════════════════════════════════════╗');
|
|
1152
1261
|
console.log('║ Installation Complete! ║');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haposoft/cafekit",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
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
|
@@ -126,3 +126,16 @@ When generating specs or structured project output, use the user's preferred lan
|
|
|
126
126
|
- State tradeoffs and assumptions when they affect decisions.
|
|
127
127
|
- Do not provide unsolicited code explanations unless asked.
|
|
128
128
|
- Do not apologize; correct the issue and continue.
|
|
129
|
+
|
|
130
|
+
## Xưng hô (Addressing - Context Overflow Indicator)
|
|
131
|
+
|
|
132
|
+
Khi giao tiếp bằng tiếng Việt, AI luôn gọi người dùng là "anh".
|
|
133
|
+
Duy trì cách gọi này nhất quán trong toàn bộ conversation.
|
|
134
|
+
|
|
135
|
+
**Ví dụ:** "Anh cần sửa dòng 45 trong file này."
|
|
136
|
+
|
|
137
|
+
**⚠️ Context Overflow Detection:**
|
|
138
|
+
Nếu AI đột nhiên không còn gọi người dùng là "anh", đây là dấu hiệu context window đã bị compact/truncate. Hãy thông báo ngay:
|
|
139
|
+
"Context có thể đã bị compact. Anh có thể cần /clear để reset session."
|
|
140
|
+
|
|
141
|
+
**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.
|