memoir-cli 1.4.1 → 1.4.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memoir-cli",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Your AI remembers everything. Sync it everywhere.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -1,44 +1,46 @@
1
1
  import inquirer from 'inquirer';
2
2
  import chalk from 'chalk';
3
- import open from 'open';
4
3
  import boxen from 'boxen';
5
4
  import gradient from 'gradient-string';
5
+ import { execSync } from 'child_process';
6
6
  import { saveConfig } from '../config.js';
7
7
  import { pushCommand } from './push.js';
8
8
  import { restoreCommand } from './restore.js';
9
9
 
10
+ function getGitUsername() {
11
+ try {
12
+ return execSync('git config --global user.name', { encoding: 'utf8' }).trim();
13
+ } catch { return ''; }
14
+ }
15
+
10
16
  export async function initCommand() {
11
- const title = gradient.pastel.multiline('memoir \\nYour AI Remembers Everything');
12
- console.log('\\n' + boxen(title, {
13
- padding: 1,
14
- margin: 1,
15
- borderStyle: 'round',
16
- borderColor: 'cyan',
17
- align: 'center'
18
- }));
17
+ console.log('');
18
+ console.log(boxen(
19
+ gradient.pastel('memoir') + '\n' +
20
+ chalk.gray('Your AI remembers everything.'),
21
+ { padding: 1, margin: 0, borderStyle: 'round', borderColor: 'cyan', align: 'center' }
22
+ ));
23
+ console.log('');
19
24
 
20
- console.log(chalk.gray("Let's get your AI memory set up.\\n"));
25
+ const gitUser = getGitUsername();
21
26
 
22
- const { direction } = await inquirer.prompt([
27
+ const { direction, provider } = await inquirer.prompt([
23
28
  {
24
29
  type: 'list',
25
30
  name: 'direction',
26
- message: 'What do you want to do?',
31
+ message: 'Upload or download?',
27
32
  choices: [
28
- { name: '⬆️ Upload ' + chalk.gray('(backup this machine\'s AI memory)'), value: 'upload' },
29
- { name: '⬇️ Download ' + chalk.gray('(restore AI memory to this machine)'), value: 'download' }
33
+ { name: 'Upload back up this machine', value: 'upload' },
34
+ { name: 'Download restore from backup', value: 'download' }
30
35
  ]
31
- }
32
- ]);
33
-
34
- const { provider } = await inquirer.prompt([
36
+ },
35
37
  {
36
38
  type: 'list',
37
39
  name: 'provider',
38
- message: 'Where do you want to store it?',
40
+ message: (answers) => answers.direction === 'upload' ? 'Back up to?' : 'Restore from?',
39
41
  choices: [
40
- { name: '☁️ GitHub ' + chalk.gray('(sync across computers)'), value: 'git' },
41
- { name: '📂 Local Directory ' + chalk.gray('(Dropbox, iCloud, etc.)'), value: 'local' }
42
+ { name: 'GitHub', value: 'git' },
43
+ { name: 'Local folder', value: 'local' }
42
44
  ]
43
45
  }
44
46
  ]);
@@ -46,46 +48,33 @@ export async function initCommand() {
46
48
  let config = { provider };
47
49
 
48
50
  if (provider === 'local') {
49
- const { localPath } = await inquirer.prompt([
50
- {
51
- type: 'input',
52
- name: 'localPath',
53
- message: 'Path to sync directory ' + chalk.gray('(e.g., ~/Dropbox/memoir):'),
54
- validate: (input) => input.trim() !== '' ? true : chalk.red('✖ Path is required')
55
- }
56
- ]);
51
+ const msg = direction === 'upload' ? 'Save to:' : 'Backup folder:';
52
+ const { localPath } = await inquirer.prompt([{
53
+ type: 'input',
54
+ name: 'localPath',
55
+ message: msg,
56
+ validate: (input) => input.trim() ? true : 'Required'
57
+ }]);
57
58
  config.localPath = localPath;
58
59
  } else {
59
- const { repoInput } = await inquirer.prompt([
60
- {
61
- type: 'input',
62
- name: 'repoInput',
63
- message: 'GitHub repo ' + chalk.gray('(e.g., camgitt/brain):'),
64
- validate: (input) => {
65
- if (input.trim() === '') return chalk.red('✖ Repo is required');
66
- return true;
67
- }
68
- }
69
- ]);
60
+ const { username } = await inquirer.prompt([{
61
+ type: 'input',
62
+ name: 'username',
63
+ message: 'GitHub username:',
64
+ default: gitUser || undefined,
65
+ validate: (input) => input.trim() ? true : 'Required'
66
+ }]);
70
67
 
71
- // Accept shorthand like "camgitt/brain" or full URLs
72
- let gitRepo = repoInput.trim();
73
- if (!gitRepo.includes('github.com') && !gitRepo.includes('gitlab.com')) {
74
- gitRepo = `https://github.com/${gitRepo}.git`;
75
- }
76
- config.gitRepo = gitRepo;
68
+ config.gitRepo = `https://github.com/${username.trim()}/ai-memory.git`;
69
+ console.log(chalk.gray(` Using repo: ${config.gitRepo}`));
77
70
  }
78
71
 
79
72
  await saveConfig(config);
73
+ console.log(chalk.green('Saved!\n'));
80
74
 
81
- console.log('\\n' + chalk.green('✔ Configuration saved!'));
82
-
83
- // Immediately run the chosen action
84
75
  if (direction === 'upload') {
85
- console.log(chalk.cyan('\\n↗ Uploading your AI memory...\\n'));
86
76
  await pushCommand();
87
77
  } else {
88
- console.log(chalk.cyan('\\n↙ Downloading your AI memory...\\n'));
89
78
  await restoreCommand();
90
79
  }
91
80
  }