wendkeep 0.61.0 → 0.63.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.
@@ -1,133 +1 @@
1
- export const OPERATING_PROFILES = Object.freeze([
2
- 'OFF',
3
- 'FLOW',
4
- 'GUIDE',
5
- 'GOVERN',
6
- 'ASSURE',
7
- ]);
8
- export const DEFAULT_OPERATING_PROFILE = 'GOVERN';
9
-
10
- const PROFILE_SET = new Set(OPERATING_PROFILES);
11
-
12
- function policy(profile, route, options) {
13
- return Object.freeze({
14
- profile,
15
- route: Object.freeze(route),
16
- keepCore: true,
17
- ...options,
18
- });
19
- }
20
-
21
- export const OPERATING_PROFILE_POLICIES = Object.freeze({
22
- OFF: policy('OFF', ['LLM'], {
23
- harness: false,
24
- contract: 'native',
25
- requiresChange: false,
26
- requiresReview: false,
27
- requiresConfirmation: false,
28
- }),
29
- FLOW: policy('FLOW', ['E', 'V'], {
30
- harness: true,
31
- contract: 'flow',
32
- requiresChange: false,
33
- requiresReview: false,
34
- requiresConfirmation: false,
35
- }),
36
- GUIDE: policy('GUIDE', ['P', 'E', 'V'], {
37
- harness: true,
38
- contract: 'simple-change',
39
- requiresChange: true,
40
- requiresReview: false,
41
- requiresConfirmation: false,
42
- }),
43
- GOVERN: policy('GOVERN', ['P', 'R', 'E', 'V'], {
44
- harness: true,
45
- contract: 'change',
46
- requiresChange: true,
47
- requiresReview: true,
48
- requiresConfirmation: false,
49
- }),
50
- ASSURE: policy('ASSURE', ['P', 'R', 'E', 'V', 'C'], {
51
- harness: true,
52
- contract: 'change',
53
- requiresChange: true,
54
- requiresReview: true,
55
- requiresConfirmation: true,
56
- }),
57
- });
58
-
59
- function invalidProfileError(value) {
60
- const rendered = typeof value === 'string' ? `"${value}"` : String(value);
61
- const error = new Error(
62
- `Perfil de Operação inválido: ${rendered}. Use ${OPERATING_PROFILES.join(', ')}.`,
63
- );
64
- error.code = 'WENDKEEP_OPERATING_PROFILE_INVALID';
65
- return error;
66
- }
67
-
68
- function canonicalProfile(value) {
69
- if (typeof value !== 'string') return '';
70
- return value.trim().toUpperCase();
71
- }
72
-
73
- export function normalizeOperatingProfile(value, { strict = false } = {}) {
74
- const normalized = canonicalProfile(value);
75
- if (PROFILE_SET.has(normalized)) return normalized;
76
- if (strict) throw invalidProfileError(value);
77
- return DEFAULT_OPERATING_PROFILE;
78
- }
79
-
80
- export function resolveOperatingProfile(config = {}) {
81
- const harness = config && typeof config === 'object' && !Array.isArray(config)
82
- && config.harness && typeof config.harness === 'object' && !Array.isArray(config.harness)
83
- ? config.harness
84
- : null;
85
- const configured = !!harness && Object.prototype.hasOwnProperty.call(harness, 'profile');
86
- if (!configured) {
87
- return {
88
- profile: DEFAULT_OPERATING_PROFILE,
89
- source: 'default',
90
- valid: true,
91
- configured: false,
92
- raw: null,
93
- };
94
- }
95
-
96
- const raw = harness.profile;
97
- const normalized = canonicalProfile(raw);
98
- if (PROFILE_SET.has(normalized)) {
99
- return {
100
- profile: normalized,
101
- source: 'project-binding',
102
- valid: true,
103
- configured: true,
104
- raw,
105
- };
106
- }
107
- return {
108
- profile: DEFAULT_OPERATING_PROFILE,
109
- source: 'default-invalid',
110
- valid: false,
111
- configured: true,
112
- raw,
113
- };
114
- }
115
-
116
- export function operatingProfilePolicy(value) {
117
- return OPERATING_PROFILE_POLICIES[normalizeOperatingProfile(value)];
118
- }
119
-
120
- export function setOperatingProfile(config = {}, value) {
121
- const profile = normalizeOperatingProfile(value, { strict: true });
122
- const base = config && typeof config === 'object' && !Array.isArray(config) ? config : {};
123
- const harness = base.harness && typeof base.harness === 'object' && !Array.isArray(base.harness)
124
- ? base.harness
125
- : {};
126
- return {
127
- ...base,
128
- harness: {
129
- ...harness,
130
- profile,
131
- },
132
- };
133
- }
1
+ export * from '../packages/harness/src/operating-profile.mjs';