gramatr 0.3.43 → 0.3.45
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/AGENTS.md +17 -0
- package/bin/install.ts +14 -18
- package/codex/install.ts +22 -5
- package/core/version.ts +1 -1
- package/gemini/install.ts +6 -2
- package/package.json +1 -1
package/AGENTS.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Gramatr Codex Guidance
|
|
2
|
+
|
|
3
|
+
## Repo Expectations
|
|
4
|
+
|
|
5
|
+
- Prefer gramatr memory and project handoff context over ad hoc local summaries.
|
|
6
|
+
- Treat Codex hook augmentation as authoritative when a `[GMTR Intelligence]` block is present.
|
|
7
|
+
- If gramatr augmentation is missing, query gramatr memory before relying on stale local notes.
|
|
8
|
+
- Prefer TypeScript implementations over shell scripts for client integration code unless the platform requires shell.
|
|
9
|
+
- Maintain test coverage for new hook and utility logic.
|
|
10
|
+
|
|
11
|
+
## Codex Integration
|
|
12
|
+
|
|
13
|
+
- Repo-local Codex hooks are configured in `.codex/hooks.json`.
|
|
14
|
+
- `UserPromptSubmit` is responsible for prompt enrichment.
|
|
15
|
+
- `SessionStart` is responsible for session restore and continuity.
|
|
16
|
+
- Hook failures must degrade cleanly and never block the user session.
|
|
17
|
+
|
package/bin/install.ts
CHANGED
|
@@ -577,7 +577,7 @@ function registerMcpServer(url: string, token: string): void {
|
|
|
577
577
|
|
|
578
578
|
// ── Step 4c: Additional CLIs ──
|
|
579
579
|
|
|
580
|
-
function installAdditionalClis(
|
|
580
|
+
async function installAdditionalClis(): Promise<void> {
|
|
581
581
|
log('━━━ Step 4c: Additional CLI platforms ━━━');
|
|
582
582
|
log('');
|
|
583
583
|
|
|
@@ -585,14 +585,12 @@ function installAdditionalClis(tsRunner: string): void {
|
|
|
585
585
|
const codexDir = join(HOME, '.codex');
|
|
586
586
|
if (existsSync(codexDir) || which('codex')) {
|
|
587
587
|
log(' Codex CLI detected — installing gramatr hooks...');
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
log(' X Codex install failed (non-fatal)');
|
|
595
|
-
}
|
|
588
|
+
try {
|
|
589
|
+
const { main: installCodex } = await import('../codex/install.ts');
|
|
590
|
+
installCodex();
|
|
591
|
+
log(' OK Codex hooks installed');
|
|
592
|
+
} catch (err: any) {
|
|
593
|
+
log(` X Codex install failed (non-fatal): ${err.message}`);
|
|
596
594
|
}
|
|
597
595
|
log('');
|
|
598
596
|
} else {
|
|
@@ -603,14 +601,12 @@ function installAdditionalClis(tsRunner: string): void {
|
|
|
603
601
|
const geminiDir = join(HOME, '.gemini');
|
|
604
602
|
if (existsSync(geminiDir) || which('gemini')) {
|
|
605
603
|
log(' Gemini CLI detected — installing gramatr extension...');
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
log(' X Gemini install failed (non-fatal)');
|
|
613
|
-
}
|
|
604
|
+
try {
|
|
605
|
+
const { main: installGemini } = await import('../gemini/install.ts');
|
|
606
|
+
await installGemini();
|
|
607
|
+
log(' OK Gemini extension installed');
|
|
608
|
+
} catch (err: any) {
|
|
609
|
+
log(` X Gemini install failed (non-fatal): ${err.message}`);
|
|
614
610
|
}
|
|
615
611
|
log('');
|
|
616
612
|
} else {
|
|
@@ -721,7 +717,7 @@ async function main(): Promise<void> {
|
|
|
721
717
|
await configureIdentity();
|
|
722
718
|
updateClaudeSettings(tsRunner, url, token);
|
|
723
719
|
registerMcpServer(url, token);
|
|
724
|
-
installAdditionalClis(
|
|
720
|
+
await installAdditionalClis();
|
|
725
721
|
|
|
726
722
|
const allOk = verify(url, token);
|
|
727
723
|
|
package/codex/install.ts
CHANGED
|
@@ -41,7 +41,7 @@ function readJsonFile<T>(path: string, fallback: T): T {
|
|
|
41
41
|
return JSON.parse(readFileSync(path, 'utf8')) as T;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
function main(): void {
|
|
44
|
+
export function main(): void {
|
|
45
45
|
const home = process.env.HOME || process.env.USERPROFILE;
|
|
46
46
|
if (!home) {
|
|
47
47
|
throw new Error('HOME is not set');
|
|
@@ -56,12 +56,25 @@ function main(): void {
|
|
|
56
56
|
const currentFile = fileURLToPath(import.meta.url);
|
|
57
57
|
const codexSourceDir = dirname(currentFile);
|
|
58
58
|
const clientSourceDir = dirname(codexSourceDir);
|
|
59
|
-
const packagesDir = dirname(clientSourceDir);
|
|
60
|
-
const repoRoot = dirname(packagesDir);
|
|
61
59
|
const codexTargetDir = join(gmtrDir, 'codex');
|
|
62
60
|
const sharedHookUtilsSource = join(clientSourceDir, 'hooks', 'lib', 'gmtr-hook-utils.ts');
|
|
63
61
|
const sharedHookUtilsTarget = join(gmtrDir, 'hooks', 'lib', 'gmtr-hook-utils.ts');
|
|
64
|
-
|
|
62
|
+
|
|
63
|
+
// AGENTS.md: check package root first (npm install), then repo root (dev)
|
|
64
|
+
let managedAgentsContent = '';
|
|
65
|
+
const agentsMdCandidates = [
|
|
66
|
+
join(clientSourceDir, 'AGENTS.md'), // npm package root
|
|
67
|
+
join(dirname(dirname(clientSourceDir)), 'AGENTS.md'), // monorepo root
|
|
68
|
+
];
|
|
69
|
+
for (const candidate of agentsMdCandidates) {
|
|
70
|
+
if (existsSync(candidate)) {
|
|
71
|
+
managedAgentsContent = readFileSync(candidate, 'utf8');
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (!managedAgentsContent) {
|
|
76
|
+
log(' WARN: AGENTS.md not found — skipping Codex agents block');
|
|
77
|
+
}
|
|
65
78
|
|
|
66
79
|
ensureDir(gmtrDir);
|
|
67
80
|
ensureDir(codexHome);
|
|
@@ -96,4 +109,8 @@ function main(): void {
|
|
|
96
109
|
log('Restart Codex or start a new session to load the updated hook configuration.');
|
|
97
110
|
}
|
|
98
111
|
|
|
99
|
-
|
|
112
|
+
// Run directly when executed as a script
|
|
113
|
+
const isDirectRun = typeof require !== 'undefined'
|
|
114
|
+
? require.main === module
|
|
115
|
+
: !import.meta.url.includes('node_modules/gramatr/bin/');
|
|
116
|
+
if (isDirectRun) main();
|
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.45';
|
package/gemini/install.ts
CHANGED
|
@@ -163,7 +163,7 @@ async function resolveApiKey(home: string): Promise<string | null> {
|
|
|
163
163
|
return null;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
async function main(): Promise<void> {
|
|
166
|
+
export async function main(): Promise<void> {
|
|
167
167
|
const home = process.env.HOME || process.env.USERPROFILE;
|
|
168
168
|
if (!home) {
|
|
169
169
|
throw new Error('HOME is not set');
|
|
@@ -269,4 +269,8 @@ async function main(): Promise<void> {
|
|
|
269
269
|
log('');
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
|
|
272
|
+
// Run directly when executed as a script
|
|
273
|
+
const isDirectRun = typeof require !== 'undefined'
|
|
274
|
+
? require.main === module
|
|
275
|
+
: !import.meta.url.includes('node_modules/gramatr/bin/');
|
|
276
|
+
if (isDirectRun) main();
|