thachvd-kit 1.0.11 → 1.0.14
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/cli.js +286 -180
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -942,14 +942,16 @@ ${autoSkillsList}
|
|
|
942
942
|
- **In Progress:** Initial setup
|
|
943
943
|
- **Next:** —
|
|
944
944
|
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
945
|
+
|
|
946
|
+
---
|
|
947
|
+
|
|
948
|
+
## Known Issues / Tasks
|
|
949
|
+
|
|
950
|
+
<!-- Add known issues or pending tasks -->
|
|
951
|
+
`;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
|
|
953
955
|
function generateClaudeMd(data) {
|
|
954
956
|
return `# CLAUDE.md — ${data.project_name}
|
|
955
957
|
# Generated by thachvd-kit. See PROJECT_CONTEXT.md for full stack info.
|
|
@@ -958,132 +960,281 @@ function generateClaudeMd(data) {
|
|
|
958
960
|
## Project
|
|
959
961
|
${data.description}
|
|
960
962
|
Stack: ${data.primary_language} | ${(data.frameworks || []).join(', ')}
|
|
961
|
-
|
|
963
|
+
|
|
962
964
|
## Rules
|
|
963
965
|
- Read PROJECT_CONTEXT.md first for stack details and agent routing.
|
|
964
966
|
- If PROJECT_CONTEXT.md is missing or stale, create/update it before major work.
|
|
965
967
|
- Follow skills in .agent/skills/ (or .claude/skills/).
|
|
966
968
|
- Tests are mandatory. Verify before claiming done.
|
|
967
969
|
- Max ${data.max_file_lines || '300'} lines per file.
|
|
968
|
-
|
|
969
|
-
## Key Skills
|
|
970
|
-
- Plan: \`plan-writing\` → \`executing-plans\`
|
|
971
|
-
- Review: \`requesting-code-review\` / \`receiving-code-review\`
|
|
972
|
-
- Quality: \`clean-code\`, \`verification-before-completion\`
|
|
973
|
-
- Workflow: \`subagent-driven-development\`, \`finishing-a-development-branch\`
|
|
974
|
-
|
|
975
|
-
## Commands
|
|
976
|
-
- \`/plan\` — Create implementation plan
|
|
977
|
-
- \`/debug\` — Systematic debugging
|
|
978
|
-
- \`/test\` — Run test suite
|
|
979
|
-
- \`/deploy\` — Deploy checklist
|
|
970
|
+
|
|
971
|
+
## Key Skills
|
|
972
|
+
- Plan: \`plan-writing\` → \`executing-plans\`
|
|
973
|
+
- Review: \`requesting-code-review\` / \`receiving-code-review\`
|
|
974
|
+
- Quality: \`clean-code\`, \`verification-before-completion\`
|
|
975
|
+
- Workflow: \`subagent-driven-development\`, \`finishing-a-development-branch\`
|
|
976
|
+
|
|
977
|
+
## Commands
|
|
978
|
+
- \`/plan\` — Create implementation plan
|
|
979
|
+
- \`/debug\` — Systematic debugging
|
|
980
|
+
- \`/test\` — Run test suite
|
|
981
|
+
- \`/deploy\` — Deploy checklist
|
|
980
982
|
|
|
981
983
|
See PROJECT_CONTEXT.md for full agent routing table.
|
|
982
984
|
`;
|
|
983
985
|
}
|
|
984
986
|
|
|
985
987
|
function generateAgentsMd(data) {
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
988
|
+
const frameworks = (data.frameworks || []);
|
|
989
|
+
const primaryLang = data.primary_language || 'javascript';
|
|
990
|
+
const pkgManager = data.package_manager || 'npm';
|
|
991
|
+
const testFramework = data.test_framework || 'auto-detect';
|
|
992
|
+
const database = data.database || 'none';
|
|
993
|
+
const cloud = data.cloud || 'none';
|
|
994
|
+
const infrastructure = (data.infrastructure || []);
|
|
995
|
+
const appRoot = data.app_root || '.';
|
|
996
|
+
const maxFileLines = data.max_file_lines || '300';
|
|
997
|
+
|
|
998
|
+
// Build dev commands section based on detected package manager and framework
|
|
999
|
+
const isNode = ['javascript', 'typescript'].includes(primaryLang);
|
|
1000
|
+
const isPython = primaryLang === 'python';
|
|
1001
|
+
const isGo = primaryLang === 'go';
|
|
1002
|
+
const isRust = primaryLang === 'rust';
|
|
1003
|
+
const isPhp = primaryLang === 'php';
|
|
1004
|
+
|
|
1005
|
+
let installCmd = 'npm install';
|
|
1006
|
+
let devCmd = 'npm run dev';
|
|
1007
|
+
let buildCmd = 'npm run build';
|
|
1008
|
+
let testCmd = 'npm test';
|
|
1009
|
+
let lintCmd = 'npm run lint';
|
|
1010
|
+
|
|
1011
|
+
if (pkgManager === 'pnpm') { installCmd = 'pnpm install'; devCmd = 'pnpm dev'; buildCmd = 'pnpm build'; testCmd = 'pnpm test'; lintCmd = 'pnpm lint'; }
|
|
1012
|
+
else if (pkgManager === 'yarn') { installCmd = 'yarn'; devCmd = 'yarn dev'; buildCmd = 'yarn build'; testCmd = 'yarn test'; lintCmd = 'yarn lint'; }
|
|
1013
|
+
else if (pkgManager === 'bun') { installCmd = 'bun install'; devCmd = 'bun dev'; buildCmd = 'bun run build'; testCmd = 'bun test'; lintCmd = 'bun run lint'; }
|
|
1014
|
+
else if (isPython) { installCmd = 'pip install -r requirements.txt'; devCmd = 'python manage.py runserver'; buildCmd = '# no build step'; testCmd = 'pytest'; lintCmd = 'ruff check .'; }
|
|
1015
|
+
else if (isGo) { installCmd = 'go mod download'; devCmd = 'go run .'; buildCmd = 'go build ./...'; testCmd = 'go test ./...'; lintCmd = 'golangci-lint run'; }
|
|
1016
|
+
else if (isRust) { installCmd = 'cargo build'; devCmd = 'cargo run'; buildCmd = 'cargo build --release'; testCmd = 'cargo test'; lintCmd = 'cargo clippy'; }
|
|
1017
|
+
else if (isPhp) {
|
|
1018
|
+
installCmd = 'composer install';
|
|
1019
|
+
buildCmd = '# no build step';
|
|
1020
|
+
testCmd = testFramework === 'pest' ? './vendor/bin/pest' : './vendor/bin/phpunit';
|
|
1021
|
+
const isCakePHP = frameworks.some(f => f.toLowerCase().includes('cakephp'));
|
|
1022
|
+
const isSymfony = frameworks.some(f => f.toLowerCase().includes('symfony'));
|
|
1023
|
+
const isCodeIgniter = frameworks.some(f => f.toLowerCase().includes('codeigniter'));
|
|
1024
|
+
if (isCakePHP) {
|
|
1025
|
+
devCmd = 'bin/cake server';
|
|
1026
|
+
lintCmd = './vendor/bin/phpcs';
|
|
1027
|
+
} else if (isSymfony) {
|
|
1028
|
+
devCmd = 'bin/console server:run';
|
|
1029
|
+
lintCmd = './vendor/bin/phpcs';
|
|
1030
|
+
} else if (isCodeIgniter) {
|
|
1031
|
+
devCmd = 'php spark serve';
|
|
1032
|
+
lintCmd = './vendor/bin/phpcs';
|
|
1033
|
+
} else {
|
|
1034
|
+
// Default: Laravel
|
|
1035
|
+
devCmd = 'php artisan serve';
|
|
1036
|
+
lintCmd = 'php artisan pint';
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
if (testFramework === 'vitest') testCmd = `${pkgManager === 'pnpm' ? 'pnpm' : pkgManager === 'yarn' ? 'yarn' : pkgManager === 'bun' ? 'bun run' : 'npx'} vitest`;
|
|
1041
|
+
else if (testFramework === 'jest') testCmd = `${pkgManager === 'pnpm' ? 'pnpm' : pkgManager === 'yarn' ? 'yarn' : 'npx'} jest`;
|
|
1042
|
+
|
|
1043
|
+
// Build stack overview section
|
|
1044
|
+
const stackLines = [
|
|
1045
|
+
`- **Language:** ${primaryLang}`,
|
|
1046
|
+
frameworks.length > 0 ? `- **Frameworks:** ${frameworks.join(', ')}` : null,
|
|
1047
|
+
database !== 'none' ? `- **Database:** ${database}` : null,
|
|
1048
|
+
pkgManager !== 'auto-detect' ? `- **Package Manager:** ${pkgManager}` : null,
|
|
1049
|
+
testFramework !== 'auto-detect' ? `- **Test Framework:** ${testFramework}` : null,
|
|
1050
|
+
cloud !== 'none' ? `- **Cloud:** ${cloud}` : null,
|
|
1051
|
+
infrastructure.length > 0 ? `- **Infrastructure:** ${infrastructure.join(', ')}` : null,
|
|
1052
|
+
].filter(Boolean).join('\n');
|
|
1053
|
+
|
|
1054
|
+
// Build architecture notes hint
|
|
1055
|
+
const archNotes = data.architecture_notes && !data.architecture_notes.includes('<!-- Add')
|
|
1056
|
+
? `\n${data.architecture_notes}`
|
|
1057
|
+
: '';
|
|
1058
|
+
|
|
1059
|
+
// Agent routing table
|
|
1060
|
+
const agentTable = resolveAgentTable(data);
|
|
1061
|
+
const agentRows = agentTable.map(([task, agent, skills]) => `| ${task} | \`${agent}\` | ${skills} |`).join('\n');
|
|
1062
|
+
|
|
1063
|
+
// Auto-resolved skills
|
|
1064
|
+
const autoSkills = resolveSkills(data);
|
|
1065
|
+
const skillsList = autoSkills.map(s => `- ${s}`).join('\n');
|
|
1066
|
+
|
|
1067
|
+
return `# ${data.project_name}
|
|
989
1068
|
|
|
990
|
-
## Project
|
|
991
1069
|
${data.description}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
-
|
|
1014
|
-
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1070
|
+
|
|
1071
|
+
## Project Overview
|
|
1072
|
+
|
|
1073
|
+
${stackLines}
|
|
1074
|
+
|
|
1075
|
+
---
|
|
1076
|
+
|
|
1077
|
+
## Core Architecture
|
|
1078
|
+
|
|
1079
|
+
<!-- AI: Scan the project and replace this section with actual directory structure and key module descriptions -->
|
|
1080
|
+
${appRoot !== '.' ? `- **App Root:** \`${appRoot}\`` : ''}
|
|
1081
|
+
|
|
1082
|
+
---
|
|
1083
|
+
|
|
1084
|
+
## Development Workflow
|
|
1085
|
+
|
|
1086
|
+
### Prerequisites
|
|
1087
|
+
- ${primaryLang.charAt(0).toUpperCase() + primaryLang.slice(1)} toolchain installed
|
|
1088
|
+
${pkgManager !== 'auto-detect' ? `- \`${pkgManager}\` (Package Manager)` : ''}
|
|
1089
|
+
|
|
1090
|
+
### Key Commands
|
|
1091
|
+
- **Install Dependencies:** \`${installCmd}\`
|
|
1092
|
+
- **Development Server:** \`${devCmd}\`
|
|
1093
|
+
- **Build for Production:** \`${buildCmd}\`
|
|
1094
|
+
- **Run Tests:** \`${testCmd}\`
|
|
1095
|
+
- **Linting:** \`${lintCmd}\`
|
|
1096
|
+
|
|
1097
|
+
---
|
|
1098
|
+
|
|
1099
|
+
## Coding Conventions
|
|
1100
|
+
|
|
1101
|
+
<!-- AI: Scan the project and replace this section with actual conventions (API patterns, state management, styling, naming, routing) -->
|
|
1102
|
+
|
|
1103
|
+
---
|
|
1104
|
+
|
|
1105
|
+
## Performance & Optimization
|
|
1106
|
+
|
|
1107
|
+
<!-- AI: Scan vite.config / webpack / build config and replace with actual optimizations used -->
|
|
1108
|
+
|
|
1109
|
+
---
|
|
1110
|
+
|
|
1111
|
+
## Coding Rules
|
|
1112
|
+
|
|
1113
|
+
**Don't assume. Don't hide confusion. Surface tradeoffs.**
|
|
1114
|
+
|
|
1115
|
+
Before implementing:
|
|
1116
|
+
- State your assumptions explicitly. If uncertain, ask.
|
|
1117
|
+
- If multiple interpretations exist, present them — don't pick silently.
|
|
1118
|
+
- If a simpler approach exists, say so. Push back when warranted.
|
|
1119
|
+
- If something is unclear, stop. Name what's confusing. Ask.
|
|
1120
|
+
|
|
1121
|
+
### 1. Simplicity First
|
|
1122
|
+
|
|
1123
|
+
**Minimum code that solves the problem. Nothing speculative.**
|
|
1124
|
+
|
|
1125
|
+
- No features beyond what was asked.
|
|
1126
|
+
- No abstractions for single-use code.
|
|
1127
|
+
- No "flexibility" or "configurability" that wasn't requested.
|
|
1128
|
+
- No error handling for impossible scenarios.
|
|
1129
|
+
- If you write 200 lines and it could be 50, rewrite it.
|
|
1130
|
+
|
|
1131
|
+
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
|
|
1132
|
+
|
|
1133
|
+
### 2. Surgical Changes
|
|
1134
|
+
|
|
1135
|
+
**Touch only what you must. Clean up only your own mess.**
|
|
1136
|
+
|
|
1137
|
+
When editing existing code:
|
|
1138
|
+
- Don't "improve" adjacent code, comments, or formatting.
|
|
1139
|
+
- Don't refactor things that aren't broken.
|
|
1140
|
+
- Match existing style, even if you'd do it differently.
|
|
1141
|
+
- If you notice unrelated dead code, mention it — don't delete it.
|
|
1142
|
+
|
|
1143
|
+
When your changes create orphans:
|
|
1144
|
+
- Remove imports/variables/functions that YOUR changes made unused.
|
|
1145
|
+
- Don't remove pre-existing dead code unless asked.
|
|
1146
|
+
|
|
1147
|
+
The test: Every changed line should trace directly to the user's request.
|
|
1148
|
+
|
|
1149
|
+
### 3. Goal-Driven Execution
|
|
1150
|
+
|
|
1151
|
+
**Define success criteria. Loop until verified.**
|
|
1152
|
+
|
|
1153
|
+
Transform tasks into verifiable goals:
|
|
1154
|
+
- "Add validation" → "Write tests for invalid inputs, then make them pass"
|
|
1155
|
+
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
|
|
1156
|
+
- "Refactor X" → "Ensure tests pass before and after"
|
|
1157
|
+
|
|
1158
|
+
For multi-step tasks, state a brief plan:
|
|
1159
|
+
\`\`\`
|
|
1160
|
+
1. [Step] → verify: [check]
|
|
1161
|
+
2. [Step] → verify: [check]
|
|
1162
|
+
3. [Step] → verify: [check]
|
|
1163
|
+
\`\`\`
|
|
1164
|
+
|
|
1165
|
+
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
|
|
1166
|
+
|
|
1167
|
+
### 4. Universal Standards
|
|
1168
|
+
|
|
1169
|
+
- Respond in user's language; code/comments in English.
|
|
1170
|
+
- \`clean-code\` applies to all code, all languages.
|
|
1171
|
+
- Tests are mandatory.
|
|
1172
|
+
- Verify with evidence before claiming done.
|
|
1173
|
+
- Identify dependent files before modifying any.
|
|
1174
|
+
- Keep files under ${maxFileLines} lines; split into modules if exceeded.
|
|
1023
1175
|
`;
|
|
1024
1176
|
}
|
|
1025
1177
|
|
|
1026
|
-
function
|
|
1178
|
+
function generateAgentsMdRefinementPrompt(data) {
|
|
1027
1179
|
const evidence = (data.scan_evidence || []).length > 0
|
|
1028
1180
|
? (data.scan_evidence || []).map(line => `- ${line}`).join('\n')
|
|
1029
1181
|
: '- No scan evidence was captured during init.';
|
|
1030
1182
|
|
|
1031
|
-
return `#
|
|
1032
|
-
|
|
1033
|
-
Use this prompt in your AI editor after \`thachvd-kit init\`.
|
|
1183
|
+
return `# AGENTS.md Refinement Prompt
|
|
1034
1184
|
|
|
1035
|
-
|
|
1185
|
+
Run this in your AI editor right after \`thachvd-kit init --scan\`.
|
|
1186
|
+
The goal is to replace the placeholder sections in \`AGENTS.md\` with real project knowledge.
|
|
1036
1187
|
|
|
1037
|
-
|
|
1188
|
+
## Baseline Detected
|
|
1038
1189
|
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
-
|
|
1042
|
-
-
|
|
1043
|
-
- Stack: ${data.primary_language} | ${(data.frameworks || []).join(', ') || 'no framework'}
|
|
1044
|
-
- Database: ${data.database || 'none'}
|
|
1045
|
-
- Infra: ${(data.infrastructure || []).join(', ') || 'none'}
|
|
1190
|
+
- **Project:** ${data.project_name}
|
|
1191
|
+
- **Stack:** ${data.primary_language} | ${(data.frameworks || []).join(', ') || 'no framework'}
|
|
1192
|
+
- **Database:** ${data.database || 'none'}
|
|
1193
|
+
- **Package Manager:** ${data.package_manager || 'auto-detect'}
|
|
1046
1194
|
|
|
1047
1195
|
## Scan Evidence
|
|
1048
1196
|
|
|
1049
1197
|
${evidence}
|
|
1050
1198
|
|
|
1051
|
-
##
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
-
|
|
1071
|
-
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
-
|
|
1077
|
-
-
|
|
1078
|
-
-
|
|
1079
|
-
-
|
|
1080
|
-
|
|
1081
|
-
##
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
-
|
|
1085
|
-
-
|
|
1086
|
-
-
|
|
1199
|
+
## Your Task
|
|
1200
|
+
|
|
1201
|
+
Update **only** the placeholder sections in \`AGENTS.md\` (marked with \`<!-- AI: ... --\`>):
|
|
1202
|
+
|
|
1203
|
+
### 1. Core Architecture
|
|
1204
|
+
Scan the \`src/\` (or equivalent) directory. For each major folder, write one bullet:
|
|
1205
|
+
\`- **\`src/folder/\`**: What it contains and its role\`
|
|
1206
|
+
Keep it concise — one line per folder.
|
|
1207
|
+
|
|
1208
|
+
### 2. Coding Conventions
|
|
1209
|
+
Inspect actual code patterns and write conventions grouped by topic:
|
|
1210
|
+
- API integration patterns (how HTTP calls are made)
|
|
1211
|
+
- State management patterns
|
|
1212
|
+
- Styling conventions
|
|
1213
|
+
- Component/file naming rules
|
|
1214
|
+
- Routing and auth patterns
|
|
1215
|
+
|
|
1216
|
+
### 3. Performance & Optimization
|
|
1217
|
+
Check \`vite.config.js\`, \`webpack.config.js\`, \`package.json\` scripts, or build configs. List actual optimizations:
|
|
1218
|
+
- Code splitting, lazy loading, chunking
|
|
1219
|
+
- Compression, caching strategies
|
|
1220
|
+
- PWA, image optimization, etc.
|
|
1221
|
+
|
|
1222
|
+
## Rules
|
|
1223
|
+
|
|
1224
|
+
- Replace placeholders with real content. Remove the \`<!-- AI: ... -->\` comments.
|
|
1225
|
+
- Do NOT change \`## Project Overview\`, \`## Development Workflow\`, or \`## Coding Rules\` sections.
|
|
1226
|
+
- Do NOT implement any product code.
|
|
1227
|
+
- If a section is not applicable, write \`N/A\` and remove the placeholder.
|
|
1228
|
+
|
|
1229
|
+
## Files To Inspect
|
|
1230
|
+
|
|
1231
|
+
- \`src/\` or \`app/\` directory structure
|
|
1232
|
+
- Build config: \`vite.config.*\`, \`webpack.config.*\`, \`next.config.*\`
|
|
1233
|
+
- Entry points: \`main.js\`, \`app.js\`, \`index.ts\`
|
|
1234
|
+
- Router definition
|
|
1235
|
+
- Example API service files
|
|
1236
|
+
- Example store/state files
|
|
1237
|
+
- README if present
|
|
1087
1238
|
`;
|
|
1088
1239
|
}
|
|
1089
1240
|
|
|
@@ -1115,7 +1266,7 @@ async function main() {
|
|
|
1115
1266
|
|
|
1116
1267
|
console.log(pc.bold(pc.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')));
|
|
1117
1268
|
console.log(' ' + pc.bold('thachvd-kit') + ' — Project Init Wizard');
|
|
1118
|
-
console.log(` Generates .
|
|
1269
|
+
console.log(` Generates AGENTS.md${useScan ? ' (scan-assisted)' : ''}`);
|
|
1119
1270
|
console.log(pc.bold(pc.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')) + '\n');
|
|
1120
1271
|
|
|
1121
1272
|
let projectSetup = 'new';
|
|
@@ -1265,91 +1416,46 @@ async function main() {
|
|
|
1265
1416
|
data.scan_evidence = scanned?.scan_evidence || [];
|
|
1266
1417
|
data.app_root = scanned?.app_root || '.';
|
|
1267
1418
|
|
|
1268
|
-
if (!assumeYes) {
|
|
1269
|
-
const aiRefineAnswer = await askQuestions({
|
|
1270
|
-
type: 'confirm',
|
|
1271
|
-
name: 'ai_refine',
|
|
1272
|
-
message: 'Should the agent refine PROJECT_CONTEXT.md on first session start?',
|
|
1273
|
-
initial: useScan
|
|
1274
|
-
});
|
|
1275
|
-
requestAiRefinement = Boolean(aiRefineAnswer.ai_refine);
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
data.context_status = 'baseline';
|
|
1279
|
-
data.needs_ai_refinement = requestAiRefinement;
|
|
1280
|
-
data.last_refined_at = 'not-yet-refined';
|
|
1281
1419
|
data.infrastructure = [];
|
|
1282
1420
|
if (data.uses_docker) data.infrastructure.push('docker');
|
|
1283
1421
|
if (data.cloud !== 'none') data.infrastructure.push(data.cloud);
|
|
1284
|
-
|
|
1285
|
-
// --- Copy .agent folder ---
|
|
1286
|
-
const agentDir = path.join(targetDir, '.agent');
|
|
1287
|
-
console.log(`\n${pc.bold(pc.cyan('━━ Generating Files ━━'))}`);
|
|
1288
|
-
|
|
1289
|
-
if (!fs.existsSync(agentDir)) {
|
|
1290
|
-
fs.mkdirSync(agentDir, { recursive: true });
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
// Copy folders: agents, rules, skills, workflows
|
|
1294
|
-
const foldersToCopy = ['agents', 'rules', 'skills', 'workflows'];
|
|
1295
|
-
for (const folder of foldersToCopy) {
|
|
1296
|
-
const srcPath = path.join(sourceDir, folder);
|
|
1297
|
-
const destPath = path.join(agentDir, folder);
|
|
1298
|
-
if (fs.existsSync(srcPath)) {
|
|
1299
|
-
// Use basic recursive copy since Node 16.7 fs.cpSync handles this
|
|
1300
|
-
fs.cpSync(srcPath, destPath, { recursive: true, force: true });
|
|
1301
|
-
console.log(` ${pc.green('✓')} Copied ${pc.bold(`.agent/${folder}`)}`);
|
|
1302
|
-
} else {
|
|
1303
|
-
console.log(` ${pc.yellow('-')} Source ${folder} not found.`);
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
// Write contexts
|
|
1308
|
-
const projectContextPath = path.join(targetDir, 'PROJECT_CONTEXT.md');
|
|
1309
|
-
fs.writeFileSync(projectContextPath, generateProjectContext(data), 'utf8');
|
|
1310
|
-
console.log(` ${pc.green('✓')} Generated ${pc.bold('PROJECT_CONTEXT.md')}`);
|
|
1311
1422
|
|
|
1312
|
-
|
|
1313
|
-
fs.writeFileSync(claudeMdPath, generateClaudeMd(data), 'utf8');
|
|
1314
|
-
console.log(` ${pc.green('✓')} Generated ${pc.bold('CLAUDE.md')}`);
|
|
1423
|
+
console.log(`\n${pc.bold(pc.cyan('━━ Generating Files ━━'))}`);
|
|
1315
1424
|
|
|
1425
|
+
// Write AGENTS.md — the only output file
|
|
1316
1426
|
const agentsMdPath = path.join(targetDir, 'AGENTS.md');
|
|
1427
|
+
const agentsMdExists = fs.existsSync(agentsMdPath);
|
|
1428
|
+
if (agentsMdExists && !assumeYes) {
|
|
1429
|
+
const res = await askQuestions({
|
|
1430
|
+
type: 'confirm',
|
|
1431
|
+
name: 'overwrite',
|
|
1432
|
+
message: 'AGENTS.md already exists. Overwrite?',
|
|
1433
|
+
initial: false
|
|
1434
|
+
});
|
|
1435
|
+
if (!res.overwrite) {
|
|
1436
|
+
console.log(pc.yellow('\nAborted. Existing AGENTS.md unchanged.'));
|
|
1437
|
+
process.exit(0);
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1317
1441
|
fs.writeFileSync(agentsMdPath, generateAgentsMd(data), 'utf8');
|
|
1318
1442
|
console.log(` ${pc.green('✓')} Generated ${pc.bold('AGENTS.md')}`);
|
|
1319
1443
|
|
|
1320
|
-
|
|
1321
|
-
if (requestAiRefinement) {
|
|
1322
|
-
aiRefinementPath = path.join(targetDir, 'AI_CONTEXT_REFINEMENT.md');
|
|
1323
|
-
fs.writeFileSync(aiRefinementPath, generateAiContextRefinementPrompt(data), 'utf8');
|
|
1324
|
-
console.log(` ${pc.green('✓')} Generated ${pc.bold('AI_CONTEXT_REFINEMENT.md')}`);
|
|
1325
|
-
}
|
|
1444
|
+
console.log(`\n${pc.bold(pc.green('━━ Done! ━━'))}
|
|
1326
1445
|
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
${pc.bold('Project:')} ${data.project_name}
|
|
1332
|
-
${pc.bold('Stack:')} ${data.primary_language} | ${(data.frameworks || []).join(', ') || 'no framework'}
|
|
1333
|
-
${pc.bold('Infra:')} ${(data.infrastructure || []).join(', ') || 'none'}
|
|
1334
|
-
|
|
1335
|
-
${pc.bold('Auto-resolved skills:')}
|
|
1336
|
-
${autoSkills.map(s => ' · ' + s).join('\n')}
|
|
1337
|
-
|
|
1338
|
-
${pc.bold('Generated files:')}
|
|
1339
|
-
· ${pc.bold(projectContextPath)}
|
|
1340
|
-
· ${pc.bold(claudeMdPath)}
|
|
1341
|
-
· ${pc.bold(agentsMdPath)}
|
|
1342
|
-
${aiRefinementPath ? ` · ${pc.bold(aiRefinementPath)}` : ''}
|
|
1446
|
+
${pc.bold('Project:')} ${data.project_name}
|
|
1447
|
+
${pc.bold('Stack:')} ${data.primary_language} | ${(data.frameworks || []).join(', ') || 'no framework'}
|
|
1448
|
+
|
|
1449
|
+
${pc.bold('Generated:')} ${pc.bold(agentsMdPath)}
|
|
1343
1450
|
|
|
1344
1451
|
${pc.bold('Next steps:')}
|
|
1345
|
-
1.
|
|
1346
|
-
2.
|
|
1347
|
-
3.
|
|
1348
|
-
4. Open project in Claude Code or Codex — the agent will read context on start
|
|
1452
|
+
1. ${useScan ? `Open ${pc.bold('AGENTS.md')} — paste its content into your AI editor to fill in the placeholders` : `Edit ${pc.bold('AGENTS.md')} and fill in Core Architecture, Coding Conventions, Performance sections`}
|
|
1453
|
+
2. Commit ${pc.bold('AGENTS.md')} to the repo
|
|
1454
|
+
3. Open project in Claude Code / Codex / Antigravity — agent reads AGENTS.md automatically
|
|
1349
1455
|
`);
|
|
1350
1456
|
}
|
|
1351
|
-
|
|
1352
|
-
main().catch(err => {
|
|
1353
|
-
console.error(pc.red('\nError during init:'), err);
|
|
1354
|
-
process.exit(1);
|
|
1355
|
-
});
|
|
1457
|
+
|
|
1458
|
+
main().catch(err => {
|
|
1459
|
+
console.error(pc.red('\nError during init:'), err);
|
|
1460
|
+
process.exit(1);
|
|
1461
|
+
});
|