@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.
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,211 +1,230 @@
1
- import { groupModelsForSelector, KubbisecModelSelectorComponent, } from "../components/kubbisec-model-selector.js";
1
+ import {
2
+ groupModelsForSelector,
3
+ KubbisecModelSelectorComponent,
4
+ } from "../components/kubbisec-model-selector.js";
2
5
  import { syncAutodetectedLocalProviders } from "../config/detect-local-llm-providers.js";
3
- import { applyLlmConfigToPiSettings, applyTemperatureToProviderPayload, getRuntimeTemperature, readLlmConfig, setRuntimeTemperature, writeLlmConfig, } from "../config/llm-config.js";
6
+ import {
7
+ applyLlmConfigToPiSettings,
8
+ applyTemperatureToProviderPayload,
9
+ getRuntimeTemperature,
10
+ readLlmConfig,
11
+ setRuntimeTemperature,
12
+ writeLlmConfig,
13
+ } from "../config/llm-config.js";
4
14
  import { KUBBISEC_LLM_PROVIDER_ID } from "../config/llm-provider-catalog.js";
5
15
  import { registerCustomLlmProviders } from "../config/register-custom-llm-providers.js";
6
16
  import { registerKubbisecLlmProvider } from "../config/register-kubbisec-llm-provider.js";
7
17
  import { requestKubbisecFooterRender } from "../theme/footer-render-hook.js";
8
- const THINKING_LEVELS = [
9
- "off",
10
- "minimal",
11
- "low",
12
- "medium",
13
- "high",
14
- "xhigh",
15
- ];
18
+
19
+ const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh"];
16
20
  function isThinkingLevel(value) {
17
- return THINKING_LEVELS.includes(value);
21
+ return THINKING_LEVELS.includes(value);
18
22
  }
19
23
  async function refreshProviders(api, cwd) {
20
- await syncAutodetectedLocalProviders(cwd);
21
- registerKubbisecLlmProvider(api.registerProvider.bind(api), cwd);
22
- registerCustomLlmProviders(api.registerProvider.bind(api), readLlmConfig(cwd));
24
+ await syncAutodetectedLocalProviders(cwd);
25
+ registerKubbisecLlmProvider(api.registerProvider.bind(api), cwd);
26
+ registerCustomLlmProviders(api.registerProvider.bind(api), readLlmConfig(cwd));
23
27
  }
24
28
  async function applyDefaultModel(api, ctx) {
25
- const config = readLlmConfig(ctx.cwd);
26
- const provider = config.defaultProvider ?? KUBBISEC_LLM_PROVIDER_ID;
27
- const modelId = config.defaultModel?.trim();
28
- if (!modelId)
29
- return;
30
- const model = ctx.modelRegistry.find(provider, modelId);
31
- if (!model)
32
- return;
33
- const current = ctx.model;
34
- if (current?.provider === model.provider && current.id === model.id)
35
- return;
36
- await api.setModel(model);
29
+ const config = readLlmConfig(ctx.cwd);
30
+ const provider = config.defaultProvider ?? KUBBISEC_LLM_PROVIDER_ID;
31
+ const modelId = config.defaultModel?.trim();
32
+ if (!modelId) return;
33
+ const model = ctx.modelRegistry.find(provider, modelId);
34
+ if (!model) return;
35
+ const current = ctx.model;
36
+ if (current?.provider === model.provider && current.id === model.id) return;
37
+ await api.setModel(model);
37
38
  }
38
39
  function applyDefaultThinking(api, ctx) {
39
- const config = readLlmConfig(ctx.cwd);
40
- if (!config.defaultThinkingLevel)
41
- return;
42
- if (api.getThinkingLevel() === config.defaultThinkingLevel)
43
- return;
44
- api.setThinkingLevel(config.defaultThinkingLevel);
40
+ const config = readLlmConfig(ctx.cwd);
41
+ if (!config.defaultThinkingLevel) return;
42
+ if (api.getThinkingLevel() === config.defaultThinkingLevel) return;
43
+ api.setThinkingLevel(config.defaultThinkingLevel);
45
44
  }
46
45
  async function showGroupedModelSelector(api, ctx, initialSearch = "") {
47
- if (!ctx.hasUI)
48
- return;
49
- ctx.modelRegistry.refresh();
50
- const models = ctx.modelRegistry.getAvailable();
51
- const groups = groupModelsForSelector(models, (provider) => ctx.modelRegistry.getProviderDisplayName(provider));
52
- await ctx.ui.custom((tui, theme, _keybindings, done) => new KubbisecModelSelectorComponent(tui, ctx.model, groups, theme, async (model) => {
53
- const ok = await api.setModel(model);
54
- if (!ok) {
55
- ctx.ui.notify("Chave de API não configurada para este provedor. Edite .kubbisec/llm.json ou use /login.", "error");
46
+ if (!ctx.hasUI) return;
47
+ ctx.modelRegistry.refresh();
48
+ const models = ctx.modelRegistry.getAvailable();
49
+ const groups = groupModelsForSelector(models, (provider) =>
50
+ ctx.modelRegistry.getProviderDisplayName(provider),
51
+ );
52
+ await ctx.ui.custom(
53
+ (tui, theme, _keybindings, done) =>
54
+ new KubbisecModelSelectorComponent(
55
+ tui,
56
+ ctx.model,
57
+ groups,
58
+ theme,
59
+ async (model) => {
60
+ const ok = await api.setModel(model);
61
+ if (!ok) {
62
+ ctx.ui.notify(
63
+ "Chave de API não configurada para este provedor. Edite .kubbisec/llm.json ou use /login.",
64
+ "error",
65
+ );
56
66
  return;
57
- }
58
- const config = readLlmConfig(ctx.cwd);
59
- writeLlmConfig(ctx.cwd, {
67
+ }
68
+ const config = readLlmConfig(ctx.cwd);
69
+ writeLlmConfig(ctx.cwd, {
60
70
  ...config,
61
71
  defaultProvider: model.provider,
62
72
  defaultModel: model.id,
63
- });
64
- ctx.ui.notify(`Modelo: ${ctx.modelRegistry.getProviderDisplayName(model.provider)} · ${model.name}`, "info");
65
- done(undefined);
66
- }, () => done(undefined), initialSearch));
73
+ });
74
+ ctx.ui.notify(
75
+ `Modelo: ${ctx.modelRegistry.getProviderDisplayName(model.provider)} · ${model.name}`,
76
+ "info",
77
+ );
78
+ done(undefined);
79
+ },
80
+ () => done(undefined),
81
+ initialSearch,
82
+ ),
83
+ );
67
84
  }
68
85
  async function handleModelCommand(api, args, ctx) {
69
- const trimmed = args.trim();
70
- if (!trimmed || trimmed === "list" || trimmed === "select") {
71
- await showGroupedModelSelector(api, ctx, trimmed === "list" ? "" : "");
72
- return;
73
- }
74
- const slash = trimmed.indexOf("/");
75
- const provider = slash >= 0 ? trimmed.slice(0, slash).trim() : KUBBISEC_LLM_PROVIDER_ID;
76
- const modelId = slash >= 0 ? trimmed.slice(slash + 1).trim() : trimmed;
77
- if (!modelId) {
78
- ctx.ui?.notify("Uso: /model [provedor/]modelo-id ou /model para abrir o seletor.", "warning");
79
- return;
80
- }
81
- const model = ctx.modelRegistry.find(provider, modelId);
82
- if (!model) {
83
- ctx.ui?.notify(`Modelo não encontrado: ${provider}/${modelId}`, "error");
84
- return;
85
- }
86
- const ok = await api.setModel(model);
87
- if (!ok) {
88
- ctx.ui?.notify("Chave de API não configurada para este provedor.", "error");
89
- return;
90
- }
91
- const config = readLlmConfig(ctx.cwd);
92
- writeLlmConfig(ctx.cwd, {
93
- ...config,
94
- defaultProvider: model.provider,
95
- defaultModel: model.id,
96
- });
97
- ctx.ui?.notify(`Modelo: ${ctx.modelRegistry.getProviderDisplayName(model.provider)} · ${model.name}`, "info");
86
+ const trimmed = args.trim();
87
+ if (!trimmed || trimmed === "list" || trimmed === "select") {
88
+ await showGroupedModelSelector(api, ctx, trimmed === "list" ? "" : "");
89
+ return;
90
+ }
91
+ const slash = trimmed.indexOf("/");
92
+ const provider = slash >= 0 ? trimmed.slice(0, slash).trim() : KUBBISEC_LLM_PROVIDER_ID;
93
+ const modelId = slash >= 0 ? trimmed.slice(slash + 1).trim() : trimmed;
94
+ if (!modelId) {
95
+ ctx.ui?.notify("Uso: /model [provedor/]modelo-id ou /model para abrir o seletor.", "warning");
96
+ return;
97
+ }
98
+ const model = ctx.modelRegistry.find(provider, modelId);
99
+ if (!model) {
100
+ ctx.ui?.notify(`Modelo não encontrado: ${provider}/${modelId}`, "error");
101
+ return;
102
+ }
103
+ const ok = await api.setModel(model);
104
+ if (!ok) {
105
+ ctx.ui?.notify("Chave de API não configurada para este provedor.", "error");
106
+ return;
107
+ }
108
+ const config = readLlmConfig(ctx.cwd);
109
+ writeLlmConfig(ctx.cwd, {
110
+ ...config,
111
+ defaultProvider: model.provider,
112
+ defaultModel: model.id,
113
+ });
114
+ ctx.ui?.notify(
115
+ `Modelo: ${ctx.modelRegistry.getProviderDisplayName(model.provider)} · ${model.name}`,
116
+ "info",
117
+ );
98
118
  }
99
119
  async function handleTemperatureCommand(args, ctx) {
100
- const trimmed = args.trim().toLowerCase();
101
- const config = readLlmConfig(ctx.cwd);
102
- if (!trimmed || trimmed === "status") {
103
- const value = getRuntimeTemperature(config);
104
- ctx.ui?.notify(value == null
105
- ? "Temperatura: padrão do modelo (não definida em .kubbisec/llm.json)"
106
- : `Temperatura: ${value}`, "info");
107
- return;
108
- }
109
- if (trimmed === "reset" || trimmed === "default") {
110
- setRuntimeTemperature(undefined, ctx.cwd);
111
- const next = readLlmConfig(ctx.cwd);
112
- writeLlmConfig(ctx.cwd, { ...next, temperature: config.temperature ?? 0.2 });
113
- ctx.ui?.notify("Temperatura restaurada ao valor de .kubbisec/llm.json", "info");
114
- requestKubbisecFooterRender();
115
- return;
116
- }
117
- const parsed = Number.parseFloat(trimmed);
118
- if (!Number.isFinite(parsed)) {
119
- ctx.ui?.notify("Uso: /temperature 0.2 · /temperature status · /temperature reset", "warning");
120
- return;
121
- }
122
- setRuntimeTemperature(parsed, ctx.cwd);
123
- ctx.ui?.notify(`Temperatura: ${getRuntimeTemperature()}`, "info");
120
+ const trimmed = args.trim().toLowerCase();
121
+ const config = readLlmConfig(ctx.cwd);
122
+ if (!trimmed || trimmed === "status") {
123
+ const value = getRuntimeTemperature(config);
124
+ ctx.ui?.notify(
125
+ value == null
126
+ ? "Temperatura: padrão do modelo (não definida em .kubbisec/llm.json)"
127
+ : `Temperatura: ${value}`,
128
+ "info",
129
+ );
130
+ return;
131
+ }
132
+ if (trimmed === "reset" || trimmed === "default") {
133
+ setRuntimeTemperature(undefined, ctx.cwd);
134
+ const next = readLlmConfig(ctx.cwd);
135
+ writeLlmConfig(ctx.cwd, { ...next, temperature: config.temperature ?? 0.2 });
136
+ ctx.ui?.notify("Temperatura restaurada ao valor de .kubbisec/llm.json", "info");
124
137
  requestKubbisecFooterRender();
138
+ return;
139
+ }
140
+ const parsed = Number.parseFloat(trimmed);
141
+ if (!Number.isFinite(parsed)) {
142
+ ctx.ui?.notify("Uso: /temperature 0.2 · /temperature status · /temperature reset", "warning");
143
+ return;
144
+ }
145
+ setRuntimeTemperature(parsed, ctx.cwd);
146
+ ctx.ui?.notify(`Temperatura: ${getRuntimeTemperature()}`, "info");
147
+ requestKubbisecFooterRender();
125
148
  }
126
149
  async function handleThinkingCommand(api, args, ctx) {
127
- const trimmed = args.trim().toLowerCase();
128
- if (!trimmed || trimmed === "status") {
129
- ctx.ui?.notify(`Reasoning effort: ${api.getThinkingLevel()}`, "info");
130
- return;
131
- }
132
- if (!isThinkingLevel(trimmed)) {
133
- ctx.ui?.notify(`Uso: /thinking ${THINKING_LEVELS.join(" | ")}`, "warning");
134
- return;
135
- }
136
- api.setThinkingLevel(trimmed);
137
- const config = readLlmConfig(ctx.cwd);
138
- writeLlmConfig(ctx.cwd, { ...config, defaultThinkingLevel: trimmed });
139
- ctx.ui?.notify(`Reasoning effort: ${trimmed}`, "info");
140
- requestKubbisecFooterRender();
150
+ const trimmed = args.trim().toLowerCase();
151
+ if (!trimmed || trimmed === "status") {
152
+ ctx.ui?.notify(`Reasoning effort: ${api.getThinkingLevel()}`, "info");
153
+ return;
154
+ }
155
+ if (!isThinkingLevel(trimmed)) {
156
+ ctx.ui?.notify(`Uso: /thinking ${THINKING_LEVELS.join(" | ")}`, "warning");
157
+ return;
158
+ }
159
+ api.setThinkingLevel(trimmed);
160
+ const config = readLlmConfig(ctx.cwd);
161
+ writeLlmConfig(ctx.cwd, { ...config, defaultThinkingLevel: trimmed });
162
+ ctx.ui?.notify(`Reasoning effort: ${trimmed}`, "info");
163
+ requestKubbisecFooterRender();
141
164
  }
142
165
  export default function kubbisecLlmConfig(api) {
143
- registerKubbisecLlmProvider(api.registerProvider.bind(api));
144
- const modelsCommand = {
145
- description: "Selecionar modelo (agrupado por provedor)",
146
- handler: (args, ctx) => handleModelCommand(api, args, ctx),
147
- };
148
- api.registerCommand("models", modelsCommand);
149
- api.on("input", async (event, ctx) => {
150
- if (event.source !== "interactive" || !ctx.hasUI)
151
- return;
152
- const trimmed = event.text.trim();
153
- if (!trimmed.startsWith("/model"))
154
- return;
155
- if (trimmed.length > 6 && !trimmed.startsWith("/model "))
156
- return;
157
- const args = trimmed === "/model" ? "" : trimmed.slice("/model ".length);
158
- await handleModelCommand(api, args, ctx);
159
- return { action: "handled" };
160
- });
161
- api.registerCommand("temperature", {
162
- description: "Ver ou definir temperatura (0–2)",
163
- handler: handleTemperatureCommand,
164
- });
165
- api.registerCommand("thinking", {
166
- description: "Ver ou definir reasoning effort (off … xhigh)",
167
- handler: (args, ctx) => handleThinkingCommand(api, args, ctx),
168
- });
169
- api.registerCommand("detect-local", {
170
- description: "Detectar Ollama e LM Studio nesta máquina",
171
- handler: async (_args, ctx) => {
172
- const { result } = await syncAutodetectedLocalProviders(ctx.cwd);
173
- await refreshProviders(api, ctx.cwd);
174
- const names = result.detected.map((provider) => provider.name ?? provider.id);
175
- if (names.length === 0) {
176
- ctx.ui?.notify("Nenhum servidor local detectado (Ollama / LM Studio).", "info");
177
- return;
178
- }
179
- ctx.ui?.notify(`Detectados: ${names.join(", ")}`, "info");
180
- },
181
- });
182
- api.on("session_start", async (_event, ctx) => {
183
- await refreshProviders(api, ctx.cwd);
184
- applyLlmConfigToPiSettings(ctx.cwd);
185
- await applyDefaultModel(api, ctx);
186
- applyDefaultThinking(api, ctx);
187
- });
188
- api.on("before_provider_request", async (event, ctx) => {
189
- const temperature = getRuntimeTemperature(readLlmConfig(ctx.cwd));
190
- return applyTemperatureToProviderPayload(event.payload, temperature);
191
- });
192
- api.on("model_select", async (_event, ctx) => {
193
- const model = ctx.model;
194
- if (!model)
195
- return;
196
- const config = readLlmConfig(ctx.cwd);
197
- writeLlmConfig(ctx.cwd, {
198
- ...config,
199
- defaultProvider: model.provider,
200
- defaultModel: model.id,
201
- });
166
+ registerKubbisecLlmProvider(api.registerProvider.bind(api));
167
+ const modelsCommand = {
168
+ description: "Selecionar modelo (agrupado por provedor)",
169
+ handler: (args, ctx) => handleModelCommand(api, args, ctx),
170
+ };
171
+ api.registerCommand("models", modelsCommand);
172
+ api.on("input", async (event, ctx) => {
173
+ if (event.source !== "interactive" || !ctx.hasUI) return;
174
+ const trimmed = event.text.trim();
175
+ if (!trimmed.startsWith("/model")) return;
176
+ if (trimmed.length > 6 && !trimmed.startsWith("/model ")) return;
177
+ const args = trimmed === "/model" ? "" : trimmed.slice("/model ".length);
178
+ await handleModelCommand(api, args, ctx);
179
+ return { action: "handled" };
180
+ });
181
+ api.registerCommand("temperature", {
182
+ description: "Ver ou definir temperatura (0–2)",
183
+ handler: handleTemperatureCommand,
184
+ });
185
+ api.registerCommand("thinking", {
186
+ description: "Ver ou definir reasoning effort (off … xhigh)",
187
+ handler: (args, ctx) => handleThinkingCommand(api, args, ctx),
188
+ });
189
+ api.registerCommand("detect-local", {
190
+ description: "Detectar Ollama e LM Studio nesta máquina",
191
+ handler: async (_args, ctx) => {
192
+ const { result } = await syncAutodetectedLocalProviders(ctx.cwd);
193
+ await refreshProviders(api, ctx.cwd);
194
+ const names = result.detected.map((provider) => provider.name ?? provider.id);
195
+ if (names.length === 0) {
196
+ ctx.ui?.notify("Nenhum servidor local detectado (Ollama / LM Studio).", "info");
197
+ return;
198
+ }
199
+ ctx.ui?.notify(`Detectados: ${names.join(", ")}`, "info");
200
+ },
201
+ });
202
+ api.on("session_start", async (_event, ctx) => {
203
+ await refreshProviders(api, ctx.cwd);
204
+ applyLlmConfigToPiSettings(ctx.cwd);
205
+ await applyDefaultModel(api, ctx);
206
+ applyDefaultThinking(api, ctx);
207
+ });
208
+ api.on("before_provider_request", async (event, ctx) => {
209
+ const temperature = getRuntimeTemperature(readLlmConfig(ctx.cwd));
210
+ return applyTemperatureToProviderPayload(event.payload, temperature);
211
+ });
212
+ api.on("model_select", async (_event, ctx) => {
213
+ const model = ctx.model;
214
+ if (!model) return;
215
+ const config = readLlmConfig(ctx.cwd);
216
+ writeLlmConfig(ctx.cwd, {
217
+ ...config,
218
+ defaultProvider: model.provider,
219
+ defaultModel: model.id,
202
220
  });
203
- api.on("thinking_level_select", async (_event, ctx) => {
204
- const config = readLlmConfig(ctx.cwd);
205
- writeLlmConfig(ctx.cwd, {
206
- ...config,
207
- defaultThinkingLevel: api.getThinkingLevel(),
208
- });
221
+ });
222
+ api.on("thinking_level_select", async (_event, ctx) => {
223
+ const config = readLlmConfig(ctx.cwd);
224
+ writeLlmConfig(ctx.cwd, {
225
+ ...config,
226
+ defaultThinkingLevel: api.getThinkingLevel(),
209
227
  });
228
+ });
210
229
  }
211
- //# sourceMappingURL=kubbisec-llm-config.extension.js.map
230
+ //# sourceMappingURL=kubbisec-llm-config.extension.js.map
@@ -1,12 +1,14 @@
1
1
  type ExtensionApi = {
2
- on: (event: string, handler: (event: unknown, ctx: ExtensionContext) => void | Promise<unknown>) => void;
2
+ on: (
3
+ event: string,
4
+ handler: (event: unknown, ctx: ExtensionContext) => undefined | Promise<unknown>,
5
+ ) => void;
3
6
  };
4
7
  type ExtensionContext = {
5
- hasUI: boolean;
6
- ui: {
7
- setStatus: (key: string, text: string | undefined) => void;
8
- };
8
+ hasUI: boolean;
9
+ ui: {
10
+ setStatus: (key: string, text: string | undefined) => void;
11
+ };
9
12
  };
10
13
  export default function kubbisecMemory(api: ExtensionApi): void;
11
- export {};
12
- //# sourceMappingURL=kubbisec-memory.extension.d.ts.map
14
+ //# sourceMappingURL=kubbisec-memory.extension.d.ts.map
@@ -1,107 +1,100 @@
1
1
  /**
2
2
  * KubbiSec memory extension — recall before turn, remember after turn.
3
3
  */
4
- import { addChatMemoryTurn, buildMemoryInjectBlock, extractRememberCandidates, isMemoryEnabled, searchChatMemory, } from "@kubbisec/chat-memory";
4
+ import {
5
+ addChatMemoryTurn,
6
+ buildMemoryInjectBlock,
7
+ extractRememberCandidates,
8
+ isMemoryEnabled,
9
+ searchChatMemory,
10
+ } from "@kubbisec/chat-memory";
11
+
5
12
  function resolveMemoryScope() {
6
- const organizationId = process.env.KUBBISEC_ORG_ID?.trim();
7
- const userId = process.env.KUBBISEC_USER_ID?.trim() ?? process.env.KUBBISEC_CLIENT_ID?.trim();
8
- if (!organizationId || !userId)
9
- return null;
10
- const projectId = process.env.KUBBISEC_PROJECT_ID?.trim();
11
- return {
12
- organizationId,
13
- userId,
14
- ...(projectId ? { projectId } : {}),
15
- };
13
+ const organizationId = process.env.KUBBISEC_ORG_ID?.trim();
14
+ const userId = process.env.KUBBISEC_USER_ID?.trim() ?? process.env.KUBBISEC_CLIENT_ID?.trim();
15
+ if (!organizationId || !userId) return null;
16
+ const projectId = process.env.KUBBISEC_PROJECT_ID?.trim();
17
+ return {
18
+ organizationId,
19
+ userId,
20
+ ...(projectId ? { projectId } : {}),
21
+ };
16
22
  }
17
23
  function extractTextContent(content) {
18
- if (typeof content === "string")
19
- return content;
20
- if (!Array.isArray(content))
21
- return "";
22
- return content
23
- .filter((block) => typeof block === "object" && block !== null)
24
- .filter((block) => block.type === "text" && typeof block.text === "string")
25
- .map((block) => block.text ?? "")
26
- .join("\n");
24
+ if (typeof content === "string") return content;
25
+ if (!Array.isArray(content)) return "";
26
+ return content
27
+ .filter((block) => typeof block === "object" && block !== null)
28
+ .filter((block) => block.type === "text" && typeof block.text === "string")
29
+ .map((block) => block.text ?? "")
30
+ .join("\n");
27
31
  }
28
32
  function lastUserMessage(messages) {
29
- for (let i = messages.length - 1; i >= 0; i -= 1) {
30
- const msg = messages[i];
31
- if (msg?.role === "user") {
32
- return extractTextContent(msg.content);
33
- }
33
+ for (let i = messages.length - 1; i >= 0; i -= 1) {
34
+ const msg = messages[i];
35
+ if (msg?.role === "user") {
36
+ return extractTextContent(msg.content);
34
37
  }
35
- return "";
38
+ }
39
+ return "";
36
40
  }
37
41
  export default function kubbisecMemory(api) {
38
- let lastUserPrompt = "";
39
- api.on("before_agent_start", async (event) => {
40
- if (!isMemoryEnabled())
41
- return undefined;
42
- const scope = resolveMemoryScope();
43
- if (!scope)
44
- return undefined;
45
- const { prompt } = event;
46
- lastUserPrompt = prompt;
47
- try {
48
- const memories = await Promise.race([
49
- searchChatMemory(scope, prompt, 5),
50
- new Promise((_, reject) => {
51
- setTimeout(() => reject(new Error("recall_timeout")), 3000);
52
- }),
53
- ]);
54
- const block = buildMemoryInjectBlock(memories);
55
- if (!block)
56
- return undefined;
57
- return {
58
- message: {
59
- customType: "kubbisec-memory-inject",
60
- content: block,
61
- display: false,
62
- },
63
- };
64
- }
65
- catch {
66
- return undefined;
67
- }
68
- });
69
- api.on("turn_end", async (event, ctx) => {
70
- if (!isMemoryEnabled())
71
- return;
72
- if (!lastUserPrompt || lastUserPrompt.length < 20)
73
- return;
74
- const scope = resolveMemoryScope();
75
- if (!scope)
76
- return;
77
- const turn = event;
78
- if (turn.message.role !== "assistant")
79
- return;
80
- const assistantText = extractTextContent(turn.message.content);
81
- const candidates = extractRememberCandidates(lastUserPrompt, assistantText);
82
- for (const candidate of candidates) {
83
- await addChatMemoryTurn(scope, candidate);
84
- }
85
- if (ctx.hasUI && candidates.length > 0) {
86
- ctx.ui.setStatus("kubbisec-memory", `memory · ${candidates.length}`);
87
- }
88
- });
89
- api.on("agent_end", async (event) => {
90
- if (!isMemoryEnabled())
91
- return;
92
- const scope = resolveMemoryScope();
93
- if (!scope)
94
- return;
95
- const agentEnd = event;
96
- const userText = lastUserMessage(agentEnd.messages);
97
- const assistantMsg = [...agentEnd.messages].reverse().find((m) => m.role === "assistant");
98
- const assistantText = assistantMsg ? extractTextContent(assistantMsg.content) : "";
99
- if (!userText || userText.length < 20)
100
- return;
101
- const candidates = extractRememberCandidates(userText, assistantText);
102
- for (const candidate of candidates) {
103
- await addChatMemoryTurn(scope, candidate);
104
- }
105
- });
42
+ let lastUserPrompt = "";
43
+ api.on("before_agent_start", async (event) => {
44
+ if (!isMemoryEnabled()) return undefined;
45
+ const scope = resolveMemoryScope();
46
+ if (!scope) return undefined;
47
+ const { prompt } = event;
48
+ lastUserPrompt = prompt;
49
+ try {
50
+ const memories = await Promise.race([
51
+ searchChatMemory(scope, prompt, 5),
52
+ new Promise((_, reject) => {
53
+ setTimeout(() => reject(new Error("recall_timeout")), 3000);
54
+ }),
55
+ ]);
56
+ const block = buildMemoryInjectBlock(memories);
57
+ if (!block) return undefined;
58
+ return {
59
+ message: {
60
+ customType: "kubbisec-memory-inject",
61
+ content: block,
62
+ display: false,
63
+ },
64
+ };
65
+ } catch {
66
+ return undefined;
67
+ }
68
+ });
69
+ api.on("turn_end", async (event, ctx) => {
70
+ if (!isMemoryEnabled()) return;
71
+ if (!lastUserPrompt || lastUserPrompt.length < 20) return;
72
+ const scope = resolveMemoryScope();
73
+ if (!scope) return;
74
+ const turn = event;
75
+ if (turn.message.role !== "assistant") return;
76
+ const assistantText = extractTextContent(turn.message.content);
77
+ const candidates = extractRememberCandidates(lastUserPrompt, assistantText);
78
+ for (const candidate of candidates) {
79
+ await addChatMemoryTurn(scope, candidate);
80
+ }
81
+ if (ctx.hasUI && candidates.length > 0) {
82
+ ctx.ui.setStatus("kubbisec-memory", `memory · ${candidates.length}`);
83
+ }
84
+ });
85
+ api.on("agent_end", async (event) => {
86
+ if (!isMemoryEnabled()) return;
87
+ const scope = resolveMemoryScope();
88
+ if (!scope) return;
89
+ const agentEnd = event;
90
+ const userText = lastUserMessage(agentEnd.messages);
91
+ const assistantMsg = [...agentEnd.messages].reverse().find((m) => m.role === "assistant");
92
+ const assistantText = assistantMsg ? extractTextContent(assistantMsg.content) : "";
93
+ if (!userText || userText.length < 20) return;
94
+ const candidates = extractRememberCandidates(userText, assistantText);
95
+ for (const candidate of candidates) {
96
+ await addChatMemoryTurn(scope, candidate);
97
+ }
98
+ });
106
99
  }
107
- //# sourceMappingURL=kubbisec-memory.extension.js.map
100
+ //# sourceMappingURL=kubbisec-memory.extension.js.map