memoir-cli 1.4.4 → 1.4.5

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.4",
3
+ "version": "1.4.5",
4
4
  "description": "Sync and translate AI memory across devices and tools. Back up Claude, Gemini, Codex, Cursor, Copilot, Windsurf, and Aider configs. Migrate instructions between AI coding assistants with one command.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -55,6 +55,7 @@
55
55
  "fs-extra": "^11.2.0",
56
56
  "gradient-string": "^3.0.0",
57
57
  "inquirer": "^9.2.15",
58
+ "memoir-cli": "^1.4.4",
58
59
  "open": "^11.0.0",
59
60
  "ora": "^7.0.1"
60
61
  }
@@ -2,17 +2,27 @@ import inquirer from 'inquirer';
2
2
  import chalk from 'chalk';
3
3
  import boxen from 'boxen';
4
4
  import gradient from 'gradient-string';
5
- import { execSync } from 'child_process';
5
+ import { execFileSync } 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
10
  function getGitUsername() {
11
11
  try {
12
- return execSync('git config --global user.name', { encoding: 'utf8' }).trim();
12
+ return execFileSync('git', ['config', '--global', 'user.name'], { encoding: 'utf8' }).trim();
13
13
  } catch { return ''; }
14
14
  }
15
15
 
16
+ function getGitHubUsername() {
17
+ try {
18
+ // Try gh CLI first
19
+ return execFileSync('gh', ['api', 'user', '--jq', '.login'], { encoding: 'utf8' }).trim();
20
+ } catch {
21
+ // Fall back to git config
22
+ return getGitUsername();
23
+ }
24
+ }
25
+
16
26
  export async function initCommand() {
17
27
  console.log('');
18
28
  console.log(boxen(
@@ -22,7 +32,7 @@ export async function initCommand() {
22
32
  ));
23
33
  console.log('');
24
34
 
25
- const gitUser = getGitUsername();
35
+ const detectedUser = getGitHubUsername();
26
36
 
27
37
  const { direction, provider } = await inquirer.prompt([
28
38
  {
@@ -57,27 +67,46 @@ export async function initCommand() {
57
67
  }]);
58
68
  config.localPath = localPath;
59
69
  } else {
60
- const { username, repo } = await inquirer.prompt([
61
- {
62
- type: 'input',
63
- name: 'username',
64
- message: 'GitHub username:',
65
- validate: (input) => input.trim() ? true : 'Required'
66
- },
67
- {
70
+ // Pre-fill username if detected, just ask for repo name
71
+ const prompts = [];
72
+
73
+ if (detectedUser) {
74
+ console.log(chalk.gray(` GitHub user: ${chalk.cyan(detectedUser)}`));
75
+ prompts.push({
68
76
  type: 'input',
69
77
  name: 'repo',
70
- message: 'Repo name:',
78
+ message: `Repo name (${detectedUser}/???):`,
71
79
  default: 'ai-memory',
72
80
  validate: (input) => input.trim() ? true : 'Required'
73
- }
74
- ]);
81
+ });
82
+ } else {
83
+ prompts.push(
84
+ {
85
+ type: 'input',
86
+ name: 'username',
87
+ message: 'GitHub username:',
88
+ validate: (input) => input.trim() ? true : 'Required'
89
+ },
90
+ {
91
+ type: 'input',
92
+ name: 'repo',
93
+ message: 'Repo name:',
94
+ default: 'ai-memory',
95
+ validate: (input) => input.trim() ? true : 'Required'
96
+ }
97
+ );
98
+ }
99
+
100
+ const answers = await inquirer.prompt(prompts);
101
+ const username = (answers.username || detectedUser).trim();
102
+ const repo = answers.repo.trim();
75
103
 
76
- config.gitRepo = `https://github.com/${username.trim()}/${repo.trim()}.git`;
104
+ config.gitRepo = `https://github.com/${username}/${repo}.git`;
105
+ console.log(chalk.gray(` → ${config.gitRepo}\n`));
77
106
  }
78
107
 
79
108
  await saveConfig(config);
80
- console.log(chalk.green('Saved!\n'));
109
+ console.log(chalk.green('Saved!\n'));
81
110
 
82
111
  if (direction === 'upload') {
83
112
  await pushCommand();