@kubbisec/ai-linux-arm64 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.
- package/bundled/clarify/clarify-gate-state.d.ts +1 -1
- package/bundled/clarify/clarify-gate-state.js +3 -3
- package/bundled/clarify/clarify-gate.d.ts +21 -14
- package/bundled/clarify/clarify-gate.js +118 -111
- package/bundled/clarify/clarify-select-panel.d.ts +16 -9
- package/bundled/clarify/clarify-select-panel.js +65 -67
- package/bundled/clarify/clarify-ui-state.d.ts +12 -10
- package/bundled/clarify/clarify-ui-state.js +26 -26
- package/bundled/clarify/parse-clarify-answer.d.ts +29 -18
- package/bundled/clarify/parse-clarify-answer.js +39 -45
- package/bundled/clarify/question-format.d.ts +34 -23
- package/bundled/clarify/question-format.js +112 -119
- package/bundled/clarify/questionnaire-tool.d.ts +28 -17
- package/bundled/clarify/questionnaire-tool.js +180 -144
- package/bundled/clarify/scope-discovery.d.ts +8 -5
- package/bundled/clarify/scope-discovery.js +102 -110
- package/bundled/clarify/session-questionnaire.d.ts +48 -13
- package/bundled/clarify/session-questionnaire.js +304 -312
- package/bundled/clarify/session-questionnaire.types.d.ts +29 -27
- package/bundled/clarify/session-questionnaire.types.js +10 -10
- package/bundled/components/kubbisec-model-selector.d.ts +47 -34
- package/bundled/components/kubbisec-model-selector.js +187 -177
- package/bundled/config/config.d.ts +6 -6
- package/bundled/config/config.js +55 -55
- package/bundled/config/detect-local-llm-providers.d.ts +26 -16
- package/bundled/config/detect-local-llm-providers.js +130 -142
- package/bundled/config/ensure-kubbisec-project-settings.d.ts +9 -9
- package/bundled/config/ensure-kubbisec-project-settings.js +44 -48
- package/bundled/config/extended-context.d.ts +5 -6
- package/bundled/config/extended-context.js +23 -22
- package/bundled/config/feature-flags.d.ts +10 -2
- package/bundled/config/feature-flags.js +8 -2
- package/bundled/config/format-kubbisec-footer-status.d.ts +1 -1
- package/bundled/config/format-kubbisec-footer-status.js +26 -31
- package/bundled/config/kubbisec-extension-manifest.d.ts +22 -2
- package/bundled/config/kubbisec-extension-manifest.js +20 -20
- package/bundled/config/llm-config-mutations.d.ts +51 -25
- package/bundled/config/llm-config-mutations.js +173 -182
- package/bundled/config/llm-config.d.ts +54 -41
- package/bundled/config/llm-config.js +199 -199
- package/bundled/config/llm-provider-catalog.d.ts +18 -15
- package/bundled/config/llm-provider-catalog.js +45 -46
- package/bundled/config/materialize-kubbisec-pi-resources.d.ts +1 -1
- package/bundled/config/materialize-kubbisec-pi-resources.js +174 -183
- package/bundled/config/register-custom-llm-providers.d.ts +11 -5
- package/bundled/config/register-custom-llm-providers.js +17 -15
- package/bundled/config/register-kubbisec-llm-provider.d.ts +14 -10
- package/bundled/config/register-kubbisec-llm-provider.js +50 -42
- package/bundled/config/resolve-agents-context-file.d.ts +1 -1
- package/bundled/config/resolve-agents-context-file.js +33 -34
- package/bundled/config/resource-budget.d.ts +12 -12
- package/bundled/config/resource-budget.js +28 -28
- package/bundled/config/sync-kubbisec-pi-models.d.ts +6 -3
- package/bundled/config/sync-kubbisec-pi-models.js +58 -58
- package/bundled/copy/cli-reference-index.d.ts +3 -2
- package/bundled/copy/cli-reference-index.js +1 -1
- package/bundled/copy/kubbisec-shell-copy.d.ts +11 -6
- package/bundled/copy/kubbisec-shell-copy.js +1 -1
- package/bundled/extensions/cli-local-shared.d.ts +45 -26
- package/bundled/extensions/cli-local-shared.js +128 -118
- package/bundled/extensions/kubbisec-aspm-local.extension.d.ts +18 -15
- package/bundled/extensions/kubbisec-aspm-local.extension.js +118 -114
- package/bundled/extensions/kubbisec-brand.extension.d.ts +1 -1
- package/bundled/extensions/kubbisec-brand.extension.js +25 -25
- package/bundled/extensions/kubbisec-byok-provider.extension.d.ts +1 -1
- package/bundled/extensions/kubbisec-byok-provider.extension.js +2 -2
- package/bundled/extensions/kubbisec-clarify.extension.d.ts +64 -35
- package/bundled/extensions/kubbisec-clarify.extension.js +323 -305
- package/bundled/extensions/kubbisec-exit.extension.d.ts +1 -1
- package/bundled/extensions/kubbisec-exit.extension.js +29 -32
- package/bundled/extensions/kubbisec-extended-context.extension.d.ts +1 -1
- package/bundled/extensions/kubbisec-extended-context.extension.js +56 -43
- package/bundled/extensions/kubbisec-footer.extension.d.ts +14 -14
- package/bundled/extensions/kubbisec-footer.extension.js +205 -215
- package/bundled/extensions/kubbisec-github-local.extension.d.ts +26 -18
- package/bundled/extensions/kubbisec-github-local.extension.js +123 -116
- package/bundled/extensions/kubbisec-llm-config.extension.d.ts +1 -1
- package/bundled/extensions/kubbisec-llm-config.extension.js +200 -181
- package/bundled/extensions/kubbisec-memory.extension.d.ts +9 -7
- package/bundled/extensions/kubbisec-memory.extension.js +88 -95
- package/bundled/extensions/kubbisec-naus-local.extension.d.ts +18 -15
- package/bundled/extensions/kubbisec-naus-local.extension.js +132 -111
- package/bundled/extensions/kubbisec-platform-tools.extension.d.ts +31 -21
- package/bundled/extensions/kubbisec-platform-tools.extension.js +152 -152
- package/bundled/extensions/kubbisec-runtime-status.extension.d.ts +10 -8
- package/bundled/extensions/kubbisec-runtime-status.extension.js +15 -13
- package/bundled/extensions/kubbisec-scope.extension.d.ts +12 -7
- package/bundled/extensions/kubbisec-scope.extension.js +13 -13
- package/bundled/extensions/kubbisec-skill-mentions.extension.d.ts +27 -16
- package/bundled/extensions/kubbisec-skill-mentions.extension.js +73 -63
- package/bundled/extensions/kubbisec-skill-telemetry.extension.d.ts +2 -3
- package/bundled/extensions/kubbisec-skill-telemetry.extension.js +59 -64
- package/bundled/extensions/kubbisec-theme-lock.extension.d.ts +1 -1
- package/bundled/extensions/kubbisec-theme-lock.extension.js +33 -34
- package/bundled/extensions/kubbisec-ui.extension.d.ts +1 -1
- package/bundled/extensions/kubbisec-ui.extension.js +114 -109
- package/bundled/extensions/kubbisec-workflow.extension.d.ts +20 -18
- package/bundled/extensions/kubbisec-workflow.extension.js +138 -140
- package/bundled/node_modules/@aspm/shared/dist/redaction.test.d.ts +2 -0
- package/bundled/node_modules/@aspm/shared/dist/redaction.test.d.ts.map +1 -0
- package/bundled/node_modules/@aspm/shared/dist/redaction.test.js +626 -0
- package/bundled/node_modules/@aspm/shared/dist/redaction.test.js.map +1 -0
- package/bundled/resolve-bundled-dist-root.js +122 -131
- package/bundled/skills/at-path-mentions.d.ts +1 -1
- package/bundled/skills/at-path-mentions.js +146 -153
- package/bundled/skills/chat-mention-render.d.ts +2 -2
- package/bundled/skills/chat-mention-render.js +121 -126
- package/bundled/skills/chat-mentions.d.ts +17 -8
- package/bundled/skills/chat-mentions.js +76 -76
- package/bundled/skills/list-bundled-skills.d.ts +3 -3
- package/bundled/skills/list-bundled-skills.js +33 -35
- package/bundled/skills/skill-mention.d.ts +10 -2
- package/bundled/skills/skill-mention.js +10 -2
- package/bundled/theme/clear-terminal.d.ts +1 -1
- package/bundled/theme/clear-terminal.js +3 -4
- package/bundled/theme/footer-render-hook.d.ts +1 -1
- package/bundled/theme/footer-render-hook.js +3 -3
- package/bundled/theme/kubbisec-brand-fg.d.ts +1 -1
- package/bundled/theme/kubbisec-brand-fg.js +2 -2
- package/bundled/theme/kubbisec-menu-themes.d.ts +7 -7
- package/bundled/theme/kubbisec-menu-themes.js +30 -31
- package/bundled/theme/kubbisec-theme-name.d.ts +1 -1
- package/bundled/theme/kubbisec-theme-name.js +1 -1
- package/bundled/theme/patch-pi-settings-theme.runtime.d.ts +1 -1
- package/bundled/theme/patch-pi-settings-theme.runtime.js +11 -10
- package/bundled/theme/render-compact-header.d.ts +13 -5
- package/bundled/theme/render-compact-header.js +127 -129
- package/bundled/workflow/session-workflow-mode.d.ts +1 -1
- package/bundled/workflow/session-workflow-mode.js +33 -33
- package/package.json +1 -1
|
@@ -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
|
-
|
|
4
|
+
gateActive = active;
|
|
5
5
|
}
|
|
6
6
|
export function isClarifyGateActive() {
|
|
7
|
-
|
|
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 {
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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 [
|
|
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
|
-
|
|
5
|
-
|
|
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
|
-
|
|
9
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 =
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
45
|
+
return PROJECT_IN_MESSAGE.test(message);
|
|
45
46
|
}
|
|
46
47
|
function messageSignalsVulnerability(message) {
|
|
47
|
-
|
|
48
|
+
return VULN_IN_MESSAGE.test(message);
|
|
48
49
|
}
|
|
49
50
|
function messageSignalsSeverity(message) {
|
|
50
|
-
|
|
51
|
+
return SEVERITY_IN_MESSAGE.test(message);
|
|
51
52
|
}
|
|
52
53
|
function fieldsSignalProject(fields) {
|
|
53
|
-
|
|
54
|
+
return (fields?.projectIds.length ?? 0) > 0;
|
|
54
55
|
}
|
|
55
56
|
function fieldsSignalSeverity(fields) {
|
|
56
|
-
|
|
57
|
+
return Boolean(fields?.severityMin);
|
|
57
58
|
}
|
|
58
59
|
function fieldsSignalRemediation(fields) {
|
|
59
|
-
|
|
60
|
+
return Boolean(fields?.remediationMode);
|
|
60
61
|
}
|
|
61
62
|
function fieldsSignalPlanObjective(fields) {
|
|
62
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return Math.min(score,
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
104
|
-
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
4
|
-
|
|
4
|
+
fg: (role: string, text: string) => string;
|
|
5
|
+
bold?: (text: string) => string;
|
|
5
6
|
};
|
|
6
|
-
export declare function renderClarifySelectPanel(
|
|
7
|
+
export declare function renderClarifySelectPanel(
|
|
8
|
+
width: number,
|
|
9
|
+
snapshot: ClarifyUiSnapshot,
|
|
10
|
+
theme: PanelTheme,
|
|
11
|
+
): string[];
|
|
7
12
|
export type ClarifyKeyResult = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
consumed: boolean;
|
|
14
|
+
snapshot: ClarifyUiSnapshot;
|
|
15
|
+
submitText?: string;
|
|
11
16
|
};
|
|
12
|
-
export declare function handleClarifyPanelKey(
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
6
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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(
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
15
|
+
onSnapshotChange = listener;
|
|
16
16
|
}
|
|
17
17
|
export function setClarifySubmitHandler(handler) {
|
|
18
|
-
|
|
18
|
+
onClarifySubmit = handler;
|
|
19
19
|
}
|
|
20
20
|
export async function submitClarifyAnswer(text) {
|
|
21
|
-
|
|
21
|
+
await onClarifySubmit?.(text);
|
|
22
22
|
}
|
|
23
23
|
function notifySnapshotChange() {
|
|
24
|
-
|
|
24
|
+
onSnapshotChange?.();
|
|
25
25
|
}
|
|
26
26
|
export function getClarifyUiSnapshot() {
|
|
27
|
-
|
|
27
|
+
return snapshot;
|
|
28
28
|
}
|
|
29
29
|
export function setClarifyUiSnapshot(next) {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
snapshot = { ...snapshot, ...next };
|
|
31
|
+
notifySnapshotChange();
|
|
32
32
|
}
|
|
33
33
|
export function resetClarifyUiSnapshot() {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
snapshot = { ...EMPTY_SNAPSHOT };
|
|
35
|
+
notifySnapshotChange();
|
|
36
36
|
}
|
|
37
37
|
export function isClarifyAsking() {
|
|
38
|
-
|
|
38
|
+
return snapshot.phase === "asking";
|
|
39
39
|
}
|
|
40
40
|
export function resetClarifySelection() {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|