gramatr 0.3.45 → 0.3.46
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/bin/install.ts +29 -18
- package/core/version.ts +1 -1
- package/package.json +1 -1
package/bin/install.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
14
|
existsSync, readFileSync, writeFileSync, mkdirSync, cpSync,
|
|
15
|
-
readdirSync, statSync, chmodSync,
|
|
15
|
+
readdirSync, statSync, chmodSync, rmSync,
|
|
16
16
|
} from 'fs';
|
|
17
17
|
import { join, dirname, basename, resolve } from 'path';
|
|
18
18
|
import { execSync, spawnSync } from 'child_process';
|
|
@@ -28,7 +28,6 @@ const CLAUDE_SETTINGS = join(CLAUDE_DIR, 'settings.json');
|
|
|
28
28
|
const CLAUDE_JSON = join(HOME, '.claude.json');
|
|
29
29
|
const CLIENT_DIR = join(HOME, 'gmtr-client');
|
|
30
30
|
const GMTR_JSON = join(HOME, '.gmtr.json');
|
|
31
|
-
const GMTR_BIN = join(HOME, '.gmtr', 'bin');
|
|
32
31
|
const SCRIPT_DIR = dirname(dirname(resolve(import.meta.filename || __filename)));
|
|
33
32
|
const DEFAULT_URL = 'https://api.gramatr.com/mcp';
|
|
34
33
|
|
|
@@ -36,6 +35,14 @@ const args = process.argv.slice(2);
|
|
|
36
35
|
const YES = args.includes('--yes') || args.includes('-y');
|
|
37
36
|
const isInteractive = process.stdin.isTTY && !YES;
|
|
38
37
|
|
|
38
|
+
function getArgValue(flag: string): string | undefined {
|
|
39
|
+
const idx = args.indexOf(flag);
|
|
40
|
+
return idx !== -1 && idx + 1 < args.length ? args[idx + 1] : undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const ARG_NAME = getArgValue('--name');
|
|
44
|
+
const ARG_TIMEZONE = getArgValue('--timezone');
|
|
45
|
+
|
|
39
46
|
// ── Helpers ──
|
|
40
47
|
|
|
41
48
|
function log(msg: string): void { process.stdout.write(`${msg}\n`); }
|
|
@@ -157,19 +164,6 @@ async function checkPrereqs(): Promise<{ tsRunner: string }> {
|
|
|
157
164
|
log(`OK TS runner: npx tsx (install bun for faster hooks)`);
|
|
158
165
|
}
|
|
159
166
|
|
|
160
|
-
// Ensure ~/.gmtr/bin exists and is on PATH
|
|
161
|
-
mkdirSync(GMTR_BIN, { recursive: true });
|
|
162
|
-
const pathLine = 'export PATH="$HOME/.gmtr/bin:$PATH"';
|
|
163
|
-
for (const rc of ['.zshrc', '.bashrc']) {
|
|
164
|
-
const rcPath = join(HOME, rc);
|
|
165
|
-
if (existsSync(rcPath)) {
|
|
166
|
-
const content = readFileSync(rcPath, 'utf8');
|
|
167
|
-
if (!content.includes('.gmtr/bin')) {
|
|
168
|
-
appendFileSync(rcPath, `\n# gramatr — local tool binaries\n${pathLine}\n`);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
167
|
// Claude Code
|
|
174
168
|
if (!existsSync(CLAUDE_DIR)) {
|
|
175
169
|
log('X Claude Code not found (~/.claude/ does not exist)');
|
|
@@ -446,23 +440,40 @@ async function configureIdentity(): Promise<void> {
|
|
|
446
440
|
|
|
447
441
|
const settings = readJson(settingsPath);
|
|
448
442
|
const currentName = settings.principal?.name || 'User';
|
|
443
|
+
let changed = false;
|
|
449
444
|
|
|
450
|
-
|
|
445
|
+
// --name flag takes precedence
|
|
446
|
+
if (ARG_NAME) {
|
|
447
|
+
settings.principal = settings.principal || {};
|
|
448
|
+
settings.principal.name = ARG_NAME;
|
|
449
|
+
log(` OK Set principal.name to "${ARG_NAME}"`);
|
|
450
|
+
changed = true;
|
|
451
|
+
} else if (currentName === 'User' && isInteractive) {
|
|
451
452
|
const name = await prompt(' What is your name? (shown in gramatr responses)');
|
|
452
453
|
if (name) {
|
|
453
454
|
settings.principal = settings.principal || {};
|
|
454
455
|
settings.principal.name = name;
|
|
455
456
|
log(` OK Set principal.name to "${name}"`);
|
|
457
|
+
changed = true;
|
|
456
458
|
}
|
|
459
|
+
}
|
|
457
460
|
|
|
461
|
+
// --timezone flag takes precedence
|
|
462
|
+
if (ARG_TIMEZONE) {
|
|
463
|
+
settings.principal = settings.principal || {};
|
|
464
|
+
settings.principal.timezone = ARG_TIMEZONE;
|
|
465
|
+
log(` OK Set timezone to "${ARG_TIMEZONE}"`);
|
|
466
|
+
changed = true;
|
|
467
|
+
} else if (currentName === 'User' && isInteractive) {
|
|
458
468
|
const tz = await prompt(' Your timezone?', 'America/Chicago');
|
|
459
469
|
settings.principal = settings.principal || {};
|
|
460
470
|
settings.principal.timezone = tz;
|
|
461
471
|
log(` OK Set timezone to "${tz}"`);
|
|
462
|
-
|
|
463
|
-
writeJson(settingsPath, settings);
|
|
472
|
+
changed = true;
|
|
464
473
|
}
|
|
465
474
|
|
|
475
|
+
if (changed) writeJson(settingsPath, settings);
|
|
476
|
+
|
|
466
477
|
log('');
|
|
467
478
|
}
|
|
468
479
|
|
package/core/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Auto-generated by version-sync.ts — do not edit */
|
|
2
|
-
export const VERSION = '0.3.
|
|
2
|
+
export const VERSION = '0.3.46';
|