@kubbisec/ai-linux-x64 0.1.22 → 0.1.23

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 (109) hide show
  1. package/bin/kubbisec +0 -0
  2. package/bundled/components/kubbisec-model-selector.d.ts +47 -34
  3. package/bundled/components/kubbisec-model-selector.js +187 -177
  4. package/bundled/config/config.d.ts +6 -6
  5. package/bundled/config/config.js +54 -52
  6. package/bundled/config/detect-local-llm-providers.d.ts +26 -16
  7. package/bundled/config/detect-local-llm-providers.js +130 -142
  8. package/bundled/config/ensure-kbs-project-settings.d.ts +8 -8
  9. package/bundled/config/ensure-kbs-project-settings.js +27 -28
  10. package/bundled/config/ensure-kubbisec-project-settings.d.ts +9 -9
  11. package/bundled/config/ensure-kubbisec-project-settings.js +62 -67
  12. package/bundled/config/extended-context.d.ts +5 -6
  13. package/bundled/config/extended-context.js +23 -22
  14. package/bundled/config/feature-flags.d.ts +10 -2
  15. package/bundled/config/feature-flags.js +8 -2
  16. package/bundled/config/format-kubbisec-footer-status.d.ts +1 -1
  17. package/bundled/config/format-kubbisec-footer-status.js +26 -31
  18. package/bundled/config/kubbisec-extension-manifest.d.ts +21 -2
  19. package/bundled/config/kubbisec-extension-manifest.js +19 -19
  20. package/bundled/config/llm-config-mutations.d.ts +51 -25
  21. package/bundled/config/llm-config-mutations.js +173 -182
  22. package/bundled/config/llm-config.d.ts +54 -41
  23. package/bundled/config/llm-config.js +199 -199
  24. package/bundled/config/llm-provider-catalog.d.ts +18 -15
  25. package/bundled/config/llm-provider-catalog.js +45 -46
  26. package/bundled/config/materialize-kubbisec-pi-resources.d.ts +1 -1
  27. package/bundled/config/materialize-kubbisec-pi-resources.js +173 -182
  28. package/bundled/config/register-custom-llm-providers.d.ts +11 -5
  29. package/bundled/config/register-custom-llm-providers.js +17 -15
  30. package/bundled/config/register-kubbisec-llm-provider.d.ts +14 -10
  31. package/bundled/config/register-kubbisec-llm-provider.js +50 -42
  32. package/bundled/config/resolve-agents-context-file.d.ts +1 -1
  33. package/bundled/config/resolve-agents-context-file.js +33 -34
  34. package/bundled/config/resource-budget.d.ts +12 -12
  35. package/bundled/config/resource-budget.js +28 -28
  36. package/bundled/config/sync-kubbisec-pi-models.d.ts +6 -3
  37. package/bundled/config/sync-kubbisec-pi-models.js +58 -58
  38. package/bundled/copy/cli-reference-index.d.ts +1 -1
  39. package/bundled/copy/cli-reference-index.js +1 -1
  40. package/bundled/copy/kubbisec-shell-copy.d.ts +11 -6
  41. package/bundled/copy/kubbisec-shell-copy.js +1 -1
  42. package/bundled/extensions/cli-local-shared.d.ts +56 -32
  43. package/bundled/extensions/cli-local-shared.js +135 -125
  44. package/bundled/extensions/kubbisec-aspm-local.extension.d.ts +18 -15
  45. package/bundled/extensions/kubbisec-aspm-local.extension.js +109 -106
  46. package/bundled/extensions/kubbisec-brand.extension.d.ts +1 -1
  47. package/bundled/extensions/kubbisec-brand.extension.js +25 -25
  48. package/bundled/extensions/kubbisec-byok-provider.extension.d.ts +1 -1
  49. package/bundled/extensions/kubbisec-byok-provider.extension.js +2 -2
  50. package/bundled/extensions/kubbisec-clarify.extension.d.ts +64 -35
  51. package/bundled/extensions/kubbisec-clarify.extension.js +323 -305
  52. package/bundled/extensions/kubbisec-exit.extension.d.ts +1 -1
  53. package/bundled/extensions/kubbisec-exit.extension.js +29 -32
  54. package/bundled/extensions/kubbisec-extended-context.extension.d.ts +1 -1
  55. package/bundled/extensions/kubbisec-extended-context.extension.js +56 -43
  56. package/bundled/extensions/kubbisec-footer.extension.d.ts +14 -14
  57. package/bundled/extensions/kubbisec-footer.extension.js +205 -215
  58. package/bundled/extensions/kubbisec-github-local.extension.d.ts +26 -18
  59. package/bundled/extensions/kubbisec-github-local.extension.js +430 -417
  60. package/bundled/extensions/kubbisec-llm-config.extension.d.ts +1 -1
  61. package/bundled/extensions/kubbisec-llm-config.extension.js +200 -181
  62. package/bundled/extensions/kubbisec-memory.extension.d.ts +9 -7
  63. package/bundled/extensions/kubbisec-memory.extension.js +88 -95
  64. package/bundled/extensions/kubbisec-naus-local.extension.d.ts +18 -15
  65. package/bundled/extensions/kubbisec-naus-local.extension.js +123 -103
  66. package/bundled/extensions/kubbisec-platform-tools.extension.d.ts +31 -21
  67. package/bundled/extensions/kubbisec-platform-tools.extension.js +152 -152
  68. package/bundled/extensions/kubbisec-runtime-status.extension.d.ts +10 -8
  69. package/bundled/extensions/kubbisec-runtime-status.extension.js +15 -13
  70. package/bundled/extensions/kubbisec-scope.extension.d.ts +12 -7
  71. package/bundled/extensions/kubbisec-scope.extension.js +13 -13
  72. package/bundled/extensions/kubbisec-skill-mentions.extension.d.ts +27 -16
  73. package/bundled/extensions/kubbisec-skill-mentions.extension.js +74 -64
  74. package/bundled/extensions/kubbisec-skill-telemetry.extension.d.ts +2 -3
  75. package/bundled/extensions/kubbisec-skill-telemetry.extension.js +59 -64
  76. package/bundled/extensions/kubbisec-theme-lock.extension.d.ts +1 -1
  77. package/bundled/extensions/kubbisec-theme-lock.extension.js +33 -34
  78. package/bundled/extensions/kubbisec-ui.extension.d.ts +1 -1
  79. package/bundled/extensions/kubbisec-ui.extension.js +90 -92
  80. package/bundled/extensions/kubbisec-workflow.extension.d.ts +20 -18
  81. package/bundled/extensions/kubbisec-workflow.extension.js +138 -140
  82. package/bundled/resolve-bundled-dist-root.js +121 -130
  83. package/bundled/skills/at-path-mentions.d.ts +1 -1
  84. package/bundled/skills/at-path-mentions.js +146 -153
  85. package/bundled/skills/chat-mention-render.d.ts +2 -2
  86. package/bundled/skills/chat-mention-render.js +121 -126
  87. package/bundled/skills/chat-mentions.d.ts +17 -8
  88. package/bundled/skills/chat-mentions.js +76 -76
  89. package/bundled/skills/list-bundled-skills.d.ts +3 -3
  90. package/bundled/skills/list-bundled-skills.js +33 -35
  91. package/bundled/skills/skill-mention.d.ts +10 -2
  92. package/bundled/skills/skill-mention.js +10 -2
  93. package/bundled/theme/clear-terminal.d.ts +1 -1
  94. package/bundled/theme/clear-terminal.js +3 -4
  95. package/bundled/theme/footer-render-hook.d.ts +1 -1
  96. package/bundled/theme/footer-render-hook.js +3 -3
  97. package/bundled/theme/kubbisec-brand-fg.d.ts +1 -1
  98. package/bundled/theme/kubbisec-brand-fg.js +2 -2
  99. package/bundled/theme/kubbisec-menu-themes.d.ts +7 -7
  100. package/bundled/theme/kubbisec-menu-themes.js +30 -31
  101. package/bundled/theme/kubbisec-theme-name.d.ts +1 -1
  102. package/bundled/theme/kubbisec-theme-name.js +1 -1
  103. package/bundled/theme/patch-pi-settings-theme.runtime.d.ts +1 -1
  104. package/bundled/theme/patch-pi-settings-theme.runtime.js +11 -10
  105. package/bundled/theme/render-compact-header.d.ts +13 -5
  106. package/bundled/theme/render-compact-header.js +126 -128
  107. package/bundled/workflow/session-workflow-mode.d.ts +1 -1
  108. package/bundled/workflow/session-workflow-mode.js +33 -33
  109. package/package.json +1 -1
@@ -6,180 +6,180 @@ import { isCliDebugMode } from "@aspm/shared/cli-user-error";
6
6
  import { Type } from "@earendil-works/pi-ai";
7
7
  import { getKubbisecConfigPath } from "@kubbisec/home";
8
8
  import { extendedContextEnabled, resolveExtendedWorkspace } from "../config/extended-context.js";
9
+
9
10
  const MAX_TOOL_RESULT_CHARS = 24_000;
10
11
  function resolveApiBaseUrl() {
11
- const raw = process.env.KUBBISEC_API_URL?.trim() ||
12
- process.env.KUBBISEC_AI_API_URL?.trim() ||
13
- process.env.ASPM_API_URL?.trim();
14
- return raw?.replace(/\/$/, "");
12
+ const raw =
13
+ process.env.KUBBISEC_API_URL?.trim() ||
14
+ process.env.KUBBISEC_AI_API_URL?.trim() ||
15
+ process.env.ASPM_API_URL?.trim();
16
+ return raw?.replace(/\/$/, "");
15
17
  }
16
18
  function resolveApiKey() {
17
- return (process.env.KUBBISEC_API_KEY?.trim() ||
18
- process.env.KUBBISEC_JOB_TOKEN?.trim() ||
19
- process.env.OPENAI_API_KEY?.trim());
19
+ return (
20
+ process.env.KUBBISEC_API_KEY?.trim() ||
21
+ process.env.KUBBISEC_JOB_TOKEN?.trim() ||
22
+ process.env.OPENAI_API_KEY?.trim()
23
+ );
20
24
  }
21
25
  function readDefaultProjectId() {
22
- const fromEnv = process.env.KUBBISEC_CONTEXT_PROJECT_ID?.trim();
23
- if (fromEnv)
24
- return fromEnv;
25
- try {
26
- const raw = fs.readFileSync(getKubbisecConfigPath(), "utf8");
27
- const parsed = JSON.parse(raw);
28
- return parsed.defaultProject?.trim() || undefined;
29
- }
30
- catch {
31
- return undefined;
32
- }
26
+ const fromEnv = process.env.KUBBISEC_CONTEXT_PROJECT_ID?.trim();
27
+ if (fromEnv) return fromEnv;
28
+ try {
29
+ const raw = fs.readFileSync(getKubbisecConfigPath(), "utf8");
30
+ const parsed = JSON.parse(raw);
31
+ return parsed.defaultProject?.trim() || undefined;
32
+ } catch {
33
+ return undefined;
34
+ }
33
35
  }
34
36
  export function extractVulnerabilityIdFromParams(params) {
35
- const id = (typeof params.vulnerabilityId === "string" ? params.vulnerabilityId.trim() : "") ||
36
- (typeof params.vulnerability_id === "string" ? params.vulnerability_id.trim() : "") ||
37
- "";
38
- return id || undefined;
37
+ const id =
38
+ (typeof params.vulnerabilityId === "string" ? params.vulnerabilityId.trim() : "") ||
39
+ (typeof params.vulnerability_id === "string" ? params.vulnerability_id.trim() : "") ||
40
+ "";
41
+ return id || undefined;
39
42
  }
40
43
  export function catalogParametersSchema(parameters) {
41
- if (parameters && typeof parameters === "object" && Object.keys(parameters).length > 0) {
42
- return parameters;
43
- }
44
- return Type.Object({});
44
+ if (parameters && typeof parameters === "object" && Object.keys(parameters).length > 0) {
45
+ return parameters;
46
+ }
47
+ return Type.Object({});
45
48
  }
46
49
  function truncateToolText(text) {
47
- if (text.length <= MAX_TOOL_RESULT_CHARS)
48
- return text;
49
- return `${text.slice(0, MAX_TOOL_RESULT_CHARS)}\n\n…[truncated ${text.length - MAX_TOOL_RESULT_CHARS} chars]`;
50
+ if (text.length <= MAX_TOOL_RESULT_CHARS) return text;
51
+ return `${text.slice(0, MAX_TOOL_RESULT_CHARS)}\n\n…[truncated ${text.length - MAX_TOOL_RESULT_CHARS} chars]`;
50
52
  }
51
53
  function catalogHeaders(apiKey) {
52
- const headers = {
53
- "x-api-key": apiKey,
54
- "Content-Type": "application/json",
55
- };
56
- const orgId = process.env.KUBBISEC_ORG_ID?.trim();
57
- if (orgId)
58
- headers["x-organization-id"] = orgId;
59
- return headers;
54
+ const headers = {
55
+ "x-api-key": apiKey,
56
+ "Content-Type": "application/json",
57
+ };
58
+ const orgId = process.env.KUBBISEC_ORG_ID?.trim();
59
+ if (orgId) headers["x-organization-id"] = orgId;
60
+ return headers;
60
61
  }
61
62
  async function fetchCatalog(baseUrl, apiKey) {
62
- const res = await fetch(`${baseUrl}/v1/ai/assistant/tools/catalog`, {
63
- headers: catalogHeaders(apiKey),
63
+ const res = await fetch(`${baseUrl}/v1/ai/assistant/tools/catalog`, {
64
+ headers: catalogHeaders(apiKey),
65
+ });
66
+ if (!res.ok) {
67
+ throw new Error(`catalog HTTP ${res.status}`);
68
+ }
69
+ const body = await res.json();
70
+ return (body.tools ?? []).filter((t) => t.available);
71
+ }
72
+ export default function kubbisecPlatformTools(api) {
73
+ let activeVulnerabilityId;
74
+ function buildToolContext() {
75
+ const projectId = readDefaultProjectId();
76
+ const ctx = projectId ? { projectId, mode: "draft" } : {};
77
+ if (extendedContextEnabled()) {
78
+ ctx.allowExtendedLocalContext = true;
79
+ ctx.localWorkspacePath = resolveExtendedWorkspace();
80
+ }
81
+ if (activeVulnerabilityId) {
82
+ ctx.vulnerabilityId = activeVulnerabilityId;
83
+ ctx.finding = { vulnerabilityId: activeVulnerabilityId };
84
+ }
85
+ return ctx;
86
+ }
87
+ async function executeRemoteTool(baseUrl, apiKey, name, args) {
88
+ const remembered = extractVulnerabilityIdFromParams(args);
89
+ if (remembered) activeVulnerabilityId = remembered;
90
+ const res = await fetch(`${baseUrl}/v1/ai/assistant/tools/execute`, {
91
+ method: "POST",
92
+ headers: catalogHeaders(apiKey),
93
+ body: JSON.stringify({
94
+ name,
95
+ arguments: args,
96
+ context: buildToolContext(),
97
+ }),
64
98
  });
65
99
  if (!res.ok) {
66
- throw new Error(`catalog HTTP ${res.status}`);
100
+ return {
101
+ ok: false,
102
+ result: { error: "Não foi possível contactar a API KubbiSec." },
103
+ userMessage: "Não foi possível contactar a API KubbiSec.",
104
+ };
67
105
  }
68
- const body = (await res.json());
69
- return (body.tools ?? []).filter((t) => t.available);
70
- }
71
- export default function kubbisecPlatformTools(api) {
72
- let activeVulnerabilityId;
73
- function buildToolContext() {
74
- const projectId = readDefaultProjectId();
75
- const ctx = projectId ? { projectId, mode: "draft" } : {};
76
- if (extendedContextEnabled()) {
77
- ctx.allowExtendedLocalContext = true;
78
- ctx.localWorkspacePath = resolveExtendedWorkspace();
79
- }
80
- if (activeVulnerabilityId) {
81
- ctx.vulnerabilityId = activeVulnerabilityId;
82
- ctx.finding = { vulnerabilityId: activeVulnerabilityId };
83
- }
84
- return ctx;
106
+ return await res.json();
107
+ }
108
+ function formatRemoteToolText(remote) {
109
+ if (!remote.ok) {
110
+ return remote.userMessage ?? "A operação na plataforma KubbiSec falhou.";
85
111
  }
86
- async function executeRemoteTool(baseUrl, apiKey, name, args) {
87
- const remembered = extractVulnerabilityIdFromParams(args);
88
- if (remembered)
89
- activeVulnerabilityId = remembered;
90
- const res = await fetch(`${baseUrl}/v1/ai/assistant/tools/execute`, {
91
- method: "POST",
92
- headers: catalogHeaders(apiKey),
93
- body: JSON.stringify({
94
- name,
95
- arguments: args,
96
- context: buildToolContext(),
97
- }),
98
- });
99
- if (!res.ok) {
100
- return {
101
- ok: false,
102
- result: { error: "Não foi possível contactar a API KubbiSec." },
103
- userMessage: "Não foi possível contactar a API KubbiSec.",
104
- };
105
- }
106
- return (await res.json());
112
+ if (isCliDebugMode()) {
113
+ return truncateToolText(JSON.stringify(remote.result, null, 2));
114
+ }
115
+ if (remote.result && typeof remote.result === "object" && !Array.isArray(remote.result)) {
116
+ const record = remote.result;
117
+ const safe = {};
118
+ for (const [key, value] of Object.entries(record)) {
119
+ if (key === "stack" || key === "traceId" || key === "trace") continue;
120
+ safe[key] = value;
121
+ }
122
+ return truncateToolText(JSON.stringify(safe, null, 2));
123
+ }
124
+ return truncateToolText(JSON.stringify(remote.result, null, 2));
125
+ }
126
+ api.on("session_start", async (_event, ctx) => {
127
+ activeVulnerabilityId = undefined;
128
+ const baseUrl = resolveApiBaseUrl();
129
+ const apiKey = resolveApiKey();
130
+ if (!baseUrl || !apiKey) {
131
+ ctx.ui?.setStatus("kubbisec-tools", "tools skipped");
132
+ ctx.ui?.notify(
133
+ "KubbiSec platform tools skipped (set KUBBISEC_API_URL + KUBBISEC_API_KEY)",
134
+ "warning",
135
+ );
136
+ return;
107
137
  }
108
- function formatRemoteToolText(remote) {
109
- if (!remote.ok) {
110
- return remote.userMessage ?? "A operação na plataforma KubbiSec falhou.";
111
- }
112
- if (isCliDebugMode()) {
113
- return truncateToolText(JSON.stringify(remote.result, null, 2));
114
- }
115
- if (remote.result && typeof remote.result === "object" && !Array.isArray(remote.result)) {
116
- const record = remote.result;
117
- const safe = {};
118
- for (const [key, value] of Object.entries(record)) {
119
- if (key === "stack" || key === "traceId" || key === "trace")
120
- continue;
121
- safe[key] = value;
122
- }
123
- return truncateToolText(JSON.stringify(safe, null, 2));
124
- }
125
- return truncateToolText(JSON.stringify(remote.result, null, 2));
138
+ let tools;
139
+ try {
140
+ tools = await fetchCatalog(baseUrl, apiKey);
141
+ } catch {
142
+ ctx.ui?.setStatus("kubbisec-tools", "tools unavailable");
143
+ ctx.ui?.notify("Não foi possível carregar as ferramentas da plataforma KubbiSec.", "warning");
144
+ return;
126
145
  }
127
- api.on("session_start", async (_event, ctx) => {
128
- activeVulnerabilityId = undefined;
129
- const baseUrl = resolveApiBaseUrl();
130
- const apiKey = resolveApiKey();
131
- if (!baseUrl || !apiKey) {
132
- ctx.ui?.setStatus("kubbisec-tools", "tools skipped");
133
- ctx.ui?.notify("KubbiSec platform tools skipped (set KUBBISEC_API_URL + KUBBISEC_API_KEY)", "warning");
134
- return;
135
- }
136
- let tools;
137
- try {
138
- tools = await fetchCatalog(baseUrl, apiKey);
139
- }
140
- catch {
141
- ctx.ui?.setStatus("kubbisec-tools", "tools unavailable");
142
- ctx.ui?.notify("Não foi possível carregar as ferramentas da plataforma KubbiSec.", "warning");
143
- return;
144
- }
145
- for (const tool of tools) {
146
- api.registerTool({
146
+ for (const tool of tools) {
147
+ api.registerTool({
148
+ name: tool.name,
149
+ label: tool.name,
150
+ description: tool.description,
151
+ parameters: catalogParametersSchema(tool.parameters),
152
+ async execute(_toolCallId, params) {
153
+ try {
154
+ const remote = await executeRemoteTool(baseUrl, apiKey, tool.name, params);
155
+ const text = formatRemoteToolText(remote);
156
+ return {
157
+ content: [{ type: "text", text }],
158
+ details: {
159
+ ok: remote.ok,
147
160
  name: tool.name,
148
- label: tool.name,
149
- description: tool.description,
150
- parameters: catalogParametersSchema(tool.parameters),
151
- async execute(_toolCallId, params) {
152
- try {
153
- const remote = await executeRemoteTool(baseUrl, apiKey, tool.name, params);
154
- const text = formatRemoteToolText(remote);
155
- return {
156
- content: [{ type: "text", text }],
157
- details: {
158
- ok: remote.ok,
159
- name: tool.name,
160
- userMessage: remote.userMessage,
161
- },
162
- };
163
- }
164
- catch {
165
- return {
166
- content: [
167
- {
168
- type: "text",
169
- text: "Não foi possível executar a ferramenta na plataforma KubbiSec.",
170
- },
171
- ],
172
- details: {
173
- ok: false,
174
- name: tool.name,
175
- userMessage: "Não foi possível executar a ferramenta na plataforma KubbiSec.",
176
- },
177
- };
178
- }
161
+ userMessage: remote.userMessage,
162
+ },
163
+ };
164
+ } catch {
165
+ return {
166
+ content: [
167
+ {
168
+ type: "text",
169
+ text: "Não foi possível executar a ferramenta na plataforma KubbiSec.",
179
170
  },
180
- });
181
- }
182
- ctx.ui?.setStatus("kubbisec-tools", `${tools.length} tools`);
183
- });
171
+ ],
172
+ details: {
173
+ ok: false,
174
+ name: tool.name,
175
+ userMessage: "Não foi possível executar a ferramenta na plataforma KubbiSec.",
176
+ },
177
+ };
178
+ }
179
+ },
180
+ });
181
+ }
182
+ ctx.ui?.setStatus("kubbisec-tools", `${tools.length} tools`);
183
+ });
184
184
  }
185
- //# sourceMappingURL=kubbisec-platform-tools.extension.js.map
185
+ //# sourceMappingURL=kubbisec-platform-tools.extension.js.map
@@ -1,13 +1,15 @@
1
1
  type ExtensionApi = {
2
- on: (event: string, handler: (event: unknown, ctx: ExtensionContext) => void | Promise<void>) => void;
2
+ on: (
3
+ event: string,
4
+ handler: (event: unknown, ctx: ExtensionContext) => void | Promise<void>,
5
+ ) => void;
3
6
  };
4
7
  type ExtensionContext = {
5
- hasUI: boolean;
6
- cwd: string;
7
- ui: {
8
- setStatus: (key: string, text: string | undefined) => void;
9
- };
8
+ hasUI: boolean;
9
+ cwd: string;
10
+ ui: {
11
+ setStatus: (key: string, text: string | undefined) => void;
12
+ };
10
13
  };
11
14
  export default function kubbisecRuntimeStatus(api: ExtensionApi): void;
12
- export {};
13
- //# sourceMappingURL=kubbisec-runtime-status.extension.d.ts.map
15
+ //# sourceMappingURL=kubbisec-runtime-status.extension.d.ts.map
@@ -1,18 +1,20 @@
1
1
  /**
2
2
  * Footer status for loaded context file (AGENTS.md / CLAUDE.md) — not shown in chat startup listing.
3
3
  */
4
- import { findAgentsContextFile, formatKubbisecContextStatus, } from "../config/resolve-agents-context-file.js";
4
+ import {
5
+ findAgentsContextFile,
6
+ formatKubbisecContextStatus,
7
+ } from "../config/resolve-agents-context-file.js";
5
8
  export default function kubbisecRuntimeStatus(api) {
6
- api.on("session_start", async (_event, ctx) => {
7
- if (!ctx.hasUI)
8
- return;
9
- const agentsFile = findAgentsContextFile(ctx.cwd);
10
- if (!agentsFile) {
11
- ctx.ui.setStatus("kubbisec-ctx", undefined);
12
- return;
13
- }
14
- const home = process.env.HOME || process.env.USERPROFILE;
15
- ctx.ui.setStatus("kubbisec-ctx", formatKubbisecContextStatus(agentsFile, home));
16
- });
9
+ api.on("session_start", async (_event, ctx) => {
10
+ if (!ctx.hasUI) return;
11
+ const agentsFile = findAgentsContextFile(ctx.cwd);
12
+ if (!agentsFile) {
13
+ ctx.ui.setStatus("kubbisec-ctx", undefined);
14
+ return;
15
+ }
16
+ const home = process.env.HOME || process.env.USERPROFILE;
17
+ ctx.ui.setStatus("kubbisec-ctx", formatKubbisecContextStatus(agentsFile, home));
18
+ });
17
19
  }
18
- //# sourceMappingURL=kubbisec-runtime-status.extension.js.map
20
+ //# sourceMappingURL=kubbisec-runtime-status.extension.js.map
@@ -1,14 +1,19 @@
1
1
  type ExtensionApi = {
2
- on: (event: string, handler: (event: {
2
+ on: (
3
+ event: string,
4
+ handler: (
5
+ event: {
3
6
  type?: string;
4
7
  content?: string;
5
- }, ctx: ExtensionContext) => void | Promise<void>) => void;
8
+ },
9
+ ctx: ExtensionContext,
10
+ ) => void | Promise<void>,
11
+ ) => void;
6
12
  };
7
13
  type ExtensionContext = {
8
- ui?: {
9
- notify: (message: string, level: string) => void;
10
- };
14
+ ui?: {
15
+ notify: (message: string, level: string) => void;
16
+ };
11
17
  };
12
18
  export default function kubbisecScope(api: ExtensionApi): void;
13
- export {};
14
- //# sourceMappingURL=kubbisec-scope.extension.d.ts.map
19
+ //# sourceMappingURL=kubbisec-scope.extension.d.ts.map
@@ -1,18 +1,18 @@
1
1
  /** Soft guard: only nudge on clearly non-technical chit-chat; platform/NAUS questions use tools. */
2
- const OFF_TOPIC_HINT = "This looks like general chat. For KubbiSec product or pipeline help, ask about ASPM, NAUS, findings, or CI — tools can fetch real docs and data.";
2
+ const OFF_TOPIC_HINT =
3
+ "This looks like general chat. For KubbiSec product or pipeline help, ask about ASPM, NAUS, findings, or CI — tools can fetch real docs and data.";
3
4
  const OFF_TOPIC_PATTERNS = [
4
- /\bwrite (me )?a poem\b/i,
5
- /\btell (me )?a joke\b/i,
6
- /\bplay a game\b/i,
5
+ /\bwrite (me )?a poem\b/i,
6
+ /\btell (me )?a joke\b/i,
7
+ /\bplay a game\b/i,
7
8
  ];
8
9
  export default function kubbisecScope(api) {
9
- api.on("before_user_message", async (event, ctx) => {
10
- const text = typeof event.content === "string" ? event.content.trim() : "";
11
- if (!text || text.startsWith("/"))
12
- return;
13
- if (OFF_TOPIC_PATTERNS.some((p) => p.test(text)) && text.length < 80) {
14
- ctx.ui?.notify(OFF_TOPIC_HINT, "info");
15
- }
16
- });
10
+ api.on("before_user_message", async (event, ctx) => {
11
+ const text = typeof event.content === "string" ? event.content.trim() : "";
12
+ if (!text || text.startsWith("/")) return;
13
+ if (OFF_TOPIC_PATTERNS.some((p) => p.test(text)) && text.length < 80) {
14
+ ctx.ui?.notify(OFF_TOPIC_HINT, "info");
15
+ }
16
+ });
17
17
  }
18
- //# sourceMappingURL=kubbisec-scope.extension.js.map
18
+ //# sourceMappingURL=kubbisec-scope.extension.js.map
@@ -2,24 +2,35 @@
2
2
  * KubbiSec skills: invoke with `@skill <name>` (autocomplete) instead of `/skill:name` in the slash menu.
3
3
  */
4
4
  import type { AutocompleteProvider } from "@earendil-works/pi-tui";
5
+
5
6
  type ExtensionApi = {
6
- on: (event: string, handler: (event: unknown, ctx: ExtensionContext) => undefined | Promise<undefined | InputEventResult>) => void;
7
+ on: (
8
+ event: string,
9
+ handler: (
10
+ event: unknown,
11
+ ctx: ExtensionContext,
12
+ ) => undefined | Promise<undefined | InputEventResult>,
13
+ ) => void;
7
14
  };
8
15
  type ExtensionContext = {
9
- hasUI: boolean;
10
- cwd: string;
11
- ui: {
12
- addAutocompleteProvider: (factory: (current: AutocompleteProvider) => AutocompleteProvider) => void;
13
- };
14
- };
15
- type InputEventResult = {
16
- action: "continue";
17
- } | {
18
- action: "transform";
19
- text: string;
20
- } | {
21
- action: "handled";
16
+ hasUI: boolean;
17
+ cwd: string;
18
+ ui: {
19
+ addAutocompleteProvider: (
20
+ factory: (current: AutocompleteProvider) => AutocompleteProvider,
21
+ ) => void;
22
+ };
22
23
  };
24
+ type InputEventResult =
25
+ | {
26
+ action: "continue";
27
+ }
28
+ | {
29
+ action: "transform";
30
+ text: string;
31
+ }
32
+ | {
33
+ action: "handled";
34
+ };
23
35
  export default function kubbisecSkillMentions(api: ExtensionApi): void;
24
- export {};
25
- //# sourceMappingURL=kubbisec-skill-mentions.extension.d.ts.map
36
+ //# sourceMappingURL=kubbisec-skill-mentions.extension.d.ts.map
@@ -1,71 +1,81 @@
1
1
  import { extractAtFilePrefix, getAtPathFileSuggestions } from "../skills/at-path-mentions.js";
2
- import { applySkillMentionCompletion, extractAtPrefix, extractSkillMentionPrefix, filterSkillSuggestions, messageActivatesPlanMode, parsePlanMentionPrefix, parseSkillMentionPrefix, transformAtSkillMentions, } from "../skills/chat-mentions.js";
2
+ import {
3
+ applySkillMentionCompletion,
4
+ extractAtPrefix,
5
+ extractSkillMentionPrefix,
6
+ filterSkillSuggestions,
7
+ messageActivatesPlanMode,
8
+ parsePlanMentionPrefix,
9
+ parseSkillMentionPrefix,
10
+ transformAtSkillMentions,
11
+ } from "../skills/chat-mentions.js";
3
12
  import { listBundledKubbisecSkills } from "../skills/list-bundled-skills.js";
4
13
  import { setSessionWorkflowMode } from "../workflow/session-workflow-mode.js";
14
+
5
15
  function wrapAutocompleteProvider(current, skills, sessionCwd) {
6
- return {
7
- async getSuggestions(lines, cursorLine, cursorCol, options) {
8
- const textBeforeCursor = (lines[cursorLine] ?? "").slice(0, cursorCol);
9
- const atPrefix = extractSkillMentionPrefix(textBeforeCursor);
10
- const skillMention = parseSkillMentionPrefix(atPrefix);
11
- if (skillMention && atPrefix) {
12
- const items = filterSkillSuggestions(skills, skillMention.query);
13
- if (items.length === 0)
14
- return null;
15
- return { items, prefix: atPrefix };
16
- }
17
- const fileAtPrefix = extractAtFilePrefix(textBeforeCursor);
18
- if (fileAtPrefix) {
19
- const cwdItems = getAtPathFileSuggestions(sessionCwd, fileAtPrefix);
20
- if (cwdItems.length > 0) {
21
- return { items: cwdItems, prefix: fileAtPrefix };
22
- }
23
- return current.getSuggestions(lines, cursorLine, cursorCol, options);
24
- }
25
- return current.getSuggestions(lines, cursorLine, cursorCol, options);
26
- },
27
- applyCompletion(lines, cursorLine, cursorCol, item, prefix) {
28
- if (prefix.startsWith("@skill")) {
29
- return applySkillMentionCompletion(lines, cursorLine, cursorCol, item, prefix);
30
- }
31
- return current.applyCompletion(lines, cursorLine, cursorCol, item, prefix);
32
- },
33
- shouldTriggerFileCompletion(lines, cursorLine, cursorCol) {
34
- const textBeforeCursor = (lines[cursorLine] ?? "").slice(0, cursorCol);
35
- const atPrefix = extractAtPrefix(textBeforeCursor);
36
- if (parseSkillMentionPrefix(atPrefix) || parsePlanMentionPrefix(atPrefix)) {
37
- return false;
38
- }
39
- if (extractAtFilePrefix(textBeforeCursor)) {
40
- return true;
41
- }
42
- return current.shouldTriggerFileCompletion?.(lines, cursorLine, cursorCol) ?? true;
43
- },
44
- };
16
+ return {
17
+ async getSuggestions(lines, cursorLine, cursorCol, options) {
18
+ const textBeforeCursor = (lines[cursorLine] ?? "").slice(0, cursorCol);
19
+ const atPrefix = extractSkillMentionPrefix(textBeforeCursor);
20
+ const skillMention = parseSkillMentionPrefix(atPrefix);
21
+ if (skillMention && atPrefix) {
22
+ const items = filterSkillSuggestions(skills, skillMention.query);
23
+ if (items.length === 0) return null;
24
+ return { items, prefix: atPrefix };
25
+ }
26
+ const fileAtPrefix = extractAtFilePrefix(textBeforeCursor);
27
+ if (fileAtPrefix) {
28
+ const cwdItems = getAtPathFileSuggestions(sessionCwd, fileAtPrefix);
29
+ if (cwdItems.length > 0) {
30
+ return { items: cwdItems, prefix: fileAtPrefix };
31
+ }
32
+ return current.getSuggestions(lines, cursorLine, cursorCol, options);
33
+ }
34
+ return current.getSuggestions(lines, cursorLine, cursorCol, options);
35
+ },
36
+ applyCompletion(lines, cursorLine, cursorCol, item, prefix) {
37
+ if (prefix.startsWith("@skill")) {
38
+ return applySkillMentionCompletion(lines, cursorLine, cursorCol, item, prefix);
39
+ }
40
+ return current.applyCompletion(lines, cursorLine, cursorCol, item, prefix);
41
+ },
42
+ shouldTriggerFileCompletion(lines, cursorLine, cursorCol) {
43
+ const textBeforeCursor = (lines[cursorLine] ?? "").slice(0, cursorCol);
44
+ const atPrefix = extractAtPrefix(textBeforeCursor);
45
+ if (parseSkillMentionPrefix(atPrefix) || parsePlanMentionPrefix(atPrefix)) {
46
+ return false;
47
+ }
48
+ if (extractAtFilePrefix(textBeforeCursor)) {
49
+ return true;
50
+ }
51
+ return current.shouldTriggerFileCompletion?.(lines, cursorLine, cursorCol) ?? true;
52
+ },
53
+ };
45
54
  }
46
55
  export default function kubbisecSkillMentions(api) {
47
- const skills = listBundledKubbisecSkills();
48
- api.on("session_start", async (_event, ctx) => {
49
- if (!ctx.hasUI)
50
- return undefined;
51
- const sessionCwd = ctx.cwd;
52
- ctx.ui.addAutocompleteProvider((current) => wrapAutocompleteProvider(current, skills, sessionCwd));
53
- return undefined;
54
- });
55
- api.on("input", async (event, _ctx) => {
56
- const input = event;
57
- const text = typeof input.text === "string" ? input.text : "";
58
- if (messageActivatesPlanMode(text)) {
59
- setSessionWorkflowMode("plan");
60
- }
61
- if (!text.includes("@skill")) {
62
- return { action: "continue" };
63
- }
64
- const transformed = transformAtSkillMentions(text);
65
- if (transformed === text) {
66
- return { action: "continue" };
67
- }
68
- return { action: "transform", text: transformed };
69
- });
56
+ const skills = listBundledKubbisecSkills();
57
+ api.on("session_start", async (_event, ctx) => {
58
+ if (!ctx.hasUI) return undefined;
59
+ const sessionCwd = ctx.cwd;
60
+ ctx.ui.addAutocompleteProvider((current) =>
61
+ wrapAutocompleteProvider(current, skills, sessionCwd),
62
+ );
63
+ return undefined;
64
+ });
65
+ api.on("input", async (event, _ctx) => {
66
+ const input = event;
67
+ const text = typeof input.text === "string" ? input.text : "";
68
+ if (messageActivatesPlanMode(text)) {
69
+ setSessionWorkflowMode("plan");
70
+ }
71
+ if (!text.includes("@skill")) {
72
+ return { action: "continue" };
73
+ }
74
+ const transformed = transformAtSkillMentions(text);
75
+ if (transformed === text) {
76
+ return { action: "continue" };
77
+ }
78
+ return { action: "transform", text: transformed };
79
+ });
70
80
  }
71
- //# sourceMappingURL=kubbisec-skill-mentions.extension.js.map
81
+ //# sourceMappingURL=kubbisec-skill-mentions.extension.js.map