@context-forge/core 0.6.40 → 0.6.41
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.
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
* Profiles declare which artifact variables each instruction type uses,
|
|
4
4
|
* enabling profile-aware filtering in ContextIntegrator.
|
|
5
5
|
*/
|
|
6
|
-
export type ProfileMap = Record<string,
|
|
7
|
-
variables: string[];
|
|
8
|
-
}>;
|
|
6
|
+
export type ProfileMap = Record<string, string[]>;
|
|
9
7
|
export declare class ContextProfileParser {
|
|
10
8
|
/**
|
|
11
9
|
* Finds and parses the context-profiles YAML block from file content.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextProfileParser.d.ts","sourceRoot":"","sources":["../../src/services/ContextProfileParser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE
|
|
1
|
+
{"version":3,"file":"ContextProfileParser.d.ts","sourceRoot":"","sources":["../../src/services/ContextProfileParser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAuHlD,qBAAa,oBAAoB;IAC/B;;;OAGG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU;IAyB9C;;;;;OAKG;IACH,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,MAAM,EAAE;IAgB7E,OAAO,CAAC,oBAAoB;CAI7B"}
|
|
@@ -5,38 +5,67 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/** Key identifying the context-profiles block; works with any yaml fence annotation */
|
|
7
7
|
const PROFILE_KEY = 'context_profiles:\n';
|
|
8
|
+
/** Matches a bracket-delimited list: [a, b, c] or [] */
|
|
9
|
+
const BRACKET_LIST = /\[([^\]]*)\]/;
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Parses the context_profiles YAML block into a ProfileMap.
|
|
12
|
+
*
|
|
13
|
+
* Handles two layout styles without relying on indent depth:
|
|
14
|
+
*
|
|
15
|
+
* Compact (one-liner):
|
|
16
|
+
* profile-name: [var1, var2]
|
|
17
|
+
*
|
|
18
|
+
* Expanded (two-liner):
|
|
19
|
+
* profile-name:
|
|
20
|
+
* variables: [var1, var2]
|
|
21
|
+
*
|
|
22
|
+
* The parser uses a simple state machine: when it sees a line with a
|
|
23
|
+
* key (word-chars + hyphens) followed by a colon, it checks whether
|
|
24
|
+
* the same line also contains a bracket list. If so, that's a compact
|
|
25
|
+
* profile. If not, it remembers the key and looks for a bracket list
|
|
26
|
+
* on a subsequent indented line.
|
|
14
27
|
*/
|
|
15
28
|
function parseProfilesYaml(yaml) {
|
|
16
29
|
const result = {};
|
|
17
30
|
const lines = yaml.split('\n');
|
|
18
|
-
|
|
31
|
+
// Pending profile name from a multi-line entry (e.g. " profile-name:")
|
|
32
|
+
let pendingProfile = null;
|
|
19
33
|
for (const rawLine of lines) {
|
|
20
34
|
const line = rawLine.trimEnd();
|
|
21
|
-
//
|
|
22
|
-
if (
|
|
35
|
+
// Skip the top-level header key
|
|
36
|
+
if (/^\s*context[_-]profiles:\s*$/.test(line))
|
|
23
37
|
continue;
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
if (profileMatch) {
|
|
27
|
-
currentProfile = profileMatch[1];
|
|
28
|
-
result[currentProfile] = { variables: [] };
|
|
38
|
+
// Skip blank lines
|
|
39
|
+
if (line.trim() === '')
|
|
29
40
|
continue;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
// Try to extract a key (word-chars/hyphens after leading whitespace, before colon)
|
|
42
|
+
const keyMatch = line.match(/^\s+([\w-]+):\s*(.*)/);
|
|
43
|
+
if (keyMatch) {
|
|
44
|
+
const key = keyMatch[1];
|
|
45
|
+
const rest = keyMatch[2];
|
|
46
|
+
// Does this line also have a bracket list?
|
|
47
|
+
const listMatch = rest.match(BRACKET_LIST);
|
|
48
|
+
if (listMatch) {
|
|
49
|
+
// Compact format OR expanded "variables: [...]" line
|
|
50
|
+
const vars = listMatch[1].split(',').map((v) => v.trim()).filter(Boolean);
|
|
51
|
+
if (key === 'variables' && pendingProfile) {
|
|
52
|
+
// Expanded: assign to the pending profile
|
|
53
|
+
result[pendingProfile] = vars;
|
|
54
|
+
pendingProfile = null;
|
|
55
|
+
}
|
|
56
|
+
else if (key !== 'variables') {
|
|
57
|
+
// Compact: key IS the profile name
|
|
58
|
+
result[key] = vars;
|
|
59
|
+
pendingProfile = null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
// No bracket list — this is a multi-line profile header
|
|
64
|
+
// (ignore 'variables' without a list, which shouldn't happen)
|
|
65
|
+
if (key !== 'variables') {
|
|
66
|
+
pendingProfile = key;
|
|
67
|
+
result[key] = [];
|
|
68
|
+
}
|
|
40
69
|
}
|
|
41
70
|
}
|
|
42
71
|
}
|
|
@@ -103,7 +132,7 @@ export class ContextProfileParser {
|
|
|
103
132
|
const yamlContent = fileContent.slice(contentStart, fenceEnd);
|
|
104
133
|
const parsed = parseProfilesYaml(yamlContent);
|
|
105
134
|
// Validate: must have at least one profile with variables
|
|
106
|
-
const hasProfiles = Object.values(parsed).some((
|
|
135
|
+
const hasProfiles = Object.values(parsed).some((vars) => vars.length > 0);
|
|
107
136
|
return hasProfiles ? parsed : {};
|
|
108
137
|
}
|
|
109
138
|
catch {
|
|
@@ -121,10 +150,10 @@ export class ContextProfileParser {
|
|
|
121
150
|
return [];
|
|
122
151
|
const normalised = this.normaliseInstruction(instruction);
|
|
123
152
|
if (profiles[normalised]) {
|
|
124
|
-
return profiles[normalised]
|
|
153
|
+
return profiles[normalised];
|
|
125
154
|
}
|
|
126
155
|
if (profiles['_default']) {
|
|
127
|
-
return profiles['_default']
|
|
156
|
+
return profiles['_default'];
|
|
128
157
|
}
|
|
129
158
|
return [];
|
|
130
159
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextProfileParser.js","sourceRoot":"","sources":["../../src/services/ContextProfileParser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,uFAAuF;AACvF,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAE1C
|
|
1
|
+
{"version":3,"file":"ContextProfileParser.js","sourceRoot":"","sources":["../../src/services/ContextProfileParser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,uFAAuF;AACvF,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAE1C,wDAAwD;AACxD,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAS,iBAAiB,CAAC,IAAY;IACrC,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/B,wEAAwE;IACxE,IAAI,cAAc,GAAkB,IAAI,CAAC;IAEzC,KAAK,MAAM,OAAO,IAAI,KAAK,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAE/B,gCAAgC;QAChC,IAAI,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,SAAS;QAExD,mBAAmB;QACnB,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,SAAS;QAEjC,mFAAmF;QACnF,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAEpD,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YACxB,MAA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