@contentful/experience-design-system-cli 2.32.1-dev-build-413e3a3.0 → 2.32.1-dev-build-12db7af.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/package.json +1 -1
- package/dist/src/index.js +67 -67
- package/dist/src/session/core/cdf/cdf-mappers.d.ts +3 -0
- package/dist/src/session/core/components/{input-hash.d.ts → hash-component-shape.d.ts} +1 -1
- package/dist/src/session/core/shared/index-rows-by-key.d.ts +1 -0
- package/dist/src/session/core/tokens/hash-token-content.d.ts +1 -0
- package/dist/src/session/db.d.ts +4 -4
- package/dist/src/session/repositories/sessions/read.d.ts +2 -2
- package/dist/src/session/repositories/sessions/write.d.ts +1 -1
- package/dist/src/session/repositories/steps/read.d.ts +1 -1
- package/dist/src/session/repositories/steps/write.d.ts +3 -3
- package/dist/src/session/services/session-resolver.d.ts +3 -15
- package/package.json +6 -6
- package/dist/src/session/core/cdf/contentful-type-map.d.ts +0 -15
- package/dist/src/session/core/shared/group-by.d.ts +0 -1
- package/dist/src/session/core/tokens/input-hash.d.ts +0 -1
- /package/dist/src/session/core/components/{component-id.d.ts → derive-component-id.d.ts} +0 -0
package/dist/package.json
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -8546,18 +8546,18 @@ var init_source_excerpt = __esm({
|
|
|
8546
8546
|
}
|
|
8547
8547
|
});
|
|
8548
8548
|
|
|
8549
|
-
// packages/experience-design-system-cli/src/session/core/components/component-id.ts
|
|
8549
|
+
// packages/experience-design-system-cli/src/session/core/components/derive-component-id.ts
|
|
8550
8550
|
import { createHash } from "node:crypto";
|
|
8551
8551
|
function deriveComponentId(name, source) {
|
|
8552
8552
|
return createHash("sha256").update(`${name}:${source}`).digest("hex").slice(0, 12);
|
|
8553
8553
|
}
|
|
8554
|
-
var
|
|
8555
|
-
"packages/experience-design-system-cli/src/session/core/components/component-id.ts"() {
|
|
8554
|
+
var init_derive_component_id = __esm({
|
|
8555
|
+
"packages/experience-design-system-cli/src/session/core/components/derive-component-id.ts"() {
|
|
8556
8556
|
"use strict";
|
|
8557
8557
|
}
|
|
8558
8558
|
});
|
|
8559
8559
|
|
|
8560
|
-
// packages/experience-design-system-cli/src/session/core/cdf/
|
|
8560
|
+
// packages/experience-design-system-cli/src/session/core/cdf/cdf-mappers.ts
|
|
8561
8561
|
function mapContentfulTypeToCdfType(contentfulType) {
|
|
8562
8562
|
switch (contentfulType.toLowerCase()) {
|
|
8563
8563
|
case "string":
|
|
@@ -8589,15 +8589,15 @@ function resolveCdfCategory(contentfulCategory, propName, contentProps, designPr
|
|
|
8589
8589
|
return "state";
|
|
8590
8590
|
}
|
|
8591
8591
|
var VALID_CATEGORIES2;
|
|
8592
|
-
var
|
|
8593
|
-
"packages/experience-design-system-cli/src/session/core/cdf/
|
|
8592
|
+
var init_cdf_mappers = __esm({
|
|
8593
|
+
"packages/experience-design-system-cli/src/session/core/cdf/cdf-mappers.ts"() {
|
|
8594
8594
|
"use strict";
|
|
8595
8595
|
VALID_CATEGORIES2 = ["content", "design", "state"];
|
|
8596
8596
|
}
|
|
8597
8597
|
});
|
|
8598
8598
|
|
|
8599
|
-
// packages/experience-design-system-cli/src/session/core/shared/
|
|
8600
|
-
function
|
|
8599
|
+
// packages/experience-design-system-cli/src/session/core/shared/index-rows-by-key.ts
|
|
8600
|
+
function indexRowsByKey(items, key) {
|
|
8601
8601
|
const map = /* @__PURE__ */ new Map();
|
|
8602
8602
|
for (const item of items) {
|
|
8603
8603
|
const k = key(item);
|
|
@@ -8610,18 +8610,18 @@ function groupBy(items, key) {
|
|
|
8610
8610
|
}
|
|
8611
8611
|
return map;
|
|
8612
8612
|
}
|
|
8613
|
-
var
|
|
8614
|
-
"packages/experience-design-system-cli/src/session/core/shared/
|
|
8613
|
+
var init_index_rows_by_key = __esm({
|
|
8614
|
+
"packages/experience-design-system-cli/src/session/core/shared/index-rows-by-key.ts"() {
|
|
8615
8615
|
"use strict";
|
|
8616
8616
|
}
|
|
8617
8617
|
});
|
|
8618
8618
|
|
|
8619
8619
|
// packages/experience-design-system-cli/src/session/repositories/sessions/read.ts
|
|
8620
|
-
function
|
|
8620
|
+
function getSessionById(db, sessionId2) {
|
|
8621
8621
|
const row = db.prepare("SELECT id FROM sessions WHERE id = ?").get(sessionId2);
|
|
8622
8622
|
return row ?? null;
|
|
8623
8623
|
}
|
|
8624
|
-
function
|
|
8624
|
+
function getLatestCompletedSessionForCommand(db, command) {
|
|
8625
8625
|
const row = db.prepare(
|
|
8626
8626
|
`SELECT s.id FROM sessions s
|
|
8627
8627
|
JOIN steps st ON st.session_id = s.id
|
|
@@ -8646,7 +8646,7 @@ function createSession(db, id, name, timestamp) {
|
|
|
8646
8646
|
timestamp
|
|
8647
8647
|
);
|
|
8648
8648
|
}
|
|
8649
|
-
function
|
|
8649
|
+
function updateSessionTimestamp(db, sessionId2, timestamp) {
|
|
8650
8650
|
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(timestamp, sessionId2);
|
|
8651
8651
|
}
|
|
8652
8652
|
var init_write = __esm({
|
|
@@ -8656,7 +8656,7 @@ var init_write = __esm({
|
|
|
8656
8656
|
});
|
|
8657
8657
|
|
|
8658
8658
|
// packages/experience-design-system-cli/src/session/repositories/steps/read.ts
|
|
8659
|
-
function
|
|
8659
|
+
function getSessionIdForStep(db, stepId) {
|
|
8660
8660
|
const row = db.prepare("SELECT session_id FROM steps WHERE id = ?").get(stepId);
|
|
8661
8661
|
return row?.session_id ?? null;
|
|
8662
8662
|
}
|
|
@@ -8667,20 +8667,20 @@ var init_read2 = __esm({
|
|
|
8667
8667
|
});
|
|
8668
8668
|
|
|
8669
8669
|
// packages/experience-design-system-cli/src/session/repositories/steps/write.ts
|
|
8670
|
-
function
|
|
8670
|
+
function updatePendingStepsToInterrupted(db, sessionId2, command, timestamp) {
|
|
8671
8671
|
db.prepare(
|
|
8672
8672
|
`UPDATE steps SET status = 'interrupted', completed_at = ?, updated_at = ?
|
|
8673
8673
|
WHERE session_id = ? AND command = ? AND status = 'pending'`
|
|
8674
8674
|
).run(timestamp, timestamp, sessionId2, command);
|
|
8675
8675
|
}
|
|
8676
|
-
function
|
|
8676
|
+
function createPendingStep(db, sessionId2, command, inputs, timestamp) {
|
|
8677
8677
|
const result = db.prepare(
|
|
8678
8678
|
`INSERT INTO steps (session_id, command, status, started_at, inputs, outputs, updated_at)
|
|
8679
8679
|
VALUES (?, ?, 'pending', ?, ?, '{}', ?)`
|
|
8680
8680
|
).run(sessionId2, command, timestamp, JSON.stringify(inputs), timestamp);
|
|
8681
8681
|
return Number(result.lastInsertRowid);
|
|
8682
8682
|
}
|
|
8683
|
-
function
|
|
8683
|
+
function updateStepStatus(db, stepId, status, outputs, error, timestamp) {
|
|
8684
8684
|
db.prepare(`UPDATE steps SET status = ?, completed_at = ?, outputs = ?, error = ?, updated_at = ? WHERE id = ?`).run(
|
|
8685
8685
|
status,
|
|
8686
8686
|
timestamp,
|
|
@@ -8921,14 +8921,14 @@ var init_session_id = __esm({
|
|
|
8921
8921
|
});
|
|
8922
8922
|
|
|
8923
8923
|
// packages/experience-design-system-cli/src/session/services/session-resolver.ts
|
|
8924
|
-
function
|
|
8924
|
+
function getOrCreateSessionForCommand(db, sessionFlag, sessionName, _hints) {
|
|
8925
8925
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
8926
8926
|
if (sessionFlag === "new" || sessionFlag === void 0) {
|
|
8927
8927
|
const id = generateSessionId();
|
|
8928
8928
|
createSession(db, id, sessionName ?? null, now);
|
|
8929
8929
|
return { sessionId: id, isNew: true, isResumed: false };
|
|
8930
8930
|
}
|
|
8931
|
-
if (!
|
|
8931
|
+
if (!getSessionById(db, sessionFlag)) {
|
|
8932
8932
|
throw new Error(`session '${sessionFlag}' not found. Run 'session list' to see active sessions.`);
|
|
8933
8933
|
}
|
|
8934
8934
|
return { sessionId: sessionFlag, isNew: false, isResumed: false };
|
|
@@ -8942,9 +8942,9 @@ var init_session_resolver = __esm({
|
|
|
8942
8942
|
}
|
|
8943
8943
|
});
|
|
8944
8944
|
|
|
8945
|
-
// packages/experience-design-system-cli/src/session/core/components/
|
|
8945
|
+
// packages/experience-design-system-cli/src/session/core/components/hash-component-shape.ts
|
|
8946
8946
|
import { createHash as createHash2 } from "node:crypto";
|
|
8947
|
-
function
|
|
8947
|
+
function hashComponentShape(component) {
|
|
8948
8948
|
const payload = {
|
|
8949
8949
|
framework: component.framework,
|
|
8950
8950
|
name: component.name,
|
|
@@ -8961,19 +8961,19 @@ function computeComponentInputHash(component) {
|
|
|
8961
8961
|
};
|
|
8962
8962
|
return createHash2("sha256").update(JSON.stringify(payload)).digest("hex");
|
|
8963
8963
|
}
|
|
8964
|
-
var
|
|
8965
|
-
"packages/experience-design-system-cli/src/session/core/components/
|
|
8964
|
+
var init_hash_component_shape = __esm({
|
|
8965
|
+
"packages/experience-design-system-cli/src/session/core/components/hash-component-shape.ts"() {
|
|
8966
8966
|
"use strict";
|
|
8967
8967
|
}
|
|
8968
8968
|
});
|
|
8969
8969
|
|
|
8970
|
-
// packages/experience-design-system-cli/src/session/core/tokens/
|
|
8970
|
+
// packages/experience-design-system-cli/src/session/core/tokens/hash-token-content.ts
|
|
8971
8971
|
import { createHash as createHash3 } from "node:crypto";
|
|
8972
|
-
function
|
|
8972
|
+
function hashTokenContent(rawTokenContent) {
|
|
8973
8973
|
return createHash3("sha256").update(rawTokenContent.trim()).digest("hex");
|
|
8974
8974
|
}
|
|
8975
|
-
var
|
|
8976
|
-
"packages/experience-design-system-cli/src/session/core/tokens/
|
|
8975
|
+
var init_hash_token_content = __esm({
|
|
8976
|
+
"packages/experience-design-system-cli/src/session/core/tokens/hash-token-content.ts"() {
|
|
8977
8977
|
"use strict";
|
|
8978
8978
|
}
|
|
8979
8979
|
});
|
|
@@ -9543,15 +9543,15 @@ function applyToolCalls(db, sessionId2, componentId, componentName, calls, incom
|
|
|
9543
9543
|
return { classified, excluded, slots, warnings };
|
|
9544
9544
|
}
|
|
9545
9545
|
function getOrCreateSession(db, sessionFlag, sessionName, hints) {
|
|
9546
|
-
return
|
|
9546
|
+
return getOrCreateSessionForCommand(db, sessionFlag, sessionName, hints);
|
|
9547
9547
|
}
|
|
9548
9548
|
function createStep(db, sessionId2, command, inputs) {
|
|
9549
9549
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
9550
9550
|
db.exec("BEGIN");
|
|
9551
9551
|
try {
|
|
9552
|
-
|
|
9553
|
-
const stepId =
|
|
9554
|
-
|
|
9552
|
+
updatePendingStepsToInterrupted(db, sessionId2, command, now);
|
|
9553
|
+
const stepId = createPendingStep(db, sessionId2, command, inputs, now);
|
|
9554
|
+
updateSessionTimestamp(db, sessionId2, now);
|
|
9555
9555
|
db.exec("COMMIT");
|
|
9556
9556
|
return stepId;
|
|
9557
9557
|
} catch (e) {
|
|
@@ -9563,10 +9563,10 @@ function updateStep(db, stepId, status, outputs, error) {
|
|
|
9563
9563
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
9564
9564
|
db.exec("BEGIN");
|
|
9565
9565
|
try {
|
|
9566
|
-
const stepSessionId =
|
|
9567
|
-
|
|
9566
|
+
const stepSessionId = getSessionIdForStep(db, stepId);
|
|
9567
|
+
updateStepStatus(db, stepId, status, outputs, error ?? null, now);
|
|
9568
9568
|
if (stepSessionId) {
|
|
9569
|
-
|
|
9569
|
+
updateSessionTimestamp(db, stepSessionId, now);
|
|
9570
9570
|
}
|
|
9571
9571
|
db.exec("COMMIT");
|
|
9572
9572
|
} catch (e) {
|
|
@@ -9764,10 +9764,10 @@ function loadRawComponents(db, sessionId2, allowedNames) {
|
|
|
9764
9764
|
`SELECT component_id, slot_name, position, allowed_component
|
|
9765
9765
|
FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`
|
|
9766
9766
|
).all(sessionId2);
|
|
9767
|
-
const propsByComponent =
|
|
9768
|
-
const allowedValuesByProp =
|
|
9769
|
-
const slotsByComponent =
|
|
9770
|
-
const allowedComponentsBySlot =
|
|
9767
|
+
const propsByComponent = indexRowsByKey(props, (p) => p.component_id);
|
|
9768
|
+
const allowedValuesByProp = indexRowsByKey(allowedValues, (av) => `${av.component_id}::${av.prop_name}`);
|
|
9769
|
+
const slotsByComponent = indexRowsByKey(slots, (s) => s.component_id);
|
|
9770
|
+
const allowedComponentsBySlot = indexRowsByKey(allowedComponents, (ac) => `${ac.component_id}::${ac.slot_name}`);
|
|
9771
9771
|
return components.map(
|
|
9772
9772
|
(c2) => ({
|
|
9773
9773
|
component_id: c2.component_id,
|
|
@@ -10167,11 +10167,11 @@ function loadCDFComponents(db, sessionId2) {
|
|
|
10167
10167
|
const tokenTypeByPath = new Map(
|
|
10168
10168
|
db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ?").all(sessionId2).map((token) => [token.path, token.type])
|
|
10169
10169
|
);
|
|
10170
|
-
const propsByComponent =
|
|
10171
|
-
const allowedValuesByProp =
|
|
10172
|
-
const slotsByComponent =
|
|
10173
|
-
const allowedComponentsBySlot =
|
|
10174
|
-
const tokenPathsByProp =
|
|
10170
|
+
const propsByComponent = indexRowsByKey(props, (p) => p.component_id);
|
|
10171
|
+
const allowedValuesByProp = indexRowsByKey(allowedValues, (av) => `${av.component_id}::${av.prop_name}`);
|
|
10172
|
+
const slotsByComponent = indexRowsByKey(slots, (s) => s.component_id);
|
|
10173
|
+
const allowedComponentsBySlot = indexRowsByKey(allowedComponents, (ac) => `${ac.component_id}::${ac.slot_name}`);
|
|
10174
|
+
const tokenPathsByProp = indexRowsByKey(tokenPaths, (t) => `${t.component_id}::${t.prop_name}`);
|
|
10175
10175
|
const toTokenPaths = (rows) => rows === void 0 ? void 0 : rows.map((r) => r.path);
|
|
10176
10176
|
return components.map(({ component_id, name, description }) => {
|
|
10177
10177
|
const compProps = propsByComponent.get(component_id) ?? [];
|
|
@@ -10236,8 +10236,8 @@ function loadScopeComponents(db, sessionId2) {
|
|
|
10236
10236
|
`SELECT component_id, slot_name, position, allowed_component
|
|
10237
10237
|
FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`
|
|
10238
10238
|
).all(sessionId2);
|
|
10239
|
-
const slotsByComponent =
|
|
10240
|
-
const allowedBySlot =
|
|
10239
|
+
const slotsByComponent = indexRowsByKey(slotRows, (s) => s.component_id);
|
|
10240
|
+
const allowedBySlot = indexRowsByKey(allowedRows, (a) => `${a.component_id}::${a.slot_name}`);
|
|
10241
10241
|
return rows.map((r) => {
|
|
10242
10242
|
const reviewReasons = parseReviewReasons(r.review_reasons);
|
|
10243
10243
|
const nonAuthorableReason = reviewReasons.find((reason) => reason.startsWith("non-authorable:"));
|
|
@@ -10351,8 +10351,8 @@ function loadDTCGTokens(db, sessionId2) {
|
|
|
10351
10351
|
});
|
|
10352
10352
|
return { groups, tokens };
|
|
10353
10353
|
}
|
|
10354
|
-
function
|
|
10355
|
-
return
|
|
10354
|
+
function findLatestSessionForCommand(db, command) {
|
|
10355
|
+
return getLatestCompletedSessionForCommand(db, command);
|
|
10356
10356
|
}
|
|
10357
10357
|
function seedCDFFromPreviewResponse(db, sessionId2, removedItems) {
|
|
10358
10358
|
if (removedItems.length === 0) return 0;
|
|
@@ -10763,18 +10763,18 @@ var init_db = __esm({
|
|
|
10763
10763
|
"packages/experience-design-system-cli/src/session/db.ts"() {
|
|
10764
10764
|
"use strict";
|
|
10765
10765
|
init_source_excerpt();
|
|
10766
|
-
|
|
10767
|
-
|
|
10768
|
-
|
|
10766
|
+
init_derive_component_id();
|
|
10767
|
+
init_cdf_mappers();
|
|
10768
|
+
init_index_rows_by_key();
|
|
10769
10769
|
init_read();
|
|
10770
10770
|
init_write();
|
|
10771
10771
|
init_read2();
|
|
10772
10772
|
init_write2();
|
|
10773
10773
|
init_session_resolver();
|
|
10774
|
-
|
|
10775
|
-
|
|
10776
|
-
|
|
10777
|
-
|
|
10774
|
+
init_derive_component_id();
|
|
10775
|
+
init_hash_component_shape();
|
|
10776
|
+
init_hash_token_content();
|
|
10777
|
+
init_cdf_mappers();
|
|
10778
10778
|
SCHEMA = `
|
|
10779
10779
|
PRAGMA journal_mode = WAL;
|
|
10780
10780
|
PRAGMA foreign_keys = ON;
|
|
@@ -30577,7 +30577,7 @@ function resolveRationaleSession(sessionFlag, dbPath) {
|
|
|
30577
30577
|
}
|
|
30578
30578
|
return sessionFlag;
|
|
30579
30579
|
}
|
|
30580
|
-
const latest =
|
|
30580
|
+
const latest = findLatestSessionForCommand(db, "analyze select");
|
|
30581
30581
|
if (!latest) {
|
|
30582
30582
|
throw new Error(
|
|
30583
30583
|
`No completed 'analyze select' session found. Run 'analyze select-agent' first, or pass --session <id>.`
|
|
@@ -30850,7 +30850,7 @@ async function selectAllComponents(agent, model, components, verbose, skillPathO
|
|
|
30850
30850
|
try {
|
|
30851
30851
|
for (let i = 0; i < components.length; i++) {
|
|
30852
30852
|
const candidate = components[i];
|
|
30853
|
-
const compHash =
|
|
30853
|
+
const compHash = hashComponentShape(candidate.component);
|
|
30854
30854
|
const hit = lookupSelectCache(db, compHash, promptHash, cliVersion2);
|
|
30855
30855
|
if (hit) {
|
|
30856
30856
|
const finalColor = hit.decision === "accepted" ? c.green : c.red;
|
|
@@ -30924,7 +30924,7 @@ async function selectAllComponents(agent, model, components, verbose, skillPathO
|
|
|
30924
30924
|
const r = results[i];
|
|
30925
30925
|
if (!r || r.failed || !r.decision) continue;
|
|
30926
30926
|
const candidate = components[i];
|
|
30927
|
-
const compHash =
|
|
30927
|
+
const compHash = hashComponentShape(candidate.component);
|
|
30928
30928
|
storeSelectCache(db, compHash, promptHash, cliVersion2, r.decision, r.reason ?? null);
|
|
30929
30929
|
}
|
|
30930
30930
|
} finally {
|
|
@@ -32870,7 +32870,7 @@ function printFallbackInstructions(options) {
|
|
|
32870
32870
|
async function runOneComponent(agent, model, db, sessionId2, component, tokensInline, tokenMapInline, index, total, verbose, noCache, skillPathOverride, promptHash, existingContentfulEntities, existingTokensInline) {
|
|
32871
32871
|
const pos = c.dim(`[${index + 1}/${total}]`);
|
|
32872
32872
|
if (!noCache) {
|
|
32873
|
-
const inputHash =
|
|
32873
|
+
const inputHash = hashComponentShape(component);
|
|
32874
32874
|
const cached = lookupCache(db, inputHash, "component", component.component_id, promptHash);
|
|
32875
32875
|
if (cached) {
|
|
32876
32876
|
copyComponentFromCache(db, cached.sourceSessionId, sessionId2, component.component_id);
|
|
@@ -32993,7 +32993,7 @@ ${outputBuf}`);
|
|
|
32993
32993
|
}
|
|
32994
32994
|
const applied = applyToolCalls(db, sessionId2, component.component_id, component.name, calls, warnings);
|
|
32995
32995
|
if (!noCache) {
|
|
32996
|
-
const inputHash =
|
|
32996
|
+
const inputHash = hashComponentShape(component);
|
|
32997
32997
|
storeCache(db, inputHash, "component", component.component_id, sessionId2, false, promptHash);
|
|
32998
32998
|
}
|
|
32999
32999
|
return {
|
|
@@ -33290,7 +33290,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
33290
33290
|
} else if (skill === "tokens") {
|
|
33291
33291
|
const noCache = opts.cache === false || process.env.EDS_NO_CACHE === "1";
|
|
33292
33292
|
const tokenInputContent = rawTokensInline ?? "";
|
|
33293
|
-
const tokenInputHash =
|
|
33293
|
+
const tokenInputHash = hashTokenContent(tokenInputContent);
|
|
33294
33294
|
const db = openPipelineDb();
|
|
33295
33295
|
try {
|
|
33296
33296
|
let resolvedSessionId = opts.session;
|
|
@@ -34199,10 +34199,10 @@ async function assertOutIsNotDirectory(outPath) {
|
|
|
34199
34199
|
if (s.isDirectory()) await die3(`Error: --out must be a file path, not a directory: ${outPath}`);
|
|
34200
34200
|
}
|
|
34201
34201
|
}
|
|
34202
|
-
async function
|
|
34202
|
+
async function resolveSession(sessionFlag, command) {
|
|
34203
34203
|
const db = openPipelineDb();
|
|
34204
34204
|
try {
|
|
34205
|
-
const sessionId2 = sessionFlag ??
|
|
34205
|
+
const sessionId2 = sessionFlag ?? findLatestSessionForCommand(db, command);
|
|
34206
34206
|
if (!sessionId2) {
|
|
34207
34207
|
const hint = command === "generate components" ? "generate components" : "generate tokens";
|
|
34208
34208
|
return await die3(`Error: no completed ${hint} session found. Run ${hint} first, or pass --session <id>.`);
|
|
@@ -34252,7 +34252,7 @@ function registerPrintCommand(program) {
|
|
|
34252
34252
|
).action(async (opts) => {
|
|
34253
34253
|
const outPath = resolve19(opts.out);
|
|
34254
34254
|
await assertOutIsNotDirectory(outPath);
|
|
34255
|
-
const sessionId2 = await
|
|
34255
|
+
const sessionId2 = await resolveSession(opts.session, "generate components");
|
|
34256
34256
|
await bindAnalyticsSessionId(sessionId2);
|
|
34257
34257
|
const db = openPipelineDb();
|
|
34258
34258
|
let components;
|
|
@@ -34309,7 +34309,7 @@ function registerPrintCommand(program) {
|
|
|
34309
34309
|
print.command("tokens").description("Write generated tokens to a DTCG JSON file").option("--session <id>", "Session ID to print from (default: most recent generate tokens session)").option("--out <path>", "Output file path", "tokens.json").action(async (opts) => {
|
|
34310
34310
|
const outPath = resolve19(opts.out);
|
|
34311
34311
|
await assertOutIsNotDirectory(outPath);
|
|
34312
|
-
const sessionId2 = await
|
|
34312
|
+
const sessionId2 = await resolveSession(opts.session, "generate tokens");
|
|
34313
34313
|
await bindAnalyticsSessionId(sessionId2);
|
|
34314
34314
|
const db = openPipelineDb();
|
|
34315
34315
|
let result;
|
|
@@ -34626,7 +34626,7 @@ async function runMapTokens(opts) {
|
|
|
34626
34626
|
const resultAgent = configuredAgent ?? "skipped";
|
|
34627
34627
|
const db = openPipelineDb();
|
|
34628
34628
|
try {
|
|
34629
|
-
const sessionId2 = opts.session ??
|
|
34629
|
+
const sessionId2 = opts.session ?? findLatestSessionForCommand(db, "generate components");
|
|
34630
34630
|
if (!sessionId2) {
|
|
34631
34631
|
die2(
|
|
34632
34632
|
"Error: no completed generate components session found. Run generate components first, or pass --session <id>."
|
|
@@ -35011,7 +35011,7 @@ async function runPipeline(opts, progressWriter, cliPathOverride) {
|
|
|
35011
35011
|
status: "skipped",
|
|
35012
35012
|
reason: "--skip-analyze"
|
|
35013
35013
|
});
|
|
35014
|
-
const prior =
|
|
35014
|
+
const prior = findLatestSessionForCommand(db, "analyze extract");
|
|
35015
35015
|
extractSessionId = prior ?? null;
|
|
35016
35016
|
} else {
|
|
35017
35017
|
const stepId = createStep(db, sessionId2, "analyze extract", {
|
|
@@ -35045,7 +35045,7 @@ async function runPipeline(opts, progressWriter, cliPathOverride) {
|
|
|
35045
35045
|
db.close();
|
|
35046
35046
|
return { session: sessionId2, project: projectRoot, steps };
|
|
35047
35047
|
}
|
|
35048
|
-
extractSessionId =
|
|
35048
|
+
extractSessionId = findLatestSessionForCommand(db, "analyze extract") ?? null;
|
|
35049
35049
|
const componentMatch = /Extracted (\d+) component/.exec(r.stderr);
|
|
35050
35050
|
const componentCount = componentMatch ? Number(componentMatch[1]) : 0;
|
|
35051
35051
|
updateStep(db, stepId, "complete", {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type CdfCategory = 'content' | 'design' | 'state';
|
|
2
|
+
export declare function mapContentfulTypeToCdfType(contentfulType: string): string;
|
|
3
|
+
export declare function resolveCdfCategory(contentfulCategory: string | null | undefined, propName: string, contentProps: Set<string>, designProps: Set<string>): CdfCategory;
|
|
@@ -2,4 +2,4 @@ import type { RawComponentDefinition } from '../../../types.js';
|
|
|
2
2
|
export type RawComponentForHash = RawComponentDefinition & {
|
|
3
3
|
component_id?: string;
|
|
4
4
|
};
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function hashComponentShape(component: RawComponentForHash): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function indexRowsByKey<T>(items: T[], key: (item: T) => string): Map<string, T[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hashTokenContent(rawTokenContent: string): string;
|
package/dist/src/session/db.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ import type { ComponentTypeSummary } from '@contentful/experience-design-system-
|
|
|
6
6
|
import type { SlotCycle, SlotEdge } from '../analyze/cycle-detection.js';
|
|
7
7
|
import { type MatchHints as SessionMatchHints } from './repositories/sessions/read.js';
|
|
8
8
|
import { type SessionResolution } from './services/session-resolver.js';
|
|
9
|
-
export { deriveComponentId } from './core/components/component-id.js';
|
|
10
|
-
export { computeComponentInputHash } from './core/components/
|
|
11
|
-
export { computeTokenInputHash } from './core/tokens/
|
|
12
|
-
export { mapContentfulTypeToCdfType, resolveCdfCategory } from './core/cdf/
|
|
9
|
+
export { deriveComponentId } from './core/components/derive-component-id.js';
|
|
10
|
+
export { hashComponentShape as computeComponentInputHash } from './core/components/hash-component-shape.js';
|
|
11
|
+
export { hashTokenContent as computeTokenInputHash } from './core/tokens/hash-token-content.js';
|
|
12
|
+
export { mapContentfulTypeToCdfType, resolveCdfCategory } from './core/cdf/cdf-mappers.js';
|
|
13
13
|
export type StepStatus = 'pending' | 'complete' | 'failed' | 'interrupted';
|
|
14
14
|
export type CommandName = 'analyze extract' | 'analyze select' | 'generate components' | 'generate tokens' | 'generate edit' | 'apply preview' | 'apply select' | 'apply push' | 'print components' | 'print tokens' | 'map tokens' | 'fetch existing entities' | 'import';
|
|
15
15
|
export interface SessionRow {
|
|
@@ -5,7 +5,7 @@ export interface MatchHints {
|
|
|
5
5
|
inputPath?: string;
|
|
6
6
|
outDir?: string;
|
|
7
7
|
}
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function getSessionById(db: DatabaseSync, sessionId: string): {
|
|
9
9
|
id: string;
|
|
10
10
|
} | null;
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function getLatestCompletedSessionForCommand(db: DatabaseSync, command: CommandName): string | null;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DatabaseSync } from 'node:sqlite';
|
|
2
2
|
export declare function createSession(db: DatabaseSync, id: string, name: string | null, timestamp: string): void;
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function updateSessionTimestamp(db: DatabaseSync, sessionId: string, timestamp: string): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function getSessionIdForStep(db: DatabaseSync, stepId: number): string | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DatabaseSync } from 'node:sqlite';
|
|
2
2
|
import type { CommandName } from '../../db.js';
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
3
|
+
export declare function updatePendingStepsToInterrupted(db: DatabaseSync, sessionId: string, command: CommandName, timestamp: string): void;
|
|
4
|
+
export declare function createPendingStep(db: DatabaseSync, sessionId: string, command: CommandName, inputs: Record<string, string>, timestamp: string): number;
|
|
5
|
+
export declare function updateStepStatus(db: DatabaseSync, stepId: number, status: 'complete' | 'failed', outputs: Record<string, string>, error: string | null, timestamp: string): void;
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
-
import type
|
|
3
|
-
export
|
|
4
|
-
command: CommandName;
|
|
5
|
-
inputPath?: string;
|
|
6
|
-
outDir?: string;
|
|
7
|
-
}
|
|
2
|
+
import { type MatchHints } from '../repositories/sessions/read.js';
|
|
3
|
+
export type { MatchHints };
|
|
8
4
|
export interface SessionResolution {
|
|
9
5
|
sessionId: string;
|
|
10
6
|
isNew: boolean;
|
|
11
7
|
isResumed: boolean;
|
|
12
8
|
}
|
|
13
|
-
|
|
14
|
-
* Resolve which session the caller should operate on:
|
|
15
|
-
* - `sessionFlag === 'new'` or undefined → create a new session
|
|
16
|
-
* - explicit id → verify it exists and reuse it (throws if missing)
|
|
17
|
-
*
|
|
18
|
-
* `MatchHints` is accepted for signature stability (callers pass it today) but
|
|
19
|
-
* is not currently used — hint-based session resumption was removed upstream.
|
|
20
|
-
*/
|
|
21
|
-
export declare function resolveSession(db: DatabaseSync, sessionFlag: string | undefined, sessionName: string | undefined, _hints: MatchHints): SessionResolution;
|
|
9
|
+
export declare function getOrCreateSessionForCommand(db: DatabaseSync, sessionFlag: string | undefined, sessionName: string | undefined, _hints: MatchHints): SessionResolution;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experience-design-system-cli",
|
|
3
|
-
"version": "2.32.1-dev-build-
|
|
3
|
+
"version": "2.32.1-dev-build-12db7af.0",
|
|
4
4
|
"description": "Contentful Experiences design system import CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"svelte": "^5.56.4",
|
|
41
41
|
"ts-morph": "^27.0.2",
|
|
42
42
|
"typescript": "^5.9.3",
|
|
43
|
-
"@contentful/experience-design-system-cli-v2": "2.32.1-dev-build-
|
|
44
|
-
"@contentful/experience-design-system-types": "2.32.1-dev-build-
|
|
43
|
+
"@contentful/experience-design-system-cli-v2": "2.32.1-dev-build-12db7af.0",
|
|
44
|
+
"@contentful/experience-design-system-types": "2.32.1-dev-build-12db7af.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@tsconfig/node24": "^24.0.4",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"ink-testing-library": "^4.0.0",
|
|
54
54
|
"typescript-eslint": "^8.67.0",
|
|
55
55
|
"vitest": "^4.0.16",
|
|
56
|
-
"@contentful/experience-design-system-
|
|
57
|
-
"@contentful/experience-design-system-
|
|
58
|
-
"@contentful/experience-design-system-generation": "2.32.1-dev-build-
|
|
56
|
+
"@contentful/experience-design-system-extraction": "2.32.1-dev-build-12db7af.0",
|
|
57
|
+
"@contentful/experience-design-system-client": "2.32.1-dev-build-12db7af.0",
|
|
58
|
+
"@contentful/experience-design-system-generation": "2.32.1-dev-build-12db7af.0"
|
|
59
59
|
},
|
|
60
60
|
"repository": {
|
|
61
61
|
"type": "git",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type CdfCategory = 'content' | 'design' | 'state';
|
|
2
|
-
/**
|
|
3
|
-
* Translate a Contentful CMA type name into the CLI's internal CDF type name.
|
|
4
|
-
* The vocabularies overlap but differ (e.g. Contentful "symbol" → CDF "enum",
|
|
5
|
-
* Contentful "text" → CDF "string"). Unknown inputs default to "string".
|
|
6
|
-
*/
|
|
7
|
-
export declare function mapContentfulTypeToCdfType(contentfulType: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Decide which CDF category (`content` | `design` | `state`) a prop belongs to.
|
|
10
|
-
*
|
|
11
|
-
* Trusts a valid Contentful-provided category when present. Otherwise, falls
|
|
12
|
-
* back to per-component prop-name classification (contentProperties /
|
|
13
|
-
* designProperties from the same Contentful response), defaulting to `state`.
|
|
14
|
-
*/
|
|
15
|
-
export declare function resolveCdfCategory(contentfulCategory: string | null | undefined, propName: string, contentProps: Set<string>, designProps: Set<string>): CdfCategory;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function groupBy<T>(items: T[], key: (item: T) => string): Map<string, T[]>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function computeTokenInputHash(rawTokenContent: string): string;
|
|
File without changes
|