@c4a/context-cli 0.5.39-beta.1 → 0.5.39-beta.2
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/cli.js +24 -6
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -68516,7 +68516,15 @@ function projectedWorkspaceFileFromInput(ctxDir, filePath, input) {
|
|
|
68516
68516
|
}
|
|
68517
68517
|
return { filePath, relativePath, root: root2 };
|
|
68518
68518
|
}
|
|
68519
|
-
function
|
|
68519
|
+
function isOwnedOnlyByCurrentCodeSource(node3, sourceIds) {
|
|
68520
|
+
if (node3 === undefined || node3.node.sources.length === 0)
|
|
68521
|
+
return false;
|
|
68522
|
+
return node3.node.sources.every((source2) => sourceIds.has(sourceIdWithoutVersion(source2)));
|
|
68523
|
+
}
|
|
68524
|
+
async function attachProjectedContainsLists(ctxDir, rendered, sourceIds) {
|
|
68525
|
+
const existingFiles = await readWorkspaceNodeFiles(ctxDir);
|
|
68526
|
+
const existingNodesBySlug = new Map(flattenWorkspaceNodes(existingFiles).map((node3) => [node3.parsed.node.id, node3.parsed]));
|
|
68527
|
+
const existingContainsByParent = new Map(existingFiles.map((file) => [file.root.node.id, file.root.containsList]));
|
|
68520
68528
|
const containsByParent = new Map;
|
|
68521
68529
|
for (const [slug, item] of rendered) {
|
|
68522
68530
|
if (!slug.includes("/"))
|
|
@@ -68537,13 +68545,23 @@ function attachProjectedContainsLists(ctxDir, rendered) {
|
|
|
68537
68545
|
]);
|
|
68538
68546
|
}
|
|
68539
68547
|
return new Map([...rendered.entries()].map(([slug, item]) => {
|
|
68540
|
-
const
|
|
68541
|
-
|
|
68548
|
+
const generatedEntries = containsByParent.get(slug) ?? [];
|
|
68549
|
+
const existingEntries = existingContainsByParent.get(slug) ?? item.input.containsList ?? [];
|
|
68550
|
+
if (existingEntries.length === 0 && generatedEntries.length === 0)
|
|
68542
68551
|
return [slug, item];
|
|
68552
|
+
const merged = new Map;
|
|
68553
|
+
for (const entry of existingEntries) {
|
|
68554
|
+
const existingNode = existingNodesBySlug.get(entry.slug);
|
|
68555
|
+
if (isOwnedOnlyByCurrentCodeSource(existingNode, sourceIds))
|
|
68556
|
+
continue;
|
|
68557
|
+
merged.set(entry.slug, entry);
|
|
68558
|
+
}
|
|
68559
|
+
for (const entry of generatedEntries)
|
|
68560
|
+
merged.set(entry.slug, entry);
|
|
68543
68561
|
return [slug, {
|
|
68544
68562
|
input: {
|
|
68545
68563
|
...item.input,
|
|
68546
|
-
containsList: [...
|
|
68564
|
+
containsList: sortContainsEntries([...merged.values()])
|
|
68547
68565
|
}
|
|
68548
68566
|
}];
|
|
68549
68567
|
}));
|
|
@@ -68557,7 +68575,7 @@ async function projectedWorkspaceFiles(ctxDir, rendered) {
|
|
|
68557
68575
|
return [...byPath.values()];
|
|
68558
68576
|
}
|
|
68559
68577
|
async function projectedRenderContext(plan) {
|
|
68560
|
-
const renderedWithContains = attachProjectedContainsLists(plan.state.ctxDir, plan.rendered);
|
|
68578
|
+
const renderedWithContains = await attachProjectedContainsLists(plan.state.ctxDir, plan.rendered, new Set(plan.sources));
|
|
68561
68579
|
const [files, currentEdges, currentExternals, renderConfig] = await Promise.all([
|
|
68562
68580
|
projectedWorkspaceFiles(plan.state.ctxDir, renderedWithContains),
|
|
68563
68581
|
loadKnowledgeGraphEdges(plan.state.ctxDir),
|
|
@@ -68622,7 +68640,7 @@ async function renderCodeProjectionPlanFromState(state) {
|
|
|
68622
68640
|
state
|
|
68623
68641
|
};
|
|
68624
68642
|
const renderContext = await projectedRenderContext(initialPlan);
|
|
68625
|
-
const renderedWithContains = attachProjectedContainsLists(state.ctxDir, rendered);
|
|
68643
|
+
const renderedWithContains = await attachProjectedContainsLists(state.ctxDir, rendered, new Set(initialPlan.sources));
|
|
68626
68644
|
const nodes = [];
|
|
68627
68645
|
for (const item of pending) {
|
|
68628
68646
|
const input = renderedWithContains.get(item.slug)?.input ?? item.input;
|