cortex-sync 0.4.0 → 0.4.1
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/cli.js +55 -42
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1342,8 +1342,8 @@ Make sure Claude Code CLI is installed and "claude" is in your PATH.`
|
|
|
1342
1342
|
|
|
1343
1343
|
// src/commands/team/init.ts
|
|
1344
1344
|
import { input as input3 } from "@inquirer/prompts";
|
|
1345
|
-
import {
|
|
1346
|
-
import { join as
|
|
1345
|
+
import { writeFile as writeFile11, mkdir as mkdir10 } from "fs/promises";
|
|
1346
|
+
import { join as join16 } from "path";
|
|
1347
1347
|
|
|
1348
1348
|
// src/lib/team-repo.ts
|
|
1349
1349
|
import { access as access3, mkdir as mkdir8, rm } from "fs/promises";
|
|
@@ -1410,10 +1410,9 @@ function commitAndPush(repoUrl, token, message, dir = TEAM_DIR) {
|
|
|
1410
1410
|
|
|
1411
1411
|
// src/lib/claude-skills.ts
|
|
1412
1412
|
import { readdir as readdir3, readFile as readFile10, mkdir as mkdir9, writeFile as writeFile9 } from "fs/promises";
|
|
1413
|
-
import { homedir as homedir4 } from "os";
|
|
1414
1413
|
import { join as join13, dirname as dirname7 } from "path";
|
|
1415
|
-
var LOCAL_SKILLS_DIR = join13(
|
|
1416
|
-
var LOCAL_CLAUDE_MD = join13(
|
|
1414
|
+
var LOCAL_SKILLS_DIR = join13(process.cwd(), ".claude", "skills");
|
|
1415
|
+
var LOCAL_CLAUDE_MD = join13(process.cwd(), ".claude", "CLAUDE.md");
|
|
1417
1416
|
async function readSkillsFromDir(dir) {
|
|
1418
1417
|
const map = /* @__PURE__ */ new Map();
|
|
1419
1418
|
let entries;
|
|
@@ -1448,10 +1447,10 @@ async function writeFileToPath(filePath, content) {
|
|
|
1448
1447
|
|
|
1449
1448
|
// src/lib/claude-plugins.ts
|
|
1450
1449
|
import { readFile as readFile11 } from "fs/promises";
|
|
1451
|
-
import { homedir as
|
|
1450
|
+
import { homedir as homedir4 } from "os";
|
|
1452
1451
|
import { join as join14 } from "path";
|
|
1453
1452
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
1454
|
-
var INSTALLED_PLUGINS_PATH = join14(
|
|
1453
|
+
var INSTALLED_PLUGINS_PATH = join14(homedir4(), ".claude", "plugins", "installed_plugins.json");
|
|
1455
1454
|
function parseInstalledPlugins(data) {
|
|
1456
1455
|
return Object.keys(data.plugins);
|
|
1457
1456
|
}
|
|
@@ -1470,6 +1469,23 @@ function installPlugin(pluginId) {
|
|
|
1470
1469
|
if (result.status !== 0) throw new Error(`Plugin install failed for ${pluginId}`);
|
|
1471
1470
|
}
|
|
1472
1471
|
|
|
1472
|
+
// src/lib/project-config.ts
|
|
1473
|
+
import { readFile as readFile12, writeFile as writeFile10 } from "fs/promises";
|
|
1474
|
+
import { join as join15 } from "path";
|
|
1475
|
+
async function readProjectConfig(cwd = process.cwd()) {
|
|
1476
|
+
try {
|
|
1477
|
+
const content = await readFile12(join15(cwd, "cortex.json"), "utf-8");
|
|
1478
|
+
return JSON.parse(content);
|
|
1479
|
+
} catch {
|
|
1480
|
+
return {};
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
async function writeProjectConfig(updates, cwd = process.cwd()) {
|
|
1484
|
+
const existing = await readProjectConfig(cwd);
|
|
1485
|
+
const merged = { ...existing, ...updates };
|
|
1486
|
+
await writeFile10(join15(cwd, "cortex.json"), JSON.stringify(merged, null, 2), "utf-8");
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1473
1489
|
// src/commands/team/init.ts
|
|
1474
1490
|
async function teamInitCommand(opts) {
|
|
1475
1491
|
const config = await loadConfig();
|
|
@@ -1484,35 +1500,33 @@ Cloning ${repoUrl} \u2192 ~/.cortex/team/`);
|
|
|
1484
1500
|
await cloneTeamRepo(repoUrl, token);
|
|
1485
1501
|
const skills = await readSkillsFromDir(LOCAL_SKILLS_DIR);
|
|
1486
1502
|
if (skills.size > 0) {
|
|
1487
|
-
await mkdir10(
|
|
1503
|
+
await mkdir10(join16(TEAM_DIR, "skills"), { recursive: true });
|
|
1488
1504
|
for (const [filename, content] of skills) {
|
|
1489
|
-
await
|
|
1505
|
+
await writeFile11(join16(TEAM_DIR, "skills", filename), content, "utf-8");
|
|
1490
1506
|
}
|
|
1491
|
-
console.log(` Copied ${skills.size} skills
|
|
1507
|
+
console.log(` Copied ${skills.size} skills from .claude/skills/`);
|
|
1492
1508
|
}
|
|
1493
1509
|
const claudeMd = await readFileFromPath(LOCAL_CLAUDE_MD);
|
|
1494
1510
|
if (claudeMd) {
|
|
1495
|
-
await
|
|
1496
|
-
console.log(" Copied CLAUDE.md");
|
|
1511
|
+
await writeFile11(join16(TEAM_DIR, "CLAUDE.md"), claudeMd, "utf-8");
|
|
1512
|
+
console.log(" Copied .claude/CLAUDE.md");
|
|
1497
1513
|
}
|
|
1498
1514
|
const plugins = await getInstalledPluginIds();
|
|
1499
1515
|
const cortexJson = { version: "1", plugins };
|
|
1500
|
-
await
|
|
1516
|
+
await writeFile11(join16(TEAM_DIR, "cortex.json"), JSON.stringify(cortexJson, null, 2), "utf-8");
|
|
1501
1517
|
console.log(` Generated cortex.json (${plugins.length} plugins)`);
|
|
1502
1518
|
commitAndPush(repoUrl, token, "feat: initial team Claude Code context");
|
|
1503
|
-
|
|
1504
|
-
raw.teamRepo = repoUrl;
|
|
1505
|
-
await writeFile10(CONFIG_PATH, JSON.stringify(raw, null, 2), "utf-8");
|
|
1519
|
+
await writeProjectConfig({ repo: repoUrl });
|
|
1506
1520
|
console.log("\n\u2713 Team repo initialized and pushed.");
|
|
1507
1521
|
console.log(` Devs can now run: cortex install --repo ${repoUrl}`);
|
|
1508
1522
|
}
|
|
1509
1523
|
|
|
1510
1524
|
// src/commands/team/push.ts
|
|
1511
|
-
import { writeFile as
|
|
1512
|
-
import { join as
|
|
1525
|
+
import { writeFile as writeFile12, mkdir as mkdir11 } from "fs/promises";
|
|
1526
|
+
import { join as join17 } from "path";
|
|
1513
1527
|
async function teamPushCommand() {
|
|
1514
1528
|
const config = await loadConfig();
|
|
1515
|
-
const repoUrl =
|
|
1529
|
+
const { repo: repoUrl } = await readProjectConfig();
|
|
1516
1530
|
const token = config.githubToken;
|
|
1517
1531
|
if (!repoUrl) throw new Error('No team repo configured. Run "cortex team init --repo <url>" first.');
|
|
1518
1532
|
if (!token) throw new Error('No GitHub token found. Run "cortex init" first.');
|
|
@@ -1521,18 +1535,18 @@ async function teamPushCommand() {
|
|
|
1521
1535
|
pullTeamRepo();
|
|
1522
1536
|
const skills = await readSkillsFromDir(LOCAL_SKILLS_DIR);
|
|
1523
1537
|
if (skills.size > 0) {
|
|
1524
|
-
await mkdir11(
|
|
1538
|
+
await mkdir11(join17(TEAM_DIR, "skills"), { recursive: true });
|
|
1525
1539
|
for (const [filename, content] of skills) {
|
|
1526
|
-
await
|
|
1540
|
+
await writeFile12(join17(TEAM_DIR, "skills", filename), content, "utf-8");
|
|
1527
1541
|
}
|
|
1528
1542
|
}
|
|
1529
1543
|
const claudeMd = await readFileFromPath(LOCAL_CLAUDE_MD);
|
|
1530
1544
|
if (claudeMd) {
|
|
1531
|
-
await
|
|
1545
|
+
await writeFile12(join17(TEAM_DIR, "CLAUDE.md"), claudeMd, "utf-8");
|
|
1532
1546
|
}
|
|
1533
1547
|
const plugins = await getInstalledPluginIds();
|
|
1534
|
-
await
|
|
1535
|
-
|
|
1548
|
+
await writeFile12(
|
|
1549
|
+
join17(TEAM_DIR, "cortex.json"),
|
|
1536
1550
|
JSON.stringify({ version: "1", plugins }, null, 2),
|
|
1537
1551
|
"utf-8"
|
|
1538
1552
|
);
|
|
@@ -1542,7 +1556,7 @@ async function teamPushCommand() {
|
|
|
1542
1556
|
|
|
1543
1557
|
// src/commands/team/pull.ts
|
|
1544
1558
|
import { readFile as readFile13 } from "fs/promises";
|
|
1545
|
-
import { join as
|
|
1559
|
+
import { join as join18 } from "path";
|
|
1546
1560
|
|
|
1547
1561
|
// src/lib/conflict.ts
|
|
1548
1562
|
import { select as select2 } from "@inquirer/prompts";
|
|
@@ -1591,13 +1605,13 @@ async function promptConflict(filename, local, remote) {
|
|
|
1591
1605
|
|
|
1592
1606
|
// src/commands/team/pull.ts
|
|
1593
1607
|
async function teamPullCommand() {
|
|
1594
|
-
|
|
1595
|
-
const repoUrl =
|
|
1608
|
+
await loadConfig();
|
|
1609
|
+
const { repo: repoUrl } = await readProjectConfig();
|
|
1596
1610
|
if (!repoUrl) throw new Error('No team repo configured. Run "cortex team init --repo <url>" first.');
|
|
1597
1611
|
if (!await hasLocalClone()) throw new Error('No local team clone found. Run "cortex install" first.');
|
|
1598
1612
|
console.log("Pulling from team repo\u2026");
|
|
1599
1613
|
pullTeamRepo();
|
|
1600
|
-
const remoteSkills = await readSkillsFromDir(
|
|
1614
|
+
const remoteSkills = await readSkillsFromDir(join18(TEAM_DIR, "skills"));
|
|
1601
1615
|
const localSkills = await readSkillsFromDir(LOCAL_SKILLS_DIR);
|
|
1602
1616
|
for (const [filename, remoteContent] of remoteSkills) {
|
|
1603
1617
|
const localContent = localSkills.get(filename) ?? null;
|
|
@@ -1618,7 +1632,7 @@ async function teamPullCommand() {
|
|
|
1618
1632
|
console.log(` ~ ${filename} skipped`);
|
|
1619
1633
|
}
|
|
1620
1634
|
}
|
|
1621
|
-
const remoteMd = await readFileFromPath(
|
|
1635
|
+
const remoteMd = await readFileFromPath(join18(TEAM_DIR, "CLAUDE.md"));
|
|
1622
1636
|
if (remoteMd) {
|
|
1623
1637
|
const localMd = await readFileFromPath(LOCAL_CLAUDE_MD);
|
|
1624
1638
|
if (!localMd) {
|
|
@@ -1639,7 +1653,7 @@ async function teamPullCommand() {
|
|
|
1639
1653
|
}
|
|
1640
1654
|
let cortexJson = {};
|
|
1641
1655
|
try {
|
|
1642
|
-
cortexJson = JSON.parse(await readFile13(
|
|
1656
|
+
cortexJson = JSON.parse(await readFile13(join18(TEAM_DIR, "cortex.json"), "utf-8"));
|
|
1643
1657
|
} catch {
|
|
1644
1658
|
}
|
|
1645
1659
|
for (const pluginId of cortexJson.plugins ?? []) {
|
|
@@ -1653,8 +1667,8 @@ async function teamPullCommand() {
|
|
|
1653
1667
|
}
|
|
1654
1668
|
|
|
1655
1669
|
// src/commands/install.ts
|
|
1656
|
-
import { readFile as readFile14
|
|
1657
|
-
import { join as
|
|
1670
|
+
import { readFile as readFile14 } from "fs/promises";
|
|
1671
|
+
import { join as join19 } from "path";
|
|
1658
1672
|
async function installCommand(opts) {
|
|
1659
1673
|
let config;
|
|
1660
1674
|
try {
|
|
@@ -1662,27 +1676,28 @@ async function installCommand(opts) {
|
|
|
1662
1676
|
} catch {
|
|
1663
1677
|
throw new Error('Run "cortex init" first to configure your GitHub token.');
|
|
1664
1678
|
}
|
|
1665
|
-
const
|
|
1679
|
+
const projectConfig = await readProjectConfig();
|
|
1680
|
+
const repoUrl = opts.repo ?? projectConfig.repo;
|
|
1666
1681
|
if (!repoUrl) {
|
|
1667
1682
|
throw new Error('No team repo URL. Pass --repo <url> or run "cortex team init" first.');
|
|
1668
1683
|
}
|
|
1669
1684
|
const token = config.githubToken;
|
|
1670
1685
|
if (!token) throw new Error('No GitHub token found. Run "cortex init" first.');
|
|
1671
|
-
console.log(`Installing from ${repoUrl}
|
|
1686
|
+
console.log(`Installing from ${repoUrl} into ${process.cwd()}/.claude/`);
|
|
1672
1687
|
await cloneTeamRepo(repoUrl, token);
|
|
1673
|
-
const skills = await readSkillsFromDir(
|
|
1688
|
+
const skills = await readSkillsFromDir(join19(TEAM_DIR, "skills"));
|
|
1674
1689
|
for (const [filename, content] of skills) {
|
|
1675
1690
|
await writeSkillToDir(LOCAL_SKILLS_DIR, filename, content);
|
|
1676
|
-
console.log(` +
|
|
1691
|
+
console.log(` + .claude/skills/${filename}`);
|
|
1677
1692
|
}
|
|
1678
|
-
const claudeMd = await readFileFromPath(
|
|
1693
|
+
const claudeMd = await readFileFromPath(join19(TEAM_DIR, "CLAUDE.md"));
|
|
1679
1694
|
if (claudeMd) {
|
|
1680
1695
|
await writeFileToPath(LOCAL_CLAUDE_MD, claudeMd);
|
|
1681
|
-
console.log(" + CLAUDE.md");
|
|
1696
|
+
console.log(" + .claude/CLAUDE.md");
|
|
1682
1697
|
}
|
|
1683
1698
|
let cortexJson = {};
|
|
1684
1699
|
try {
|
|
1685
|
-
cortexJson = JSON.parse(await readFile14(
|
|
1700
|
+
cortexJson = JSON.parse(await readFile14(join19(TEAM_DIR, "cortex.json"), "utf-8"));
|
|
1686
1701
|
} catch {
|
|
1687
1702
|
}
|
|
1688
1703
|
for (const pluginId of cortexJson.plugins ?? []) {
|
|
@@ -1692,9 +1707,7 @@ async function installCommand(opts) {
|
|
|
1692
1707
|
console.warn(` \u26A0 Could not install ${pluginId}: ${e.message}`);
|
|
1693
1708
|
}
|
|
1694
1709
|
}
|
|
1695
|
-
|
|
1696
|
-
raw.teamRepo = repoUrl;
|
|
1697
|
-
await writeFile13(CONFIG_PATH, JSON.stringify(raw, null, 2), "utf-8");
|
|
1710
|
+
await writeProjectConfig({ repo: repoUrl });
|
|
1698
1711
|
console.log("\n\u2713 Team context installed. Restart Claude Code to activate new skills and plugins.");
|
|
1699
1712
|
}
|
|
1700
1713
|
|