@dezkareid/ai-context-sync 1.4.0 → 1.5.0

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/constants.js CHANGED
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CONFIG_FILENAME = exports.AGENTS_FILENAME = void 0;
4
- exports.AGENTS_FILENAME = 'AGENTS.md';
5
- exports.CONFIG_FILENAME = '.ai-context-configrc';
1
+ export const AGENTS_FILENAME = 'AGENTS.md';
2
+ export const CONFIG_FILENAME = '.ai-context-configrc';
package/dist/engine.js CHANGED
@@ -1,21 +1,15 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SyncEngine = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const path_1 = __importDefault(require("path"));
9
- const constants_js_1 = require("./constants.js");
10
- const claude_js_1 = require("./strategies/claude.js");
11
- const gemini_js_1 = require("./strategies/gemini.js");
12
- const gemini_md_js_1 = require("./strategies/gemini-md.js");
13
- const other_js_1 = require("./strategies/other.js");
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+ import { AGENTS_FILENAME } from './constants.js';
4
+ import { ClaudeStrategy } from './strategies/claude.js';
5
+ import { GeminiStrategy } from './strategies/gemini.js';
6
+ import { GeminiMdStrategy } from './strategies/gemini-md.js';
7
+ import { OtherStrategy } from './strategies/other.js';
14
8
  function buildBuiltInStrategies(fromFile) {
15
9
  return [
16
- new claude_js_1.ClaudeStrategy(fromFile),
17
- new gemini_js_1.GeminiStrategy(fromFile),
18
- new gemini_md_js_1.GeminiMdStrategy(fromFile)
10
+ new ClaudeStrategy(fromFile),
11
+ new GeminiStrategy(fromFile),
12
+ new GeminiMdStrategy(fromFile)
19
13
  ];
20
14
  }
21
15
  function resolveStrategiesToRun(selectedStrategies, builtInStrategies, otherFiles, fromFile) {
@@ -36,20 +30,20 @@ function resolveStrategiesToRun(selectedStrategies, builtInStrategies, otherFile
36
30
  throw new Error('Strategy "other" requires otherFiles to be specified.');
37
31
  }
38
32
  for (const filename of otherFiles) {
39
- strategies.push(new other_js_1.OtherStrategy(filename, fromFile));
33
+ strategies.push(new OtherStrategy(filename, fromFile));
40
34
  }
41
35
  }
42
36
  return strategies;
43
37
  }
44
- class SyncEngine {
38
+ export class SyncEngine {
45
39
  async sync(projectRoot, selectedStrategies, targetDir, fromFile, otherFiles) {
46
- const sourceFile = fromFile ?? constants_js_1.AGENTS_FILENAME;
47
- const agentsPath = path_1.default.join(projectRoot, sourceFile);
40
+ const sourceFile = fromFile ?? AGENTS_FILENAME;
41
+ const agentsPath = path.join(projectRoot, sourceFile);
48
42
  const outputDir = targetDir ?? projectRoot;
49
- if (!(await fs_extra_1.default.pathExists(agentsPath))) {
43
+ if (!(await fs.pathExists(agentsPath))) {
50
44
  throw new Error(`${sourceFile} not found in ${projectRoot}`);
51
45
  }
52
- const context = await fs_extra_1.default.readFile(agentsPath, 'utf-8');
46
+ const context = await fs.readFile(agentsPath, 'utf-8');
53
47
  const builtInStrategies = buildBuiltInStrategies(fromFile);
54
48
  const strategiesToRun = resolveStrategiesToRun(selectedStrategies, builtInStrategies, otherFiles, fromFile);
55
49
  if (strategiesToRun.length === 0 && selectedStrategies) {
@@ -62,4 +56,3 @@ class SyncEngine {
62
56
  }
63
57
  }
64
58
  }
65
- exports.SyncEngine = SyncEngine;
package/dist/index.js CHANGED
@@ -1,29 +1,20 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.readConfig = readConfig;
8
- exports.resolveProjectConfig = resolveProjectConfig;
9
- exports.addProject = addProject;
10
- exports.createProgram = createProgram;
11
- const commander_1 = require("commander");
12
- const engine_js_1 = require("./engine.js");
13
- const path_1 = __importDefault(require("path"));
14
- const inquirer_1 = __importDefault(require("inquirer"));
15
- const fs_extra_1 = __importDefault(require("fs-extra"));
16
- const constants_js_1 = require("./constants.js");
17
- async function readConfig(configPath) {
2
+ import { Command } from 'commander';
3
+ import { SyncEngine } from './engine.js';
4
+ import path from 'path';
5
+ import inquirer from 'inquirer';
6
+ import fs from 'fs-extra';
7
+ import { CONFIG_FILENAME } from './constants.js';
8
+ export async function readConfig(configPath) {
18
9
  try {
19
- return await fs_extra_1.default.readJson(configPath);
10
+ return await fs.readJson(configPath);
20
11
  }
21
12
  catch {
22
13
  return {};
23
14
  }
24
15
  }
25
16
  async function promptStrategies() {
26
- const answers = await inquirer_1.default.prompt([
17
+ const answers = await inquirer.prompt([
27
18
  {
28
19
  type: 'checkbox',
29
20
  name: 'strategies',
@@ -45,7 +36,7 @@ async function promptStrategies() {
45
36
  return answers.strategies;
46
37
  }
47
38
  async function promptOtherFiles() {
48
- const filesAnswer = await inquirer_1.default.prompt([
39
+ const filesAnswer = await inquirer.prompt([
49
40
  {
50
41
  type: 'input',
51
42
  name: 'otherFiles',
@@ -74,7 +65,7 @@ async function applyConfig(options, configPath) {
74
65
  let otherFiles;
75
66
  let fromFile;
76
67
  let config = {};
77
- if (!options.skipConfig && await fs_extra_1.default.pathExists(configPath)) {
68
+ if (!options.skipConfig && await fs.pathExists(configPath)) {
78
69
  config = await readConfig(configPath);
79
70
  if (!strategy && config.strategies) {
80
71
  strategy = config.strategies;
@@ -87,7 +78,7 @@ async function applyConfig(options, configPath) {
87
78
  function resolveFromFile(optionFrom, configFromFile) {
88
79
  if (!optionFrom)
89
80
  return configFromFile;
90
- if (path_1.default.isAbsolute(optionFrom)) {
81
+ if (path.isAbsolute(optionFrom)) {
91
82
  throw new Error('--from must be a relative path, not an absolute path.');
92
83
  }
93
84
  return optionFrom;
@@ -98,8 +89,8 @@ function mergeOtherFiles(optionFiles, configOtherFiles) {
98
89
  const flagFiles = optionFiles.split(',').map((s) => s.trim()).filter(Boolean);
99
90
  return [...new Set([...(configOtherFiles ?? []), ...flagFiles])];
100
91
  }
101
- async function resolveProjectConfig(projectPath, rootConfig, overrides) {
102
- const configPath = path_1.default.join(projectPath, constants_js_1.CONFIG_FILENAME);
92
+ export async function resolveProjectConfig(projectPath, rootConfig, overrides) {
93
+ const configPath = path.join(projectPath, CONFIG_FILENAME);
103
94
  const localConfig = await readConfig(configPath);
104
95
  const strategy = overrides?.strategies ?? localConfig.strategies ?? rootConfig.strategies;
105
96
  const otherFiles = overrides?.otherFiles ?? localConfig.otherFiles ?? rootConfig.otherFiles;
@@ -117,7 +108,7 @@ async function syncProject(projectRoot, strategy, targetDir, fromFile, otherFile
117
108
  if (strategy.includes('other') && (!otherFiles || otherFiles.length === 0)) {
118
109
  throw new Error('Strategy "other" requires custom files to be defined.');
119
110
  }
120
- const engine = new engine_js_1.SyncEngine();
111
+ const engine = new SyncEngine();
121
112
  await engine.sync(projectRoot, strategy, targetDir, fromFile, otherFiles);
122
113
  console.log(`[${projectName}] Successfully synchronized using "${strategy.join(', ')}"!`);
123
114
  }
@@ -126,14 +117,14 @@ async function runRootSync(options, config, projectRoot, configPath, configResul
126
117
  const fromFile = resolveFromFile(options.from, configResult.fromFile);
127
118
  const otherFiles = mergeOtherFiles(options.files, configResult.otherFiles);
128
119
  const resolved = await resolveStrategy(configResult.strategy, otherFiles);
129
- await syncProject(projectRoot, resolved.strategy, options.targetDir ? path_1.default.resolve(options.targetDir) : projectRoot, fromFile, resolved.otherFiles, 'root');
120
+ await syncProject(projectRoot, resolved.strategy, options.targetDir ? path.resolve(options.targetDir) : projectRoot, fromFile, resolved.otherFiles, 'root');
130
121
  if (!options.skipConfig) {
131
122
  const configData = { ...config, strategies: resolved.strategy };
132
123
  if (resolved.otherFiles?.length)
133
124
  configData.otherFiles = resolved.otherFiles;
134
125
  if (fromFile)
135
126
  configData.from = fromFile;
136
- await fs_extra_1.default.writeJson(configPath, configData, { spaces: 2 });
127
+ await fs.writeJson(configPath, configData, { spaces: 2 });
137
128
  }
138
129
  return { name: 'root', success: true };
139
130
  }
@@ -147,8 +138,8 @@ async function runProjectsSync(config, projectRoot) {
147
138
  return results;
148
139
  for (const [projectPath, projectOverrides] of Object.entries(config.projects)) {
149
140
  try {
150
- const absoluteProjectPath = path_1.default.resolve(projectRoot, projectPath);
151
- if (!(await fs_extra_1.default.pathExists(absoluteProjectPath))) {
141
+ const absoluteProjectPath = path.resolve(projectRoot, projectPath);
142
+ if (!(await fs.pathExists(absoluteProjectPath))) {
152
143
  throw new Error(`Project path does not exist: ${projectPath}`);
153
144
  }
154
145
  const resolved = await resolveProjectConfig(absoluteProjectPath, config, projectOverrides);
@@ -177,8 +168,8 @@ function displaySummary(results) {
177
168
  }
178
169
  }
179
170
  async function runSync(options) {
180
- const projectRoot = path_1.default.resolve(options.dir);
181
- const configPath = path_1.default.join(projectRoot, constants_js_1.CONFIG_FILENAME);
171
+ const projectRoot = path.resolve(options.dir);
172
+ const configPath = path.join(projectRoot, CONFIG_FILENAME);
182
173
  const configResult = await applyConfig(options, configPath);
183
174
  const results = [];
184
175
  const rootResult = await runRootSync(options, configResult.config, projectRoot, configPath, configResult);
@@ -187,15 +178,15 @@ async function runSync(options) {
187
178
  results.push(...projectResults);
188
179
  displaySummary(results);
189
180
  }
190
- async function addProject(projectPath, options) {
191
- const projectRoot = path_1.default.resolve(options.dir);
192
- const configPath = path_1.default.join(projectRoot, constants_js_1.CONFIG_FILENAME);
181
+ export async function addProject(projectPath, options) {
182
+ const projectRoot = path.resolve(options.dir);
183
+ const configPath = path.join(projectRoot, CONFIG_FILENAME);
193
184
  const config = await readConfig(configPath);
194
- const relativePath = path_1.default.isAbsolute(projectPath)
195
- ? path_1.default.relative(projectRoot, projectPath)
185
+ const relativePath = path.isAbsolute(projectPath)
186
+ ? path.relative(projectRoot, projectPath)
196
187
  : projectPath;
197
- const absoluteProjectPath = path_1.default.resolve(projectRoot, relativePath);
198
- if (!(await fs_extra_1.default.pathExists(absoluteProjectPath))) {
188
+ const absoluteProjectPath = path.resolve(projectRoot, relativePath);
189
+ if (!(await fs.pathExists(absoluteProjectPath))) {
199
190
  console.warn(`Warning: Project path does not exist: ${absoluteProjectPath}`);
200
191
  }
201
192
  const otherFiles = options.files ? options.files.split(',').map(s => s.trim()) : undefined;
@@ -221,11 +212,11 @@ async function addProject(projectPath, options) {
221
212
  [relativePath]: projectConfig
222
213
  }
223
214
  };
224
- await fs_extra_1.default.writeJson(configPath, newConfig, { spaces: 2 });
215
+ await fs.writeJson(configPath, newConfig, { spaces: 2 });
225
216
  console.log(`Successfully added project "${relativePath}" to configuration.`);
226
217
  }
227
- function createProgram() {
228
- const program = new commander_1.Command();
218
+ export function createProgram() {
219
+ const program = new Command();
229
220
  program
230
221
  .name('ai-context-sync')
231
222
  .description('Sync AI context files across different providers')
@@ -271,6 +262,6 @@ function createProgram() {
271
262
  }
272
263
  if (process.argv[1] && (process.argv[1].endsWith('dist/index.js') ||
273
264
  process.argv[1].endsWith('bin/ai-context-sync') ||
274
- (fs_extra_1.default.existsSync(path_1.default.resolve('dist/index.js')) && fs_extra_1.default.realpathSync(process.argv[1]) === fs_extra_1.default.realpathSync(path_1.default.resolve('dist/index.js'))))) {
265
+ (fs.existsSync(path.resolve('dist/index.js')) && fs.realpathSync(process.argv[1]) === fs.realpathSync(path.resolve('dist/index.js'))))) {
275
266
  createProgram().parse();
276
267
  }
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClaudeStrategy = void 0;
4
- const symlink_js_1 = require("./symlink.js");
5
- class ClaudeStrategy extends symlink_js_1.SymlinkStrategy {
1
+ import { SymlinkStrategy } from './symlink.js';
2
+ export class ClaudeStrategy extends SymlinkStrategy {
6
3
  name = 'claude';
7
4
  targetFilename = 'CLAUDE.md';
8
5
  constructor(fromFile) {
9
6
  super(fromFile);
10
7
  }
11
8
  }
12
- exports.ClaudeStrategy = ClaudeStrategy;
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GeminiMdStrategy = void 0;
4
- const symlink_js_1 = require("./symlink.js");
5
- class GeminiMdStrategy extends symlink_js_1.SymlinkStrategy {
1
+ import { SymlinkStrategy } from './symlink.js';
2
+ export class GeminiMdStrategy extends SymlinkStrategy {
6
3
  name = 'gemini-md';
7
4
  targetFilename = 'GEMINI.md';
8
5
  constructor(fromFile) {
9
6
  super(fromFile);
10
7
  }
11
8
  }
12
- exports.GeminiMdStrategy = GeminiMdStrategy;
@@ -1,32 +1,26 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GeminiStrategy = void 0;
7
- const index_js_1 = require("./index.js");
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const path_1 = __importDefault(require("path"));
10
- class GeminiStrategy {
1
+ import { AGENTS_FILE } from './index.js';
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+ export class GeminiStrategy {
11
5
  name = 'gemini';
12
6
  fromFile;
13
- constructor(fromFile = index_js_1.AGENTS_FILE) {
7
+ constructor(fromFile = AGENTS_FILE) {
14
8
  this.fromFile = fromFile;
15
9
  }
16
10
  async sync(_context, projectRoot, targetDir) {
17
11
  const outputDir = targetDir ?? projectRoot;
18
- const geminiDir = path_1.default.join(outputDir, '.gemini');
19
- const settingsPath = path_1.default.join(geminiDir, 'settings.json');
12
+ const geminiDir = path.join(outputDir, '.gemini');
13
+ const settingsPath = path.join(geminiDir, 'settings.json');
20
14
  // Compute the path to the source file relative to the target .gemini directory
21
- const agentsAbsPath = path_1.default.join(projectRoot, this.fromFile);
22
- const agentsRelativePath = path_1.default.relative(outputDir, agentsAbsPath);
23
- await fs_extra_1.default.ensureDir(geminiDir);
15
+ const agentsAbsPath = path.join(projectRoot, this.fromFile);
16
+ const agentsRelativePath = path.relative(outputDir, agentsAbsPath);
17
+ await fs.ensureDir(geminiDir);
24
18
  let settings = {};
25
19
  let exists = false;
26
- if (await fs_extra_1.default.pathExists(settingsPath)) {
20
+ if (await fs.pathExists(settingsPath)) {
27
21
  exists = true;
28
22
  try {
29
- settings = await fs_extra_1.default.readJson(settingsPath);
23
+ settings = await fs.readJson(settingsPath);
30
24
  }
31
25
  catch {
32
26
  settings = {};
@@ -54,8 +48,7 @@ class GeminiStrategy {
54
48
  modified = true;
55
49
  }
56
50
  if (modified || !exists) {
57
- await fs_extra_1.default.writeJson(settingsPath, settings, { spaces: 2 });
51
+ await fs.writeJson(settingsPath, settings, { spaces: 2 });
58
52
  }
59
53
  }
60
54
  }
61
- exports.GeminiStrategy = GeminiStrategy;
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AGENTS_FILE = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- exports.AGENTS_FILE = constants_js_1.AGENTS_FILENAME;
1
+ import { AGENTS_FILENAME } from '../constants.js';
2
+ export const AGENTS_FILE = AGENTS_FILENAME;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OtherStrategy = void 0;
4
- const symlink_js_1 = require("./symlink.js");
5
- class OtherStrategy extends symlink_js_1.SymlinkStrategy {
1
+ import { SymlinkStrategy } from './symlink.js';
2
+ export class OtherStrategy extends SymlinkStrategy {
6
3
  name = 'other';
7
4
  targetFilename;
8
5
  constructor(targetFilename, fromFile) {
@@ -10,4 +7,3 @@ class OtherStrategy extends symlink_js_1.SymlinkStrategy {
10
7
  this.targetFilename = targetFilename;
11
8
  }
12
9
  }
13
- exports.OtherStrategy = OtherStrategy;
@@ -1,38 +1,31 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SymlinkStrategy = void 0;
7
- const index_js_1 = require("./index.js");
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const path_1 = __importDefault(require("path"));
10
- class SymlinkStrategy {
1
+ import { AGENTS_FILE } from './index.js';
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+ export class SymlinkStrategy {
11
5
  fromFile;
12
- constructor(fromFile = index_js_1.AGENTS_FILE) {
6
+ constructor(fromFile = AGENTS_FILE) {
13
7
  this.fromFile = fromFile;
14
8
  }
15
9
  async sync(_context, projectRoot, targetDir) {
16
10
  const outputDir = targetDir ?? projectRoot;
17
- const targetPath = path_1.default.join(outputDir, this.targetFilename);
11
+ const targetPath = path.join(outputDir, this.targetFilename);
18
12
  // Compute the symlink value: relative path from outputDir to the source file in projectRoot
19
- const agentsAbsPath = path_1.default.join(projectRoot, this.fromFile);
20
- const symlinkTarget = path_1.default.relative(outputDir, agentsAbsPath);
13
+ const agentsAbsPath = path.join(projectRoot, this.fromFile);
14
+ const symlinkTarget = path.relative(outputDir, agentsAbsPath);
21
15
  // Check if it exists and what type it is
22
- if (await fs_extra_1.default.pathExists(targetPath)) {
23
- const stats = await fs_extra_1.default.lstat(targetPath);
16
+ if (await fs.pathExists(targetPath)) {
17
+ const stats = await fs.lstat(targetPath);
24
18
  if (stats.isSymbolicLink()) {
25
- const existingTarget = await fs_extra_1.default.readlink(targetPath);
19
+ const existingTarget = await fs.readlink(targetPath);
26
20
  if (existingTarget === symlinkTarget) {
27
21
  // Already points to the correct location, nothing to do
28
22
  return;
29
23
  }
30
24
  }
31
25
  // If it's a file or a link to somewhere else, remove it
32
- await fs_extra_1.default.remove(targetPath);
26
+ await fs.remove(targetPath);
33
27
  }
34
28
  // Create symlink pointing to the source file
35
- await fs_extra_1.default.ensureSymlink(symlinkTarget, targetPath);
29
+ await fs.ensureSymlink(symlinkTarget, targetPath);
36
30
  }
37
31
  }
38
- exports.SymlinkStrategy = SymlinkStrategy;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@dezkareid/ai-context-sync",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "CLI utility to synchronize AI agent context files from AGENTS.md",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "bin": {
7
8
  "ai-context-sync": "./dist/index.js"