MCPcopy
hub / github.com/shareAI-lab/Kode-CLI / main

Function main

cli.js:78–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76}
77
78function main() {
79 const packageRoot = findPackageRoot(__dirname)
80 const pkg = readPackageJson(packageRoot)
81 const version = pkg?.version || ''
82
83 if (hasFlag('--help-lite')) {
84 printHelpLite()
85 process.exit(0)
86 }
87
88 if (hasFlag('--version') || hasFlag('-v')) {
89 process.stdout.write(`${version}\n`)
90 process.exit(0)
91 }
92
93 // Native binary (npm optionalDependencies, no GitHub postinstall).
94 const nativeBin = tryResolveNativeBinaryFromOptionalDeps()
95 if (nativeBin) {
96 run(nativeBin, process.argv.slice(2))
97 }
98
99 // Node.js runtime fallback.
100 const distEntry = path.join(packageRoot, 'dist', 'index.js')
101 if (fs.existsSync(distEntry)) {
102 run(process.execPath, [distEntry, ...process.argv.slice(2)])
103 }
104
105 // Final fallback: explain what to do
106 process.stderr.write(
107 [
108 '❌ Kode is not runnable on this system.',
109 '',
110 'Tried:',
111 '- Native binary (optionalDependencies)',
112 '- Node.js runtime (dist/index.js)',
113 '',
114 'Fix:',
115 '- Reinstall with optionalDependencies enabled (avoid --no-optional/--omit=optional)',
116 '- Or install a platform binary package: @shareai-lab/kode-bin-<platform>-<arch>',
117 '- Or reinstall and ensure dist/ is present (npm install -g @shareai-lab/kode)',
118 '- Or run from source: bun run dev',
119 '',
120 version ? `Package version: ${version}` : '',
121 ].join('\n'),
122 )
123 process.exit(1)
124}
125
126if (require.main === module) {
127 main()

Callers 1

cli.jsFile · 0.70

Calls 8

joinMethod · 0.80
findPackageRootFunction · 0.70
readPackageJsonFunction · 0.70
hasFlagFunction · 0.70
printHelpLiteFunction · 0.70
runFunction · 0.70
writeMethod · 0.65

Tested by

no test coverage detected