@claudetools/tools 0.8.7 → 0.8.10
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/dist/setup.js +118 -37
- package/package.json +1 -1
package/dist/setup.js
CHANGED
|
@@ -1506,26 +1506,74 @@ async function runOnboarding(apiUrl, apiKey, projectId, projectName) {
|
|
|
1506
1506
|
}
|
|
1507
1507
|
}
|
|
1508
1508
|
// -----------------------------------------------------------------------------
|
|
1509
|
-
// Project Init
|
|
1509
|
+
// Project Init (Simplified - handles everything in one command)
|
|
1510
1510
|
// -----------------------------------------------------------------------------
|
|
1511
1511
|
export async function runInit() {
|
|
1512
|
-
console.log('\n' + chalk.bold.cyan(' ClaudeTools
|
|
1512
|
+
console.log('\n' + chalk.bold.cyan(' ClaudeTools Setup') + '\n');
|
|
1513
|
+
console.log(' ' + chalk.dim('Persistent AI memory for Claude Code') + '\n');
|
|
1513
1514
|
const cwd = process.cwd();
|
|
1514
1515
|
const projectName = basename(cwd);
|
|
1515
1516
|
const projectClaudeDir = join(cwd, '.claude');
|
|
1516
1517
|
const projectClaudeMd = join(projectClaudeDir, 'CLAUDE.md');
|
|
1517
|
-
//
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1518
|
+
// Ensure config directory exists
|
|
1519
|
+
await ensureConfigDir();
|
|
1520
|
+
// Load or create config (merge with defaults to ensure all fields exist)
|
|
1521
|
+
const loadedConfig = await loadConfigFromFile();
|
|
1522
|
+
let config = { ...DEFAULT_CONFIG, ...loadedConfig };
|
|
1523
|
+
// Step 1: API Key
|
|
1524
|
+
if (!config.apiKey) {
|
|
1525
|
+
header('API Key');
|
|
1526
|
+
console.log(' Get your API key from: ' + chalk.cyan.underline('https://claudetools.dev/dashboard') + '\n');
|
|
1527
|
+
const { apiKey } = await prompts({
|
|
1528
|
+
type: 'password',
|
|
1529
|
+
name: 'apiKey',
|
|
1530
|
+
message: 'Enter your API key:',
|
|
1531
|
+
validate: (v) => v.startsWith('ct_') || 'API key should start with ct_',
|
|
1532
|
+
});
|
|
1533
|
+
if (!apiKey) {
|
|
1534
|
+
error('API key is required');
|
|
1535
|
+
process.exit(1);
|
|
1536
|
+
}
|
|
1537
|
+
config.apiKey = apiKey;
|
|
1538
|
+
// Verify API key
|
|
1539
|
+
const spinner = ora('Verifying API key...').start();
|
|
1540
|
+
try {
|
|
1541
|
+
const response = await fetch(`${config.apiUrl || DEFAULT_CONFIG.apiUrl}/api/v1/users/me`, {
|
|
1542
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
1543
|
+
});
|
|
1544
|
+
if (!response.ok) {
|
|
1545
|
+
spinner.fail('Invalid API key');
|
|
1546
|
+
process.exit(1);
|
|
1547
|
+
}
|
|
1548
|
+
const userData = await response.json();
|
|
1549
|
+
spinner.succeed(`Authenticated as ${userData.email || userData.name || 'user'}`);
|
|
1550
|
+
}
|
|
1551
|
+
catch {
|
|
1552
|
+
spinner.fail('Could not verify API key');
|
|
1553
|
+
process.exit(1);
|
|
1554
|
+
}
|
|
1555
|
+
// Save config immediately
|
|
1556
|
+
await saveConfig(config);
|
|
1557
|
+
success(`API key saved to ${getConfigPath()}`);
|
|
1522
1558
|
}
|
|
1523
|
-
|
|
1524
|
-
|
|
1559
|
+
else {
|
|
1560
|
+
info(`Using existing API key: ${config.apiKey.substring(0, 10)}...`);
|
|
1561
|
+
}
|
|
1562
|
+
// Step 2: System Registration (auto-register if needed)
|
|
1563
|
+
let systemInfo = loadSystemInfo();
|
|
1525
1564
|
if (!systemInfo?.system_id) {
|
|
1526
|
-
|
|
1527
|
-
|
|
1565
|
+
systemInfo = await registerSystem(config.apiUrl || DEFAULT_CONFIG.apiUrl, config.apiKey);
|
|
1566
|
+
if (systemInfo) {
|
|
1567
|
+
saveSystemInfo(systemInfo);
|
|
1568
|
+
success(`System registered: ${systemInfo.system_id}`);
|
|
1569
|
+
}
|
|
1570
|
+
else {
|
|
1571
|
+
error('Could not register system');
|
|
1572
|
+
process.exit(1);
|
|
1573
|
+
}
|
|
1528
1574
|
}
|
|
1575
|
+
// Initialize projects file
|
|
1576
|
+
initializeProjectsFile();
|
|
1529
1577
|
// Detect git remote for this directory
|
|
1530
1578
|
const gitRemote = detectGitRemote(cwd);
|
|
1531
1579
|
// Try to register project with API
|
|
@@ -1666,41 +1714,74 @@ export async function runInit() {
|
|
|
1666
1714
|
const newContent = existingContent.trimEnd() + '\n' + projectContent;
|
|
1667
1715
|
writeFileSync(projectClaudeMd, newContent);
|
|
1668
1716
|
success('Created .claude/CLAUDE.md');
|
|
1669
|
-
//
|
|
1670
|
-
|
|
1671
|
-
|
|
1717
|
+
// Step 3: Configure Claude Code integration
|
|
1718
|
+
header('Claude Code Integration');
|
|
1719
|
+
// Configure MCP settings (adds claudetools_memory server)
|
|
1720
|
+
try {
|
|
1721
|
+
ensureClaudeDir();
|
|
1722
|
+
// Read existing MCP config or create new one
|
|
1723
|
+
let mcpConfig = { mcpServers: {} };
|
|
1724
|
+
if (existsSync(MCP_CONFIG_PATH)) {
|
|
1725
|
+
try {
|
|
1726
|
+
mcpConfig = JSON.parse(readFileSync(MCP_CONFIG_PATH, 'utf-8'));
|
|
1727
|
+
}
|
|
1728
|
+
catch {
|
|
1729
|
+
// Start fresh
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
if (!mcpConfig.mcpServers || typeof mcpConfig.mcpServers !== 'object') {
|
|
1733
|
+
mcpConfig.mcpServers = {};
|
|
1734
|
+
}
|
|
1735
|
+
const servers = mcpConfig.mcpServers;
|
|
1736
|
+
// Add claudetools if not already present
|
|
1737
|
+
if (!servers['claudetools_memory']) {
|
|
1738
|
+
servers['claudetools_memory'] = {
|
|
1739
|
+
command: 'claudetools',
|
|
1740
|
+
};
|
|
1741
|
+
writeFileSync(MCP_CONFIG_PATH, JSON.stringify(mcpConfig, null, 2));
|
|
1742
|
+
success('Added ClaudeTools to MCP config');
|
|
1743
|
+
}
|
|
1744
|
+
else {
|
|
1745
|
+
info('ClaudeTools already in MCP config');
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
catch (err) {
|
|
1749
|
+
console.log(chalk.yellow('⚠ Warning: Could not configure MCP. You may need to add claudetools manually.'));
|
|
1750
|
+
}
|
|
1751
|
+
// Add global CLAUDE.md section (auto, no prompt)
|
|
1752
|
+
try {
|
|
1753
|
+
let globalContent = '';
|
|
1754
|
+
if (existsSync(CLAUDE_MD_PATH)) {
|
|
1755
|
+
globalContent = readFileSync(CLAUDE_MD_PATH, 'utf-8');
|
|
1756
|
+
}
|
|
1757
|
+
if (!globalContent.includes(SECTION_START)) {
|
|
1758
|
+
const newGlobalContent = globalContent.trimEnd() + '\n' + GLOBAL_TEMPLATE;
|
|
1759
|
+
writeFileSync(CLAUDE_MD_PATH, newGlobalContent);
|
|
1760
|
+
success('Added ClaudeTools to global CLAUDE.md');
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
catch {
|
|
1764
|
+
// Non-fatal
|
|
1765
|
+
}
|
|
1766
|
+
// Install hooks
|
|
1672
1767
|
try {
|
|
1673
1768
|
await installHooks();
|
|
1674
1769
|
await configureSettings();
|
|
1675
|
-
|
|
1770
|
+
success('Hooks installed');
|
|
1676
1771
|
}
|
|
1677
1772
|
catch (err) {
|
|
1678
|
-
|
|
1679
|
-
console.log(chalk.yellow('⚠ Warning: Could not configure hooks. Run "claudetools --setup" to fix.'));
|
|
1773
|
+
console.log(chalk.yellow('⚠ Warning: Could not configure hooks.'));
|
|
1680
1774
|
}
|
|
1681
|
-
//
|
|
1682
|
-
|
|
1775
|
+
// Clean up legacy configs
|
|
1776
|
+
cleanupAllLegacyConfigs();
|
|
1777
|
+
// Done!
|
|
1778
|
+
header('Setup Complete');
|
|
1779
|
+
console.log(chalk.green(' ClaudeTools is ready!\n'));
|
|
1683
1780
|
console.log(' ' + chalk.bold('Project:') + ` ${projectName}`);
|
|
1684
1781
|
console.log(' ' + chalk.bold('ID:') + ` ${projectId}`);
|
|
1685
1782
|
console.log(' ' + chalk.bold('Config:') + ` ${projectClaudeMd}\n`);
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
const { runOnboard } = await prompts({
|
|
1689
|
-
type: 'confirm',
|
|
1690
|
-
name: 'runOnboard',
|
|
1691
|
-
message: 'Run project onboarding? (Helps Claude understand your project)',
|
|
1692
|
-
initial: true,
|
|
1693
|
-
});
|
|
1694
|
-
if (runOnboard) {
|
|
1695
|
-
await runOnboarding(config.apiUrl || DEFAULT_CONFIG.apiUrl, config.apiKey, projectId, projectName);
|
|
1696
|
-
}
|
|
1697
|
-
else {
|
|
1698
|
-
console.log(chalk.dim('\n You can run onboarding later with: claudetools onboard\n'));
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
else {
|
|
1702
|
-
console.log(chalk.dim(' Memory tools are now configured for this project.\n'));
|
|
1703
|
-
}
|
|
1783
|
+
console.log(' ' + chalk.bold('Next step:') + ' Restart Claude Code\n');
|
|
1784
|
+
console.log(chalk.dim(' Run `claudetools onboard` to teach Claude about this project.\n'));
|
|
1704
1785
|
}
|
|
1705
1786
|
// -----------------------------------------------------------------------------
|
|
1706
1787
|
// Cleanup Command (standalone)
|