@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,161 +1,197 @@
|
|
|
1
1
|
import { Type } from "@earendil-works/pi-ai";
|
|
2
2
|
import { syncExtendedContextFromFields } from "../config/extended-context.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
formatQuestionFromInput,
|
|
5
|
+
inferScenarioFromMessage,
|
|
6
|
+
suggestScenarioFields,
|
|
7
|
+
} from "./question-format.js";
|
|
8
|
+
import {
|
|
9
|
+
applyPendingAnswer,
|
|
10
|
+
askQuestion,
|
|
11
|
+
completeQuestionnaire,
|
|
12
|
+
hasMinimumRemediationScope,
|
|
13
|
+
mergeRecordedFields,
|
|
14
|
+
} from "./session-questionnaire.js";
|
|
5
15
|
export function executeQuestionnaireTool(questionnaire, input, userMessage) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
questionnaire,
|
|
28
|
-
};
|
|
16
|
+
const action = input.action;
|
|
17
|
+
if (action === "status") {
|
|
18
|
+
const scenario =
|
|
19
|
+
input.scenario ?? questionnaire.scenario ?? inferScenarioFromMessage(userMessage ?? "");
|
|
20
|
+
const suggestion = suggestScenarioFields(scenario, questionnaire.fields);
|
|
21
|
+
const lines = [
|
|
22
|
+
`Status: ${questionnaire.status}`,
|
|
23
|
+
`Scenario: ${scenario}`,
|
|
24
|
+
`Awaiting answer: ${questionnaire.awaitingUserAnswer ? "yes" : "no"}`,
|
|
25
|
+
`History: ${questionnaire.history.length} answer(s)`,
|
|
26
|
+
suggestion.missingFields.length
|
|
27
|
+
? `Missing hints: ${suggestion.missingFields.join(", ")}`
|
|
28
|
+
: "No missing hinted fields for this scenario.",
|
|
29
|
+
];
|
|
30
|
+
if (suggestion.nextHint) {
|
|
31
|
+
lines.push(
|
|
32
|
+
"",
|
|
33
|
+
`Suggested next field: ${suggestion.nextHint.field} (${suggestion.nextHint.purpose})`,
|
|
34
|
+
`Example question: ${suggestion.nextHint.exampleQuestion}`,
|
|
35
|
+
`Example options: ${suggestion.nextHint.exampleOptions.join(" | ")}`,
|
|
36
|
+
);
|
|
29
37
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
input.scenario === "explore" ||
|
|
64
|
-
input.scenario === "review") {
|
|
65
|
-
next = completeQuestionnaire(next);
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
ok: true,
|
|
69
|
-
action,
|
|
70
|
-
status: next.status,
|
|
71
|
-
message: next.status === "ready"
|
|
72
|
-
? "Recorded scope fields and marked questionnaire ready."
|
|
73
|
-
: "Recorded scope fields. Use ask for any remaining gaps.",
|
|
74
|
-
questionnaire: next,
|
|
75
|
-
};
|
|
38
|
+
return {
|
|
39
|
+
ok: true,
|
|
40
|
+
action,
|
|
41
|
+
status: questionnaire.status,
|
|
42
|
+
message: lines.join("\n"),
|
|
43
|
+
questionnaire,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (action === "complete") {
|
|
47
|
+
const mergedFields = input.fields
|
|
48
|
+
? mergeRecordedFields(questionnaire.fields, input.fields)
|
|
49
|
+
: questionnaire.fields;
|
|
50
|
+
syncExtendedContextFromFields(mergedFields);
|
|
51
|
+
const next = completeQuestionnaire(
|
|
52
|
+
input.fields ? { ...questionnaire, fields: mergedFields } : questionnaire,
|
|
53
|
+
);
|
|
54
|
+
return {
|
|
55
|
+
ok: true,
|
|
56
|
+
action,
|
|
57
|
+
status: next.status,
|
|
58
|
+
message: "Scope questionnaire marked ready. Mutation tools may proceed when policy allows.",
|
|
59
|
+
questionnaire: next,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (action === "record") {
|
|
63
|
+
if (!input.fields || Object.keys(input.fields).length === 0) {
|
|
64
|
+
return {
|
|
65
|
+
ok: false,
|
|
66
|
+
action,
|
|
67
|
+
status: questionnaire.status,
|
|
68
|
+
message: "record requires at least one field in `fields`.",
|
|
69
|
+
questionnaire,
|
|
70
|
+
};
|
|
76
71
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
const { markdown, optionLabels, selectionMode } = formatQuestionFromInput({
|
|
94
|
-
question,
|
|
95
|
-
options,
|
|
96
|
-
language: input.language,
|
|
97
|
-
field,
|
|
98
|
-
});
|
|
99
|
-
const next = askQuestion(questionnaire, {
|
|
100
|
-
field,
|
|
101
|
-
questionMarkdown: markdown,
|
|
102
|
-
optionLabels,
|
|
103
|
-
scenario,
|
|
104
|
-
selectionMode,
|
|
105
|
-
});
|
|
106
|
-
return {
|
|
107
|
-
ok: true,
|
|
108
|
-
action,
|
|
109
|
-
status: next.status,
|
|
110
|
-
formattedQuestion: markdown,
|
|
111
|
-
message: [
|
|
112
|
-
`Question queued for field "${field}".`,
|
|
113
|
-
"Options are shown in the KubbiSec panel only.",
|
|
114
|
-
"Reply to the user with one short line (e.g. ask them to pick A–E in the panel).",
|
|
115
|
-
"Do not list options or repeat the question body in chat.",
|
|
116
|
-
].join(" "),
|
|
117
|
-
questionnaire: next,
|
|
118
|
-
};
|
|
72
|
+
const merged = mergeRecordedFields(questionnaire.fields, input.fields);
|
|
73
|
+
syncExtendedContextFromFields(merged);
|
|
74
|
+
let next = {
|
|
75
|
+
...questionnaire,
|
|
76
|
+
fields: merged,
|
|
77
|
+
scenario: input.scenario ?? questionnaire.scenario,
|
|
78
|
+
updatedAt: new Date().toISOString(),
|
|
79
|
+
};
|
|
80
|
+
if (
|
|
81
|
+
hasMinimumRemediationScope(merged) ||
|
|
82
|
+
input.scenario === "explore" ||
|
|
83
|
+
input.scenario === "review"
|
|
84
|
+
) {
|
|
85
|
+
next = completeQuestionnaire(next);
|
|
119
86
|
}
|
|
120
87
|
return {
|
|
88
|
+
ok: true,
|
|
89
|
+
action,
|
|
90
|
+
status: next.status,
|
|
91
|
+
message:
|
|
92
|
+
next.status === "ready"
|
|
93
|
+
? "Recorded scope fields and marked questionnaire ready."
|
|
94
|
+
: "Recorded scope fields. Use ask for any remaining gaps.",
|
|
95
|
+
questionnaire: next,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (action === "ask") {
|
|
99
|
+
const scenario =
|
|
100
|
+
input.scenario ?? questionnaire.scenario ?? inferScenarioFromMessage(userMessage ?? "");
|
|
101
|
+
const field =
|
|
102
|
+
input.field?.trim() || suggestScenarioFields(scenario, questionnaire.fields).nextHint?.field;
|
|
103
|
+
const question =
|
|
104
|
+
input.question?.trim() ||
|
|
105
|
+
suggestScenarioFields(scenario, questionnaire.fields).nextHint?.exampleQuestion;
|
|
106
|
+
const options =
|
|
107
|
+
input.options?.filter(Boolean) ||
|
|
108
|
+
suggestScenarioFields(scenario, questionnaire.fields).nextHint?.exampleOptions;
|
|
109
|
+
if (!field || !question || !options?.length) {
|
|
110
|
+
return {
|
|
121
111
|
ok: false,
|
|
122
112
|
action,
|
|
123
113
|
status: questionnaire.status,
|
|
124
|
-
message:
|
|
114
|
+
message:
|
|
115
|
+
"ask requires field + question + options (2–4), or a scenario with remaining hinted fields.",
|
|
125
116
|
questionnaire,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const { markdown, optionLabels, selectionMode } = formatQuestionFromInput({
|
|
120
|
+
question,
|
|
121
|
+
options,
|
|
122
|
+
language: input.language,
|
|
123
|
+
field,
|
|
124
|
+
});
|
|
125
|
+
const next = askQuestion(questionnaire, {
|
|
126
|
+
field,
|
|
127
|
+
questionMarkdown: markdown,
|
|
128
|
+
optionLabels,
|
|
129
|
+
scenario,
|
|
130
|
+
selectionMode,
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
ok: true,
|
|
134
|
+
action,
|
|
135
|
+
status: next.status,
|
|
136
|
+
formattedQuestion: markdown,
|
|
137
|
+
message: [
|
|
138
|
+
`Question queued for field "${field}".`,
|
|
139
|
+
"Options are shown in the KubbiSec panel only.",
|
|
140
|
+
"Reply to the user with one short line (e.g. ask them to pick A–E in the panel).",
|
|
141
|
+
"Do not list options or repeat the question body in chat.",
|
|
142
|
+
].join(" "),
|
|
143
|
+
questionnaire: next,
|
|
126
144
|
};
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
ok: false,
|
|
148
|
+
action,
|
|
149
|
+
status: questionnaire.status,
|
|
150
|
+
message: `Unknown action: ${String(action)}`,
|
|
151
|
+
questionnaire,
|
|
152
|
+
};
|
|
127
153
|
}
|
|
128
154
|
export function questionnaireToolParametersSchema() {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
return Type.Object({
|
|
156
|
+
action: Type.Union([
|
|
157
|
+
Type.Literal("ask"),
|
|
158
|
+
Type.Literal("record"),
|
|
159
|
+
Type.Literal("complete"),
|
|
160
|
+
Type.Literal("status"),
|
|
161
|
+
]),
|
|
162
|
+
field: Type.Optional(
|
|
163
|
+
Type.String({ description: "Scope field key, e.g. projectIds, severityMin" }),
|
|
164
|
+
),
|
|
165
|
+
question: Type.Optional(Type.String({ description: "Question text tailored to the scenario" })),
|
|
166
|
+
options: Type.Optional(
|
|
167
|
+
Type.Array(Type.String(), {
|
|
168
|
+
description: "2–3 short option labels (tool assigns A–C; D is always Other)",
|
|
169
|
+
minItems: 2,
|
|
170
|
+
maxItems: 3,
|
|
171
|
+
}),
|
|
172
|
+
),
|
|
173
|
+
scenario: Type.Optional(
|
|
174
|
+
Type.Union([
|
|
175
|
+
Type.Literal("remediation"),
|
|
176
|
+
Type.Literal("plan"),
|
|
177
|
+
Type.Literal("explore"),
|
|
178
|
+
Type.Literal("review"),
|
|
179
|
+
]),
|
|
180
|
+
),
|
|
181
|
+
fields: Type.Optional(
|
|
182
|
+
Type.Object(
|
|
183
|
+
{},
|
|
184
|
+
{
|
|
185
|
+
description: "Partial scope fields for record/complete",
|
|
186
|
+
additionalProperties: true,
|
|
187
|
+
},
|
|
188
|
+
),
|
|
189
|
+
),
|
|
190
|
+
language: Type.Optional(Type.Union([Type.Literal("pt"), Type.Literal("en")])),
|
|
191
|
+
});
|
|
155
192
|
}
|
|
156
193
|
export function applyParsedUserAnswerIfPending(questionnaire, parsed) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return applyPendingAnswer(questionnaire, parsed);
|
|
194
|
+
if (!questionnaire.awaitingUserAnswer || !questionnaire.pending) return questionnaire;
|
|
195
|
+
return applyPendingAnswer(questionnaire, parsed);
|
|
160
196
|
}
|
|
161
|
-
//# sourceMappingURL=questionnaire-tool.js.map
|
|
197
|
+
//# sourceMappingURL=questionnaire-tool.js.map
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
QuestionnaireScenario,
|
|
3
|
+
SessionQuestionnaireFields,
|
|
4
|
+
} from "./session-questionnaire.types.js";
|
|
2
5
|
export type ScopeDiscoveryResult = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
scenario: QuestionnaireScenario;
|
|
7
|
+
fields: Partial<SessionQuestionnaireFields> & Record<string, unknown>;
|
|
8
|
+
notes: string[];
|
|
6
9
|
};
|
|
7
10
|
/** Discover scope from env, workspace, and user message before asking questions. */
|
|
8
11
|
export declare function discoverScopeHints(cwd: string, userMessage: string): ScopeDiscoveryResult;
|
|
9
|
-
//# sourceMappingURL=scope-discovery.d.ts.map
|
|
12
|
+
//# sourceMappingURL=scope-discovery.d.ts.map
|
|
@@ -1,130 +1,122 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
KUBBISEC_CONTEXT_DIR,
|
|
5
|
+
KUBBISEC_PROJECT_CONFIG_DIR,
|
|
6
|
+
} from "../config/ensure-kubbisec-project-settings.js";
|
|
4
7
|
import { inferScenarioFromMessage } from "./question-format.js";
|
|
5
8
|
import { readDefaultProjectId } from "./session-questionnaire.js";
|
|
9
|
+
|
|
6
10
|
const PROJECT_IN_MESSAGE = /\b(project[:\s]+([\w-]+)|projeto[:\s]+([\w-]+))\b/i;
|
|
7
|
-
const SEVERITY_IN_MESSAGE =
|
|
8
|
-
|
|
11
|
+
const SEVERITY_IN_MESSAGE =
|
|
12
|
+
/\b(severity|severidade|critical|critico|crítico|high|alto|medium|medio|médio)\b/i;
|
|
13
|
+
const REMEDIATION_MODE_IN_MESSAGE =
|
|
14
|
+
/\b(auto|automático|automatico|suggestion|sugestão|sugestao|manual|híbrido|hibrido)\b/i;
|
|
9
15
|
function readLocalSettings(cwd) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
16
|
+
const settingsPath = path.join(cwd, KUBBISEC_PROJECT_CONFIG_DIR, "settings.json");
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(fs.readFileSync(settingsPath, "utf8"));
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
function readPackageName(cwd) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
24
|
+
try {
|
|
25
|
+
const raw = fs.readFileSync(path.join(cwd, "package.json"), "utf8");
|
|
26
|
+
const parsed = JSON.parse(raw);
|
|
27
|
+
return typeof parsed.name === "string" ? parsed.name.trim() : undefined;
|
|
28
|
+
} catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
27
31
|
}
|
|
28
32
|
function readGitRemote(cwd) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
33
|
+
try {
|
|
34
|
+
const raw = fs.readFileSync(path.join(cwd, ".git", "config"), "utf8");
|
|
35
|
+
const match = raw.match(/url\s*=\s*(.+)/);
|
|
36
|
+
return match?.[1]?.trim();
|
|
37
|
+
} catch {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
41
|
function severityFromMessage(message) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return "MEDIUM";
|
|
46
|
-
if (/\bALL|TODAS\b/.test(upper))
|
|
47
|
-
return "ALL";
|
|
48
|
-
return undefined;
|
|
42
|
+
const upper = message.toUpperCase();
|
|
43
|
+
if (/\bCRITICAL|CRÍTICO|CRITICO\b/.test(upper)) return "CRITICAL";
|
|
44
|
+
if (/\bHIGH|ALTO\b/.test(upper)) return "HIGH";
|
|
45
|
+
if (/\bMEDIUM|MÉDIO|MEDIO\b/.test(upper)) return "MEDIUM";
|
|
46
|
+
if (/\bALL|TODAS\b/.test(upper)) return "ALL";
|
|
47
|
+
return undefined;
|
|
49
48
|
}
|
|
50
49
|
function remediationModeFromMessage(message) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return "auto";
|
|
55
|
-
return undefined;
|
|
50
|
+
if (/\b(sugest|suggest|manual|híbrido|hibrido|plano)\b/i.test(message)) return "suggestion";
|
|
51
|
+
if (/\b(auto|automático|automatico|pr|patch)\b/i.test(message)) return "auto";
|
|
52
|
+
return undefined;
|
|
56
53
|
}
|
|
57
54
|
function objectiveFromMessage(message) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return trimmed;
|
|
55
|
+
const trimmed = message.trim();
|
|
56
|
+
if (trimmed.length < 12) return undefined;
|
|
57
|
+
if (/^@plan\b/i.test(trimmed)) {
|
|
58
|
+
return trimmed.replace(/^@plan\b\s*/i, "").trim() || undefined;
|
|
59
|
+
}
|
|
60
|
+
if (/^@planejar\b/i.test(trimmed)) {
|
|
61
|
+
return trimmed.replace(/^@planejar\b\s*/i, "").trim() || undefined;
|
|
62
|
+
}
|
|
63
|
+
return trimmed;
|
|
68
64
|
}
|
|
69
65
|
/** Discover scope from env, workspace, and user message before asking questions. */
|
|
70
66
|
export function discoverScopeHints(cwd, userMessage) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (Object.keys(extras).length > 0) {
|
|
126
|
-
fields.extras = extras;
|
|
127
|
-
}
|
|
128
|
-
return { scenario, fields, notes };
|
|
67
|
+
const scenario = inferScenarioFromMessage(userMessage);
|
|
68
|
+
const fields = {};
|
|
69
|
+
const extras = {};
|
|
70
|
+
const notes = [];
|
|
71
|
+
const defaultProject = readDefaultProjectId();
|
|
72
|
+
if (defaultProject) {
|
|
73
|
+
fields.projectIds = [defaultProject];
|
|
74
|
+
notes.push("default project from config");
|
|
75
|
+
}
|
|
76
|
+
const projectMatch = PROJECT_IN_MESSAGE.exec(userMessage);
|
|
77
|
+
const projectFromMsg = projectMatch?.[2] ?? projectMatch?.[3];
|
|
78
|
+
if (projectFromMsg) {
|
|
79
|
+
fields.projectIds = [projectFromMsg];
|
|
80
|
+
notes.push("project from message");
|
|
81
|
+
}
|
|
82
|
+
const severity = severityFromMessage(userMessage);
|
|
83
|
+
if (severity) {
|
|
84
|
+
fields.severityMin = severity;
|
|
85
|
+
notes.push("severity from message");
|
|
86
|
+
} else if (SEVERITY_IN_MESSAGE.test(userMessage)) {
|
|
87
|
+
notes.push("severity cue in message");
|
|
88
|
+
}
|
|
89
|
+
const remediationMode = remediationModeFromMessage(userMessage);
|
|
90
|
+
if (remediationMode) {
|
|
91
|
+
fields.remediationMode = remediationMode;
|
|
92
|
+
notes.push("remediation mode from message");
|
|
93
|
+
} else if (REMEDIATION_MODE_IN_MESSAGE.test(userMessage)) {
|
|
94
|
+
notes.push("remediation mode cue in message");
|
|
95
|
+
}
|
|
96
|
+
const objective = objectiveFromMessage(userMessage);
|
|
97
|
+
if (objective && scenario === "plan") {
|
|
98
|
+
fields.customNotes = objective;
|
|
99
|
+
notes.push("plan objective from message");
|
|
100
|
+
}
|
|
101
|
+
const pkg = readPackageName(cwd);
|
|
102
|
+
if (pkg) extras.stack = pkg;
|
|
103
|
+
const remote = readGitRemote(cwd);
|
|
104
|
+
if (remote) extras.gitRemote = remote;
|
|
105
|
+
const settings = readLocalSettings(cwd);
|
|
106
|
+
if (settings && typeof settings.defaultProject === "string" && settings.defaultProject.trim()) {
|
|
107
|
+
if (!fields.projectIds?.length) {
|
|
108
|
+
fields.projectIds = [settings.defaultProject.trim()];
|
|
109
|
+
notes.push("project from .kubbisec/settings.json");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const contextDir = path.join(cwd, KUBBISEC_PROJECT_CONFIG_DIR, KUBBISEC_CONTEXT_DIR);
|
|
113
|
+
if (fs.existsSync(contextDir)) {
|
|
114
|
+
extras.workspaceContext = "present";
|
|
115
|
+
notes.push("local .kubbisec/context");
|
|
116
|
+
}
|
|
117
|
+
if (Object.keys(extras).length > 0) {
|
|
118
|
+
fields.extras = extras;
|
|
119
|
+
}
|
|
120
|
+
return { scenario, fields, notes };
|
|
129
121
|
}
|
|
130
|
-
//# sourceMappingURL=scope-discovery.js.map
|
|
122
|
+
//# sourceMappingURL=scope-discovery.js.map
|