@contentful/experience-design-system-cli 2.37.1-dev-build-34dbca05.0 → 2.37.1-dev-build-ced30421.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/app.js +421 -564
- package/dist/index.js +1701 -1994
- package/dist/package.json +1 -1
- package/dist/src/tui/import/steps/07-scope-gate/keymap.d.ts +2 -0
- package/dist/src/tui/import/steps/07-scope-gate/sidebar/components/GroupedSidebar.d.ts +2 -0
- package/dist/src/tui/import/steps/07-scope-gate/state.d.ts +3 -2
- package/dist/src/tui/import/steps/07-scope-gate/types.d.ts +7 -0
- package/dist/src/tui/import/steps/07-scope-gate/use-scope-gate.d.ts +1 -1
- package/dist/src/tui/import/steps/08-generation/types.d.ts +2 -4
- package/legacy/dist/src/analytics/apply.d.ts +6 -0
- package/legacy/dist/src/analytics/client.d.ts +8 -0
- package/legacy/dist/src/analytics/constants.d.ts +4 -0
- package/legacy/dist/src/analytics/exit.d.ts +1 -1
- package/legacy/dist/src/analytics/index.d.ts +5 -2
- package/legacy/dist/src/analytics/normalize.d.ts +3 -0
- package/legacy/dist/src/analytics/os.d.ts +2 -0
- package/legacy/dist/src/analytics/session.d.ts +3 -0
- package/legacy/dist/src/analytics/tracker.d.ts +16 -0
- package/legacy/dist/src/analytics/types.d.ts +28 -0
- package/legacy/dist/src/index.js +19173 -19237
- package/legacy/package.json +1 -1
- package/package.json +3 -3
package/dist/app.js
CHANGED
|
@@ -2699,8 +2699,8 @@ function indexRowsByKey(items, key) {
|
|
|
2699
2699
|
}
|
|
2700
2700
|
|
|
2701
2701
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/sessions/read.js
|
|
2702
|
-
function getSessionById(db,
|
|
2703
|
-
const row = db.prepare("SELECT id FROM sessions WHERE id = ?").get(
|
|
2702
|
+
function getSessionById(db, sessionId) {
|
|
2703
|
+
const row = db.prepare("SELECT id FROM sessions WHERE id = ?").get(sessionId);
|
|
2704
2704
|
return row ?? null;
|
|
2705
2705
|
}
|
|
2706
2706
|
function getLatestCompletedSessionForCommand(db, command) {
|
|
@@ -2716,8 +2716,8 @@ function getLatestCompletedSessionForCommand(db, command) {
|
|
|
2716
2716
|
function createSession(db, id, name, timestamp) {
|
|
2717
2717
|
db.prepare("INSERT INTO sessions (id, name, created_at, updated_at) VALUES (?, ?, ?, ?)").run(id, name, timestamp, timestamp);
|
|
2718
2718
|
}
|
|
2719
|
-
function updateSessionTimestamp(db,
|
|
2720
|
-
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(timestamp,
|
|
2719
|
+
function updateSessionTimestamp(db, sessionId, timestamp) {
|
|
2720
|
+
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(timestamp, sessionId);
|
|
2721
2721
|
}
|
|
2722
2722
|
|
|
2723
2723
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/steps/read.js
|
|
@@ -2727,13 +2727,13 @@ function getSessionIdForStep(db, stepId) {
|
|
|
2727
2727
|
}
|
|
2728
2728
|
|
|
2729
2729
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/steps/write.js
|
|
2730
|
-
function updatePendingStepsToInterrupted(db,
|
|
2730
|
+
function updatePendingStepsToInterrupted(db, sessionId, command, timestamp) {
|
|
2731
2731
|
db.prepare(`UPDATE steps SET status = 'interrupted', completed_at = ?, updated_at = ?
|
|
2732
|
-
WHERE session_id = ? AND command = ? AND status = 'pending'`).run(timestamp, timestamp,
|
|
2732
|
+
WHERE session_id = ? AND command = ? AND status = 'pending'`).run(timestamp, timestamp, sessionId, command);
|
|
2733
2733
|
}
|
|
2734
|
-
function createPendingStep(db,
|
|
2734
|
+
function createPendingStep(db, sessionId, command, inputs, timestamp) {
|
|
2735
2735
|
const result = db.prepare(`INSERT INTO steps (session_id, command, status, started_at, inputs, outputs, updated_at)
|
|
2736
|
-
VALUES (?, ?, 'pending', ?, ?, '{}', ?)`).run(
|
|
2736
|
+
VALUES (?, ?, 'pending', ?, ?, '{}', ?)`).run(sessionId, command, timestamp, JSON.stringify(inputs), timestamp);
|
|
2737
2737
|
return Number(result.lastInsertRowid);
|
|
2738
2738
|
}
|
|
2739
2739
|
function updateStepStatus(db, stepId, status, outputs, error, timestamp) {
|
|
@@ -2995,12 +2995,12 @@ function buildDtcgTokens(tokenRows) {
|
|
|
2995
2995
|
}
|
|
2996
2996
|
|
|
2997
2997
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/tokens/read.js
|
|
2998
|
-
function getDtcgTokensForSession(db,
|
|
2999
|
-
const groupRows = db.prepare("SELECT path, description FROM raw_token_groups WHERE session_id = ? ORDER BY path").all(
|
|
2998
|
+
function getDtcgTokensForSession(db, sessionId) {
|
|
2999
|
+
const groupRows = db.prepare("SELECT path, description FROM raw_token_groups WHERE session_id = ? ORDER BY path").all(sessionId).map((row) => ({
|
|
3000
3000
|
path: String(row.path),
|
|
3001
3001
|
description: row.description === null ? null : String(row.description)
|
|
3002
3002
|
}));
|
|
3003
|
-
const tokenRows = db.prepare("SELECT path, type, value, description FROM raw_tokens WHERE session_id = ? ORDER BY path").all(
|
|
3003
|
+
const tokenRows = db.prepare("SELECT path, type, value, description FROM raw_tokens WHERE session_id = ? ORDER BY path").all(sessionId).map((row) => ({
|
|
3004
3004
|
path: String(row.path),
|
|
3005
3005
|
type: String(row.type),
|
|
3006
3006
|
value: String(row.value),
|
|
@@ -3011,12 +3011,12 @@ function getDtcgTokensForSession(db, sessionId2) {
|
|
|
3011
3011
|
tokens: buildDtcgTokens(tokenRows)
|
|
3012
3012
|
};
|
|
3013
3013
|
}
|
|
3014
|
-
function getRawTokenNamePaths(db,
|
|
3015
|
-
const rows = db.prepare("SELECT raw_name, path FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(
|
|
3014
|
+
function getRawTokenNamePaths(db, sessionId) {
|
|
3015
|
+
const rows = db.prepare("SELECT raw_name, path FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId);
|
|
3016
3016
|
return Object.fromEntries(rows.map((row) => [String(row.raw_name), String(row.path)]));
|
|
3017
3017
|
}
|
|
3018
|
-
function getRawTokenNamePathRows(db,
|
|
3019
|
-
return db.prepare("SELECT raw_name, path, source FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(
|
|
3018
|
+
function getRawTokenNamePathRows(db, sessionId) {
|
|
3019
|
+
return db.prepare("SELECT raw_name, path, source FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId).map((row) => ({
|
|
3020
3020
|
rawName: String(row.raw_name),
|
|
3021
3021
|
path: String(row.path),
|
|
3022
3022
|
source: String(row.source)
|
|
@@ -3049,49 +3049,49 @@ function hashTokenContent(rawTokenContent) {
|
|
|
3049
3049
|
}
|
|
3050
3050
|
|
|
3051
3051
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/tokens/write.js
|
|
3052
|
-
function deleteRawTokensForSession(db,
|
|
3053
|
-
db.prepare("DELETE FROM raw_token_groups WHERE session_id = ?").run(
|
|
3054
|
-
db.prepare("DELETE FROM raw_tokens WHERE session_id = ?").run(
|
|
3052
|
+
function deleteRawTokensForSession(db, sessionId) {
|
|
3053
|
+
db.prepare("DELETE FROM raw_token_groups WHERE session_id = ?").run(sessionId);
|
|
3054
|
+
db.prepare("DELETE FROM raw_tokens WHERE session_id = ?").run(sessionId);
|
|
3055
3055
|
}
|
|
3056
|
-
function createRawTokenGroups(db,
|
|
3056
|
+
function createRawTokenGroups(db, sessionId, groups) {
|
|
3057
3057
|
const insertGroup = db.prepare(`INSERT INTO raw_token_groups (session_id, path, description) VALUES (?, ?, ?)`);
|
|
3058
3058
|
for (const group of groups) {
|
|
3059
|
-
insertGroup.run(
|
|
3059
|
+
insertGroup.run(sessionId, group.path, group.$description ?? null);
|
|
3060
3060
|
}
|
|
3061
3061
|
}
|
|
3062
|
-
function createRawTokens(db,
|
|
3062
|
+
function createRawTokens(db, sessionId, tokens) {
|
|
3063
3063
|
const insertToken = db.prepare(`INSERT INTO raw_tokens (session_id, path, type, value, description) VALUES (?, ?, ?, ?, ?)`);
|
|
3064
3064
|
for (const token of tokens) {
|
|
3065
|
-
insertToken.run(
|
|
3065
|
+
insertToken.run(sessionId, token.path, token.$type, JSON.stringify(token.$value), token.$description ?? null);
|
|
3066
3066
|
}
|
|
3067
3067
|
}
|
|
3068
|
-
function upsertRawToken(db,
|
|
3068
|
+
function upsertRawToken(db, sessionId, call) {
|
|
3069
3069
|
db.prepare(`INSERT INTO raw_tokens (session_id, path, type, value, description) VALUES (?, ?, ?, ?, ?)
|
|
3070
|
-
ON CONFLICT(session_id, path) DO UPDATE SET type = excluded.type, value = excluded.value, description = excluded.description`).run(
|
|
3070
|
+
ON CONFLICT(session_id, path) DO UPDATE SET type = excluded.type, value = excluded.value, description = excluded.description`).run(sessionId, call.path, call.type, JSON.stringify(call.value), call.description ?? null);
|
|
3071
3071
|
}
|
|
3072
|
-
function upsertRawTokenGroup(db,
|
|
3072
|
+
function upsertRawTokenGroup(db, sessionId, call) {
|
|
3073
3073
|
db.prepare(`INSERT INTO raw_token_groups (session_id, path, description) VALUES (?, ?, ?)
|
|
3074
|
-
ON CONFLICT(session_id, path) DO UPDATE SET description = excluded.description`).run(
|
|
3074
|
+
ON CONFLICT(session_id, path) DO UPDATE SET description = excluded.description`).run(sessionId, call.path, call.description ?? null);
|
|
3075
3075
|
}
|
|
3076
|
-
function updateRawTokenNamePaths(db,
|
|
3076
|
+
function updateRawTokenNamePaths(db, sessionId, tokenNamePaths, source) {
|
|
3077
3077
|
const entries = Object.entries(tokenNamePaths);
|
|
3078
3078
|
const deletePaths = db.prepare("DELETE FROM raw_token_name_paths WHERE session_id = ? AND source = ?");
|
|
3079
3079
|
const insertPath = db.prepare("INSERT OR IGNORE INTO raw_token_name_paths (session_id, raw_name, path, source) VALUES (?, ?, ?, ?)");
|
|
3080
3080
|
const deleteAutomaticByName = db.prepare("DELETE FROM raw_token_name_paths WHERE session_id = ? AND raw_name = ? AND source = 'automatic'");
|
|
3081
|
-
deletePaths.run(
|
|
3081
|
+
deletePaths.run(sessionId, source);
|
|
3082
3082
|
for (const [rawName, path5] of entries) {
|
|
3083
3083
|
if (source === "manual")
|
|
3084
|
-
deleteAutomaticByName.run(
|
|
3085
|
-
insertPath.run(
|
|
3084
|
+
deleteAutomaticByName.run(sessionId, rawName);
|
|
3085
|
+
insertPath.run(sessionId, rawName, path5, source);
|
|
3086
3086
|
}
|
|
3087
3087
|
}
|
|
3088
|
-
function updateRawPropTokenPaths(db,
|
|
3088
|
+
function updateRawPropTokenPaths(db, sessionId, componentId, propName, paths, source) {
|
|
3089
3089
|
db.prepare(`DELETE FROM raw_prop_token_paths
|
|
3090
|
-
WHERE session_id = ? AND component_id = ? AND prop_name = ?`).run(
|
|
3090
|
+
WHERE session_id = ? AND component_id = ? AND prop_name = ?`).run(sessionId, componentId, propName);
|
|
3091
3091
|
const insertPath = db.prepare(`INSERT INTO raw_prop_token_paths (session_id, component_id, prop_name, source, position, path)
|
|
3092
3092
|
VALUES (?, ?, ?, ?, ?, ?)`);
|
|
3093
3093
|
paths.forEach((path5, position) => {
|
|
3094
|
-
insertPath.run(
|
|
3094
|
+
insertPath.run(sessionId, componentId, propName, source, position, path5);
|
|
3095
3095
|
});
|
|
3096
3096
|
}
|
|
3097
3097
|
|
|
@@ -3109,18 +3109,18 @@ function withTransaction(db, fn) {
|
|
|
3109
3109
|
}
|
|
3110
3110
|
|
|
3111
3111
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/services/tokens/store-dtcg-tokens.js
|
|
3112
|
-
function storeDtcgTokens(db,
|
|
3112
|
+
function storeDtcgTokens(db, sessionId, groups, tokens) {
|
|
3113
3113
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3114
3114
|
withTransaction(db, () => {
|
|
3115
|
-
deleteRawTokensForSession(db,
|
|
3116
|
-
createRawTokenGroups(db,
|
|
3117
|
-
createRawTokens(db,
|
|
3118
|
-
updateSessionTimestamp(db,
|
|
3115
|
+
deleteRawTokensForSession(db, sessionId);
|
|
3116
|
+
createRawTokenGroups(db, sessionId, groups);
|
|
3117
|
+
createRawTokens(db, sessionId, tokens);
|
|
3118
|
+
updateSessionTimestamp(db, sessionId, now);
|
|
3119
3119
|
});
|
|
3120
3120
|
}
|
|
3121
3121
|
|
|
3122
3122
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/services/tokens/apply-tool-calls.js
|
|
3123
|
-
function applyTokenToolCalls(db,
|
|
3123
|
+
function applyTokenToolCalls(db, sessionId, calls, incomingWarnings) {
|
|
3124
3124
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3125
3125
|
const warnings = [...incomingWarnings];
|
|
3126
3126
|
let tokens = 0;
|
|
@@ -3128,31 +3128,31 @@ function applyTokenToolCalls(db, sessionId2, calls, incomingWarnings) {
|
|
|
3128
3128
|
withTransaction(db, () => {
|
|
3129
3129
|
for (const call of calls) {
|
|
3130
3130
|
if (call.tool === "set_token") {
|
|
3131
|
-
upsertRawToken(db,
|
|
3131
|
+
upsertRawToken(db, sessionId, call);
|
|
3132
3132
|
tokens++;
|
|
3133
3133
|
} else if (call.tool === "set_group") {
|
|
3134
|
-
upsertRawTokenGroup(db,
|
|
3134
|
+
upsertRawTokenGroup(db, sessionId, call);
|
|
3135
3135
|
groups++;
|
|
3136
3136
|
}
|
|
3137
3137
|
}
|
|
3138
|
-
updateSessionTimestamp(db,
|
|
3138
|
+
updateSessionTimestamp(db, sessionId, now);
|
|
3139
3139
|
});
|
|
3140
3140
|
return { tokens, groups, warnings };
|
|
3141
3141
|
}
|
|
3142
3142
|
|
|
3143
3143
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/services/tokens/replace-raw-token-name-paths.js
|
|
3144
|
-
function replaceRawTokenNamePaths(db,
|
|
3144
|
+
function replaceRawTokenNamePaths(db, sessionId, tokenNamePaths, source = "automatic") {
|
|
3145
3145
|
withTransaction(db, () => {
|
|
3146
|
-
updateRawTokenNamePaths(db,
|
|
3147
|
-
updateSessionTimestamp(db,
|
|
3146
|
+
updateRawTokenNamePaths(db, sessionId, tokenNamePaths, source);
|
|
3147
|
+
updateSessionTimestamp(db, sessionId, (/* @__PURE__ */ new Date()).toISOString());
|
|
3148
3148
|
});
|
|
3149
3149
|
}
|
|
3150
3150
|
|
|
3151
3151
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/services/tokens/replace-raw-prop-token-paths.js
|
|
3152
|
-
function replaceRawPropTokenPaths(db,
|
|
3152
|
+
function replaceRawPropTokenPaths(db, sessionId, componentId, propName, paths, source) {
|
|
3153
3153
|
withTransaction(db, () => {
|
|
3154
|
-
updateRawPropTokenPaths(db,
|
|
3155
|
-
updateSessionTimestamp(db,
|
|
3154
|
+
updateRawPropTokenPaths(db, sessionId, componentId, propName, paths, source);
|
|
3155
|
+
updateSessionTimestamp(db, sessionId, (/* @__PURE__ */ new Date()).toISOString());
|
|
3156
3156
|
});
|
|
3157
3157
|
}
|
|
3158
3158
|
|
|
@@ -3596,11 +3596,11 @@ function applyDbMigrations(db) {
|
|
|
3596
3596
|
`);
|
|
3597
3597
|
}
|
|
3598
3598
|
}
|
|
3599
|
-
function loadComponentReviewMetadata(db,
|
|
3600
|
-
const compRow = db.prepare(`SELECT component_id, source, source_path FROM raw_components WHERE session_id = ? AND name = ?`).get(
|
|
3599
|
+
function loadComponentReviewMetadata(db, sessionId, componentName) {
|
|
3600
|
+
const compRow = db.prepare(`SELECT component_id, source, source_path FROM raw_components WHERE session_id = ? AND name = ?`).get(sessionId, componentName);
|
|
3601
3601
|
if (!compRow)
|
|
3602
3602
|
return null;
|
|
3603
|
-
const propRows = db.prepare(`SELECT name, rationale, source_start_line, source_end_line FROM raw_props WHERE session_id = ? AND component_id = ?`).all(
|
|
3603
|
+
const propRows = db.prepare(`SELECT name, rationale, source_start_line, source_end_line FROM raw_props WHERE session_id = ? AND component_id = ?`).all(sessionId, compRow.component_id);
|
|
3604
3604
|
const props = {};
|
|
3605
3605
|
for (const r of propRows) {
|
|
3606
3606
|
props[r.name] = {
|
|
@@ -3622,15 +3622,15 @@ function loadComponentReviewMetadata(db, sessionId2, componentName) {
|
|
|
3622
3622
|
props
|
|
3623
3623
|
};
|
|
3624
3624
|
}
|
|
3625
|
-
function loadComponentRationale(db,
|
|
3625
|
+
function loadComponentRationale(db, sessionId, componentName) {
|
|
3626
3626
|
const compRow = db.prepare(`SELECT component_id, name, description, component_description_rationale, props_rationale, slots_rationale
|
|
3627
|
-
FROM raw_components WHERE session_id = ? AND name = ?`).get(
|
|
3627
|
+
FROM raw_components WHERE session_id = ? AND name = ?`).get(sessionId, componentName);
|
|
3628
3628
|
if (!compRow)
|
|
3629
3629
|
return null;
|
|
3630
3630
|
const propRows = db.prepare(`SELECT name, cdf_category, category, description, rationale FROM raw_props
|
|
3631
|
-
WHERE session_id = ? AND component_id = ? ORDER BY position`).all(
|
|
3631
|
+
WHERE session_id = ? AND component_id = ? ORDER BY position`).all(sessionId, compRow.component_id);
|
|
3632
3632
|
const slotRows = db.prepare(`SELECT name, description, rationale FROM raw_slots
|
|
3633
|
-
WHERE session_id = ? AND component_id = ? ORDER BY position`).all(
|
|
3633
|
+
WHERE session_id = ? AND component_id = ? ORDER BY position`).all(sessionId, compRow.component_id);
|
|
3634
3634
|
return {
|
|
3635
3635
|
name: compRow.name,
|
|
3636
3636
|
description: compRow.description,
|
|
@@ -3650,7 +3650,7 @@ function loadComponentRationale(db, sessionId2, componentName) {
|
|
|
3650
3650
|
}))
|
|
3651
3651
|
};
|
|
3652
3652
|
}
|
|
3653
|
-
function applyToolCalls(db,
|
|
3653
|
+
function applyToolCalls(db, sessionId, componentId, componentName, calls, incomingWarnings, options = {}) {
|
|
3654
3654
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3655
3655
|
const warnings = [...incomingWarnings];
|
|
3656
3656
|
let classified = 0;
|
|
@@ -3678,58 +3678,58 @@ function applyToolCalls(db, sessionId2, componentId, componentName, calls, incom
|
|
|
3678
3678
|
for (const call of calls) {
|
|
3679
3679
|
if (call.tool === "classify_component") {
|
|
3680
3680
|
if (call.description !== void 0) {
|
|
3681
|
-
db.prepare("UPDATE raw_components SET description = ? WHERE session_id = ? AND component_id = ?").run(call.description,
|
|
3681
|
+
db.prepare("UPDATE raw_components SET description = ? WHERE session_id = ? AND component_id = ?").run(call.description, sessionId, componentId);
|
|
3682
3682
|
}
|
|
3683
3683
|
if (call.rationale) {
|
|
3684
3684
|
if (call.rationale.description !== void 0) {
|
|
3685
|
-
db.prepare("UPDATE raw_components SET component_description_rationale = ? WHERE session_id = ? AND component_id = ?").run(call.rationale.description,
|
|
3685
|
+
db.prepare("UPDATE raw_components SET component_description_rationale = ? WHERE session_id = ? AND component_id = ?").run(call.rationale.description, sessionId, componentId);
|
|
3686
3686
|
}
|
|
3687
3687
|
if (call.rationale.props !== void 0) {
|
|
3688
|
-
db.prepare("UPDATE raw_components SET props_rationale = ? WHERE session_id = ? AND component_id = ?").run(call.rationale.props,
|
|
3688
|
+
db.prepare("UPDATE raw_components SET props_rationale = ? WHERE session_id = ? AND component_id = ?").run(call.rationale.props, sessionId, componentId);
|
|
3689
3689
|
}
|
|
3690
3690
|
if (call.rationale.slots !== void 0) {
|
|
3691
|
-
db.prepare("UPDATE raw_components SET slots_rationale = ? WHERE session_id = ? AND component_id = ?").run(call.rationale.slots,
|
|
3691
|
+
db.prepare("UPDATE raw_components SET slots_rationale = ? WHERE session_id = ? AND component_id = ?").run(call.rationale.slots, sessionId, componentId);
|
|
3692
3692
|
}
|
|
3693
3693
|
}
|
|
3694
3694
|
} else if (call.tool === "classify_prop") {
|
|
3695
|
-
const changes = updateProp.run(call.cdf_type, call.cdf_category, call.token_kind ?? null, call.required !== void 0 ? call.required ? 1 : 0 : 0, call.description ?? null, call.reason ?? null,
|
|
3695
|
+
const changes = updateProp.run(call.cdf_type, call.cdf_category, call.token_kind ?? null, call.required !== void 0 ? call.required ? 1 : 0 : 0, call.description ?? null, call.reason ?? null, sessionId, componentId, call.prop);
|
|
3696
3696
|
if (changes.changes === 0) {
|
|
3697
3697
|
warnings.push(`${componentName}: classify_prop '${call.prop}' \u2014 prop not found, skipped`);
|
|
3698
3698
|
continue;
|
|
3699
3699
|
}
|
|
3700
3700
|
if (call.cdf_type === "token") {
|
|
3701
|
-
deleteAllowedValues.run(
|
|
3701
|
+
deleteAllowedValues.run(sessionId, componentId, call.prop);
|
|
3702
3702
|
if (call.values && call.values.length > 0) {
|
|
3703
3703
|
const count = call.values.length;
|
|
3704
3704
|
warnings.push(`${componentName}: classify_prop '${call.prop}' \u2014 dropped ${count} value${count === 1 ? "" : "s"} on a token property; its options list is $token.allowed, not $values`);
|
|
3705
3705
|
}
|
|
3706
3706
|
} else {
|
|
3707
|
-
deleteTokenPaths.run(
|
|
3707
|
+
deleteTokenPaths.run(sessionId, componentId, call.prop);
|
|
3708
3708
|
if (call.values && call.values.length > 0) {
|
|
3709
|
-
deleteAllowedValues.run(
|
|
3710
|
-
call.values.forEach((v, i) => insertAllowedValue.run(
|
|
3709
|
+
deleteAllowedValues.run(sessionId, componentId, call.prop);
|
|
3710
|
+
call.values.forEach((v, i) => insertAllowedValue.run(sessionId, componentId, call.prop, v, i));
|
|
3711
3711
|
}
|
|
3712
3712
|
}
|
|
3713
3713
|
if (call.default !== void 0) {
|
|
3714
3714
|
const storedDefault = typeof call.default === "boolean" ? String(call.default) : call.default;
|
|
3715
|
-
db.prepare(`UPDATE raw_props SET default_value = ? WHERE session_id = ? AND component_id = ? AND name = ?`).run(storedDefault,
|
|
3715
|
+
db.prepare(`UPDATE raw_props SET default_value = ? WHERE session_id = ? AND component_id = ? AND name = ?`).run(storedDefault, sessionId, componentId, call.prop);
|
|
3716
3716
|
}
|
|
3717
3717
|
classified++;
|
|
3718
3718
|
} else if (call.tool === "exclude_prop") {
|
|
3719
|
-
clearProp.run(call.reason || null,
|
|
3719
|
+
clearProp.run(call.reason || null, sessionId, componentId, call.prop);
|
|
3720
3720
|
excluded++;
|
|
3721
3721
|
} else if (call.tool === "classify_slot") {
|
|
3722
3722
|
const slotRequired = call.required !== void 0 ? call.required ? 1 : 0 : 1;
|
|
3723
|
-
const slotChanges = updateSlot.run(slotRequired, call.description ?? null,
|
|
3723
|
+
const slotChanges = updateSlot.run(slotRequired, call.description ?? null, sessionId, componentId, call.slot);
|
|
3724
3724
|
if (slotChanges.changes === 0) {
|
|
3725
3725
|
warnings.push(`${componentName}: classify_slot '${call.slot}' \u2014 slot not found, skipped`);
|
|
3726
3726
|
continue;
|
|
3727
3727
|
}
|
|
3728
3728
|
if (call.rationale !== void 0) {
|
|
3729
|
-
db.prepare("UPDATE raw_slots SET rationale = ? WHERE session_id = ? AND component_id = ? AND name = ?").run(call.rationale,
|
|
3729
|
+
db.prepare("UPDATE raw_slots SET rationale = ? WHERE session_id = ? AND component_id = ? AND name = ?").run(call.rationale, sessionId, componentId, call.slot);
|
|
3730
3730
|
}
|
|
3731
3731
|
if (call.allowed_components !== void 0) {
|
|
3732
|
-
deleteAllowedComponents.run(
|
|
3732
|
+
deleteAllowedComponents.run(sessionId, componentId, call.slot);
|
|
3733
3733
|
const allowedComponents = options.allowedComponentNames ? call.allowed_components.filter((allowedComponent) => options.allowedComponentNames.has(allowedComponent)) : call.allowed_components;
|
|
3734
3734
|
if (options.allowedComponentNames) {
|
|
3735
3735
|
const dropped = [
|
|
@@ -3739,13 +3739,13 @@ function applyToolCalls(db, sessionId2, componentId, componentName, calls, incom
|
|
|
3739
3739
|
warnings.push(`${componentName}: classify_slot '${call.slot}' \u2014 dropped unknown allowed component '${allowedComponent}'`);
|
|
3740
3740
|
}
|
|
3741
3741
|
}
|
|
3742
|
-
allowedComponents.forEach((ac, i) => insertAllowedComponent.run(
|
|
3742
|
+
allowedComponents.forEach((ac, i) => insertAllowedComponent.run(sessionId, componentId, call.slot, ac, i));
|
|
3743
3743
|
}
|
|
3744
3744
|
slots++;
|
|
3745
3745
|
}
|
|
3746
3746
|
}
|
|
3747
|
-
db.prepare(`UPDATE raw_components SET status = 'generated', extracted_at = ? WHERE session_id = ? AND component_id = ?`).run(now,
|
|
3748
|
-
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now,
|
|
3747
|
+
db.prepare(`UPDATE raw_components SET status = 'generated', extracted_at = ? WHERE session_id = ? AND component_id = ?`).run(now, sessionId, componentId);
|
|
3748
|
+
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId);
|
|
3749
3749
|
db.exec("COMMIT");
|
|
3750
3750
|
} catch (e) {
|
|
3751
3751
|
db.exec("ROLLBACK");
|
|
@@ -3756,13 +3756,13 @@ function applyToolCalls(db, sessionId2, componentId, componentName, calls, incom
|
|
|
3756
3756
|
function getOrCreateSession(db, sessionFlag, sessionName, hints) {
|
|
3757
3757
|
return getOrCreateSessionForCommand(db, sessionFlag, sessionName, hints);
|
|
3758
3758
|
}
|
|
3759
|
-
function createStep(db,
|
|
3759
|
+
function createStep(db, sessionId, command, inputs) {
|
|
3760
3760
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3761
3761
|
db.exec("BEGIN");
|
|
3762
3762
|
try {
|
|
3763
|
-
updatePendingStepsToInterrupted(db,
|
|
3764
|
-
const stepId = createPendingStep(db,
|
|
3765
|
-
updateSessionTimestamp(db,
|
|
3763
|
+
updatePendingStepsToInterrupted(db, sessionId, command, now);
|
|
3764
|
+
const stepId = createPendingStep(db, sessionId, command, inputs, now);
|
|
3765
|
+
updateSessionTimestamp(db, sessionId, now);
|
|
3766
3766
|
db.exec("COMMIT");
|
|
3767
3767
|
return stepId;
|
|
3768
3768
|
} catch (e) {
|
|
@@ -3785,7 +3785,7 @@ function updateStep(db, stepId, status, outputs, error) {
|
|
|
3785
3785
|
throw e;
|
|
3786
3786
|
}
|
|
3787
3787
|
}
|
|
3788
|
-
function storeRawComponents(db,
|
|
3788
|
+
function storeRawComponents(db, sessionId, components, options) {
|
|
3789
3789
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3790
3790
|
const insertComp = db.prepare(`INSERT INTO raw_components (session_id, component_id, name, source, framework, extracted_at, extraction_confidence, review_reasons, needs_review, source_path)
|
|
3791
3791
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);
|
|
@@ -3806,34 +3806,34 @@ function storeRawComponents(db, sessionId2, components, options) {
|
|
|
3806
3806
|
let statusSnapshot = [];
|
|
3807
3807
|
if (options?.preserveCDF) {
|
|
3808
3808
|
cdfSnapshot = db.prepare(`SELECT component_id, name, position, cdf_type, cdf_category, cdf_token_kind
|
|
3809
|
-
FROM raw_props WHERE session_id = ? AND cdf_type IS NOT NULL`).all(
|
|
3809
|
+
FROM raw_props WHERE session_id = ? AND cdf_type IS NOT NULL`).all(sessionId);
|
|
3810
3810
|
descSnapshot = db.prepare(`SELECT component_id, description
|
|
3811
|
-
FROM raw_components WHERE session_id = ? AND description IS NOT NULL`).all(
|
|
3811
|
+
FROM raw_components WHERE session_id = ? AND description IS NOT NULL`).all(sessionId);
|
|
3812
3812
|
if (cdfSnapshot.length > 0) {
|
|
3813
3813
|
avSnapshot = db.prepare(`SELECT component_id, prop_name, position, value
|
|
3814
|
-
FROM raw_prop_allowed_values WHERE session_id = ?`).all(
|
|
3814
|
+
FROM raw_prop_allowed_values WHERE session_id = ?`).all(sessionId);
|
|
3815
3815
|
}
|
|
3816
3816
|
}
|
|
3817
3817
|
if (options?.preserveStatus) {
|
|
3818
3818
|
statusSnapshot = db.prepare(`SELECT component_id, status, reject_reason
|
|
3819
|
-
FROM raw_components WHERE session_id = ?`).all(
|
|
3819
|
+
FROM raw_components WHERE session_id = ?`).all(sessionId);
|
|
3820
3820
|
}
|
|
3821
|
-
db.prepare("DELETE FROM raw_components WHERE session_id = ?").run(
|
|
3821
|
+
db.prepare("DELETE FROM raw_components WHERE session_id = ?").run(sessionId);
|
|
3822
3822
|
for (const comp of components) {
|
|
3823
3823
|
const componentId = deriveComponentId(comp.name, comp.source);
|
|
3824
|
-
insertComp.run(
|
|
3824
|
+
insertComp.run(sessionId, componentId, comp.name, comp.source, comp.framework, now, comp.extractionConfidence ?? null, JSON.stringify(comp.reviewReasons ?? []), comp.needsReview ? 1 : 0, comp.sourcePath ?? null);
|
|
3825
3825
|
for (let i = 0; i < comp.props.length; i++) {
|
|
3826
3826
|
const prop = comp.props[i];
|
|
3827
|
-
insertProp.run(
|
|
3827
|
+
insertProp.run(sessionId, componentId, prop.name, prop.type, prop.required ? 1 : 0, prop.category ?? null, prop.defaultValue ?? null, prop.description ?? null, prop.tokenReference ?? null, i, prop.sourceStartLine ?? null, prop.sourceEndLine ?? null);
|
|
3828
3828
|
if (prop.allowedValues) {
|
|
3829
|
-
prop.allowedValues.forEach((v, j) => insertAllowedValue.run(
|
|
3829
|
+
prop.allowedValues.forEach((v, j) => insertAllowedValue.run(sessionId, componentId, prop.name, j, v));
|
|
3830
3830
|
}
|
|
3831
3831
|
}
|
|
3832
3832
|
for (let i = 0; i < comp.slots.length; i++) {
|
|
3833
3833
|
const slot = comp.slots[i];
|
|
3834
|
-
insertSlot.run(
|
|
3834
|
+
insertSlot.run(sessionId, componentId, slot.name, slot.isDefault ? 1 : 0, slot.description ?? null, i);
|
|
3835
3835
|
if (slot.allowedComponents) {
|
|
3836
|
-
slot.allowedComponents.forEach((ac, j) => insertAllowedComponent.run(
|
|
3836
|
+
slot.allowedComponents.forEach((ac, j) => insertAllowedComponent.run(sessionId, componentId, slot.name, j, ac));
|
|
3837
3837
|
}
|
|
3838
3838
|
}
|
|
3839
3839
|
}
|
|
@@ -3845,7 +3845,7 @@ function storeRawComponents(db, sessionId2, components, options) {
|
|
|
3845
3845
|
const restoredPropKeys = /* @__PURE__ */ new Set();
|
|
3846
3846
|
const unmatchedSnaps = [];
|
|
3847
3847
|
for (const snap of cdfSnapshot) {
|
|
3848
|
-
const result = updateCDFByName.run(snap.cdf_type, snap.cdf_category, snap.cdf_token_kind,
|
|
3848
|
+
const result = updateCDFByName.run(snap.cdf_type, snap.cdf_category, snap.cdf_token_kind, sessionId, snap.component_id, snap.name);
|
|
3849
3849
|
if (Number(result.changes) > 0) {
|
|
3850
3850
|
restoredPropKeys.add(`${snap.component_id}::${snap.name}`);
|
|
3851
3851
|
} else {
|
|
@@ -3853,9 +3853,9 @@ function storeRawComponents(db, sessionId2, components, options) {
|
|
|
3853
3853
|
}
|
|
3854
3854
|
}
|
|
3855
3855
|
for (const snap of unmatchedSnaps) {
|
|
3856
|
-
const result = updateCDFByPosition.run(snap.cdf_type, snap.cdf_category, snap.cdf_token_kind,
|
|
3856
|
+
const result = updateCDFByPosition.run(snap.cdf_type, snap.cdf_category, snap.cdf_token_kind, sessionId, snap.component_id, snap.position);
|
|
3857
3857
|
if (Number(result.changes) > 0) {
|
|
3858
|
-
const matched = db.prepare(`SELECT name FROM raw_props WHERE session_id = ? AND component_id = ? AND position = ?`).get(
|
|
3858
|
+
const matched = db.prepare(`SELECT name FROM raw_props WHERE session_id = ? AND component_id = ? AND position = ?`).get(sessionId, snap.component_id, snap.position);
|
|
3859
3859
|
if (matched) {
|
|
3860
3860
|
restoredPropKeys.add(`${snap.component_id}::${matched.name}`);
|
|
3861
3861
|
}
|
|
@@ -3863,7 +3863,7 @@ function storeRawComponents(db, sessionId2, components, options) {
|
|
|
3863
3863
|
}
|
|
3864
3864
|
const updateDesc = db.prepare(`UPDATE raw_components SET description = ? WHERE session_id = ? AND component_id = ?`);
|
|
3865
3865
|
for (const snap of descSnapshot) {
|
|
3866
|
-
updateDesc.run(snap.description,
|
|
3866
|
+
updateDesc.run(snap.description, sessionId, snap.component_id);
|
|
3867
3867
|
}
|
|
3868
3868
|
const relevantAV = avSnapshot.filter((av) => restoredPropKeys.has(`${av.component_id}::${av.prop_name}`));
|
|
3869
3869
|
if (relevantAV.length > 0) {
|
|
@@ -3874,10 +3874,10 @@ function storeRawComponents(db, sessionId2, components, options) {
|
|
|
3874
3874
|
for (const av of relevantAV) {
|
|
3875
3875
|
const key = `${av.component_id}::${av.prop_name}`;
|
|
3876
3876
|
if (!deletedKeys.has(key)) {
|
|
3877
|
-
deleteAV.run(
|
|
3877
|
+
deleteAV.run(sessionId, av.component_id, av.prop_name);
|
|
3878
3878
|
deletedKeys.add(key);
|
|
3879
3879
|
}
|
|
3880
|
-
insertAV.run(
|
|
3880
|
+
insertAV.run(sessionId, av.component_id, av.prop_name, av.position, av.value);
|
|
3881
3881
|
}
|
|
3882
3882
|
}
|
|
3883
3883
|
}
|
|
@@ -3885,33 +3885,33 @@ function storeRawComponents(db, sessionId2, components, options) {
|
|
|
3885
3885
|
const restoreStatus = db.prepare(`UPDATE raw_components SET status = ?, reject_reason = ?
|
|
3886
3886
|
WHERE session_id = ? AND component_id = ?`);
|
|
3887
3887
|
for (const snapshot of statusSnapshot) {
|
|
3888
|
-
restoreStatus.run(snapshot.status, snapshot.reject_reason,
|
|
3888
|
+
restoreStatus.run(snapshot.status, snapshot.reject_reason, sessionId, snapshot.component_id);
|
|
3889
3889
|
}
|
|
3890
3890
|
}
|
|
3891
3891
|
if (options?.status) {
|
|
3892
|
-
db.prepare("UPDATE raw_components SET status = ? WHERE session_id = ?").run(options.status,
|
|
3892
|
+
db.prepare("UPDATE raw_components SET status = ? WHERE session_id = ?").run(options.status, sessionId);
|
|
3893
3893
|
}
|
|
3894
|
-
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now,
|
|
3894
|
+
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId);
|
|
3895
3895
|
db.exec("COMMIT");
|
|
3896
3896
|
} catch (e) {
|
|
3897
3897
|
db.exec("ROLLBACK");
|
|
3898
3898
|
throw e;
|
|
3899
3899
|
}
|
|
3900
3900
|
}
|
|
3901
|
-
function loadRawComponents(db,
|
|
3902
|
-
const all = db.prepare("SELECT component_id, name, source, framework, extraction_confidence, review_reasons, needs_review, source_path FROM raw_components WHERE session_id = ? ORDER BY rowid").all(
|
|
3901
|
+
function loadRawComponents(db, sessionId, allowedNames) {
|
|
3902
|
+
const all = db.prepare("SELECT component_id, name, source, framework, extraction_confidence, review_reasons, needs_review, source_path FROM raw_components WHERE session_id = ? ORDER BY rowid").all(sessionId);
|
|
3903
3903
|
const components = allowedNames ? all.filter((c2) => allowedNames.has(c2.name)) : all;
|
|
3904
3904
|
if (components.length === 0)
|
|
3905
3905
|
return [];
|
|
3906
3906
|
const props = db.prepare(`SELECT component_id, name, type, required, category, default_value, description, token_reference, position,
|
|
3907
3907
|
rationale, source_start_line, source_end_line
|
|
3908
|
-
FROM raw_props WHERE session_id = ? ORDER BY component_id, position`).all(
|
|
3908
|
+
FROM raw_props WHERE session_id = ? ORDER BY component_id, position`).all(sessionId);
|
|
3909
3909
|
const allowedValues = db.prepare(`SELECT component_id, prop_name, position, value
|
|
3910
|
-
FROM raw_prop_allowed_values WHERE session_id = ? ORDER BY component_id, prop_name, position`).all(
|
|
3910
|
+
FROM raw_prop_allowed_values WHERE session_id = ? ORDER BY component_id, prop_name, position`).all(sessionId);
|
|
3911
3911
|
const slots = db.prepare(`SELECT component_id, name, is_default, description, position
|
|
3912
|
-
FROM raw_slots WHERE session_id = ? ORDER BY component_id, position`).all(
|
|
3912
|
+
FROM raw_slots WHERE session_id = ? ORDER BY component_id, position`).all(sessionId);
|
|
3913
3913
|
const allowedComponents = db.prepare(`SELECT component_id, slot_name, position, allowed_component
|
|
3914
|
-
FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`).all(
|
|
3914
|
+
FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`).all(sessionId);
|
|
3915
3915
|
const propsByComponent = indexRowsByKey(props, (p) => p.component_id);
|
|
3916
3916
|
const allowedValuesByProp = indexRowsByKey(allowedValues, (av) => `${av.component_id}::${av.prop_name}`);
|
|
3917
3917
|
const slotsByComponent = indexRowsByKey(slots, (s) => s.component_id);
|
|
@@ -4116,18 +4116,18 @@ async function loadComponentSourceRef(name, sourcePath, propNames = [], propType
|
|
|
4116
4116
|
ref.usesNotShown = notShown;
|
|
4117
4117
|
return ref;
|
|
4118
4118
|
}
|
|
4119
|
-
async function loadComponentSourceRefs(db,
|
|
4120
|
-
const rows = db.prepare(`SELECT component_id, name, source, source_path FROM raw_components WHERE session_id = ? AND status = 'generated' ORDER BY rowid`).all(
|
|
4119
|
+
async function loadComponentSourceRefs(db, sessionId) {
|
|
4120
|
+
const rows = db.prepare(`SELECT component_id, name, source, source_path FROM raw_components WHERE session_id = ? AND status = 'generated' ORDER BY rowid`).all(sessionId);
|
|
4121
4121
|
const propsFor = db.prepare(`SELECT name, type FROM raw_props WHERE session_id = ? AND component_id = ? ORDER BY position`);
|
|
4122
4122
|
return Promise.all(rows.map((r) => {
|
|
4123
|
-
const props = propsFor.all(
|
|
4123
|
+
const props = propsFor.all(sessionId, r.component_id);
|
|
4124
4124
|
return loadComponentSourceRef(r.name, r.source_path ?? r.source, props.map((p) => p.name), props.map((p) => p.type));
|
|
4125
4125
|
}));
|
|
4126
4126
|
}
|
|
4127
|
-
function renameEmptySlots(db,
|
|
4127
|
+
function renameEmptySlots(db, sessionId, componentId, componentName, slotCount) {
|
|
4128
4128
|
const emptySlots = db.prepare(`SELECT name, position FROM raw_slots
|
|
4129
4129
|
WHERE session_id = ? AND component_id = ? AND trim(name) = ''
|
|
4130
|
-
ORDER BY position`).all(
|
|
4130
|
+
ORDER BY position`).all(sessionId, componentId);
|
|
4131
4131
|
if (emptySlots.length === 0)
|
|
4132
4132
|
return { renames: [], warnings: [] };
|
|
4133
4133
|
const renames = [];
|
|
@@ -4137,7 +4137,7 @@ function renameEmptySlots(db, sessionId2, componentId, componentName, slotCount)
|
|
|
4137
4137
|
try {
|
|
4138
4138
|
for (const slot of emptySlots) {
|
|
4139
4139
|
const newName = slotCount === 1 ? "children" : `slot_${slot.position}`;
|
|
4140
|
-
rename3.run(newName,
|
|
4140
|
+
rename3.run(newName, sessionId, componentId, slot.name, slot.position);
|
|
4141
4141
|
renames.push({ oldName: slot.name, newName });
|
|
4142
4142
|
warnings.push(`${componentName}: slot at position ${slot.position} had empty name \u2014 renamed to "${newName}" for classification`);
|
|
4143
4143
|
}
|
|
@@ -4156,7 +4156,7 @@ function parseReviewReasons(raw) {
|
|
|
4156
4156
|
return [];
|
|
4157
4157
|
}
|
|
4158
4158
|
}
|
|
4159
|
-
function storeCDFComponents(db,
|
|
4159
|
+
function storeCDFComponents(db, sessionId, components) {
|
|
4160
4160
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4161
4161
|
const updateComp = db.prepare(`UPDATE raw_components SET status = 'generated', description = ? WHERE session_id = ? AND name = ?`);
|
|
4162
4162
|
const updateProp = db.prepare(`UPDATE raw_props SET cdf_type = ?, cdf_category = ?, cdf_token_kind = ?, required = ? WHERE session_id = ? AND component_id = ? AND name = ?`);
|
|
@@ -4169,8 +4169,8 @@ function storeCDFComponents(db, sessionId2, components) {
|
|
|
4169
4169
|
const insertTokenPath = db.prepare(`INSERT INTO raw_prop_token_paths (session_id, component_id, prop_name, source, position, path)
|
|
4170
4170
|
VALUES (?, ?, ?, ?, ?, ?)`);
|
|
4171
4171
|
const writeTokenPaths = (componentId, propName, paths) => {
|
|
4172
|
-
deleteTokenPaths.run(
|
|
4173
|
-
paths.forEach((path5, position) => insertTokenPath.run(
|
|
4172
|
+
deleteTokenPaths.run(sessionId, componentId, propName);
|
|
4173
|
+
paths.forEach((path5, position) => insertTokenPath.run(sessionId, componentId, propName, "review", position, path5));
|
|
4174
4174
|
};
|
|
4175
4175
|
const deleteSlots = db.prepare(`DELETE FROM raw_slots WHERE session_id = ? AND component_id = ?`);
|
|
4176
4176
|
const deleteSlotAllowedComponents = db.prepare(`DELETE FROM raw_slot_allowed_components WHERE session_id = ? AND component_id = ?`);
|
|
@@ -4180,42 +4180,42 @@ function storeCDFComponents(db, sessionId2, components) {
|
|
|
4180
4180
|
db.exec("BEGIN");
|
|
4181
4181
|
try {
|
|
4182
4182
|
for (const { key, entry } of components) {
|
|
4183
|
-
const row = db.prepare("SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?").get(
|
|
4183
|
+
const row = db.prepare("SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?").get(sessionId, key);
|
|
4184
4184
|
if (row) {
|
|
4185
4185
|
const { component_id: componentId } = row;
|
|
4186
|
-
updateComp.run(entry.$description ?? null,
|
|
4186
|
+
updateComp.run(entry.$description ?? null, sessionId, key);
|
|
4187
4187
|
for (const [propName, prop] of Object.entries(entry.$properties)) {
|
|
4188
|
-
updateProp.run(prop.$type, prop.$category, prop["$token.kind"] ?? null, prop.$required ? 1 : 0,
|
|
4188
|
+
updateProp.run(prop.$type, prop.$category, prop["$token.kind"] ?? null, prop.$required ? 1 : 0, sessionId, componentId, propName);
|
|
4189
4189
|
if (prop.$values && prop.$values.length > 0) {
|
|
4190
|
-
deleteAllowedValues.run(
|
|
4191
|
-
prop.$values.forEach((v, i) => insertAllowedValue.run(
|
|
4190
|
+
deleteAllowedValues.run(sessionId, componentId, propName);
|
|
4191
|
+
prop.$values.forEach((v, i) => insertAllowedValue.run(sessionId, componentId, propName, v, i));
|
|
4192
4192
|
}
|
|
4193
4193
|
if (prop.$type === "token" && prop.$category === "design") {
|
|
4194
4194
|
writeTokenPaths(componentId, propName, prop["$token.allowed"] ?? []);
|
|
4195
4195
|
}
|
|
4196
4196
|
}
|
|
4197
|
-
const existingDefaults = new Map(readExistingSlotDefaults.all(
|
|
4198
|
-
deleteSlotAllowedComponents.run(
|
|
4199
|
-
deleteSlots.run(
|
|
4197
|
+
const existingDefaults = new Map(readExistingSlotDefaults.all(sessionId, componentId).map((r) => [r.name, r.is_default]));
|
|
4198
|
+
deleteSlotAllowedComponents.run(sessionId, componentId);
|
|
4199
|
+
deleteSlots.run(sessionId, componentId);
|
|
4200
4200
|
let slotPos = 0;
|
|
4201
4201
|
for (const [slotName, slot] of Object.entries(entry.$slots ?? {})) {
|
|
4202
4202
|
const isDefault = existingDefaults.get(slotName) ?? 0;
|
|
4203
|
-
insertSlotOnUpdate.run(
|
|
4203
|
+
insertSlotOnUpdate.run(sessionId, componentId, slotName, isDefault, slot.$required ? 1 : 0, slot.$description ?? null, slotPos++);
|
|
4204
4204
|
if (slot.$allowedComponents && slot.$allowedComponents.length > 0) {
|
|
4205
|
-
slot.$allowedComponents.forEach((ac, i) => insertAllowedComponent.run(
|
|
4205
|
+
slot.$allowedComponents.forEach((ac, i) => insertAllowedComponent.run(sessionId, componentId, slotName, ac, i));
|
|
4206
4206
|
}
|
|
4207
4207
|
}
|
|
4208
4208
|
} else {
|
|
4209
4209
|
const componentId = deriveComponentId(key, "generated");
|
|
4210
4210
|
db.prepare(`INSERT INTO raw_components (session_id, component_id, name, source, framework, extracted_at, status, description)
|
|
4211
|
-
VALUES (?, ?, ?, '', 'react', ?, 'generated', ?)`).run(
|
|
4211
|
+
VALUES (?, ?, ?, '', 'react', ?, 'generated', ?)`).run(sessionId, componentId, key, now, entry.$description ?? null);
|
|
4212
4212
|
let position = 0;
|
|
4213
4213
|
for (const [propName, prop] of Object.entries(entry.$properties)) {
|
|
4214
4214
|
db.prepare(`INSERT OR REPLACE INTO raw_props
|
|
4215
4215
|
(session_id, component_id, name, type, required, category, default_value, description, token_reference, position, cdf_type, cdf_category, cdf_token_kind)
|
|
4216
|
-
VALUES (?, ?, ?, '', ?, NULL, NULL, NULL, NULL, ?, ?, ?, ?)`).run(
|
|
4216
|
+
VALUES (?, ?, ?, '', ?, NULL, NULL, NULL, NULL, ?, ?, ?, ?)`).run(sessionId, componentId, propName, prop.$required ? 1 : 0, position++, prop.$type, prop.$category, prop["$token.kind"] ?? null);
|
|
4217
4217
|
if (prop.$values && prop.$values.length > 0) {
|
|
4218
|
-
prop.$values.forEach((v, i) => insertAllowedValue.run(
|
|
4218
|
+
prop.$values.forEach((v, i) => insertAllowedValue.run(sessionId, componentId, propName, v, i));
|
|
4219
4219
|
}
|
|
4220
4220
|
if (prop.$type === "token" && prop.$category === "design") {
|
|
4221
4221
|
writeTokenPaths(componentId, propName, prop["$token.allowed"] ?? []);
|
|
@@ -4225,39 +4225,39 @@ function storeCDFComponents(db, sessionId2, components) {
|
|
|
4225
4225
|
for (const [slotName, slot] of Object.entries(entry.$slots ?? {})) {
|
|
4226
4226
|
db.prepare(`INSERT OR REPLACE INTO raw_slots
|
|
4227
4227
|
(session_id, component_id, name, is_default, required, description, position)
|
|
4228
|
-
VALUES (?, ?, ?, 0, ?, ?, ?)`).run(
|
|
4228
|
+
VALUES (?, ?, ?, 0, ?, ?, ?)`).run(sessionId, componentId, slotName, slot.$required ? 1 : 0, slot.$description ?? null, slotPos++);
|
|
4229
4229
|
if (slot.$allowedComponents && slot.$allowedComponents.length > 0) {
|
|
4230
|
-
slot.$allowedComponents.forEach((ac, i) => insertAllowedComponent.run(
|
|
4230
|
+
slot.$allowedComponents.forEach((ac, i) => insertAllowedComponent.run(sessionId, componentId, slotName, ac, i));
|
|
4231
4231
|
}
|
|
4232
4232
|
}
|
|
4233
4233
|
}
|
|
4234
4234
|
}
|
|
4235
|
-
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now,
|
|
4235
|
+
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId);
|
|
4236
4236
|
db.exec("COMMIT");
|
|
4237
4237
|
} catch (e) {
|
|
4238
4238
|
db.exec("ROLLBACK");
|
|
4239
4239
|
throw e;
|
|
4240
4240
|
}
|
|
4241
4241
|
}
|
|
4242
|
-
function loadCDFComponents(db,
|
|
4242
|
+
function loadCDFComponents(db, sessionId) {
|
|
4243
4243
|
const components = db.prepare(`SELECT component_id, name, description FROM raw_components
|
|
4244
|
-
WHERE session_id = ? AND status = 'generated' ORDER BY rowid`).all(
|
|
4244
|
+
WHERE session_id = ? AND status = 'generated' ORDER BY rowid`).all(sessionId);
|
|
4245
4245
|
if (components.length === 0)
|
|
4246
4246
|
return [];
|
|
4247
4247
|
const props = db.prepare(`SELECT component_id, name, required, default_value, description,
|
|
4248
4248
|
cdf_type, cdf_category, cdf_token_kind, position
|
|
4249
4249
|
FROM raw_props
|
|
4250
4250
|
WHERE session_id = ? AND cdf_type IS NOT NULL
|
|
4251
|
-
ORDER BY component_id, position`).all(
|
|
4251
|
+
ORDER BY component_id, position`).all(sessionId);
|
|
4252
4252
|
const allowedValues = db.prepare(`SELECT component_id, prop_name, value, position
|
|
4253
|
-
FROM raw_prop_allowed_values WHERE session_id = ? ORDER BY component_id, prop_name, position`).all(
|
|
4254
|
-
const slots = db.prepare(`SELECT component_id, name, description, required FROM raw_slots WHERE session_id = ? ORDER BY component_id, position`).all(
|
|
4253
|
+
FROM raw_prop_allowed_values WHERE session_id = ? ORDER BY component_id, prop_name, position`).all(sessionId);
|
|
4254
|
+
const slots = db.prepare(`SELECT component_id, name, description, required FROM raw_slots WHERE session_id = ? ORDER BY component_id, position`).all(sessionId);
|
|
4255
4255
|
const allowedComponents = db.prepare(`SELECT component_id, slot_name, allowed_component
|
|
4256
|
-
FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`).all(
|
|
4256
|
+
FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`).all(sessionId);
|
|
4257
4257
|
const tokenPaths = db.prepare(`SELECT component_id, prop_name, position, path
|
|
4258
|
-
FROM raw_prop_token_paths WHERE session_id = ? ORDER BY component_id, prop_name, position`).all(
|
|
4259
|
-
const resolvedDefaultPaths = getRawTokenNamePaths(db,
|
|
4260
|
-
const tokenTypeByPath = new Map(db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ?").all(
|
|
4258
|
+
FROM raw_prop_token_paths WHERE session_id = ? ORDER BY component_id, prop_name, position`).all(sessionId);
|
|
4259
|
+
const resolvedDefaultPaths = getRawTokenNamePaths(db, sessionId);
|
|
4260
|
+
const tokenTypeByPath = new Map(db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ?").all(sessionId).map((token) => [token.path, token.type]));
|
|
4261
4261
|
const propsByComponent = indexRowsByKey(props, (p) => p.component_id);
|
|
4262
4262
|
const allowedValuesByProp = indexRowsByKey(allowedValues, (av) => `${av.component_id}::${av.prop_name}`);
|
|
4263
4263
|
const slotsByComponent = indexRowsByKey(slots, (s) => s.component_id);
|
|
@@ -4324,16 +4324,16 @@ function loadCDFComponents(db, sessionId2) {
|
|
|
4324
4324
|
return { key: name, entry };
|
|
4325
4325
|
});
|
|
4326
4326
|
}
|
|
4327
|
-
function loadScopeComponents(db,
|
|
4327
|
+
function loadScopeComponents(db, sessionId) {
|
|
4328
4328
|
const rows = db.prepare(`SELECT name, component_id, status, reject_reason, review_reasons, needs_review FROM raw_components
|
|
4329
4329
|
WHERE session_id = ? AND status IN ('extracted', 'accepted', 'rejected')
|
|
4330
|
-
ORDER BY name`).all(
|
|
4330
|
+
ORDER BY name`).all(sessionId);
|
|
4331
4331
|
if (rows.length === 0)
|
|
4332
4332
|
return [];
|
|
4333
4333
|
const slotRows = db.prepare(`SELECT component_id, name, position
|
|
4334
|
-
FROM raw_slots WHERE session_id = ? ORDER BY component_id, position`).all(
|
|
4334
|
+
FROM raw_slots WHERE session_id = ? ORDER BY component_id, position`).all(sessionId);
|
|
4335
4335
|
const allowedRows = db.prepare(`SELECT component_id, slot_name, position, allowed_component
|
|
4336
|
-
FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`).all(
|
|
4336
|
+
FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`).all(sessionId);
|
|
4337
4337
|
const slotsByComponent = indexRowsByKey(slotRows, (s) => s.component_id);
|
|
4338
4338
|
const allowedBySlot = indexRowsByKey(allowedRows, (a) => `${a.component_id}::${a.slot_name}`);
|
|
4339
4339
|
return rows.map((r) => {
|
|
@@ -4352,25 +4352,47 @@ function loadScopeComponents(db, sessionId2) {
|
|
|
4352
4352
|
};
|
|
4353
4353
|
});
|
|
4354
4354
|
}
|
|
4355
|
-
function applyScopeDecisions(db,
|
|
4355
|
+
function applyScopeDecisions(db, sessionId, decisions) {
|
|
4356
4356
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4357
4357
|
const acceptedSet = new Set(decisions.accepted);
|
|
4358
4358
|
const accepted = [...acceptedSet];
|
|
4359
4359
|
const rejected = [...new Set(decisions.rejected)].filter((n) => !acceptedSet.has(n));
|
|
4360
4360
|
if (rejected.length > 0) {
|
|
4361
4361
|
const placeholders = rejected.map(() => "?").join(",");
|
|
4362
|
-
db.prepare(`UPDATE raw_components SET status = 'rejected' WHERE session_id = ? AND name IN (${placeholders})`).run(
|
|
4362
|
+
db.prepare(`UPDATE raw_components SET status = 'rejected' WHERE session_id = ? AND name IN (${placeholders})`).run(sessionId, ...rejected);
|
|
4363
4363
|
}
|
|
4364
4364
|
if (accepted.length > 0) {
|
|
4365
4365
|
const placeholders = accepted.map(() => "?").join(",");
|
|
4366
|
-
db.prepare(`UPDATE raw_components SET status = 'generated' WHERE session_id = ? AND name IN (${placeholders})`).run(
|
|
4366
|
+
db.prepare(`UPDATE raw_components SET status = 'generated' WHERE session_id = ? AND name IN (${placeholders})`).run(sessionId, ...accepted);
|
|
4367
|
+
}
|
|
4368
|
+
removeSlotAllowedComponents(db, sessionId, decisions.excludedSlotEdges ?? [], rejected);
|
|
4369
|
+
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId);
|
|
4370
|
+
}
|
|
4371
|
+
function removeSlotAllowedComponents(db, sessionId, edges, rejectedNames) {
|
|
4372
|
+
if (edges.length === 0 && rejectedNames.length === 0)
|
|
4373
|
+
return;
|
|
4374
|
+
const componentId = db.prepare("SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?");
|
|
4375
|
+
const removeEdge = db.prepare("DELETE FROM raw_slot_allowed_components WHERE session_id = ? AND component_id = ? AND allowed_component = ?");
|
|
4376
|
+
const removeEverywhere = db.prepare("DELETE FROM raw_slot_allowed_components WHERE session_id = ? AND allowed_component = ?");
|
|
4377
|
+
db.exec("BEGIN");
|
|
4378
|
+
try {
|
|
4379
|
+
for (const edge of edges) {
|
|
4380
|
+
const row = componentId.get(sessionId, edge.parent);
|
|
4381
|
+
if (row)
|
|
4382
|
+
removeEdge.run(sessionId, row.component_id, edge.child);
|
|
4383
|
+
}
|
|
4384
|
+
for (const name of rejectedNames)
|
|
4385
|
+
removeEverywhere.run(sessionId, name);
|
|
4386
|
+
db.exec("COMMIT");
|
|
4387
|
+
} catch (e) {
|
|
4388
|
+
db.exec("ROLLBACK");
|
|
4389
|
+
throw e;
|
|
4367
4390
|
}
|
|
4368
|
-
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId2);
|
|
4369
4391
|
}
|
|
4370
4392
|
function findLatestSessionForCommand(db, command) {
|
|
4371
4393
|
return getLatestCompletedSessionForCommand(db, command);
|
|
4372
4394
|
}
|
|
4373
|
-
function seedCDFFromPreviewResponse(db,
|
|
4395
|
+
function seedCDFFromPreviewResponse(db, sessionId, removedItems) {
|
|
4374
4396
|
if (removedItems.length === 0)
|
|
4375
4397
|
return 0;
|
|
4376
4398
|
let totalSeeded = 0;
|
|
@@ -4380,7 +4402,7 @@ function seedCDFFromPreviewResponse(db, sessionId2, removedItems) {
|
|
|
4380
4402
|
for (const item of removedItems) {
|
|
4381
4403
|
if (!item.fullProperties)
|
|
4382
4404
|
continue;
|
|
4383
|
-
const localComponent = db.prepare(`SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?`).get(
|
|
4405
|
+
const localComponent = db.prepare(`SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?`).get(sessionId, item.name);
|
|
4384
4406
|
if (!localComponent)
|
|
4385
4407
|
continue;
|
|
4386
4408
|
const contentProps = new Set(item.contentProperties);
|
|
@@ -4388,13 +4410,13 @@ function seedCDFFromPreviewResponse(db, sessionId2, removedItems) {
|
|
|
4388
4410
|
for (const [propName, propSummary] of Object.entries(item.fullProperties)) {
|
|
4389
4411
|
const cdfType = mapContentfulTypeToCdfType(propSummary.type);
|
|
4390
4412
|
const cdfCategory = resolveCdfCategory(propSummary.category, propName, contentProps, designProps);
|
|
4391
|
-
const result = updateStmt.run(cdfType, cdfCategory,
|
|
4413
|
+
const result = updateStmt.run(cdfType, cdfCategory, sessionId, localComponent.component_id, propName);
|
|
4392
4414
|
totalSeeded += Number(result.changes);
|
|
4393
4415
|
}
|
|
4394
4416
|
}
|
|
4395
4417
|
return totalSeeded;
|
|
4396
4418
|
}
|
|
4397
|
-
function seedDefaultsFromChangedItems(db,
|
|
4419
|
+
function seedDefaultsFromChangedItems(db, sessionId, changedItems) {
|
|
4398
4420
|
if (changedItems.length === 0)
|
|
4399
4421
|
return 0;
|
|
4400
4422
|
let totalSeeded = 0;
|
|
@@ -4405,7 +4427,7 @@ function seedDefaultsFromChangedItems(db, sessionId2, changedItems) {
|
|
|
4405
4427
|
for (const { current } of changedItems) {
|
|
4406
4428
|
if (!current.fullProperties)
|
|
4407
4429
|
continue;
|
|
4408
|
-
const localComponent = db.prepare(`SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?`).get(
|
|
4430
|
+
const localComponent = db.prepare(`SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?`).get(sessionId, current.name);
|
|
4409
4431
|
if (!localComponent)
|
|
4410
4432
|
continue;
|
|
4411
4433
|
const contentProps = new Set(current.contentProperties);
|
|
@@ -4413,38 +4435,38 @@ function seedDefaultsFromChangedItems(db, sessionId2, changedItems) {
|
|
|
4413
4435
|
for (const [propName, propSummary] of Object.entries(current.fullProperties)) {
|
|
4414
4436
|
if (propSummary.default !== void 0 && propSummary.default !== null) {
|
|
4415
4437
|
const defaultStr = typeof propSummary.default === "string" ? propSummary.default : JSON.stringify(propSummary.default);
|
|
4416
|
-
const result2 = updateDefaultStmt.run(defaultStr,
|
|
4438
|
+
const result2 = updateDefaultStmt.run(defaultStr, sessionId, localComponent.component_id, propName);
|
|
4417
4439
|
totalSeeded += Number(result2.changes);
|
|
4418
4440
|
}
|
|
4419
4441
|
const cdfType = mapContentfulTypeToCdfType(propSummary.type);
|
|
4420
4442
|
const cdfCategory = resolveCdfCategory(propSummary.category, propName, contentProps, designProps);
|
|
4421
|
-
const result = updateCDFStmt.run(cdfType, cdfCategory,
|
|
4443
|
+
const result = updateCDFStmt.run(cdfType, cdfCategory, sessionId, localComponent.component_id, propName);
|
|
4422
4444
|
totalSeeded += Number(result.changes);
|
|
4423
4445
|
}
|
|
4424
4446
|
}
|
|
4425
4447
|
return totalSeeded;
|
|
4426
4448
|
}
|
|
4427
|
-
function backfillUnclassifiedProps(db,
|
|
4449
|
+
function backfillUnclassifiedProps(db, sessionId) {
|
|
4428
4450
|
const withCategory = db.prepare(`UPDATE raw_props SET cdf_type = 'string', cdf_category = category
|
|
4429
4451
|
WHERE session_id = ? AND cdf_type IS NULL AND category IS NOT NULL
|
|
4430
4452
|
AND component_id IN (
|
|
4431
4453
|
SELECT component_id FROM raw_components WHERE session_id = ? AND status = 'generated'
|
|
4432
|
-
)`).run(
|
|
4454
|
+
)`).run(sessionId, sessionId);
|
|
4433
4455
|
const withoutCategory = db.prepare(`UPDATE raw_props SET cdf_type = 'string', cdf_category = 'content'
|
|
4434
4456
|
WHERE session_id = ? AND cdf_type IS NULL AND category IS NULL
|
|
4435
4457
|
AND component_id IN (
|
|
4436
4458
|
SELECT component_id FROM raw_components WHERE session_id = ? AND status = 'generated'
|
|
4437
|
-
)`).run(
|
|
4459
|
+
)`).run(sessionId, sessionId);
|
|
4438
4460
|
return Number(withCategory.changes) + Number(withoutCategory.changes);
|
|
4439
4461
|
}
|
|
4440
|
-
function computeMapTokensInputHash(db,
|
|
4462
|
+
function computeMapTokensInputHash(db, sessionId, componentSourceRefs = []) {
|
|
4441
4463
|
const props = db.prepare(`SELECT rc.name AS component_name, rp.name AS prop_name, rp.cdf_token_kind, rp.default_value
|
|
4442
4464
|
FROM raw_props rp
|
|
4443
4465
|
JOIN raw_components rc ON rc.session_id = rp.session_id AND rc.component_id = rp.component_id
|
|
4444
4466
|
WHERE rp.session_id = ? AND rp.cdf_type = 'token' AND rp.cdf_category = 'design'
|
|
4445
|
-
ORDER BY rc.name, rp.name`).all(
|
|
4446
|
-
const tokens = db.prepare(`SELECT path, type FROM raw_tokens WHERE session_id = ? ORDER BY path`).all(
|
|
4447
|
-
const defaultMappings = db.prepare("SELECT raw_name, path, source FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(
|
|
4467
|
+
ORDER BY rc.name, rp.name`).all(sessionId);
|
|
4468
|
+
const tokens = db.prepare(`SELECT path, type FROM raw_tokens WHERE session_id = ? ORDER BY path`).all(sessionId);
|
|
4469
|
+
const defaultMappings = db.prepare("SELECT raw_name, path, source FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId);
|
|
4448
4470
|
const payload = {
|
|
4449
4471
|
props: props.map((p) => ({
|
|
4450
4472
|
component: p.component_name,
|
|
@@ -4525,13 +4547,13 @@ function storeCaches(db, entries) {
|
|
|
4525
4547
|
throw e;
|
|
4526
4548
|
}
|
|
4527
4549
|
}
|
|
4528
|
-
function storeScannedFiles(db,
|
|
4550
|
+
function storeScannedFiles(db, sessionId, filePaths) {
|
|
4529
4551
|
db.exec("BEGIN");
|
|
4530
4552
|
try {
|
|
4531
|
-
db.prepare("DELETE FROM scanned_files WHERE session_id = ?").run(
|
|
4553
|
+
db.prepare("DELETE FROM scanned_files WHERE session_id = ?").run(sessionId);
|
|
4532
4554
|
const insert = db.prepare("INSERT INTO scanned_files (session_id, path) VALUES (?, ?)");
|
|
4533
4555
|
for (const path5 of filePaths) {
|
|
4534
|
-
insert.run(
|
|
4556
|
+
insert.run(sessionId, path5);
|
|
4535
4557
|
}
|
|
4536
4558
|
db.exec("COMMIT");
|
|
4537
4559
|
} catch (e) {
|
|
@@ -4539,15 +4561,15 @@ function storeScannedFiles(db, sessionId2, filePaths) {
|
|
|
4539
4561
|
throw e;
|
|
4540
4562
|
}
|
|
4541
4563
|
}
|
|
4542
|
-
function storeSlotCycles(db,
|
|
4564
|
+
function storeSlotCycles(db, sessionId, cycles) {
|
|
4543
4565
|
db.exec("BEGIN");
|
|
4544
4566
|
try {
|
|
4545
|
-
db.prepare("DELETE FROM slot_cycles WHERE session_id = ?").run(
|
|
4567
|
+
db.prepare("DELETE FROM slot_cycles WHERE session_id = ?").run(sessionId);
|
|
4546
4568
|
const insert = db.prepare(`INSERT INTO slot_cycles (session_id, cycle_index, path_json, edges_json, suggested_break_json)
|
|
4547
4569
|
VALUES (?, ?, ?, ?, ?)`);
|
|
4548
4570
|
for (let i = 0; i < cycles.length; i += 1) {
|
|
4549
4571
|
const cycle = cycles[i];
|
|
4550
|
-
insert.run(
|
|
4572
|
+
insert.run(sessionId, i, JSON.stringify(cycle.path), JSON.stringify(cycle.edges), cycle.suggestedBreak ? JSON.stringify(cycle.suggestedBreak) : null);
|
|
4551
4573
|
}
|
|
4552
4574
|
db.exec("COMMIT");
|
|
4553
4575
|
} catch (e) {
|
|
@@ -4555,20 +4577,20 @@ function storeSlotCycles(db, sessionId2, cycles) {
|
|
|
4555
4577
|
throw e;
|
|
4556
4578
|
}
|
|
4557
4579
|
}
|
|
4558
|
-
function loadSlotCycles(db,
|
|
4559
|
-
const rows = db.prepare("SELECT cycle_index, path_json, edges_json, suggested_break_json FROM slot_cycles WHERE session_id = ? ORDER BY cycle_index").all(
|
|
4580
|
+
function loadSlotCycles(db, sessionId) {
|
|
4581
|
+
const rows = db.prepare("SELECT cycle_index, path_json, edges_json, suggested_break_json FROM slot_cycles WHERE session_id = ? ORDER BY cycle_index").all(sessionId);
|
|
4560
4582
|
return rows.map((r) => ({
|
|
4561
4583
|
path: JSON.parse(r.path_json),
|
|
4562
4584
|
edges: JSON.parse(r.edges_json),
|
|
4563
4585
|
suggestedBreak: r.suggested_break_json ? JSON.parse(r.suggested_break_json) : null
|
|
4564
4586
|
}));
|
|
4565
4587
|
}
|
|
4566
|
-
function findUnknownSlotAllowedComponents(db,
|
|
4588
|
+
function findUnknownSlotAllowedComponents(db, sessionId, allowedComponentNames2, componentId) {
|
|
4567
4589
|
const rows = db.prepare(`SELECT a.component_id, c.name AS component_name, a.slot_name, a.allowed_component
|
|
4568
4590
|
FROM raw_slot_allowed_components a
|
|
4569
4591
|
JOIN raw_components c ON c.session_id = a.session_id AND c.component_id = a.component_id
|
|
4570
4592
|
WHERE a.session_id = ? AND (? IS NULL OR a.component_id = ?)
|
|
4571
|
-
ORDER BY a.component_id, a.slot_name, a.position`).all(
|
|
4593
|
+
ORDER BY a.component_id, a.slot_name, a.position`).all(sessionId, componentId ?? null, componentId ?? null);
|
|
4572
4594
|
return rows.filter((row) => !allowedComponentNames2.has(row.allowed_component)).map((row) => ({
|
|
4573
4595
|
componentId: row.component_id,
|
|
4574
4596
|
componentName: row.component_name,
|
|
@@ -4576,8 +4598,8 @@ function findUnknownSlotAllowedComponents(db, sessionId2, allowedComponentNames2
|
|
|
4576
4598
|
allowedComponent: row.allowed_component
|
|
4577
4599
|
}));
|
|
4578
4600
|
}
|
|
4579
|
-
function filterUnknownSlotAllowedComponents(db,
|
|
4580
|
-
const unknown5 = findUnknownSlotAllowedComponents(db,
|
|
4601
|
+
function filterUnknownSlotAllowedComponents(db, sessionId, allowedComponentNames2) {
|
|
4602
|
+
const unknown5 = findUnknownSlotAllowedComponents(db, sessionId, allowedComponentNames2);
|
|
4581
4603
|
if (unknown5.length === 0)
|
|
4582
4604
|
return unknown5;
|
|
4583
4605
|
db.exec("BEGIN");
|
|
@@ -4585,7 +4607,7 @@ function filterUnknownSlotAllowedComponents(db, sessionId2, allowedComponentName
|
|
|
4585
4607
|
const remove = db.prepare(`DELETE FROM raw_slot_allowed_components
|
|
4586
4608
|
WHERE session_id = ? AND component_id = ? AND slot_name = ? AND allowed_component = ?`);
|
|
4587
4609
|
for (const row of unknown5) {
|
|
4588
|
-
remove.run(
|
|
4610
|
+
remove.run(sessionId, row.componentId, row.slotName, row.allowedComponent);
|
|
4589
4611
|
}
|
|
4590
4612
|
db.exec("COMMIT");
|
|
4591
4613
|
} catch (e) {
|
|
@@ -4733,7 +4755,7 @@ async function getCliCacheVersion() {
|
|
|
4733
4755
|
return _cliCacheVersionCache;
|
|
4734
4756
|
}
|
|
4735
4757
|
}
|
|
4736
|
-
function storeExtractCache(db, filePath, fileHash,
|
|
4758
|
+
function storeExtractCache(db, filePath, fileHash, cliVersion, components) {
|
|
4737
4759
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4738
4760
|
const componentsJson = JSON.stringify(components);
|
|
4739
4761
|
db.prepare(`INSERT INTO extract_cache (file_path, file_hash, cli_version, created_at, updated_at, components_json)
|
|
@@ -4741,12 +4763,12 @@ function storeExtractCache(db, filePath, fileHash, cliVersion2, components) {
|
|
|
4741
4763
|
ON CONFLICT(file_hash, cli_version) DO UPDATE SET
|
|
4742
4764
|
file_path = excluded.file_path,
|
|
4743
4765
|
updated_at = excluded.updated_at,
|
|
4744
|
-
components_json = excluded.components_json`).run(filePath, fileHash,
|
|
4766
|
+
components_json = excluded.components_json`).run(filePath, fileHash, cliVersion, now, now, componentsJson);
|
|
4745
4767
|
}
|
|
4746
|
-
function lookupExtractCache(db, fileHash,
|
|
4768
|
+
function lookupExtractCache(db, fileHash, cliVersion) {
|
|
4747
4769
|
const row = db.prepare(`SELECT file_path, file_hash, cli_version, created_at, updated_at, components_json
|
|
4748
4770
|
FROM extract_cache
|
|
4749
|
-
WHERE file_hash = ? AND cli_version = ?`).get(fileHash,
|
|
4771
|
+
WHERE file_hash = ? AND cli_version = ?`).get(fileHash, cliVersion);
|
|
4750
4772
|
if (!row)
|
|
4751
4773
|
return null;
|
|
4752
4774
|
let components = [];
|
|
@@ -4764,31 +4786,31 @@ function lookupExtractCache(db, fileHash, cliVersion2) {
|
|
|
4764
4786
|
components
|
|
4765
4787
|
};
|
|
4766
4788
|
}
|
|
4767
|
-
function storeCompositionCache(db, inputHash,
|
|
4789
|
+
function storeCompositionCache(db, inputHash, cliVersion, agentOutput) {
|
|
4768
4790
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4769
4791
|
db.prepare(`INSERT INTO composition_cache (input_hash, cli_version, agent_output, created_at, updated_at)
|
|
4770
4792
|
VALUES (?, ?, ?, ?, ?)
|
|
4771
4793
|
ON CONFLICT(input_hash, cli_version) DO UPDATE SET
|
|
4772
4794
|
agent_output = excluded.agent_output,
|
|
4773
|
-
updated_at = excluded.updated_at`).run(inputHash,
|
|
4795
|
+
updated_at = excluded.updated_at`).run(inputHash, cliVersion, agentOutput, now, now);
|
|
4774
4796
|
}
|
|
4775
|
-
function lookupCompositionCache(db, inputHash,
|
|
4776
|
-
const row = db.prepare(`SELECT agent_output FROM composition_cache WHERE input_hash = ? AND cli_version = ?`).get(inputHash,
|
|
4797
|
+
function lookupCompositionCache(db, inputHash, cliVersion) {
|
|
4798
|
+
const row = db.prepare(`SELECT agent_output FROM composition_cache WHERE input_hash = ? AND cli_version = ?`).get(inputHash, cliVersion);
|
|
4777
4799
|
return row ? row.agent_output : null;
|
|
4778
4800
|
}
|
|
4779
|
-
function storeSelectCache(db, componentHash, promptHash,
|
|
4801
|
+
function storeSelectCache(db, componentHash, promptHash, cliVersion, decision, reason) {
|
|
4780
4802
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4781
4803
|
db.prepare(`INSERT INTO select_cache (component_hash, prompt_hash, cli_version, decision, reason, created_at, updated_at)
|
|
4782
4804
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
4783
4805
|
ON CONFLICT(component_hash, prompt_hash, cli_version) DO UPDATE SET
|
|
4784
4806
|
decision = excluded.decision,
|
|
4785
4807
|
reason = excluded.reason,
|
|
4786
|
-
updated_at = excluded.updated_at`).run(componentHash, promptHash,
|
|
4808
|
+
updated_at = excluded.updated_at`).run(componentHash, promptHash, cliVersion, decision, reason, now, now);
|
|
4787
4809
|
}
|
|
4788
|
-
function lookupSelectCache(db, componentHash, promptHash,
|
|
4810
|
+
function lookupSelectCache(db, componentHash, promptHash, cliVersion) {
|
|
4789
4811
|
const row = db.prepare(`SELECT component_hash, prompt_hash, cli_version, decision, reason, created_at, updated_at
|
|
4790
4812
|
FROM select_cache
|
|
4791
|
-
WHERE component_hash = ? AND prompt_hash = ? AND cli_version = ?`).get(componentHash, promptHash,
|
|
4813
|
+
WHERE component_hash = ? AND prompt_hash = ? AND cli_version = ?`).get(componentHash, promptHash, cliVersion);
|
|
4792
4814
|
if (!row)
|
|
4793
4815
|
return null;
|
|
4794
4816
|
return {
|
|
@@ -12286,11 +12308,11 @@ async function loadReviewInput(components, options = {}) {
|
|
|
12286
12308
|
}
|
|
12287
12309
|
|
|
12288
12310
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/selection/src/controller/review/load-and-validate-for-review.js
|
|
12289
|
-
async function loadAndValidateForReview(
|
|
12311
|
+
async function loadAndValidateForReview(sessionId, projectRoot) {
|
|
12290
12312
|
const db = openPipelineDb();
|
|
12291
12313
|
let rawComponents;
|
|
12292
12314
|
try {
|
|
12293
|
-
rawComponents = loadRawComponents(db,
|
|
12315
|
+
rawComponents = loadRawComponents(db, sessionId);
|
|
12294
12316
|
} finally {
|
|
12295
12317
|
db.close();
|
|
12296
12318
|
}
|
|
@@ -12306,8 +12328,8 @@ import { access as access2, mkdir, readFile as readFile7, writeFile } from "node
|
|
|
12306
12328
|
|
|
12307
12329
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/review-session-paths.js
|
|
12308
12330
|
import { resolve as resolve15 } from "node:path";
|
|
12309
|
-
async function getRefineSessionPaths(
|
|
12310
|
-
const sessionDir = resolve15(artifactsRoot,
|
|
12331
|
+
async function getRefineSessionPaths(sessionId, artifactsRoot) {
|
|
12332
|
+
const sessionDir = resolve15(artifactsRoot, sessionId);
|
|
12311
12333
|
return {
|
|
12312
12334
|
sessionDir,
|
|
12313
12335
|
eventsPath: resolve15(sessionDir, "events.jsonl"),
|
|
@@ -12316,8 +12338,8 @@ async function getRefineSessionPaths(sessionId2, artifactsRoot) {
|
|
|
12316
12338
|
}
|
|
12317
12339
|
|
|
12318
12340
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/ensure-review-session.js
|
|
12319
|
-
async function ensureRefineSession(
|
|
12320
|
-
const paths = await getRefineSessionPaths(
|
|
12341
|
+
async function ensureRefineSession(sessionId, artifactsRoot, initialSnapshot) {
|
|
12342
|
+
const paths = await getRefineSessionPaths(sessionId, artifactsRoot);
|
|
12321
12343
|
await mkdir(paths.sessionDir, { recursive: true });
|
|
12322
12344
|
try {
|
|
12323
12345
|
await access2(paths.statePath);
|
|
@@ -12346,16 +12368,16 @@ async function saveReviewState(statePath, session) {
|
|
|
12346
12368
|
}
|
|
12347
12369
|
|
|
12348
12370
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/selection/src/controller/review/merge-preview-validation-errors-into-review-session.js
|
|
12349
|
-
async function mergePreviewValidationErrorsIntoReviewSession(
|
|
12371
|
+
async function mergePreviewValidationErrorsIntoReviewSession(sessionId, errors, opts = {}) {
|
|
12350
12372
|
const artifactsRoot = opts.artifactsRoot ?? getRefineArtifactsRoot();
|
|
12351
|
-
const paths = await getRefineSessionPaths(
|
|
12373
|
+
const paths = await getRefineSessionPaths(sessionId, artifactsRoot);
|
|
12352
12374
|
let snapshot;
|
|
12353
12375
|
try {
|
|
12354
12376
|
await access3(paths.statePath);
|
|
12355
12377
|
snapshot = JSON.parse(await readFile8(paths.statePath, "utf8"));
|
|
12356
12378
|
} catch {
|
|
12357
|
-
snapshot = await loadAndValidateForReview(
|
|
12358
|
-
snapshot = await ensureRefineSession(
|
|
12379
|
+
snapshot = await loadAndValidateForReview(sessionId, void 0);
|
|
12380
|
+
snapshot = await ensureRefineSession(sessionId, artifactsRoot, snapshot);
|
|
12359
12381
|
}
|
|
12360
12382
|
const errorsByName = /* @__PURE__ */ new Map();
|
|
12361
12383
|
for (const err of errors) {
|
|
@@ -12391,18 +12413,18 @@ async function mergePreviewValidationErrorsIntoReviewSession(sessionId2, errors,
|
|
|
12391
12413
|
|
|
12392
12414
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/selection/src/controller/review/reject-components-by-name.js
|
|
12393
12415
|
import { readFile as readFile9 } from "node:fs/promises";
|
|
12394
|
-
async function rejectComponentsByName(
|
|
12416
|
+
async function rejectComponentsByName(sessionId, names, opts = {}) {
|
|
12395
12417
|
if (names.length === 0)
|
|
12396
12418
|
return;
|
|
12397
12419
|
const db = openPipelineDb();
|
|
12398
12420
|
try {
|
|
12399
12421
|
const placeholders = names.map(() => "?").join(",");
|
|
12400
|
-
db.prepare(`UPDATE raw_components SET status = 'generate-rejected' WHERE session_id = ? AND name IN (${placeholders})`).run(
|
|
12422
|
+
db.prepare(`UPDATE raw_components SET status = 'generate-rejected' WHERE session_id = ? AND name IN (${placeholders})`).run(sessionId, ...names);
|
|
12401
12423
|
} finally {
|
|
12402
12424
|
db.close();
|
|
12403
12425
|
}
|
|
12404
12426
|
const artifactsRoot = opts.artifactsRoot ?? getRefineArtifactsRoot();
|
|
12405
|
-
const paths = await getRefineSessionPaths(
|
|
12427
|
+
const paths = await getRefineSessionPaths(sessionId, artifactsRoot);
|
|
12406
12428
|
const nameSet = new Set(names);
|
|
12407
12429
|
let snapshot;
|
|
12408
12430
|
try {
|
|
@@ -12830,9 +12852,9 @@ function buildTimestampedSubdir(base, now = /* @__PURE__ */ new Date()) {
|
|
|
12830
12852
|
|
|
12831
12853
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/services/write-scope-decisions-snapshot.js
|
|
12832
12854
|
import { mkdir as mkdir3 } from "node:fs/promises";
|
|
12833
|
-
async function writeScopeDecisionsSnapshot(db,
|
|
12855
|
+
async function writeScopeDecisionsSnapshot(db, sessionId, decisions) {
|
|
12834
12856
|
const acceptedSet = new Set(decisions.accepted);
|
|
12835
|
-
const rawComponents = loadRawComponents(db,
|
|
12857
|
+
const rawComponents = loadRawComponents(db, sessionId);
|
|
12836
12858
|
const records = rawComponents.map((c2) => {
|
|
12837
12859
|
const status = acceptedSet.has(c2.name) ? "accepted" : "rejected";
|
|
12838
12860
|
const proposal = {
|
|
@@ -12855,17 +12877,17 @@ async function writeScopeDecisionsSnapshot(db, sessionId2, decisions) {
|
|
|
12855
12877
|
status
|
|
12856
12878
|
};
|
|
12857
12879
|
});
|
|
12858
|
-
const paths = await getRefineSessionPaths(
|
|
12880
|
+
const paths = await getRefineSessionPaths(sessionId, getRefineArtifactsRoot());
|
|
12859
12881
|
await mkdir3(paths.sessionDir, { recursive: true });
|
|
12860
12882
|
await saveReviewState(paths.statePath, { components: records });
|
|
12861
12883
|
}
|
|
12862
12884
|
|
|
12863
12885
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/load-accepted-names.js
|
|
12864
12886
|
import { readFile as readFile12 } from "node:fs/promises";
|
|
12865
|
-
async function loadAcceptedNames(
|
|
12887
|
+
async function loadAcceptedNames(sessionId) {
|
|
12866
12888
|
try {
|
|
12867
12889
|
const artifactsRoot = getRefineArtifactsRoot();
|
|
12868
|
-
const paths = await getRefineSessionPaths(
|
|
12890
|
+
const paths = await getRefineSessionPaths(sessionId, artifactsRoot);
|
|
12869
12891
|
const raw = await readFile12(paths.statePath, "utf8");
|
|
12870
12892
|
const snapshot = JSON.parse(raw);
|
|
12871
12893
|
const accepted = snapshot.components.filter((c2) => c2.status === "accepted").map((c2) => c2.name);
|
|
@@ -12880,60 +12902,6 @@ async function loadAcceptedNames(sessionId2) {
|
|
|
12880
12902
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/index.js
|
|
12881
12903
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
12882
12904
|
|
|
12883
|
-
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/helpers/generate-session-id.js
|
|
12884
|
-
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
12885
|
-
var ADJECTIVES2 = [
|
|
12886
|
-
"bright",
|
|
12887
|
-
"calm",
|
|
12888
|
-
"dark",
|
|
12889
|
-
"fast",
|
|
12890
|
-
"green",
|
|
12891
|
-
"happy",
|
|
12892
|
-
"keen",
|
|
12893
|
-
"light",
|
|
12894
|
-
"long",
|
|
12895
|
-
"loud",
|
|
12896
|
-
"pale",
|
|
12897
|
-
"quick",
|
|
12898
|
-
"sharp",
|
|
12899
|
-
"slow",
|
|
12900
|
-
"soft",
|
|
12901
|
-
"warm",
|
|
12902
|
-
"wild",
|
|
12903
|
-
"wise"
|
|
12904
|
-
];
|
|
12905
|
-
var NOUNS2 = [
|
|
12906
|
-
"cloud",
|
|
12907
|
-
"creek",
|
|
12908
|
-
"dawn",
|
|
12909
|
-
"dusk",
|
|
12910
|
-
"field",
|
|
12911
|
-
"flame",
|
|
12912
|
-
"frost",
|
|
12913
|
-
"grove",
|
|
12914
|
-
"hill",
|
|
12915
|
-
"lake",
|
|
12916
|
-
"leaf",
|
|
12917
|
-
"moon",
|
|
12918
|
-
"peak",
|
|
12919
|
-
"rain",
|
|
12920
|
-
"river",
|
|
12921
|
-
"rock",
|
|
12922
|
-
"snow",
|
|
12923
|
-
"star",
|
|
12924
|
-
"storm",
|
|
12925
|
-
"tide",
|
|
12926
|
-
"tree",
|
|
12927
|
-
"wave",
|
|
12928
|
-
"wind"
|
|
12929
|
-
];
|
|
12930
|
-
function generateSessionId2() {
|
|
12931
|
-
const adj = ADJECTIVES2[Math.floor(Math.random() * ADJECTIVES2.length)];
|
|
12932
|
-
const noun = NOUNS2[Math.floor(Math.random() * NOUNS2.length)];
|
|
12933
|
-
const hex = randomBytes3(2).toString("hex");
|
|
12934
|
-
return `${adj}-${noun}-${hex}`;
|
|
12935
|
-
}
|
|
12936
|
-
|
|
12937
12905
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/migration.js
|
|
12938
12906
|
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
12939
12907
|
|
|
@@ -14636,33 +14604,33 @@ function filterAllowedPaths(args) {
|
|
|
14636
14604
|
}
|
|
14637
14605
|
|
|
14638
14606
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/helpers/map-tokens/is-prop-reviewed.js
|
|
14639
|
-
function isPropReviewed(db,
|
|
14607
|
+
function isPropReviewed(db, sessionId, componentId, propName) {
|
|
14640
14608
|
const row = db.prepare(`SELECT COUNT(*) AS count FROM raw_prop_token_paths
|
|
14641
14609
|
WHERE session_id = ? AND component_id = ? AND prop_name = ?
|
|
14642
|
-
AND source = 'review'`).get(
|
|
14610
|
+
AND source = 'review'`).get(sessionId, componentId, propName);
|
|
14643
14611
|
return row.count > 0;
|
|
14644
14612
|
}
|
|
14645
14613
|
|
|
14646
14614
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/helpers/map-tokens/load-token-type-by-path.js
|
|
14647
|
-
function loadTokenTypeByPath(db,
|
|
14648
|
-
const rows = db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ?").all(
|
|
14615
|
+
function loadTokenTypeByPath(db, sessionId) {
|
|
14616
|
+
const rows = db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ?").all(sessionId);
|
|
14649
14617
|
return new Map(rows.map((r) => [r.path, r.type]));
|
|
14650
14618
|
}
|
|
14651
14619
|
|
|
14652
14620
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/controller/map-tokens/apply-map-token-prop-calls.js
|
|
14653
|
-
function applyMapTokenPropCalls(db,
|
|
14621
|
+
function applyMapTokenPropCalls(db, sessionId, calls, incomingWarnings) {
|
|
14654
14622
|
const warnings = [...incomingWarnings];
|
|
14655
14623
|
let applied = 0;
|
|
14656
|
-
const tokenTypeByPath = loadTokenTypeByPath(db,
|
|
14624
|
+
const tokenTypeByPath = loadTokenTypeByPath(db, sessionId);
|
|
14657
14625
|
const findComponent = db.prepare("SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?");
|
|
14658
14626
|
const findProp = db.prepare("SELECT cdf_type, cdf_category, cdf_token_kind FROM raw_props WHERE session_id = ? AND component_id = ? AND name = ?");
|
|
14659
14627
|
for (const call of calls) {
|
|
14660
|
-
const component = findComponent.get(
|
|
14628
|
+
const component = findComponent.get(sessionId, call.component);
|
|
14661
14629
|
if (!component) {
|
|
14662
14630
|
warnings.push(`map_token_prop: unknown component '${call.component}' \u2014 skipped`);
|
|
14663
14631
|
continue;
|
|
14664
14632
|
}
|
|
14665
|
-
const prop = findProp.get(
|
|
14633
|
+
const prop = findProp.get(sessionId, component.component_id, call.prop);
|
|
14666
14634
|
if (!prop) {
|
|
14667
14635
|
warnings.push(`map_token_prop '${call.component}.${call.prop}': unknown prop \u2014 skipped`);
|
|
14668
14636
|
continue;
|
|
@@ -14671,7 +14639,7 @@ function applyMapTokenPropCalls(db, sessionId2, calls, incomingWarnings) {
|
|
|
14671
14639
|
warnings.push(`map_token_prop '${call.component}.${call.prop}': target is not a design-category token prop \u2014 skipped`);
|
|
14672
14640
|
continue;
|
|
14673
14641
|
}
|
|
14674
|
-
if (isPropReviewed(db,
|
|
14642
|
+
if (isPropReviewed(db, sessionId, component.component_id, call.prop)) {
|
|
14675
14643
|
warnings.push(`map_token_prop '${call.component}.${call.prop}': a reviewer already set this restriction \u2014 skipped`);
|
|
14676
14644
|
continue;
|
|
14677
14645
|
}
|
|
@@ -14687,7 +14655,7 @@ function applyMapTokenPropCalls(db, sessionId2, calls, incomingWarnings) {
|
|
|
14687
14655
|
warnings.push(`map_token_prop '${call.component}.${call.prop}': no valid token_allowed remain \u2014 skipped`);
|
|
14688
14656
|
continue;
|
|
14689
14657
|
}
|
|
14690
|
-
replaceRawPropTokenPaths(db,
|
|
14658
|
+
replaceRawPropTokenPaths(db, sessionId, component.component_id, call.prop, filteredAllowed, "agent");
|
|
14691
14659
|
applied++;
|
|
14692
14660
|
}
|
|
14693
14661
|
return { applied, warnings };
|
|
@@ -14725,176 +14693,18 @@ function countMappableProps(cdfEntries) {
|
|
|
14725
14693
|
}
|
|
14726
14694
|
|
|
14727
14695
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/helpers/map-tokens/load-raw-defaults.js
|
|
14728
|
-
function loadRawDefaults(db,
|
|
14696
|
+
function loadRawDefaults(db, sessionId) {
|
|
14729
14697
|
return db.prepare(`SELECT rp.default_value AS default_reference, rp.cdf_token_kind
|
|
14730
14698
|
FROM raw_props rp
|
|
14731
14699
|
JOIN raw_components rc ON rc.session_id = rp.session_id AND rc.component_id = rp.component_id
|
|
14732
14700
|
WHERE rp.session_id = ? AND rc.status = 'generated'
|
|
14733
14701
|
AND rp.cdf_type = 'token' AND rp.cdf_category = 'design'
|
|
14734
|
-
AND rp.default_value IS NOT NULL`).all(
|
|
14702
|
+
AND rp.default_value IS NOT NULL`).all(sessionId);
|
|
14735
14703
|
}
|
|
14736
14704
|
|
|
14737
14705
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/helpers/map-tokens/load-token-leaves.js
|
|
14738
|
-
function loadTokenLeaves(db,
|
|
14739
|
-
return db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ? ORDER BY path").all(
|
|
14740
|
-
}
|
|
14741
|
-
|
|
14742
|
-
// packages/experience-design-system-backend-pipeline/dist/src/analytics/client.js
|
|
14743
|
-
import { Analytics } from "@segment/analytics-node";
|
|
14744
|
-
var DEFAULT_WRITE_KEY = "6DmxiEPN3SV1vbRTTMcNqDzCvkfwT06N";
|
|
14745
|
-
var analyticsClient = null;
|
|
14746
|
-
var persistedDisabled = false;
|
|
14747
|
-
var cliVersionString = "0.0.0-unknown";
|
|
14748
|
-
function cliVersion() {
|
|
14749
|
-
return cliVersionString;
|
|
14750
|
-
}
|
|
14751
|
-
function analyticsEnabled() {
|
|
14752
|
-
return !persistedDisabled && !process.env["DISABLE_ANALYTICS"];
|
|
14753
|
-
}
|
|
14754
|
-
function resolveWriteKey() {
|
|
14755
|
-
const key = (process.env["SEGMENT_WRITE_KEY"] ?? "").trim();
|
|
14756
|
-
return key.length > 0 ? key : DEFAULT_WRITE_KEY;
|
|
14757
|
-
}
|
|
14758
|
-
function getClient() {
|
|
14759
|
-
if (!analyticsEnabled())
|
|
14760
|
-
return null;
|
|
14761
|
-
const writeKey = resolveWriteKey();
|
|
14762
|
-
if (!writeKey)
|
|
14763
|
-
return null;
|
|
14764
|
-
if (!analyticsClient) {
|
|
14765
|
-
analyticsClient = new Analytics({ writeKey });
|
|
14766
|
-
analyticsClient.on("error", () => {
|
|
14767
|
-
});
|
|
14768
|
-
}
|
|
14769
|
-
return analyticsClient;
|
|
14770
|
-
}
|
|
14771
|
-
async function trackEvent(event, properties, anonymousId, options) {
|
|
14772
|
-
const client2 = getClient();
|
|
14773
|
-
if (!client2)
|
|
14774
|
-
return;
|
|
14775
|
-
try {
|
|
14776
|
-
client2.track({
|
|
14777
|
-
event,
|
|
14778
|
-
properties,
|
|
14779
|
-
anonymousId,
|
|
14780
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
14781
|
-
});
|
|
14782
|
-
if (options?.flush)
|
|
14783
|
-
await flushAnalytics();
|
|
14784
|
-
} catch {
|
|
14785
|
-
}
|
|
14786
|
-
}
|
|
14787
|
-
async function flushAnalytics() {
|
|
14788
|
-
if (!analyticsClient)
|
|
14789
|
-
return;
|
|
14790
|
-
try {
|
|
14791
|
-
await analyticsClient.closeAndFlush();
|
|
14792
|
-
} catch {
|
|
14793
|
-
} finally {
|
|
14794
|
-
analyticsClient = null;
|
|
14795
|
-
}
|
|
14796
|
-
}
|
|
14797
|
-
|
|
14798
|
-
// packages/experience-design-system-backend-pipeline/dist/src/analytics/constants.js
|
|
14799
|
-
var ANALYTICS_SESSION_ENV = "EDS_ANALYTICS_SESSION_ID";
|
|
14800
|
-
var IMPORT_PIPELINE_ENV = "EDS_IMPORT_PIPELINE";
|
|
14801
|
-
|
|
14802
|
-
// packages/experience-design-system-backend-pipeline/dist/src/analytics/session.js
|
|
14803
|
-
function resolveAnalyticsSessionId(explicit) {
|
|
14804
|
-
const inherited = process.env[ANALYTICS_SESSION_ENV]?.trim();
|
|
14805
|
-
if (inherited)
|
|
14806
|
-
return inherited;
|
|
14807
|
-
const passed = explicit?.trim();
|
|
14808
|
-
if (passed)
|
|
14809
|
-
return passed;
|
|
14810
|
-
return generateSessionId2();
|
|
14811
|
-
}
|
|
14812
|
-
function isPipelineAnalyticsChild() {
|
|
14813
|
-
return Boolean(process.env[ANALYTICS_SESSION_ENV]?.trim());
|
|
14814
|
-
}
|
|
14815
|
-
|
|
14816
|
-
// packages/experience-design-system-backend-pipeline/dist/src/analytics/os.js
|
|
14817
|
-
var OS_NAMES2 = {
|
|
14818
|
-
android: "Android",
|
|
14819
|
-
aix: "Linux",
|
|
14820
|
-
darwin: "macOS",
|
|
14821
|
-
freebsd: "Linux",
|
|
14822
|
-
linux: "Linux",
|
|
14823
|
-
openbsd: "Linux",
|
|
14824
|
-
sunos: "Linux",
|
|
14825
|
-
win32: "Windows"
|
|
14826
|
-
};
|
|
14827
|
-
function getOsName() {
|
|
14828
|
-
return OS_NAMES2[process.platform] ?? "other";
|
|
14829
|
-
}
|
|
14830
|
-
|
|
14831
|
-
// packages/experience-design-system-backend-pipeline/dist/src/analytics/tracker.js
|
|
14832
|
-
var pending = null;
|
|
14833
|
-
var sessionId;
|
|
14834
|
-
var sessionStartedEmitted = false;
|
|
14835
|
-
function isPipelineStep() {
|
|
14836
|
-
return process.env[IMPORT_PIPELINE_ENV] === "1";
|
|
14837
|
-
}
|
|
14838
|
-
function buildBaseProps(command) {
|
|
14839
|
-
return {
|
|
14840
|
-
dsi_session_id: sessionId,
|
|
14841
|
-
command,
|
|
14842
|
-
...isPipelineStep() ? { is_pipeline_step: true } : {}
|
|
14843
|
-
};
|
|
14844
|
-
}
|
|
14845
|
-
function mergeContext(target, source) {
|
|
14846
|
-
if (source.space_key !== void 0)
|
|
14847
|
-
target.space_key = source.space_key;
|
|
14848
|
-
if (source.environment_key !== void 0)
|
|
14849
|
-
target.environment_key = source.environment_key;
|
|
14850
|
-
if (source.x_contentful_request_id !== void 0) {
|
|
14851
|
-
target.x_contentful_request_id = source.x_contentful_request_id;
|
|
14852
|
-
}
|
|
14853
|
-
}
|
|
14854
|
-
async function bindAnalyticsSessionId(explicit, context) {
|
|
14855
|
-
const id = resolveAnalyticsSessionId(explicit);
|
|
14856
|
-
await bindAnalyticsSession(id, context);
|
|
14857
|
-
return id;
|
|
14858
|
-
}
|
|
14859
|
-
function setCommandContext(context) {
|
|
14860
|
-
if (!pending)
|
|
14861
|
-
return;
|
|
14862
|
-
mergeContext(pending.context, context);
|
|
14863
|
-
mergeContext(pending.completion, context);
|
|
14864
|
-
}
|
|
14865
|
-
function enrichCommandResult(fields) {
|
|
14866
|
-
if (!pending)
|
|
14867
|
-
return;
|
|
14868
|
-
Object.assign(pending.completion, fields);
|
|
14869
|
-
mergeContext(pending.context, fields);
|
|
14870
|
-
}
|
|
14871
|
-
async function bindAnalyticsSession(id, context) {
|
|
14872
|
-
sessionId = id;
|
|
14873
|
-
if (context)
|
|
14874
|
-
setCommandContext(context);
|
|
14875
|
-
await emitInvokedIfReady();
|
|
14876
|
-
}
|
|
14877
|
-
async function emitSessionStarted(entryCommand) {
|
|
14878
|
-
if (!sessionId || sessionStartedEmitted)
|
|
14879
|
-
return;
|
|
14880
|
-
sessionStartedEmitted = true;
|
|
14881
|
-
await trackEvent("dsi_cli_session_started", {
|
|
14882
|
-
dsi_session_id: sessionId,
|
|
14883
|
-
entry_command: entryCommand,
|
|
14884
|
-
cli_version: cliVersion(),
|
|
14885
|
-
node_version: process.version,
|
|
14886
|
-
os_name: getOsName()
|
|
14887
|
-
}, sessionId, { flush: true });
|
|
14888
|
-
await emitInvokedIfReady();
|
|
14889
|
-
}
|
|
14890
|
-
async function emitInvokedIfReady() {
|
|
14891
|
-
if (!pending || pending.invoked || !sessionId)
|
|
14892
|
-
return;
|
|
14893
|
-
pending.invoked = true;
|
|
14894
|
-
await trackEvent("dsi_cli_command_invoked", {
|
|
14895
|
-
...buildBaseProps(pending.command),
|
|
14896
|
-
...pending.context
|
|
14897
|
-
}, sessionId, { flush: true });
|
|
14706
|
+
function loadTokenLeaves(db, sessionId) {
|
|
14707
|
+
return db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ? ORDER BY path").all(sessionId);
|
|
14898
14708
|
}
|
|
14899
14709
|
|
|
14900
14710
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/controller/map-tokens/run-map-tokens.js
|
|
@@ -14922,53 +14732,42 @@ async function runMapTokens(request) {
|
|
|
14922
14732
|
const timeoutMs = request.agentTimeoutMs ?? DEFAULT_TIMEOUT_MS2;
|
|
14923
14733
|
const db = openPipelineDb();
|
|
14924
14734
|
try {
|
|
14925
|
-
const
|
|
14926
|
-
if (!
|
|
14735
|
+
const sessionId = request.sessionId ?? findLatestSessionForCommand(db, "generate components");
|
|
14736
|
+
if (!sessionId) {
|
|
14927
14737
|
throw new MapTokensRunFailure({ type: "no-session" });
|
|
14928
14738
|
}
|
|
14929
|
-
|
|
14930
|
-
const tokenLeaves = loadTokenLeaves(db, sessionId2);
|
|
14739
|
+
const tokenLeaves = loadTokenLeaves(db, sessionId);
|
|
14931
14740
|
const knownTokenPaths = new Set(tokenLeaves.map((t) => t.path));
|
|
14932
|
-
const diagnostics = [];
|
|
14933
14741
|
if (request.tokenMapInline) {
|
|
14934
14742
|
const validMappings = {};
|
|
14935
14743
|
for (const [rawName, path5] of Object.entries(request.tokenMapInline)) {
|
|
14936
|
-
if (knownTokenPaths.has(path5))
|
|
14744
|
+
if (knownTokenPaths.has(path5))
|
|
14937
14745
|
validMappings[rawName] = path5;
|
|
14938
|
-
} else {
|
|
14939
|
-
diagnostics.push(`Token map '${rawName}' -> '${path5}': path not found in session tokens \u2014 skipped.`);
|
|
14940
|
-
}
|
|
14941
14746
|
}
|
|
14942
|
-
replaceRawTokenNamePaths(db,
|
|
14747
|
+
replaceRawTokenNamePaths(db, sessionId, validMappings, "manual");
|
|
14943
14748
|
}
|
|
14944
|
-
const rawDefaults = loadRawDefaults(db,
|
|
14749
|
+
const rawDefaults = loadRawDefaults(db, sessionId);
|
|
14945
14750
|
const defaultResolution = resolveTokenDefaults(rawDefaults.map((row) => ({ rawDefault: row.default_reference, tokenKind: row.cdf_token_kind })), tokenLeaves);
|
|
14946
|
-
|
|
14947
|
-
diagnostics.push(diagnostic.message);
|
|
14948
|
-
const manualMappings = new Map(getRawTokenNamePathRows(db, sessionId2).filter((row) => row.source === "manual").map((row) => [row.rawName, row.path]));
|
|
14751
|
+
const manualMappings = new Map(getRawTokenNamePathRows(db, sessionId).filter((row) => row.source === "manual").map((row) => [row.rawName, row.path]));
|
|
14949
14752
|
const automaticMappings = {};
|
|
14950
14753
|
for (const [rawName, path5] of Object.entries(defaultResolution.mappings)) {
|
|
14951
|
-
|
|
14952
|
-
if (manualPath === void 0) {
|
|
14754
|
+
if (manualMappings.get(rawName) === void 0)
|
|
14953
14755
|
automaticMappings[rawName] = path5;
|
|
14954
|
-
} else if (manualPath !== path5) {
|
|
14955
|
-
diagnostics.push(`Token default '${rawName}' automatically resolves to '${path5}', but manual mapping '${manualPath}' is retained.`);
|
|
14956
|
-
}
|
|
14957
14756
|
}
|
|
14958
|
-
replaceRawTokenNamePaths(db,
|
|
14959
|
-
const cdfEntries = loadCDFComponents(db,
|
|
14757
|
+
replaceRawTokenNamePaths(db, sessionId, automaticMappings, "automatic");
|
|
14758
|
+
const cdfEntries = loadCDFComponents(db, sessionId);
|
|
14960
14759
|
if (cdfEntries.length === 0) {
|
|
14961
|
-
throw new MapTokensRunFailure({ type: "no-components", sessionId
|
|
14760
|
+
throw new MapTokensRunFailure({ type: "no-components", sessionId });
|
|
14962
14761
|
}
|
|
14963
14762
|
const mappablePropCount = countMappableProps(cdfEntries);
|
|
14964
|
-
const { groups, tokens } = getDtcgTokensForSession(db,
|
|
14763
|
+
const { groups, tokens } = getDtcgTokensForSession(db, sessionId);
|
|
14965
14764
|
const tokenCount = tokens.length;
|
|
14966
14765
|
if (mappablePropCount === 0 || tokenCount === 0) {
|
|
14967
|
-
return { type: "nothing-to-map", sessionId
|
|
14766
|
+
return { type: "nothing-to-map", sessionId, mappablePropCount, tokenCount };
|
|
14968
14767
|
}
|
|
14969
14768
|
const generatedCdf = Object.fromEntries(cdfEntries.map((c2) => [c2.key, c2.entry]));
|
|
14970
14769
|
const tokenTree = rebuildDTCGTree(groups, tokens);
|
|
14971
|
-
const componentSourceRefs = await loadComponentSourceRefs(db,
|
|
14770
|
+
const componentSourceRefs = await loadComponentSourceRefs(db, sessionId);
|
|
14972
14771
|
const buildMapPrompt = () => buildPrompt({
|
|
14973
14772
|
skill: "map-tokens",
|
|
14974
14773
|
mode: "autonomous",
|
|
@@ -14982,28 +14781,28 @@ async function runMapTokens(request) {
|
|
|
14982
14781
|
});
|
|
14983
14782
|
if (request.printPrompt) {
|
|
14984
14783
|
const prompt2 = await buildMapPrompt();
|
|
14985
|
-
return { type: "printed-prompt", sessionId
|
|
14784
|
+
return { type: "printed-prompt", sessionId, prompt: prompt2 };
|
|
14986
14785
|
}
|
|
14987
14786
|
if (request.skipAgent) {
|
|
14988
|
-
const stepId2 = createStep(db,
|
|
14787
|
+
const stepId2 = createStep(db, sessionId, "map tokens", {
|
|
14989
14788
|
agent: request.agent,
|
|
14990
14789
|
model: request.model ?? "",
|
|
14991
14790
|
skipAgent: "true"
|
|
14992
14791
|
});
|
|
14993
14792
|
updateStep(db, stepId2, "complete", { applied: "0", skipAgent: "true" });
|
|
14994
|
-
return { type: "skipped", sessionId
|
|
14793
|
+
return { type: "skipped", sessionId, stepId: stepId2 };
|
|
14995
14794
|
}
|
|
14996
14795
|
const agent = request.agent;
|
|
14997
14796
|
const noCache = request.cache === false || process.env["EDS_NO_CACHE"] === "1";
|
|
14998
14797
|
const promptHash = await hashPromptForSkill("map-tokens", agent, request.model, request.skillPathOverride, request.existingEntitiesInline ? [hashContent(request.existingEntitiesInline)] : [], request.skillContentOverride);
|
|
14999
|
-
const inputHash = computeMapTokensInputHash(db,
|
|
14798
|
+
const inputHash = computeMapTokensInputHash(db, sessionId, componentSourceRefs);
|
|
15000
14799
|
if (!noCache) {
|
|
15001
14800
|
const cached = lookupCache(db, inputHash, "token_mapping", "__map_tokens__", promptHash);
|
|
15002
14801
|
if (cached) {
|
|
15003
|
-
const applied2 = copyMapTokensFromCache(db, cached.sourceSessionId,
|
|
15004
|
-
const stepId2 = createStep(db,
|
|
14802
|
+
const applied2 = copyMapTokensFromCache(db, cached.sourceSessionId, sessionId);
|
|
14803
|
+
const stepId2 = createStep(db, sessionId, "map tokens", { agent, model: request.model ?? "" });
|
|
15005
14804
|
updateStep(db, stepId2, "complete", { cached: "true", applied: String(applied2) });
|
|
15006
|
-
return { type: "cached", sessionId
|
|
14805
|
+
return { type: "cached", sessionId, applied: applied2, stepId: stepId2 };
|
|
15007
14806
|
}
|
|
15008
14807
|
}
|
|
15009
14808
|
const binary = resolveBinary(agent);
|
|
@@ -15015,22 +14814,22 @@ async function runMapTokens(request) {
|
|
|
15015
14814
|
skillPath: resolveSkillPath("map-tokens")
|
|
15016
14815
|
});
|
|
15017
14816
|
}
|
|
15018
|
-
const stepId = createStep(db,
|
|
14817
|
+
const stepId = createStep(db, sessionId, "map tokens", { agent, model: request.model ?? "" });
|
|
15019
14818
|
const prompt = await buildMapPrompt();
|
|
15020
14819
|
const invoker = createLocalCliAgentInvoker();
|
|
15021
14820
|
const result = await invoker.invoke({ agent, model: request.model, prompt, timeoutMs });
|
|
15022
14821
|
if (result.timedOut || result.exitCode !== 0) {
|
|
15023
14822
|
const error = result.timedOut ? `timed out after ${timeoutMs / 6e4} minutes` : describeAgentFailure(result);
|
|
15024
14823
|
updateStep(db, stepId, "failed", {}, error);
|
|
15025
|
-
throw new MapTokensRunFailure({ type: "agent-failed", sessionId
|
|
14824
|
+
throw new MapTokensRunFailure({ type: "agent-failed", sessionId, stepId, error });
|
|
15026
14825
|
}
|
|
15027
14826
|
const { calls, warnings: parseWarnings } = parseMapTokenPropToolCalls(result.stdout);
|
|
15028
|
-
const { applied, warnings } = applyMapTokenPropCalls(db,
|
|
14827
|
+
const { applied, warnings } = applyMapTokenPropCalls(db, sessionId, calls, parseWarnings);
|
|
15029
14828
|
if (!noCache) {
|
|
15030
|
-
storeCache(db, inputHash, "token_mapping", "__map_tokens__",
|
|
14829
|
+
storeCache(db, inputHash, "token_mapping", "__map_tokens__", sessionId, false, promptHash);
|
|
15031
14830
|
}
|
|
15032
14831
|
updateStep(db, stepId, "complete", { applied: String(applied), warnings: String(warnings.length) });
|
|
15033
|
-
return { type: "applied", sessionId
|
|
14832
|
+
return { type: "applied", sessionId, applied, warnings, stepId };
|
|
15034
14833
|
} finally {
|
|
15035
14834
|
db.close();
|
|
15036
14835
|
}
|
|
@@ -16093,14 +15892,14 @@ async function retryDatabaseWrite(operation, attempts = 8) {
|
|
|
16093
15892
|
}
|
|
16094
15893
|
|
|
16095
15894
|
// packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-extract-and-compose-session/helpers/persist-slot-cycles.js
|
|
16096
|
-
async function persistSlotCycles(db,
|
|
15895
|
+
async function persistSlotCycles(db, sessionId, components) {
|
|
16097
15896
|
const graph = components.map((c2) => ({
|
|
16098
15897
|
name: c2.name,
|
|
16099
15898
|
slots: c2.slots.map((s) => ({ name: s.name, allowedComponents: s.allowedComponents }))
|
|
16100
15899
|
}));
|
|
16101
15900
|
const cycles = findSlotCycles(graph);
|
|
16102
15901
|
const withBreaks = cycles.map((cycle) => ({ ...cycle, suggestedBreak: suggestCycleBreakEdge(cycle, cycles) }));
|
|
16103
|
-
await retryDatabaseWrite(() => storeSlotCycles(db,
|
|
15902
|
+
await retryDatabaseWrite(() => storeSlotCycles(db, sessionId, withBreaks));
|
|
16104
15903
|
}
|
|
16105
15904
|
|
|
16106
15905
|
// packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-extract-and-compose-session/helpers/resolve-composition.js
|
|
@@ -16244,23 +16043,20 @@ async function runExtractAndComposeSession(request) {
|
|
|
16244
16043
|
onDebugEvent
|
|
16245
16044
|
});
|
|
16246
16045
|
await mkdir4(outDir, { recursive: true });
|
|
16247
|
-
const { sessionId
|
|
16046
|
+
const { sessionId } = getOrCreateSession(db, void 0, void 0, {
|
|
16248
16047
|
command: "analyze extract",
|
|
16249
16048
|
inputPath: projectPath,
|
|
16250
16049
|
outDir
|
|
16251
16050
|
});
|
|
16252
|
-
await onSessionCreated?.(
|
|
16253
|
-
|
|
16254
|
-
if (!isPipelineAnalyticsChild())
|
|
16255
|
-
await emitSessionStarted("analyze_extract");
|
|
16256
|
-
const stepId = createStep(db, sessionId2, "analyze extract", { project: projectPath });
|
|
16051
|
+
await onSessionCreated?.(sessionId);
|
|
16052
|
+
const stepId = createStep(db, sessionId, "analyze extract", { project: projectPath });
|
|
16257
16053
|
if (cacheHits === 0 && !noCache) {
|
|
16258
16054
|
await persistExtractCache(db, sourceFiles, extraction.components, cacheVersion);
|
|
16259
16055
|
}
|
|
16260
16056
|
emitPreClassificationExclusions(extraction, onExclusion);
|
|
16261
16057
|
const classifiedComponents = extraction.components.map(preClassifyComponent);
|
|
16262
16058
|
const { components: initialValidatedComponents, warnings: filterWarnings } = await evaluateExtractionQuality(classifiedComponents);
|
|
16263
|
-
storeRawComponents(db,
|
|
16059
|
+
storeRawComponents(db, sessionId, initialValidatedComponents);
|
|
16264
16060
|
const sources = resolveCompositionSources({ noCache, compositionRefresh });
|
|
16265
16061
|
const composition = await resolveComposition({
|
|
16266
16062
|
db,
|
|
@@ -16276,13 +16072,12 @@ async function runExtractAndComposeSession(request) {
|
|
|
16276
16072
|
onProgress,
|
|
16277
16073
|
onDebugEvent
|
|
16278
16074
|
});
|
|
16279
|
-
await retryDatabaseWrite(() => storeRawComponents(db,
|
|
16280
|
-
await persistSlotCycles(db,
|
|
16281
|
-
storeScannedFiles(db,
|
|
16282
|
-
await retryDatabaseWrite(() => updateStep(db, stepId, "complete", { sessionId
|
|
16283
|
-
enrichCommandResult({ extracted_component_count: composition.components.length });
|
|
16075
|
+
await retryDatabaseWrite(() => storeRawComponents(db, sessionId, composition.components, { preserveStatus: true }));
|
|
16076
|
+
await persistSlotCycles(db, sessionId, composition.components);
|
|
16077
|
+
storeScannedFiles(db, sessionId, sourceFiles.map((f) => relative2(projectPath, f)));
|
|
16078
|
+
await retryDatabaseWrite(() => updateStep(db, stepId, "complete", { sessionId }));
|
|
16284
16079
|
return {
|
|
16285
|
-
sessionId
|
|
16080
|
+
sessionId,
|
|
16286
16081
|
compositionPhase: composition.phase,
|
|
16287
16082
|
components: composition.components,
|
|
16288
16083
|
warnings: [...extraction.warnings, ...filterWarnings],
|
|
@@ -16309,11 +16104,11 @@ init_resolve_prompt_override();
|
|
|
16309
16104
|
// packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-tokens-session/helpers/write-tokens-file.js
|
|
16310
16105
|
import { mkdir as mkdir5, writeFile as writeFile5 } from "node:fs/promises";
|
|
16311
16106
|
import { join as join15 } from "node:path";
|
|
16312
|
-
async function writeTokensFile(db,
|
|
16107
|
+
async function writeTokensFile(db, sessionId, outDir, onProgress) {
|
|
16313
16108
|
onProgress?.({ kind: "writing-file" });
|
|
16314
|
-
const result = getDtcgTokensForSession(db,
|
|
16109
|
+
const result = getDtcgTokensForSession(db, sessionId);
|
|
16315
16110
|
if (result.tokens.length === 0) {
|
|
16316
|
-
throw new Error(`generate tokens: no tokens persisted for session ${
|
|
16111
|
+
throw new Error(`generate tokens: no tokens persisted for session ${sessionId}`);
|
|
16317
16112
|
}
|
|
16318
16113
|
const tree = rebuildDTCGTree(result.groups, result.tokens);
|
|
16319
16114
|
const tokensPath = join15(outDir, "tokens.json");
|
|
@@ -16343,7 +16138,6 @@ async function runGenerateTokensSession(request) {
|
|
|
16343
16138
|
outDir
|
|
16344
16139
|
});
|
|
16345
16140
|
await onSessionCreated?.(tokenSessionId);
|
|
16346
|
-
await bindAnalyticsSessionId(tokenSessionId);
|
|
16347
16141
|
const tokenPromptHash = await hashPromptForSkill("tokens", agent, agentModel, skillPath);
|
|
16348
16142
|
const warnings = [];
|
|
16349
16143
|
onProgress?.({ kind: "resolving" });
|
|
@@ -16407,9 +16201,9 @@ init_create_local_cli_agent_invoker();
|
|
|
16407
16201
|
init_cache_keys();
|
|
16408
16202
|
|
|
16409
16203
|
// packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-components-session/helpers/build-empty-session-response.js
|
|
16410
|
-
function buildEmptySessionResponse(
|
|
16204
|
+
function buildEmptySessionResponse(sessionId) {
|
|
16411
16205
|
return {
|
|
16412
|
-
sessionId
|
|
16206
|
+
sessionId,
|
|
16413
16207
|
results: [],
|
|
16414
16208
|
allOk: true,
|
|
16415
16209
|
renamedSlotsCount: 0,
|
|
@@ -16431,11 +16225,11 @@ function collectDuplicateNames(components) {
|
|
|
16431
16225
|
}
|
|
16432
16226
|
|
|
16433
16227
|
// packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-components-session/helpers/filter-dropped-allowed-components.js
|
|
16434
|
-
function filterDroppedAllowedComponents(db,
|
|
16435
|
-
const dropped = filterUnknownSlotAllowedComponents(db,
|
|
16228
|
+
function filterDroppedAllowedComponents(db, sessionId, components, allowedComponentNames2, acceptedNames) {
|
|
16229
|
+
const dropped = filterUnknownSlotAllowedComponents(db, sessionId, allowedComponentNames2);
|
|
16436
16230
|
if (dropped.length === 0)
|
|
16437
16231
|
return { components, dropped: [] };
|
|
16438
|
-
return { components: loadRawComponents(db,
|
|
16232
|
+
return { components: loadRawComponents(db, sessionId, acceptedNames), dropped };
|
|
16439
16233
|
}
|
|
16440
16234
|
|
|
16441
16235
|
// packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-components-session/helpers/read-existing-entities.js
|
|
@@ -16503,8 +16297,8 @@ function buildFailedComponentResult(componentName, error, renamedSlotsCount) {
|
|
|
16503
16297
|
var DEFAULT_TIMEOUT_MS4 = Number(process.env["EDS_AGENT_TIMEOUT_MS"] ?? 5 * 60 * 1e3);
|
|
16504
16298
|
var RETRY_BACKOFF_MS = Number(process.env["EDS_RETRY_BACKOFF_MS"] ?? 5e3);
|
|
16505
16299
|
async function runOneGenerateComponent(options, component, index, total) {
|
|
16506
|
-
const { db, sessionId
|
|
16507
|
-
const { renames } = renameEmptySlots(db,
|
|
16300
|
+
const { db, sessionId, invoker, agent, model, tokensInline, tokenMapInline, verbose, noCache, skillPathOverride, skillContentOverride, promptHash, existingContentfulEntities, existingTokensInline, precomputedCachedNames, allowedComponentNames: allowedComponentNames2, onProgress } = options;
|
|
16301
|
+
const { renames } = renameEmptySlots(db, sessionId, component.component_id, component.name, component.slots.length);
|
|
16508
16302
|
let effectiveSlots = component.slots;
|
|
16509
16303
|
if (renames.length > 0) {
|
|
16510
16304
|
const renameMap = new Map(renames.map((r) => [r.oldName, r.newName]));
|
|
@@ -16527,7 +16321,7 @@ async function runOneGenerateComponent(options, component, index, total) {
|
|
|
16527
16321
|
if (!noCache) {
|
|
16528
16322
|
const resolution = resolveComponentCache(db, component, promptHash, allowedComponentNames2);
|
|
16529
16323
|
if (resolution && !resolution.humanEdited) {
|
|
16530
|
-
copyComponentFromCache(db, resolution.entry.sourceSessionId,
|
|
16324
|
+
copyComponentFromCache(db, resolution.entry.sourceSessionId, sessionId, component.component_id, true, {
|
|
16531
16325
|
allowedComponentNames: allowedComponentNames2
|
|
16532
16326
|
});
|
|
16533
16327
|
storeCache(db, hashComponentShape(cacheComponent), "component", component.component_id, resolution.entry.sourceSessionId, resolution.entry.humanEdited, promptHash);
|
|
@@ -16535,7 +16329,7 @@ async function runOneGenerateComponent(options, component, index, total) {
|
|
|
16535
16329
|
return buildCachedComponentResult(component.name);
|
|
16536
16330
|
}
|
|
16537
16331
|
if (resolution?.humanEdited) {
|
|
16538
|
-
copyComponentFromCache(db, resolution.entry.sourceSessionId,
|
|
16332
|
+
copyComponentFromCache(db, resolution.entry.sourceSessionId, sessionId, component.component_id, true, {
|
|
16539
16333
|
allowedComponentNames: allowedComponentNames2
|
|
16540
16334
|
});
|
|
16541
16335
|
onProgress?.({ kind: "component:cached", index, total, name: component.name, pinned: true });
|
|
@@ -16591,11 +16385,11 @@ async function runOneGenerateComponent(options, component, index, total) {
|
|
|
16591
16385
|
lastError = describeAgentFailure(result);
|
|
16592
16386
|
continue;
|
|
16593
16387
|
}
|
|
16594
|
-
const applied = applyToolCalls(db,
|
|
16388
|
+
const applied = applyToolCalls(db, sessionId, component.component_id, component.name, calls, warnings, {
|
|
16595
16389
|
allowedComponentNames: allowedComponentNames2
|
|
16596
16390
|
});
|
|
16597
16391
|
if (!noCache) {
|
|
16598
|
-
storeCache(db, hashComponentShape(cacheComponent), "component", component.component_id,
|
|
16392
|
+
storeCache(db, hashComponentShape(cacheComponent), "component", component.component_id, sessionId, false, promptHash);
|
|
16599
16393
|
}
|
|
16600
16394
|
onProgress?.({
|
|
16601
16395
|
kind: "component:completed",
|
|
@@ -16640,18 +16434,18 @@ async function runWithPool(items, concurrency, worker) {
|
|
|
16640
16434
|
init_cache_keys();
|
|
16641
16435
|
|
|
16642
16436
|
// packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-components-session/helpers/restore-cached-components.js
|
|
16643
|
-
async function restoreCachedComponents(db,
|
|
16437
|
+
async function restoreCachedComponents(db, sessionId, cachedComponents, promptHash, allowedComponentNames2) {
|
|
16644
16438
|
const restorations = [];
|
|
16645
16439
|
const rekeyed = [];
|
|
16646
16440
|
const componentStatus = db.prepare("SELECT status FROM raw_components WHERE session_id = ? AND component_id = ?");
|
|
16647
16441
|
for (const { component, resolution } of cachedComponents) {
|
|
16648
|
-
const current = componentStatus.get(
|
|
16442
|
+
const current = componentStatus.get(sessionId, component.component_id);
|
|
16649
16443
|
if (current?.status === "generated")
|
|
16650
16444
|
continue;
|
|
16651
|
-
renameEmptySlots(db,
|
|
16445
|
+
renameEmptySlots(db, sessionId, component.component_id, component.name, component.slots.length);
|
|
16652
16446
|
restorations.push({
|
|
16653
16447
|
sourceSessionId: resolution.entry.sourceSessionId,
|
|
16654
|
-
targetSessionId:
|
|
16448
|
+
targetSessionId: sessionId,
|
|
16655
16449
|
componentId: component.component_id
|
|
16656
16450
|
});
|
|
16657
16451
|
rekeyed.push({ component, cached: resolution.entry });
|
|
@@ -16720,7 +16514,6 @@ async function runGenerateComponentsSession(request) {
|
|
|
16720
16514
|
const existingTokensHash = existingTokensInline ? [hashContent(existingTokensInline)] : [];
|
|
16721
16515
|
const agent = request.agent;
|
|
16722
16516
|
const promptHash = await hashPromptForSkill("components", agent, request.agentModel, effectiveSkillPath, existingTokensHash, prompt.text);
|
|
16723
|
-
await bindAnalyticsSessionId(request.sessionId);
|
|
16724
16517
|
const db = openPipelineDb();
|
|
16725
16518
|
try {
|
|
16726
16519
|
const acceptedNames = await loadAcceptedNames(request.sessionId);
|
|
@@ -17420,7 +17213,7 @@ function ExtractionScreen({
|
|
|
17420
17213
|
}
|
|
17421
17214
|
|
|
17422
17215
|
// packages/experience-design-system-types/dist/src/config/index.js
|
|
17423
|
-
import { randomBytes as
|
|
17216
|
+
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
17424
17217
|
import { mkdir as mkdir6, readFile as readFile18, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
|
|
17425
17218
|
import { homedir as homedir3 } from "node:os";
|
|
17426
17219
|
import { dirname as dirname13, join as join17 } from "node:path";
|
|
@@ -17439,7 +17232,7 @@ async function readSettings2() {
|
|
|
17439
17232
|
async function writeSettings2(settings) {
|
|
17440
17233
|
const path5 = configFilePath2();
|
|
17441
17234
|
await mkdir6(dirname13(path5), { recursive: true });
|
|
17442
|
-
const tmp = `${path5}.${process.pid}.${
|
|
17235
|
+
const tmp = `${path5}.${process.pid}.${randomBytes3(4).toString("hex")}.tmp`;
|
|
17443
17236
|
await writeFile6(tmp, `${JSON.stringify(settings, null, 2)}
|
|
17444
17237
|
`, { mode: 384 });
|
|
17445
17238
|
await rename2(tmp, path5);
|
|
@@ -17485,13 +17278,13 @@ async function runSelection(options) {
|
|
|
17485
17278
|
const db = openPipelineDb();
|
|
17486
17279
|
let components;
|
|
17487
17280
|
const cachedDecisions = /* @__PURE__ */ new Map();
|
|
17488
|
-
const
|
|
17281
|
+
const cliVersion = await getCliCacheVersion();
|
|
17489
17282
|
const promptHash = await hashSelectPrompt(options);
|
|
17490
17283
|
try {
|
|
17491
17284
|
components = loadRawComponents(db, options.sessionId);
|
|
17492
17285
|
if (!options.noCache) {
|
|
17493
17286
|
for (const component of components) {
|
|
17494
|
-
const cached = lookupSelectCache(db, hashComponentShape(component), promptHash,
|
|
17287
|
+
const cached = lookupSelectCache(db, hashComponentShape(component), promptHash, cliVersion);
|
|
17495
17288
|
if (cached) cachedDecisions.set(component.name, { decision: cached.decision, reason: cached.reason });
|
|
17496
17289
|
}
|
|
17497
17290
|
}
|
|
@@ -17546,7 +17339,7 @@ async function runSelection(options) {
|
|
|
17546
17339
|
writeDb,
|
|
17547
17340
|
hashComponentShape(component),
|
|
17548
17341
|
promptHash,
|
|
17549
|
-
|
|
17342
|
+
cliVersion,
|
|
17550
17343
|
rejected ? "rejected" : "accepted",
|
|
17551
17344
|
rejected ? reason : null
|
|
17552
17345
|
);
|
|
@@ -17627,12 +17420,12 @@ async function runExtraction(input, onProgress, deps = realDeps) {
|
|
|
17627
17420
|
}) : null;
|
|
17628
17421
|
let selection = null;
|
|
17629
17422
|
let selectionError;
|
|
17630
|
-
const startSelection = (
|
|
17423
|
+
const startSelection = (sessionId) => {
|
|
17631
17424
|
if (selection) return;
|
|
17632
17425
|
selection = (async () => {
|
|
17633
17426
|
if (entities) await entities;
|
|
17634
17427
|
await deps.runSelection({
|
|
17635
|
-
sessionId
|
|
17428
|
+
sessionId,
|
|
17636
17429
|
agent: input.agent,
|
|
17637
17430
|
model: input.agentModel,
|
|
17638
17431
|
...selectionPrompt,
|
|
@@ -17653,7 +17446,7 @@ async function runExtraction(input, onProgress, deps = realDeps) {
|
|
|
17653
17446
|
promptOverrides: input.promptOverrides,
|
|
17654
17447
|
noCache: input.noCache,
|
|
17655
17448
|
onProgress: (event) => update(applyProgressEvent(progress, event)),
|
|
17656
|
-
onSessionCreated: (
|
|
17449
|
+
onSessionCreated: (sessionId) => startSelection(sessionId)
|
|
17657
17450
|
});
|
|
17658
17451
|
} catch (error) {
|
|
17659
17452
|
return fail("analyze extract", errorMessage2(error));
|
|
@@ -17994,11 +17787,11 @@ function CyclesPanel({ cycles, cursor }) {
|
|
|
17994
17787
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/panels/reject-prompt.tsx
|
|
17995
17788
|
import { Box as Box13, Text as Text14 } from "ink";
|
|
17996
17789
|
import { jsx as jsx16, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
17997
|
-
function RejectPrompt({ pending
|
|
17790
|
+
function RejectPrompt({ pending }) {
|
|
17998
17791
|
return /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", borderStyle: "single", borderColor: PALETTE2.warning, paddingX: 1, marginTop: 1, children: [
|
|
17999
|
-
/* @__PURE__ */ jsx16(Text14, { bold: true, color: PALETTE2.warning, children: `Rejecting ${
|
|
18000
|
-
|
|
18001
|
-
|
|
17792
|
+
/* @__PURE__ */ jsx16(Text14, { bold: true, color: PALETTE2.warning, children: `Rejecting ${pending.target} will:` }),
|
|
17793
|
+
pending.ancestors.length > 0 && /* @__PURE__ */ jsx16(Text14, { children: `- Reject ancestors: ${pending.ancestors.join(", ")}` }),
|
|
17794
|
+
pending.descendants.length > 0 && /* @__PURE__ */ jsx16(Text14, { children: `- Deselect descendants: ${pending.descendants.join(", ")}` }),
|
|
18002
17795
|
/* @__PURE__ */ jsx16(Text14, { children: "[y] confirm \xB7 [n]/[Esc] cancel" })
|
|
18003
17796
|
] });
|
|
18004
17797
|
}
|
|
@@ -18603,7 +18396,7 @@ function buildVisibleRows(props) {
|
|
|
18603
18396
|
if (visited.has(target)) continue;
|
|
18604
18397
|
visited.add(target);
|
|
18605
18398
|
const isCycleMember = cycleParticipants.has(target);
|
|
18606
|
-
out.push({ name: target, depth: cur.depth + 1, isCycleMember });
|
|
18399
|
+
out.push({ name: target, depth: cur.depth + 1, isCycleMember, parent: cur.name });
|
|
18607
18400
|
queue.push({ name: target, depth: cur.depth + 1 });
|
|
18608
18401
|
}
|
|
18609
18402
|
}
|
|
@@ -18650,7 +18443,8 @@ function buildVisibleRows(props) {
|
|
|
18650
18443
|
sharedSuffix,
|
|
18651
18444
|
cycleChild: child.isCycleMember || void 0,
|
|
18652
18445
|
itemIdx: childRec?.idx ?? -1,
|
|
18653
|
-
rootName: key
|
|
18446
|
+
rootName: key,
|
|
18447
|
+
parentName: child.parent
|
|
18654
18448
|
});
|
|
18655
18449
|
});
|
|
18656
18450
|
}
|
|
@@ -18733,13 +18527,19 @@ function buildVisibleRows(props) {
|
|
|
18733
18527
|
injectedChildren.push({
|
|
18734
18528
|
name: target,
|
|
18735
18529
|
depth: parentDepth + 1,
|
|
18736
|
-
isCycleChild: true
|
|
18530
|
+
isCycleChild: true,
|
|
18531
|
+
parent: parentName
|
|
18737
18532
|
});
|
|
18738
18533
|
}
|
|
18739
18534
|
};
|
|
18740
18535
|
emitCycleChildrenOf(root, 0);
|
|
18741
18536
|
for (const c2 of closureChildren) {
|
|
18742
|
-
injectedChildren.push({
|
|
18537
|
+
injectedChildren.push({
|
|
18538
|
+
name: c2.name,
|
|
18539
|
+
depth: c2.depth,
|
|
18540
|
+
isCycleChild: false,
|
|
18541
|
+
parent: c2.path[c2.path.length - 2] ?? root
|
|
18542
|
+
});
|
|
18743
18543
|
emitCycleChildrenOf(c2.name, c2.depth);
|
|
18744
18544
|
}
|
|
18745
18545
|
const isLastAtDepth = (idx) => {
|
|
@@ -18773,7 +18573,8 @@ function buildVisibleRows(props) {
|
|
|
18773
18573
|
sharedSuffix,
|
|
18774
18574
|
cycleChild: child.isCycleChild || void 0,
|
|
18775
18575
|
itemIdx: childRec?.idx ?? -1,
|
|
18776
|
-
rootName: root
|
|
18576
|
+
rootName: root,
|
|
18577
|
+
parentName: child.parent
|
|
18777
18578
|
});
|
|
18778
18579
|
});
|
|
18779
18580
|
}
|
|
@@ -18926,7 +18727,7 @@ function GroupedSidebar(props) {
|
|
|
18926
18727
|
const rs = itemName ? renderStatusByKey?.get(itemName) : void 0;
|
|
18927
18728
|
const badge = itemName ? previewBadge(previewAnnotationByKey?.get(itemName)) : null;
|
|
18928
18729
|
const showInheritance = rs !== void 0 && row.kind !== "cycle" && row.kind !== "empty" && row.kind !== "group-root";
|
|
18929
|
-
const supportsSelectionGlyph = selectionStateByKey !== void 0 && itemName !== void 0 && (row.kind === "standalone" || row.kind === "group-root" || row.kind === "group-child" || row.kind === "flat" || row.kind === "cycle");
|
|
18730
|
+
const supportsSelectionGlyph = selectionStateByKey !== void 0 && itemName !== void 0 && (row.kind === "standalone" || row.kind === "group-root" || row.kind === "group-child" || row.kind === "flat" || row.kind === "empty" || row.kind === "cycle");
|
|
18930
18731
|
const selState = supportsSelectionGlyph ? selectionStateByKey.get(itemName) ?? "undecided" : void 0;
|
|
18931
18732
|
const isCycleRow = row.kind === "cycle";
|
|
18932
18733
|
const selStyle = selectionGlyphStyleFor(selState, isCycleRow);
|
|
@@ -18956,7 +18757,7 @@ function GroupedSidebar(props) {
|
|
|
18956
18757
|
color: isSelected ? PALETTE2.info : labelStyle.dim ? PALETTE2.muted : labelStyle.color,
|
|
18957
18758
|
bold: isSelected || labelStyle.bold,
|
|
18958
18759
|
inverse: false,
|
|
18959
|
-
underline: isSelected &&
|
|
18760
|
+
underline: isSelected && focused,
|
|
18960
18761
|
wrap: wrapLabels ? "wrap" : "truncate",
|
|
18961
18762
|
children: [
|
|
18962
18763
|
" ",
|
|
@@ -19615,6 +19416,7 @@ function resolveKey(mode, key, ctx) {
|
|
|
19615
19416
|
function resolveMain(key, ctx) {
|
|
19616
19417
|
const { input } = key;
|
|
19617
19418
|
const inMain = ctx.focusedColumn === "main";
|
|
19419
|
+
if (key.ctrl && input === "z") return { type: "undo" };
|
|
19618
19420
|
if (input === "q" || key.escape) {
|
|
19619
19421
|
if (key.escape && ctx.jumpFilterActive) return { type: "clear-jump-filter" };
|
|
19620
19422
|
if (key.escape && ctx.searchActive) return { type: "clear-search" };
|
|
@@ -19873,21 +19675,42 @@ function rejectNeedsConfirmation(graph, name, state) {
|
|
|
19873
19675
|
const ancestors = toReject.filter((n) => n !== name);
|
|
19874
19676
|
return ancestors.length + toDeselect.length >= 2;
|
|
19875
19677
|
}
|
|
19876
|
-
function
|
|
19678
|
+
function removeSlotChild(components, edge) {
|
|
19679
|
+
return components.map(
|
|
19680
|
+
(component) => component.name === edge.parent ? {
|
|
19681
|
+
...component,
|
|
19682
|
+
slots: component.slots?.map((slot) => ({
|
|
19683
|
+
...slot,
|
|
19684
|
+
allowedComponents: slot.allowedComponents.filter((name) => name !== edge.child)
|
|
19685
|
+
}))
|
|
19686
|
+
} : component
|
|
19687
|
+
);
|
|
19688
|
+
}
|
|
19689
|
+
function withoutSlotChildren(components, removedEdges) {
|
|
19690
|
+
return removedEdges.reduce(removeSlotChild, components);
|
|
19691
|
+
}
|
|
19692
|
+
function partitionDecisions(components, state, removedEdges) {
|
|
19877
19693
|
const accepted = [];
|
|
19878
19694
|
const rejected = [];
|
|
19879
19695
|
for (const c2 of components) {
|
|
19880
19696
|
if (state.get(c2.name) === "accepted") accepted.push(c2.name);
|
|
19881
19697
|
else rejected.push(c2.name);
|
|
19882
19698
|
}
|
|
19883
|
-
|
|
19699
|
+
const rejectedNames = new Set(rejected);
|
|
19700
|
+
const excludedSlotEdges = removedEdges.filter((e) => !rejectedNames.has(e.parent) && !rejectedNames.has(e.child));
|
|
19701
|
+
return { accepted, rejected, excludedSlotEdges };
|
|
19884
19702
|
}
|
|
19885
19703
|
|
|
19886
19704
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate.ts
|
|
19887
|
-
function useScopeGate({ components, onConfirm, onQuit }) {
|
|
19705
|
+
function useScopeGate({ components: loadedComponents, onConfirm, onQuit }) {
|
|
19888
19706
|
const { columns: totalWidth, rows: terminalRows } = useTerminalSize();
|
|
19889
19707
|
const columnPlan = useMemo2(() => computeColumnWidths(totalWidth), [totalWidth]);
|
|
19890
19708
|
const [decisions, setDecisions] = useState12(/* @__PURE__ */ new Map());
|
|
19709
|
+
const [removedEdges, setRemovedEdges] = useState12([]);
|
|
19710
|
+
const components = useMemo2(
|
|
19711
|
+
() => withoutSlotChildren(loadedComponents, removedEdges),
|
|
19712
|
+
[loadedComponents, removedEdges]
|
|
19713
|
+
);
|
|
19891
19714
|
const [nav, setNav] = useState12({ cursor: 0, scrollOffset: 0 });
|
|
19892
19715
|
const [focusedColumn, setFocusedColumn] = useState12("main");
|
|
19893
19716
|
const [addedComponentsCursor, setAddedComponentsCursor] = useState12(0);
|
|
@@ -20059,6 +19882,14 @@ function useScopeGate({ components, onConfirm, onQuit }) {
|
|
|
20059
19882
|
return void 0;
|
|
20060
19883
|
}
|
|
20061
19884
|
};
|
|
19885
|
+
const focusedNestedEdge = () => {
|
|
19886
|
+
const row = visibleRows[safeCursor];
|
|
19887
|
+
if (row?.kind !== "group-child" || !row.parentName || row.itemIdx < 0) return void 0;
|
|
19888
|
+
const child = groupedItems[row.itemIdx]?.key;
|
|
19889
|
+
return child ? { parent: row.parentName, child } : void 0;
|
|
19890
|
+
};
|
|
19891
|
+
const removeFromParentSlot = (edge) => setRemovedEdges((edges) => [...edges, edge]);
|
|
19892
|
+
const undoSlotRemoval = () => setRemovedEdges((edges) => edges.slice(0, -1));
|
|
20062
19893
|
const jumpCursorTo = (name) => {
|
|
20063
19894
|
let idx = -1;
|
|
20064
19895
|
for (let i = 0; i < visibleRows.length; i++) {
|
|
@@ -20158,7 +19989,7 @@ function useScopeGate({ components, onConfirm, onQuit }) {
|
|
|
20158
19989
|
onQuit();
|
|
20159
19990
|
return;
|
|
20160
19991
|
case "confirm":
|
|
20161
|
-
onConfirm(partitionDecisions(components, decisions));
|
|
19992
|
+
onConfirm(partitionDecisions(components, decisions, removedEdges));
|
|
20162
19993
|
return;
|
|
20163
19994
|
case "close-help":
|
|
20164
19995
|
setShowHelp(false);
|
|
@@ -20211,6 +20042,11 @@ function useScopeGate({ components, onConfirm, onQuit }) {
|
|
|
20211
20042
|
return;
|
|
20212
20043
|
}
|
|
20213
20044
|
case "reject": {
|
|
20045
|
+
const edge = focusedColumn === "main" ? focusedNestedEdge() : void 0;
|
|
20046
|
+
if (edge) {
|
|
20047
|
+
removeFromParentSlot(edge);
|
|
20048
|
+
return;
|
|
20049
|
+
}
|
|
20214
20050
|
const key = focusedColumn === "added-components" ? addedComponents[safeAddedComponentsCursor]?.name : focusedRowKey();
|
|
20215
20051
|
if (key) requestReject(key);
|
|
20216
20052
|
return;
|
|
@@ -20218,6 +20054,9 @@ function useScopeGate({ components, onConfirm, onQuit }) {
|
|
|
20218
20054
|
case "toggle-all":
|
|
20219
20055
|
decide({ type: "toggle-all" });
|
|
20220
20056
|
return;
|
|
20057
|
+
case "undo":
|
|
20058
|
+
undoSlotRemoval();
|
|
20059
|
+
return;
|
|
20221
20060
|
case "accept-unflagged":
|
|
20222
20061
|
decide({ type: "accept-unflagged" });
|
|
20223
20062
|
return;
|
|
@@ -20507,11 +20346,11 @@ async function checkGenerationCache(input) {
|
|
|
20507
20346
|
}
|
|
20508
20347
|
|
|
20509
20348
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/load.ts
|
|
20510
|
-
function loadScopeGate(
|
|
20349
|
+
function loadScopeGate(sessionId) {
|
|
20511
20350
|
try {
|
|
20512
20351
|
const db = openPipelineDb();
|
|
20513
20352
|
try {
|
|
20514
|
-
const components = loadScopeComponents(db,
|
|
20353
|
+
const components = loadScopeComponents(db, sessionId);
|
|
20515
20354
|
if (components.length === 0) {
|
|
20516
20355
|
return { ok: false, message: "No components found for this session. Please run the import again." };
|
|
20517
20356
|
}
|
|
@@ -20530,8 +20369,8 @@ function loadScopeGate(sessionId2) {
|
|
|
20530
20369
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.ts
|
|
20531
20370
|
var realDeps2 = { load: loadScopeGate, checkCache: checkGenerationCache };
|
|
20532
20371
|
function useScopeGateFlow(input, deps = realDeps2) {
|
|
20533
|
-
const
|
|
20534
|
-
const loaded = useMemo3(() =>
|
|
20372
|
+
const sessionId = input?.sessionId;
|
|
20373
|
+
const loaded = useMemo3(() => sessionId ? deps.load(sessionId) : void 0, [sessionId]);
|
|
20535
20374
|
const cacheCheck = useRef5(void 0);
|
|
20536
20375
|
const [confirmed, setConfirmed] = useState13();
|
|
20537
20376
|
useEffect8(() => {
|
|
@@ -20708,7 +20547,7 @@ async function runGeneration(input, onProgress, deps = realDeps3) {
|
|
|
20708
20547
|
update({ mapTokens: "running" });
|
|
20709
20548
|
try {
|
|
20710
20549
|
const mapTokensOptions = await buildMapTokensOptions(input);
|
|
20711
|
-
|
|
20550
|
+
await deps.runMapTokens({
|
|
20712
20551
|
sessionId: input.sessionId,
|
|
20713
20552
|
agent: input.agent,
|
|
20714
20553
|
...input.agentModel ? { model: input.agentModel } : {},
|
|
@@ -20716,11 +20555,6 @@ async function runGeneration(input, onProgress, deps = realDeps3) {
|
|
|
20716
20555
|
skillPathOverride: MAP_TOKENS_SKILL_PATH,
|
|
20717
20556
|
...mapTokensOptions
|
|
20718
20557
|
});
|
|
20719
|
-
if (mapResult.diagnostics.length > 0) {
|
|
20720
|
-
process.stderr.write(`Unresolved token defaults:
|
|
20721
|
-
${mapResult.diagnostics.map((d) => ` ${d}`).join("\n")}
|
|
20722
|
-
`);
|
|
20723
|
-
}
|
|
20724
20558
|
} catch (error) {
|
|
20725
20559
|
const message = error instanceof MapTokensRunFailure ? error.message : error instanceof Error ? error.message : String(error);
|
|
20726
20560
|
return fail2("map tokens", message);
|
|
@@ -22865,8 +22699,8 @@ function FieldEditor({
|
|
|
22865
22699
|
return /* @__PURE__ */ jsxs22(Box21, { flexDirection: "column", width, borderStyle: "single", borderColor: PALETTE3.warning, children: [
|
|
22866
22700
|
/* @__PURE__ */ jsx27(Text23, { bold: true, color: PALETTE3.warning, children: "FIELD EDITOR \u2014 no fields" }),
|
|
22867
22701
|
/* @__PURE__ */ jsx27(Text23, { color: PALETTE3.warning, children: "\u26A0 No properties classified for this component. The LLM didn't find anything to classify." }),
|
|
22868
|
-
/* @__PURE__ */ jsx27(Text23, { color: PALETTE3.muted, children: "
|
|
22869
|
-
/* @__PURE__ */ jsx27(Text23, { color: PALETTE3.muted, children: "
|
|
22702
|
+
/* @__PURE__ */ jsx27(Text23, { color: PALETTE3.muted, children: "There is nothing to edit here." }),
|
|
22703
|
+
/* @__PURE__ */ jsx27(Text23, { color: PALETTE3.muted, children: active ? "[Esc] go back to the list" : "In the list: [r] reject this component \xB7 [a] accept it" })
|
|
22870
22704
|
] });
|
|
22871
22705
|
}
|
|
22872
22706
|
const hasEmptyProperties = props.length === 0 && slots.length === 0;
|
|
@@ -23081,7 +22915,7 @@ function FieldEditor({
|
|
|
23081
22915
|
children: [
|
|
23082
22916
|
hasEmptyProperties && /* @__PURE__ */ jsx27(Text23, { color: PALETTE3.warning, children: "\u26A0 No properties classified for this component. The LLM didn't find anything to classify. Reject this component or add fields manually." }),
|
|
23083
22917
|
header,
|
|
23084
|
-
/* @__PURE__ */ jsx27(Box21, { flexDirection: "column", width: innerWidth, flexShrink: 0, children: focusLevel === "field" && !inComponentDesc && currentProp ? /* @__PURE__ */ jsx27(
|
|
22918
|
+
/* @__PURE__ */ jsx27(Box21, { flexDirection: "column", width: innerWidth, flexShrink: 0, children: focusLevel === "field" && !inComponentDesc && !inSlots && currentProp ? /* @__PURE__ */ jsx27(
|
|
23085
22919
|
PropRow,
|
|
23086
22920
|
{
|
|
23087
22921
|
prop: currentProp,
|
|
@@ -23990,6 +23824,7 @@ function finalizeReviewSession(extractSessionId, components) {
|
|
|
23990
23824
|
db.exec("ROLLBACK");
|
|
23991
23825
|
throw error;
|
|
23992
23826
|
}
|
|
23827
|
+
removeSlotAllowedComponents(db, extractSessionId, [], toReject);
|
|
23993
23828
|
} finally {
|
|
23994
23829
|
db.close();
|
|
23995
23830
|
}
|
|
@@ -24069,17 +23904,17 @@ var TimeoutError = class extends Error {
|
|
|
24069
23904
|
};
|
|
24070
23905
|
var DEFAULT_TIMEOUT_MS6 = 15e3;
|
|
24071
23906
|
async function runLivePreview(opts) {
|
|
24072
|
-
const { sessionId
|
|
23907
|
+
const { sessionId, tokensPath, spaceId, environmentId, cmaToken, host, generation } = opts;
|
|
24073
23908
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS6;
|
|
24074
23909
|
if (!spaceId || !environmentId || !cmaToken) {
|
|
24075
23910
|
return { generation, response: null };
|
|
24076
23911
|
}
|
|
24077
23912
|
let components = [];
|
|
24078
|
-
if (
|
|
23913
|
+
if (sessionId) {
|
|
24079
23914
|
const db = openPipelineDb();
|
|
24080
23915
|
try {
|
|
24081
|
-
backfillUnclassifiedProps(db,
|
|
24082
|
-
components = loadCDFComponents(db,
|
|
23916
|
+
backfillUnclassifiedProps(db, sessionId);
|
|
23917
|
+
components = loadCDFComponents(db, sessionId);
|
|
24083
23918
|
} finally {
|
|
24084
23919
|
db.close();
|
|
24085
23920
|
}
|
|
@@ -24996,7 +24831,7 @@ function useReviewPreview({
|
|
|
24996
24831
|
components,
|
|
24997
24832
|
loading,
|
|
24998
24833
|
livePreview,
|
|
24999
|
-
sessionId
|
|
24834
|
+
sessionId,
|
|
25000
24835
|
tokensPath,
|
|
25001
24836
|
spaceId,
|
|
25002
24837
|
environmentId,
|
|
@@ -25023,7 +24858,7 @@ function useReviewPreview({
|
|
|
25023
24858
|
);
|
|
25024
24859
|
const livePreviewHook = useLivePreview({
|
|
25025
24860
|
enabled: livePreview,
|
|
25026
|
-
sessionId
|
|
24861
|
+
sessionId,
|
|
25027
24862
|
tokensPath,
|
|
25028
24863
|
spaceId,
|
|
25029
24864
|
environmentId,
|
|
@@ -25311,7 +25146,7 @@ function GenerateReviewStepView({
|
|
|
25311
25146
|
() => loadReviewSessionState({
|
|
25312
25147
|
extractSessionId,
|
|
25313
25148
|
tokenSessionId,
|
|
25314
|
-
loadExtra: (db,
|
|
25149
|
+
loadExtra: (db, sessionId) => loadSlotCycles(db, sessionId),
|
|
25315
25150
|
sortEntries: (entries, cycles) => {
|
|
25316
25151
|
const cycleParticipants = /* @__PURE__ */ new Set();
|
|
25317
25152
|
for (const cycle of cycles ?? []) {
|
|
@@ -25721,33 +25556,50 @@ function GenerateReviewStepView({
|
|
|
25721
25556
|
const cycle = cycleRows[cyclesCursor];
|
|
25722
25557
|
return cycle ? enumerateCycleBreaks(cycle, components) : [];
|
|
25723
25558
|
}, [cycleRows, cyclesCursor, components]);
|
|
25724
|
-
const
|
|
25725
|
-
const target = components.find((component) => component.key === edge.fromComponent);
|
|
25726
|
-
const slot = target?.entry.$slots?.[edge.slotName];
|
|
25727
|
-
if (!target || !slot || !Array.isArray(slot.$allowedComponents)) return;
|
|
25728
|
-
const nextEntry = {
|
|
25729
|
-
...target.entry,
|
|
25730
|
-
$slots: {
|
|
25731
|
-
...target.entry.$slots,
|
|
25732
|
-
[edge.slotName]: {
|
|
25733
|
-
...slot,
|
|
25734
|
-
$allowedComponents: slot.$allowedComponents.filter((value) => value !== edge.toComponent)
|
|
25735
|
-
}
|
|
25736
|
-
}
|
|
25737
|
-
};
|
|
25559
|
+
const saveSlotChange = (parentKey, nextEntry, historyLabel) => {
|
|
25738
25560
|
const next = components.map(
|
|
25739
|
-
(component) => component.key ===
|
|
25561
|
+
(component) => component.key === parentKey ? { ...component, entry: nextEntry } : component
|
|
25740
25562
|
);
|
|
25741
25563
|
setComponents(next);
|
|
25742
25564
|
const db = openPipelineDb();
|
|
25743
25565
|
try {
|
|
25744
|
-
storeCDFComponents(db, extractSessionId, [{ key:
|
|
25566
|
+
storeCDFComponents(db, extractSessionId, [{ key: parentKey, entry: nextEntry }]);
|
|
25745
25567
|
} finally {
|
|
25746
25568
|
db.close();
|
|
25747
25569
|
}
|
|
25748
25570
|
recomputeCycles(next);
|
|
25749
25571
|
livePreviewHook.trigger();
|
|
25750
|
-
pushHistorySnapshot(next,
|
|
25572
|
+
pushHistorySnapshot(next, historyLabel);
|
|
25573
|
+
};
|
|
25574
|
+
const handleBreakEdge = (edge) => {
|
|
25575
|
+
const target = components.find((component) => component.key === edge.fromComponent);
|
|
25576
|
+
const slot = target?.entry.$slots?.[edge.slotName];
|
|
25577
|
+
if (!target || !slot || !Array.isArray(slot.$allowedComponents)) return;
|
|
25578
|
+
saveSlotChange(
|
|
25579
|
+
target.key,
|
|
25580
|
+
{
|
|
25581
|
+
...target.entry,
|
|
25582
|
+
$slots: {
|
|
25583
|
+
...target.entry.$slots,
|
|
25584
|
+
[edge.slotName]: {
|
|
25585
|
+
...slot,
|
|
25586
|
+
$allowedComponents: slot.$allowedComponents.filter((value) => value !== edge.toComponent)
|
|
25587
|
+
}
|
|
25588
|
+
}
|
|
25589
|
+
},
|
|
25590
|
+
"break-cycle-edge"
|
|
25591
|
+
);
|
|
25592
|
+
};
|
|
25593
|
+
const handleRemoveSlotChild = (parentKey, childKey) => {
|
|
25594
|
+
const parent = components.find((component) => component.key === parentKey);
|
|
25595
|
+
if (!parent?.entry.$slots) return;
|
|
25596
|
+
const slots = Object.fromEntries(
|
|
25597
|
+
Object.entries(parent.entry.$slots).map(([slotName, slot]) => [
|
|
25598
|
+
slotName,
|
|
25599
|
+
Array.isArray(slot.$allowedComponents) ? { ...slot, $allowedComponents: slot.$allowedComponents.filter((value) => value !== childKey) } : slot
|
|
25600
|
+
])
|
|
25601
|
+
);
|
|
25602
|
+
saveSlotChange(parentKey, { ...parent.entry, $slots: slots }, "remove-slot-child");
|
|
25751
25603
|
};
|
|
25752
25604
|
const handleRejectComponent = (key) => {
|
|
25753
25605
|
const rejectCascade2 = computeRejectCascade(key, componentGraph);
|
|
@@ -26077,6 +25929,11 @@ function GenerateReviewStepView({
|
|
|
26077
25929
|
if (input === "r") {
|
|
26078
25930
|
const current = components[selectedIdx];
|
|
26079
25931
|
if (!current) return;
|
|
25932
|
+
const row = visibleRowsMemo[cursorRowIdx];
|
|
25933
|
+
if (row?.kind === "group-child" && row.parentName) {
|
|
25934
|
+
handleRemoveSlotChild(row.parentName, current.key);
|
|
25935
|
+
return;
|
|
25936
|
+
}
|
|
26080
25937
|
handleRejectComponent(current.key);
|
|
26081
25938
|
return;
|
|
26082
25939
|
}
|
|
@@ -27837,10 +27694,10 @@ function realFlowDeps() {
|
|
|
27837
27694
|
preview: realPreviewDeps(),
|
|
27838
27695
|
push: realPushDeps(log),
|
|
27839
27696
|
save: realSaveDeps(),
|
|
27840
|
-
loadAcceptedComponents: (
|
|
27697
|
+
loadAcceptedComponents: (sessionId) => {
|
|
27841
27698
|
const db = openPipelineDb();
|
|
27842
27699
|
try {
|
|
27843
|
-
return loadCDFComponents(db,
|
|
27700
|
+
return loadCDFComponents(db, sessionId);
|
|
27844
27701
|
} finally {
|
|
27845
27702
|
db.close();
|
|
27846
27703
|
}
|
|
@@ -28865,9 +28722,9 @@ function App({ importOptions, inkClear }) {
|
|
|
28865
28722
|
}
|
|
28866
28723
|
await startExtraction(launch, "generate", result);
|
|
28867
28724
|
};
|
|
28868
|
-
const chooseTokenStrategy = (
|
|
28725
|
+
const chooseTokenStrategy = (pending, tokenStrategy) => {
|
|
28869
28726
|
setPendingLaunch(void 0);
|
|
28870
|
-
void startExtraction(
|
|
28727
|
+
void startExtraction(pending.launch, tokenStrategy, pending.credentials);
|
|
28871
28728
|
};
|
|
28872
28729
|
const startExtraction = async (launch, tokenStrategy, credentials) => {
|
|
28873
28730
|
const settings = await readSettings2();
|