cortex-sync 0.4.11 → 0.4.12
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 +25 -8
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1444,6 +1444,25 @@ async function writeFileToPath(filePath, content) {
|
|
|
1444
1444
|
await mkdir9(dirname7(filePath), { recursive: true });
|
|
1445
1445
|
await writeFile9(filePath, content, "utf-8");
|
|
1446
1446
|
}
|
|
1447
|
+
var CORTEX_BLOCK_START = "<!-- cortex-sync:start -->";
|
|
1448
|
+
var CORTEX_BLOCK_END = "<!-- cortex-sync:end -->";
|
|
1449
|
+
function injectCortexPathBlock(content, cwd) {
|
|
1450
|
+
const block = [
|
|
1451
|
+
CORTEX_BLOCK_START,
|
|
1452
|
+
`> **[cortex-sync]** Project root on this machine: \`${cwd}\``,
|
|
1453
|
+
`> Sessions shared via cortex-sync may reference paths from other machines. Always resolve file operations against the project root above.`,
|
|
1454
|
+
CORTEX_BLOCK_END
|
|
1455
|
+
].join("\n");
|
|
1456
|
+
const startIdx = content.indexOf(CORTEX_BLOCK_START);
|
|
1457
|
+
const endIdx = content.indexOf(CORTEX_BLOCK_END);
|
|
1458
|
+
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
|
|
1459
|
+
const before = content.slice(0, startIdx);
|
|
1460
|
+
const after = content.slice(endIdx + CORTEX_BLOCK_END.length);
|
|
1461
|
+
return before + block + after;
|
|
1462
|
+
}
|
|
1463
|
+
const separator = content.length > 0 ? "\n\n" : "";
|
|
1464
|
+
return block + separator + content;
|
|
1465
|
+
}
|
|
1447
1466
|
|
|
1448
1467
|
// src/lib/claude-plugins.ts
|
|
1449
1468
|
import { readFile as readFile11 } from "fs/promises";
|
|
@@ -1785,15 +1804,15 @@ async function teamPullCommand() {
|
|
|
1785
1804
|
if (remoteMd) {
|
|
1786
1805
|
const localMd = await readFileFromPath(LOCAL_CLAUDE_MD);
|
|
1787
1806
|
if (!localMd) {
|
|
1788
|
-
await writeFileToPath(LOCAL_CLAUDE_MD, remoteMd);
|
|
1807
|
+
await writeFileToPath(LOCAL_CLAUDE_MD, injectCortexPathBlock(remoteMd, process.cwd()));
|
|
1789
1808
|
console.log(" + CLAUDE.md (new)");
|
|
1790
1809
|
} else if (hasConflict(localMd, remoteMd)) {
|
|
1791
1810
|
const resolution = await promptConflict("CLAUDE.md", localMd, remoteMd);
|
|
1792
1811
|
if (resolution === "overwrite") {
|
|
1793
|
-
await writeFileToPath(LOCAL_CLAUDE_MD, remoteMd);
|
|
1812
|
+
await writeFileToPath(LOCAL_CLAUDE_MD, injectCortexPathBlock(remoteMd, process.cwd()));
|
|
1794
1813
|
console.log(" \u2713 CLAUDE.md overwritten");
|
|
1795
1814
|
} else if (resolution === "merge") {
|
|
1796
|
-
await writeFileToPath(LOCAL_CLAUDE_MD, mergeContent(localMd, remoteMd));
|
|
1815
|
+
await writeFileToPath(LOCAL_CLAUDE_MD, injectCortexPathBlock(mergeContent(localMd, remoteMd), process.cwd()));
|
|
1797
1816
|
console.log(" \u2713 CLAUDE.md merged");
|
|
1798
1817
|
} else {
|
|
1799
1818
|
console.log(" ~ CLAUDE.md skipped");
|
|
@@ -1853,11 +1872,9 @@ async function installCommand(opts) {
|
|
|
1853
1872
|
await writeSkillToDir(LOCAL_SKILLS_DIR, filename, content);
|
|
1854
1873
|
console.log(` + .claude/skills/${filename}`);
|
|
1855
1874
|
}
|
|
1856
|
-
const
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
console.log(" + .claude/CLAUDE.md");
|
|
1860
|
-
}
|
|
1875
|
+
const teamMd = await readFileFromPath(join20(TEAM_DIR, "CLAUDE.md")) ?? "";
|
|
1876
|
+
await writeFileToPath(LOCAL_CLAUDE_MD, injectCortexPathBlock(teamMd, process.cwd()));
|
|
1877
|
+
if (teamMd) console.log(" + .claude/CLAUDE.md");
|
|
1861
1878
|
let cortexJson = {};
|
|
1862
1879
|
try {
|
|
1863
1880
|
cortexJson = JSON.parse(await readFile15(join20(TEAM_DIR, "cortex.json"), "utf-8"));
|