@kubbisec/ai-win32-x64 0.1.21 → 0.1.22

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.
Files changed (130) hide show
  1. package/bundled/clarify/clarify-gate-state.d.ts +1 -1
  2. package/bundled/clarify/clarify-gate-state.js +3 -3
  3. package/bundled/clarify/clarify-gate.d.ts +21 -14
  4. package/bundled/clarify/clarify-gate.js +118 -111
  5. package/bundled/clarify/clarify-select-panel.d.ts +16 -9
  6. package/bundled/clarify/clarify-select-panel.js +65 -67
  7. package/bundled/clarify/clarify-ui-state.d.ts +12 -10
  8. package/bundled/clarify/clarify-ui-state.js +26 -26
  9. package/bundled/clarify/parse-clarify-answer.d.ts +29 -18
  10. package/bundled/clarify/parse-clarify-answer.js +39 -45
  11. package/bundled/clarify/question-format.d.ts +34 -23
  12. package/bundled/clarify/question-format.js +112 -119
  13. package/bundled/clarify/questionnaire-tool.d.ts +28 -17
  14. package/bundled/clarify/questionnaire-tool.js +180 -144
  15. package/bundled/clarify/scope-discovery.d.ts +8 -5
  16. package/bundled/clarify/scope-discovery.js +102 -110
  17. package/bundled/clarify/session-questionnaire.d.ts +48 -13
  18. package/bundled/clarify/session-questionnaire.js +304 -312
  19. package/bundled/clarify/session-questionnaire.types.d.ts +29 -27
  20. package/bundled/clarify/session-questionnaire.types.js +10 -10
  21. package/bundled/components/kubbisec-model-selector.d.ts +47 -34
  22. package/bundled/components/kubbisec-model-selector.js +187 -177
  23. package/bundled/config/config.d.ts +6 -6
  24. package/bundled/config/config.js +55 -55
  25. package/bundled/config/detect-local-llm-providers.d.ts +26 -16
  26. package/bundled/config/detect-local-llm-providers.js +130 -142
  27. package/bundled/config/ensure-kubbisec-project-settings.d.ts +9 -9
  28. package/bundled/config/ensure-kubbisec-project-settings.js +44 -48
  29. package/bundled/config/extended-context.d.ts +5 -6
  30. package/bundled/config/extended-context.js +23 -22
  31. package/bundled/config/feature-flags.d.ts +10 -2
  32. package/bundled/config/feature-flags.js +8 -2
  33. package/bundled/config/format-kubbisec-footer-status.d.ts +1 -1
  34. package/bundled/config/format-kubbisec-footer-status.js +26 -31
  35. package/bundled/config/kubbisec-extension-manifest.d.ts +22 -2
  36. package/bundled/config/kubbisec-extension-manifest.js +20 -20
  37. package/bundled/config/llm-config-mutations.d.ts +51 -25
  38. package/bundled/config/llm-config-mutations.js +173 -182
  39. package/bundled/config/llm-config.d.ts +54 -41
  40. package/bundled/config/llm-config.js +199 -199
  41. package/bundled/config/llm-provider-catalog.d.ts +18 -15
  42. package/bundled/config/llm-provider-catalog.js +45 -46
  43. package/bundled/config/materialize-kubbisec-pi-resources.d.ts +1 -1
  44. package/bundled/config/materialize-kubbisec-pi-resources.js +174 -183
  45. package/bundled/config/register-custom-llm-providers.d.ts +11 -5
  46. package/bundled/config/register-custom-llm-providers.js +17 -15
  47. package/bundled/config/register-kubbisec-llm-provider.d.ts +14 -10
  48. package/bundled/config/register-kubbisec-llm-provider.js +50 -42
  49. package/bundled/config/resolve-agents-context-file.d.ts +1 -1
  50. package/bundled/config/resolve-agents-context-file.js +33 -34
  51. package/bundled/config/resource-budget.d.ts +12 -12
  52. package/bundled/config/resource-budget.js +28 -28
  53. package/bundled/config/sync-kubbisec-pi-models.d.ts +6 -3
  54. package/bundled/config/sync-kubbisec-pi-models.js +58 -58
  55. package/bundled/copy/cli-reference-index.d.ts +3 -2
  56. package/bundled/copy/cli-reference-index.js +1 -1
  57. package/bundled/copy/kubbisec-shell-copy.d.ts +11 -6
  58. package/bundled/copy/kubbisec-shell-copy.js +1 -1
  59. package/bundled/extensions/cli-local-shared.d.ts +45 -26
  60. package/bundled/extensions/cli-local-shared.js +128 -118
  61. package/bundled/extensions/kubbisec-aspm-local.extension.d.ts +18 -15
  62. package/bundled/extensions/kubbisec-aspm-local.extension.js +118 -114
  63. package/bundled/extensions/kubbisec-brand.extension.d.ts +1 -1
  64. package/bundled/extensions/kubbisec-brand.extension.js +25 -25
  65. package/bundled/extensions/kubbisec-byok-provider.extension.d.ts +1 -1
  66. package/bundled/extensions/kubbisec-byok-provider.extension.js +2 -2
  67. package/bundled/extensions/kubbisec-clarify.extension.d.ts +64 -35
  68. package/bundled/extensions/kubbisec-clarify.extension.js +323 -305
  69. package/bundled/extensions/kubbisec-exit.extension.d.ts +1 -1
  70. package/bundled/extensions/kubbisec-exit.extension.js +29 -32
  71. package/bundled/extensions/kubbisec-extended-context.extension.d.ts +1 -1
  72. package/bundled/extensions/kubbisec-extended-context.extension.js +56 -43
  73. package/bundled/extensions/kubbisec-footer.extension.d.ts +14 -14
  74. package/bundled/extensions/kubbisec-footer.extension.js +205 -215
  75. package/bundled/extensions/kubbisec-github-local.extension.d.ts +26 -18
  76. package/bundled/extensions/kubbisec-github-local.extension.js +123 -116
  77. package/bundled/extensions/kubbisec-llm-config.extension.d.ts +1 -1
  78. package/bundled/extensions/kubbisec-llm-config.extension.js +200 -181
  79. package/bundled/extensions/kubbisec-memory.extension.d.ts +9 -7
  80. package/bundled/extensions/kubbisec-memory.extension.js +88 -95
  81. package/bundled/extensions/kubbisec-naus-local.extension.d.ts +18 -15
  82. package/bundled/extensions/kubbisec-naus-local.extension.js +132 -111
  83. package/bundled/extensions/kubbisec-platform-tools.extension.d.ts +31 -21
  84. package/bundled/extensions/kubbisec-platform-tools.extension.js +152 -152
  85. package/bundled/extensions/kubbisec-runtime-status.extension.d.ts +10 -8
  86. package/bundled/extensions/kubbisec-runtime-status.extension.js +15 -13
  87. package/bundled/extensions/kubbisec-scope.extension.d.ts +12 -7
  88. package/bundled/extensions/kubbisec-scope.extension.js +13 -13
  89. package/bundled/extensions/kubbisec-skill-mentions.extension.d.ts +27 -16
  90. package/bundled/extensions/kubbisec-skill-mentions.extension.js +73 -63
  91. package/bundled/extensions/kubbisec-skill-telemetry.extension.d.ts +2 -3
  92. package/bundled/extensions/kubbisec-skill-telemetry.extension.js +59 -64
  93. package/bundled/extensions/kubbisec-theme-lock.extension.d.ts +1 -1
  94. package/bundled/extensions/kubbisec-theme-lock.extension.js +33 -34
  95. package/bundled/extensions/kubbisec-ui.extension.d.ts +1 -1
  96. package/bundled/extensions/kubbisec-ui.extension.js +114 -109
  97. package/bundled/extensions/kubbisec-workflow.extension.d.ts +20 -18
  98. package/bundled/extensions/kubbisec-workflow.extension.js +138 -140
  99. package/bundled/node_modules/@aspm/shared/dist/redaction.test.d.ts +2 -0
  100. package/bundled/node_modules/@aspm/shared/dist/redaction.test.d.ts.map +1 -0
  101. package/bundled/node_modules/@aspm/shared/dist/redaction.test.js +626 -0
  102. package/bundled/node_modules/@aspm/shared/dist/redaction.test.js.map +1 -0
  103. package/bundled/resolve-bundled-dist-root.js +122 -131
  104. package/bundled/skills/at-path-mentions.d.ts +1 -1
  105. package/bundled/skills/at-path-mentions.js +146 -153
  106. package/bundled/skills/chat-mention-render.d.ts +2 -2
  107. package/bundled/skills/chat-mention-render.js +121 -126
  108. package/bundled/skills/chat-mentions.d.ts +17 -8
  109. package/bundled/skills/chat-mentions.js +76 -76
  110. package/bundled/skills/list-bundled-skills.d.ts +3 -3
  111. package/bundled/skills/list-bundled-skills.js +33 -35
  112. package/bundled/skills/skill-mention.d.ts +10 -2
  113. package/bundled/skills/skill-mention.js +10 -2
  114. package/bundled/theme/clear-terminal.d.ts +1 -1
  115. package/bundled/theme/clear-terminal.js +3 -4
  116. package/bundled/theme/footer-render-hook.d.ts +1 -1
  117. package/bundled/theme/footer-render-hook.js +3 -3
  118. package/bundled/theme/kubbisec-brand-fg.d.ts +1 -1
  119. package/bundled/theme/kubbisec-brand-fg.js +2 -2
  120. package/bundled/theme/kubbisec-menu-themes.d.ts +7 -7
  121. package/bundled/theme/kubbisec-menu-themes.js +30 -31
  122. package/bundled/theme/kubbisec-theme-name.d.ts +1 -1
  123. package/bundled/theme/kubbisec-theme-name.js +1 -1
  124. package/bundled/theme/patch-pi-settings-theme.runtime.d.ts +1 -1
  125. package/bundled/theme/patch-pi-settings-theme.runtime.js +11 -10
  126. package/bundled/theme/render-compact-header.d.ts +13 -5
  127. package/bundled/theme/render-compact-header.js +127 -129
  128. package/bundled/workflow/session-workflow-mode.d.ts +1 -1
  129. package/bundled/workflow/session-workflow-mode.js +33 -33
  130. package/package.json +1 -1
@@ -1,3 +1,3 @@
1
1
  export declare function setClarifyGateActive(active: boolean): void;
2
2
  export declare function isClarifyGateActive(): boolean;
3
- //# sourceMappingURL=clarify-gate-state.d.ts.map
3
+ //# sourceMappingURL=clarify-gate-state.d.ts.map
@@ -1,9 +1,9 @@
1
1
  /** Shared gate flag for skill router and extensions. */
2
2
  let gateActive = false;
3
3
  export function setClarifyGateActive(active) {
4
- gateActive = active;
4
+ gateActive = active;
5
5
  }
6
6
  export function isClarifyGateActive() {
7
- return gateActive;
7
+ return gateActive;
8
8
  }
9
- //# sourceMappingURL=clarify-gate-state.js.map
9
+ //# sourceMappingURL=clarify-gate-state.js.map
@@ -1,20 +1,27 @@
1
- import type { QuestionnaireScenario, SessionQuestionnaireFields } from "./session-questionnaire.types.js";
1
+ import type {
2
+ QuestionnaireScenario,
3
+ SessionQuestionnaireFields,
4
+ } from "./session-questionnaire.types.js";
2
5
  export type ClarifySurface = "chat" | "fix" | "watch" | "task-consumer";
3
6
  export type ClarifyIntent = "factual" | "execute" | "ambiguous";
4
7
  export type ClarifyGateInput = {
5
- surface: ClarifySurface;
6
- userMessage: string;
7
- hasProjectId: boolean;
8
- hasVulnerabilityId: boolean;
9
- hasSeverityFilter: boolean;
10
- mode?: "plan" | "default";
11
- scenario?: QuestionnaireScenario | null;
12
- questionnaireStatus?: "collecting" | "ready";
13
- fields?: SessionQuestionnaireFields;
14
- historyCount?: number;
15
- clarifyMaxRounds?: number;
8
+ surface: ClarifySurface;
9
+ userMessage: string;
10
+ hasProjectId: boolean;
11
+ hasVulnerabilityId: boolean;
12
+ hasSeverityFilter: boolean;
13
+ mode?: "plan" | "default";
14
+ scenario?: QuestionnaireScenario | null;
15
+ questionnaireStatus?: "collecting" | "ready";
16
+ fields?: SessionQuestionnaireFields;
17
+ historyCount?: number;
18
+ clarifyMaxRounds?: number;
16
19
  };
17
- export declare const REQUIRED_FOR_FIX_INTENT: readonly ["projectId", "severityMin", "remediationMode"];
20
+ export declare const REQUIRED_FOR_FIX_INTENT: readonly [
21
+ "projectId",
22
+ "severityMin",
23
+ "remediationMode",
24
+ ];
18
25
  /** Classify user intent for ClarifyGate (CLAR-001). */
19
26
  export declare function classifyIntent(userMessage: string): ClarifyIntent;
20
27
  /** Confidence that required execute fields are present (0–1). */
@@ -25,4 +32,4 @@ export declare function hasRequiredExecuteFields(input: ClarifyGateInput): boole
25
32
  * fix/watch/task-consumer surfaces always return false.
26
33
  */
27
34
  export declare function shouldClarify(input: ClarifyGateInput): boolean;
28
- //# sourceMappingURL=clarify-gate.d.ts.map
35
+ //# sourceMappingURL=clarify-gate.d.ts.map
@@ -1,152 +1,159 @@
1
1
  import { hasMinimumScopeForScenario } from "./session-questionnaire.js";
2
2
  export const REQUIRED_FOR_FIX_INTENT = ["projectId", "severityMin", "remediationMode"];
3
3
  const FACTUAL_PATTERNS = [
4
- /^(?:o que (?:é|e)|what is|how does|como funciona|explain|defina|define)(?:\s|[?.!,]|$)/iu,
5
- /\b(documentação|documentation|docs)\b/iu,
4
+ /^(?:o que (?:é|e)|what is|how does|como funciona|explain|defina|define)(?:\s|[?.!,]|$)/iu,
5
+ /\b(documentação|documentation|docs)\b/iu,
6
6
  ];
7
7
  const EXECUTE_PATTERNS = [
8
- /\b(corrige|corrigir|fix|remediate|remediação|remediacao)\b/i,
9
- /\b(finding|findings|vuln|vulnerability|cve-\d)/i,
8
+ /\b(corrige|corrigir|fix|remediate|remediação|remediacao)\b/i,
9
+ /\b(finding|findings|vuln|vulnerability|cve-\d)/i,
10
10
  ];
11
11
  const AMBIGUOUS_PATTERNS = [
12
- /\b(melhorar|melhore|improve|harden|reforçar|reforcar)\b.*\b(segurança|seguranca|security)\b/i,
13
- /@plan\b/i,
14
- /\/mode:plan\b/i,
12
+ /\b(melhorar|melhore|improve|harden|reforçar|reforcar)\b.*\b(segurança|seguranca|security)\b/i,
13
+ /@plan\b/i,
14
+ /\/mode:plan\b/i,
15
15
  ];
16
16
  const PROJECT_IN_MESSAGE = /\b(project[:\s]+[\w-]+|projeto[:\s]+[\w-]+)\b/i;
17
17
  const VULN_IN_MESSAGE = /\b(cve-\d{4}-\d+|vuln(?:erability)?[:\s#]*[\w-]+)\b/i;
18
- const SEVERITY_IN_MESSAGE = /\b(severity|severidade|critical|critico|crítico|high|alto|medium|medio|médio)\b/i;
18
+ const SEVERITY_IN_MESSAGE =
19
+ /\b(severity|severidade|critical|critico|crítico|high|alto|medium|medio|médio)\b/i;
19
20
  /** Classify user intent for ClarifyGate (CLAR-001). */
20
21
  export function classifyIntent(userMessage) {
21
- const msg = userMessage.trim();
22
- if (!msg)
23
- return "ambiguous";
24
- if (FACTUAL_PATTERNS.some((re) => re.test(msg))) {
25
- return "factual";
26
- }
27
- const hasExecuteCue = EXECUTE_PATTERNS.some((re) => re.test(msg));
28
- const hasScopeCue = PROJECT_IN_MESSAGE.test(msg) || VULN_IN_MESSAGE.test(msg) || SEVERITY_IN_MESSAGE.test(msg);
29
- if (hasExecuteCue && hasScopeCue) {
30
- return "execute";
31
- }
32
- if (AMBIGUOUS_PATTERNS.some((re) => re.test(msg))) {
33
- return "ambiguous";
34
- }
35
- if (hasExecuteCue) {
36
- return "execute";
37
- }
38
- if (msg.length < 40 && !hasExecuteCue) {
39
- return "ambiguous";
40
- }
22
+ const msg = userMessage.trim();
23
+ if (!msg) return "ambiguous";
24
+ if (FACTUAL_PATTERNS.some((re) => re.test(msg))) {
25
+ return "factual";
26
+ }
27
+ const hasExecuteCue = EXECUTE_PATTERNS.some((re) => re.test(msg));
28
+ const hasScopeCue =
29
+ PROJECT_IN_MESSAGE.test(msg) || VULN_IN_MESSAGE.test(msg) || SEVERITY_IN_MESSAGE.test(msg);
30
+ if (hasExecuteCue && hasScopeCue) {
31
+ return "execute";
32
+ }
33
+ if (AMBIGUOUS_PATTERNS.some((re) => re.test(msg))) {
41
34
  return "ambiguous";
35
+ }
36
+ if (hasExecuteCue) {
37
+ return "execute";
38
+ }
39
+ if (msg.length < 40 && !hasExecuteCue) {
40
+ return "ambiguous";
41
+ }
42
+ return "ambiguous";
42
43
  }
43
44
  function messageSignalsProject(message) {
44
- return PROJECT_IN_MESSAGE.test(message);
45
+ return PROJECT_IN_MESSAGE.test(message);
45
46
  }
46
47
  function messageSignalsVulnerability(message) {
47
- return VULN_IN_MESSAGE.test(message);
48
+ return VULN_IN_MESSAGE.test(message);
48
49
  }
49
50
  function messageSignalsSeverity(message) {
50
- return SEVERITY_IN_MESSAGE.test(message);
51
+ return SEVERITY_IN_MESSAGE.test(message);
51
52
  }
52
53
  function fieldsSignalProject(fields) {
53
- return (fields?.projectIds.length ?? 0) > 0;
54
+ return (fields?.projectIds.length ?? 0) > 0;
54
55
  }
55
56
  function fieldsSignalSeverity(fields) {
56
- return Boolean(fields?.severityMin);
57
+ return Boolean(fields?.severityMin);
57
58
  }
58
59
  function fieldsSignalRemediation(fields) {
59
- return Boolean(fields?.remediationMode);
60
+ return Boolean(fields?.remediationMode);
60
61
  }
61
62
  function fieldsSignalPlanObjective(fields) {
62
- return Boolean(fields?.customNotes?.trim());
63
+ return Boolean(fields?.customNotes?.trim());
63
64
  }
64
65
  /** Confidence that required execute fields are present (0–1). */
65
66
  export function computeGateConfidence(input) {
66
- const msg = input.userMessage;
67
- let score = 0.35;
68
- if (input.hasProjectId || messageSignalsProject(msg) || fieldsSignalProject(input.fields)) {
69
- score += 0.25;
70
- }
71
- if (input.hasVulnerabilityId || messageSignalsVulnerability(msg)) {
72
- score += 0.2;
73
- }
74
- if (input.hasSeverityFilter ||
75
- messageSignalsSeverity(msg) ||
76
- fieldsSignalSeverity(input.fields)) {
77
- score += 0.2;
78
- }
79
- if (classifyIntent(msg) === "factual") {
80
- return Math.min(score, 0.5);
81
- }
82
- return Math.min(score, 1);
67
+ const msg = input.userMessage;
68
+ let score = 0.35;
69
+ if (input.hasProjectId || messageSignalsProject(msg) || fieldsSignalProject(input.fields)) {
70
+ score += 0.25;
71
+ }
72
+ if (input.hasVulnerabilityId || messageSignalsVulnerability(msg)) {
73
+ score += 0.2;
74
+ }
75
+ if (
76
+ input.hasSeverityFilter ||
77
+ messageSignalsSeverity(msg) ||
78
+ fieldsSignalSeverity(input.fields)
79
+ ) {
80
+ score += 0.2;
81
+ }
82
+ if (classifyIntent(msg) === "factual") {
83
+ return Math.min(score, 0.5);
84
+ }
85
+ return Math.min(score, 1);
83
86
  }
84
87
  export function hasRequiredExecuteFields(input) {
85
- const scenario = input.scenario ?? (input.mode === "plan" ? "plan" : "remediation");
86
- const fields = input.fields;
87
- if (!fields)
88
- return false;
89
- if (scenario === "plan") {
90
- return fieldsSignalProject(fields) && fieldsSignalPlanObjective(fields);
91
- }
92
- if (scenario === "explore" || scenario === "review") {
93
- return fieldsSignalProject(fields);
94
- }
95
- const msg = input.userMessage;
96
- const hasProject = input.hasProjectId || messageSignalsProject(msg) || fieldsSignalProject(fields);
97
- const hasSeverity = input.hasSeverityFilter || messageSignalsSeverity(msg) || fieldsSignalSeverity(fields);
98
- const hasRemediationMode = fieldsSignalRemediation(fields) ||
99
- /\b(auto|automático|automatico|suggestion|sugestão|sugestao|manual)\b/i.test(msg);
100
- return hasProject && hasSeverity && hasRemediationMode;
88
+ const scenario = input.scenario ?? (input.mode === "plan" ? "plan" : "remediation");
89
+ const fields = input.fields;
90
+ if (!fields) return false;
91
+ if (scenario === "plan") {
92
+ return fieldsSignalProject(fields) && fieldsSignalPlanObjective(fields);
93
+ }
94
+ if (scenario === "explore" || scenario === "review") {
95
+ return fieldsSignalProject(fields);
96
+ }
97
+ const msg = input.userMessage;
98
+ const hasProject =
99
+ input.hasProjectId || messageSignalsProject(msg) || fieldsSignalProject(fields);
100
+ const hasSeverity =
101
+ input.hasSeverityFilter || messageSignalsSeverity(msg) || fieldsSignalSeverity(fields);
102
+ const hasRemediationMode =
103
+ fieldsSignalRemediation(fields) ||
104
+ /\b(auto|automático|automatico|suggestion|sugestão|sugestao|manual)\b/i.test(msg);
105
+ return hasProject && hasSeverity && hasRemediationMode;
101
106
  }
102
107
  function hasClarifyCue(message) {
103
- return (EXECUTE_PATTERNS.some((re) => re.test(message)) ||
104
- AMBIGUOUS_PATTERNS.some((re) => re.test(message)));
108
+ return (
109
+ EXECUTE_PATTERNS.some((re) => re.test(message)) ||
110
+ AMBIGUOUS_PATTERNS.some((re) => re.test(message))
111
+ );
105
112
  }
106
113
  /**
107
114
  * Whether sec-clarify should run for this turn (CLAR-001).
108
115
  * fix/watch/task-consumer surfaces always return false.
109
116
  */
110
117
  export function shouldClarify(input) {
111
- if (input.surface !== "chat") {
112
- return false;
113
- }
114
- if (process.env.KUBBISEC_SKIP_CLARIFY === "1") {
115
- return false;
116
- }
117
- if (input.questionnaireStatus === "ready") {
118
- return false;
119
- }
120
- const msg = input.userMessage.trim();
121
- if (!msg || !hasClarifyCue(msg)) {
122
- return false;
123
- }
124
- const intent = classifyIntent(msg);
125
- if (intent === "factual") {
126
- return false;
127
- }
128
- const maxRounds = input.clarifyMaxRounds ?? 3;
129
- if ((input.historyCount ?? 0) >= maxRounds) {
130
- return false;
131
- }
132
- const scenario = input.scenario ?? (input.mode === "plan" ? "plan" : "remediation");
133
- const fields = input.fields;
134
- if (fields && hasMinimumScopeForScenario(scenario, fields)) {
135
- return false;
136
- }
137
- const confidence = computeGateConfidence(input);
138
- if (intent === "execute" && confidence >= 0.85 && hasRequiredExecuteFields(input)) {
139
- return false;
140
- }
141
- if (intent === "execute" && !hasRequiredExecuteFields(input)) {
142
- return true;
143
- }
144
- if (intent === "ambiguous") {
145
- return true;
146
- }
147
- if (input.mode === "plan" || scenario === "plan") {
148
- return !hasRequiredExecuteFields(input);
149
- }
150
- return confidence < 0.85;
118
+ if (input.surface !== "chat") {
119
+ return false;
120
+ }
121
+ if (process.env.KUBBISEC_SKIP_CLARIFY === "1") {
122
+ return false;
123
+ }
124
+ if (input.questionnaireStatus === "ready") {
125
+ return false;
126
+ }
127
+ const msg = input.userMessage.trim();
128
+ if (!msg || !hasClarifyCue(msg)) {
129
+ return false;
130
+ }
131
+ const intent = classifyIntent(msg);
132
+ if (intent === "factual") {
133
+ return false;
134
+ }
135
+ const maxRounds = input.clarifyMaxRounds ?? 3;
136
+ if ((input.historyCount ?? 0) >= maxRounds) {
137
+ return false;
138
+ }
139
+ const scenario = input.scenario ?? (input.mode === "plan" ? "plan" : "remediation");
140
+ const fields = input.fields;
141
+ if (fields && hasMinimumScopeForScenario(scenario, fields)) {
142
+ return false;
143
+ }
144
+ const confidence = computeGateConfidence(input);
145
+ if (intent === "execute" && confidence >= 0.85 && hasRequiredExecuteFields(input)) {
146
+ return false;
147
+ }
148
+ if (intent === "execute" && !hasRequiredExecuteFields(input)) {
149
+ return true;
150
+ }
151
+ if (intent === "ambiguous") {
152
+ return true;
153
+ }
154
+ if (input.mode === "plan" || scenario === "plan") {
155
+ return !hasRequiredExecuteFields(input);
156
+ }
157
+ return confidence < 0.85;
151
158
  }
152
- //# sourceMappingURL=clarify-gate.js.map
159
+ //# sourceMappingURL=clarify-gate.js.map
@@ -1,14 +1,21 @@
1
1
  import type { ClarifyUiSnapshot } from "./clarify-ui-state.js";
2
+
2
3
  type PanelTheme = {
3
- fg: (role: string, text: string) => string;
4
- bold?: (text: string) => string;
4
+ fg: (role: string, text: string) => string;
5
+ bold?: (text: string) => string;
5
6
  };
6
- export declare function renderClarifySelectPanel(width: number, snapshot: ClarifyUiSnapshot, theme: PanelTheme): string[];
7
+ export declare function renderClarifySelectPanel(
8
+ width: number,
9
+ snapshot: ClarifyUiSnapshot,
10
+ theme: PanelTheme,
11
+ ): string[];
7
12
  export type ClarifyKeyResult = {
8
- consumed: boolean;
9
- snapshot: ClarifyUiSnapshot;
10
- submitText?: string;
13
+ consumed: boolean;
14
+ snapshot: ClarifyUiSnapshot;
15
+ submitText?: string;
11
16
  };
12
- export declare function handleClarifyPanelKey(snapshot: ClarifyUiSnapshot, data: string): ClarifyKeyResult;
13
- export {};
14
- //# sourceMappingURL=clarify-select-panel.d.ts.map
17
+ export declare function handleClarifyPanelKey(
18
+ snapshot: ClarifyUiSnapshot,
19
+ data: string,
20
+ ): ClarifyKeyResult;
21
+ //# sourceMappingURL=clarify-select-panel.d.ts.map
@@ -1,82 +1,80 @@
1
1
  import { truncateToWidth } from "@earendil-works/pi-tui";
2
2
  import { formatSelectionSubmit } from "./parse-clarify-answer.js";
3
+
3
4
  const OPTION_IDS = ["A", "B", "C", "D"];
4
5
  function optionLabel(snapshot, index) {
5
- if (index < 3)
6
- return snapshot.optionLabels[index] ?? `Opção ${index + 1}`;
7
- return snapshot.selectionMode === "multi" ? "Outro — escreva abaixo" : "Outro — escreva abaixo";
6
+ if (index < 3) return snapshot.optionLabels[index] ?? `Opção ${index + 1}`;
7
+ return snapshot.selectionMode === "multi" ? "Outro — escreva abaixo" : "Outro — escreva abaixo";
8
8
  }
9
9
  function renderOptionLine(snapshot, index, theme, width) {
10
- const id = OPTION_IDS[index] ?? "D";
11
- const focused = snapshot.focusedIndex === index;
12
- const selected = snapshot.selected.includes(id);
13
- const marker = focused ? "▸" : " ";
14
- const check = selected ? (snapshot.selectionMode === "multi" ? "[x]" : "●") : "[ ]";
15
- const line = `${marker} ${check} ${id}) ${optionLabel(snapshot, index)}`;
16
- const role = focused ? "planAccent" : "warning";
17
- try {
18
- return truncateToWidth(theme.fg(role, line), width, "");
19
- }
20
- catch {
21
- return truncateToWidth(line, width, "");
22
- }
10
+ const id = OPTION_IDS[index] ?? "D";
11
+ const focused = snapshot.focusedIndex === index;
12
+ const selected = snapshot.selected.includes(id);
13
+ const marker = focused ? "▸" : " ";
14
+ const check = selected ? (snapshot.selectionMode === "multi" ? "[x]" : "●") : "[ ]";
15
+ const line = `${marker} ${check} ${id}) ${optionLabel(snapshot, index)}`;
16
+ const role = focused ? "planAccent" : "warning";
17
+ try {
18
+ return truncateToWidth(theme.fg(role, line), width, "");
19
+ } catch {
20
+ return truncateToWidth(line, width, "");
21
+ }
23
22
  }
24
23
  export function renderClarifySelectPanel(width, snapshot, theme) {
25
- if (snapshot.phase !== "asking" || !snapshot.questionText)
26
- return [];
27
- const border = theme.fg("warning", "".repeat(Math.max(0, width)));
28
- const titleBase = snapshot.progressLabel ?? "Questionário";
29
- const title = typeof theme.bold === "function"
30
- ? theme.bold(theme.fg("warning", titleBase))
31
- : theme.fg("warning", titleBase);
32
- const lines = [truncateToWidth(border, width, ""), truncateToWidth(title, width, "")];
33
- lines.push(truncateToWidth(theme.fg("text", snapshot.questionText), width, ""));
34
- const optionCount = Math.min(3, snapshot.optionLabels.length) + 1;
35
- for (let i = 0; i < optionCount; i += 1) {
36
- lines.push(renderOptionLine(snapshot, i, theme, width));
37
- }
38
- const hint = snapshot.selectionMode === "multi"
39
- ? "↑↓ navegar · Espaço alternar · Enter confirmar · ou escreva abaixo"
40
- : "↑↓ navegar · Espaço selecionar · Enter confirmar · ou escreva abaixo";
41
- lines.push(truncateToWidth(theme.fg("dim", hint), width, ""));
42
- lines.push(truncateToWidth(border, width, ""));
43
- return lines;
24
+ if (snapshot.phase !== "asking" || !snapshot.questionText) return [];
25
+ const border = theme.fg("warning", "─".repeat(Math.max(0, width)));
26
+ const titleBase = snapshot.progressLabel ?? "Questionário";
27
+ const title =
28
+ typeof theme.bold === "function"
29
+ ? theme.bold(theme.fg("warning", titleBase))
30
+ : theme.fg("warning", titleBase);
31
+ const lines = [truncateToWidth(border, width, ""), truncateToWidth(title, width, "")];
32
+ lines.push(truncateToWidth(theme.fg("text", snapshot.questionText), width, ""));
33
+ const optionCount = Math.min(3, snapshot.optionLabels.length) + 1;
34
+ for (let i = 0; i < optionCount; i += 1) {
35
+ lines.push(renderOptionLine(snapshot, i, theme, width));
36
+ }
37
+ const hint =
38
+ snapshot.selectionMode === "multi"
39
+ ? "↑↓ navegar · Espaço alternar · Enter confirmar · ou escreva abaixo"
40
+ : "↑↓ navegar · Espaço selecionar · Enter confirmar · ou escreva abaixo";
41
+ lines.push(truncateToWidth(theme.fg("dim", hint), width, ""));
42
+ lines.push(truncateToWidth(border, width, ""));
43
+ return lines;
44
44
  }
45
45
  function toggleSelection(snapshot, optionId) {
46
- if (snapshot.selectionMode === "single") {
47
- return { ...snapshot, selected: [optionId] };
48
- }
49
- const selected = new Set(snapshot.selected);
50
- if (selected.has(optionId))
51
- selected.delete(optionId);
52
- else
53
- selected.add(optionId);
54
- return { ...snapshot, selected: [...selected] };
46
+ if (snapshot.selectionMode === "single") {
47
+ return { ...snapshot, selected: [optionId] };
48
+ }
49
+ const selected = new Set(snapshot.selected);
50
+ if (selected.has(optionId)) selected.delete(optionId);
51
+ else selected.add(optionId);
52
+ return { ...snapshot, selected: [...selected] };
55
53
  }
56
54
  export function handleClarifyPanelKey(snapshot, data) {
57
- if (snapshot.phase !== "asking") {
58
- return { consumed: false, snapshot };
59
- }
60
- const optionCount = Math.min(3, snapshot.optionLabels.length) + 1;
61
- if (data === "\x1b[A") {
62
- const focusedIndex = (snapshot.focusedIndex - 1 + optionCount) % optionCount;
63
- return { consumed: true, snapshot: { ...snapshot, focusedIndex } };
64
- }
65
- if (data === "\x1b[B") {
66
- const focusedIndex = (snapshot.focusedIndex + 1) % optionCount;
67
- return { consumed: true, snapshot: { ...snapshot, focusedIndex } };
68
- }
69
- if (data === " ") {
70
- const id = OPTION_IDS[snapshot.focusedIndex] ?? "D";
71
- return { consumed: true, snapshot: toggleSelection(snapshot, id) };
72
- }
73
- if (data === "\r" || data === "\n") {
74
- const submit = formatSelectionSubmit(new Set(snapshot.selected), snapshot.selectionMode);
75
- if (submit) {
76
- return { consumed: true, snapshot, submitText: submit };
77
- }
78
- return { consumed: false, snapshot };
55
+ if (snapshot.phase !== "asking") {
56
+ return { consumed: false, snapshot };
57
+ }
58
+ const optionCount = Math.min(3, snapshot.optionLabels.length) + 1;
59
+ if (data === "\x1b[A") {
60
+ const focusedIndex = (snapshot.focusedIndex - 1 + optionCount) % optionCount;
61
+ return { consumed: true, snapshot: { ...snapshot, focusedIndex } };
62
+ }
63
+ if (data === "\x1b[B") {
64
+ const focusedIndex = (snapshot.focusedIndex + 1) % optionCount;
65
+ return { consumed: true, snapshot: { ...snapshot, focusedIndex } };
66
+ }
67
+ if (data === " ") {
68
+ const id = OPTION_IDS[snapshot.focusedIndex] ?? "D";
69
+ return { consumed: true, snapshot: toggleSelection(snapshot, id) };
70
+ }
71
+ if (data === "\r" || data === "\n") {
72
+ const submit = formatSelectionSubmit(new Set(snapshot.selected), snapshot.selectionMode);
73
+ if (submit) {
74
+ return { consumed: true, snapshot, submitText: submit };
79
75
  }
80
76
  return { consumed: false, snapshot };
77
+ }
78
+ return { consumed: false, snapshot };
81
79
  }
82
- //# sourceMappingURL=clarify-select-panel.js.map
80
+ //# sourceMappingURL=clarify-select-panel.js.map
@@ -1,21 +1,23 @@
1
1
  import type { ClarifyOptionId, ClarifySelectionMode } from "./session-questionnaire.types.js";
2
2
  export type ClarifyUiPhase = "idle" | "asking" | "ready";
3
3
  export type ClarifyUiSnapshot = {
4
- phase: ClarifyUiPhase;
5
- progressLabel: string | null;
6
- questionMarkdown: string | null;
7
- questionText: string | null;
8
- optionLabels: string[];
9
- selectionMode: ClarifySelectionMode;
10
- selected: ClarifyOptionId[];
11
- focusedIndex: number;
4
+ phase: ClarifyUiPhase;
5
+ progressLabel: string | null;
6
+ questionMarkdown: string | null;
7
+ questionText: string | null;
8
+ optionLabels: string[];
9
+ selectionMode: ClarifySelectionMode;
10
+ selected: ClarifyOptionId[];
11
+ focusedIndex: number;
12
12
  };
13
13
  export declare function setClarifyUiChangeListener(listener: (() => void) | undefined): void;
14
- export declare function setClarifySubmitHandler(handler: ((text: string) => void | Promise<void>) | undefined): void;
14
+ export declare function setClarifySubmitHandler(
15
+ handler: ((text: string) => void | Promise<void>) | undefined,
16
+ ): void;
15
17
  export declare function submitClarifyAnswer(text: string): Promise<void>;
16
18
  export declare function getClarifyUiSnapshot(): ClarifyUiSnapshot;
17
19
  export declare function setClarifyUiSnapshot(next: Partial<ClarifyUiSnapshot>): void;
18
20
  export declare function resetClarifyUiSnapshot(): void;
19
21
  export declare function isClarifyAsking(): boolean;
20
22
  export declare function resetClarifySelection(): void;
21
- //# sourceMappingURL=clarify-ui-state.d.ts.map
23
+ //# sourceMappingURL=clarify-ui-state.d.ts.map
@@ -1,48 +1,48 @@
1
1
  const EMPTY_SNAPSHOT = {
2
- phase: "idle",
3
- progressLabel: null,
4
- questionMarkdown: null,
5
- questionText: null,
6
- optionLabels: [],
7
- selectionMode: "single",
8
- selected: [],
9
- focusedIndex: 0,
2
+ phase: "idle",
3
+ progressLabel: null,
4
+ questionMarkdown: null,
5
+ questionText: null,
6
+ optionLabels: [],
7
+ selectionMode: "single",
8
+ selected: [],
9
+ focusedIndex: 0,
10
10
  };
11
11
  let snapshot = { ...EMPTY_SNAPSHOT };
12
12
  let onSnapshotChange;
13
13
  let onClarifySubmit;
14
14
  export function setClarifyUiChangeListener(listener) {
15
- onSnapshotChange = listener;
15
+ onSnapshotChange = listener;
16
16
  }
17
17
  export function setClarifySubmitHandler(handler) {
18
- onClarifySubmit = handler;
18
+ onClarifySubmit = handler;
19
19
  }
20
20
  export async function submitClarifyAnswer(text) {
21
- await onClarifySubmit?.(text);
21
+ await onClarifySubmit?.(text);
22
22
  }
23
23
  function notifySnapshotChange() {
24
- onSnapshotChange?.();
24
+ onSnapshotChange?.();
25
25
  }
26
26
  export function getClarifyUiSnapshot() {
27
- return snapshot;
27
+ return snapshot;
28
28
  }
29
29
  export function setClarifyUiSnapshot(next) {
30
- snapshot = { ...snapshot, ...next };
31
- notifySnapshotChange();
30
+ snapshot = { ...snapshot, ...next };
31
+ notifySnapshotChange();
32
32
  }
33
33
  export function resetClarifyUiSnapshot() {
34
- snapshot = { ...EMPTY_SNAPSHOT };
35
- notifySnapshotChange();
34
+ snapshot = { ...EMPTY_SNAPSHOT };
35
+ notifySnapshotChange();
36
36
  }
37
37
  export function isClarifyAsking() {
38
- return snapshot.phase === "asking";
38
+ return snapshot.phase === "asking";
39
39
  }
40
40
  export function resetClarifySelection() {
41
- snapshot = {
42
- ...snapshot,
43
- selected: [],
44
- focusedIndex: 0,
45
- };
46
- notifySnapshotChange();
47
- }
48
- //# sourceMappingURL=clarify-ui-state.js.map
41
+ snapshot = {
42
+ ...snapshot,
43
+ selected: [],
44
+ focusedIndex: 0,
45
+ };
46
+ notifySnapshotChange();
47
+ }
48
+ //# sourceMappingURL=clarify-ui-state.js.map