MCPcopy
hub / github.com/renatoasse/opensquad / init

Function init

src/init.js:38–125  ·  view source on GitHub ↗
(targetDir, options = {})

Source from the content-addressed store, hash-verified

36];
37
38export async function init(targetDir, options = {}) {
39
40 // Check if already initialized
41 let isReInit = false;
42 try {
43 await stat(join(targetDir, '_opensquad'));
44 isReInit = true;
45 } catch {
46 // Not initialized yet — continue
47 }
48
49 console.log(isReInit ? '\n 🔄 Opensquad — Re-configure\n' : '\n 🟢 Opensquad — Setup\n');
50
51 // Guided installation (skip in test mode)
52 let language = options._language || 'English';
53 let ides = options._ides ?? ['claude-code'];
54 let userName = '';
55
56 if (!options._skipPrompts) {
57 const prompt = createPrompt();
58
59 try {
60 // Language is asked FIRST (in English, before locale is loaded)
61 const langChoice = await prompt.choose('What language do you prefer for outputs?', LANGUAGES);
62 language = langChoice.value;
63
64 // Load locale — all messages from here are translated
65 await loadLocale(language);
66
67 console.log(`\n ${t('welcome')}\n`);
68
69 userName = (await prompt.ask(` ${t('askName')}`)).trim();
70
71 ides = await prompt.multiChoose(t('chooseIdes'), IDES);
72 } finally {
73 prompt.close();
74 }
75 } else {
76 await loadLocale(language);
77 }
78
79 // Copy template files
80 await copyCommonTemplates(targetDir);
81 await copyCanonicalSources(targetDir);
82 await copyIdeTemplates(ides, targetDir);
83 await installAllSkills(targetDir);
84 if (!options._skipPrompts) {
85 await installDependencies(targetDir);
86 }
87 await writeProjectReadme(targetDir);
88
89 // Write user preferences
90 const prefsPath = join(targetDir, '_opensquad', '_memory', 'preferences.md');
91 await mkdir(dirname(prefsPath), { recursive: true });
92 const prefsContent = `# Opensquad Preferences
93
94- **User Name:** ${userName}
95- **Output Language:** ${language}

Callers 3

init.test.jsFile · 0.90
update.test.jsFile · 0.90
opensquad.jsFile · 0.90

Calls 10

createPromptFunction · 0.90
loadLocaleFunction · 0.90
tFunction · 0.90
logEventFunction · 0.90
copyCommonTemplatesFunction · 0.85
copyCanonicalSourcesFunction · 0.85
copyIdeTemplatesFunction · 0.85
installAllSkillsFunction · 0.85
installDependenciesFunction · 0.85
writeProjectReadmeFunction · 0.85

Tested by

no test coverage detected