@gajae-code/coding-agent 0.7.10 → 0.8.0
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/CHANGELOG.md +58 -0
- package/README.md +2 -2
- package/dist/types/capability/mcp.d.ts +2 -0
- package/dist/types/config/keybindings.d.ts +11 -5
- package/dist/types/config/settings-schema.d.ts +25 -2
- package/dist/types/defaults/gjc-defaults.d.ts +7 -0
- package/dist/types/discovery/cursor.d.ts +4 -1
- package/dist/types/discovery/index.d.ts +0 -1
- package/dist/types/discovery/windsurf.d.ts +3 -1
- package/dist/types/gjc-runtime/launch-tmux.d.ts +3 -0
- package/dist/types/gjc-runtime/ralplan-runtime.d.ts +3 -2
- package/dist/types/gjc-runtime/restricted-role-agent-bash.d.ts +1 -0
- package/dist/types/gjc-runtime/session-state-sidecar.d.ts +5 -0
- package/dist/types/gjc-runtime/state-writer.d.ts +1 -0
- package/dist/types/modes/components/custom-editor.d.ts +6 -1
- package/dist/types/modes/components/settings-selector.d.ts +1 -0
- package/dist/types/modes/components/skill-message.d.ts +1 -0
- package/dist/types/modes/components/status-line.d.ts +8 -0
- package/dist/types/modes/components/two-column-body.d.ts +9 -0
- package/dist/types/modes/components/welcome.d.ts +9 -1
- package/dist/types/modes/controllers/command-controller.d.ts +1 -0
- package/dist/types/modes/controllers/input-controller.d.ts +5 -1
- package/dist/types/modes/controllers/selector-controller.d.ts +8 -0
- package/dist/types/modes/interactive-mode.d.ts +2 -0
- package/dist/types/modes/prompt-action-autocomplete.d.ts +2 -0
- package/dist/types/modes/rpc/rpc-types.d.ts +1 -0
- package/dist/types/modes/slash-command-visibility.d.ts +1 -0
- package/dist/types/modes/types.d.ts +2 -0
- package/dist/types/runtime-mcp/config-writer.d.ts +9 -0
- package/dist/types/runtime-mcp/config.d.ts +2 -0
- package/dist/types/runtime-mcp/loader.d.ts +2 -0
- package/dist/types/runtime-mcp/manager.d.ts +2 -0
- package/dist/types/runtime-mcp/types.d.ts +6 -0
- package/dist/types/sdk.d.ts +1 -1
- package/dist/types/session/agent-session.d.ts +8 -5
- package/dist/types/slash-commands/types.d.ts +2 -0
- package/dist/types/system-prompt.d.ts +7 -0
- package/dist/types/utils/cmux-workspace.d.ts +30 -1
- package/dist/types/web/search/index.d.ts +3 -1
- package/dist/types/web/search/provider.d.ts +9 -0
- package/dist/types/web/search/providers/utils.d.ts +42 -13
- package/dist/types/workflow/workflow-intent-diff.d.ts +19 -0
- package/package.json +10 -10
- package/src/capability/mcp.ts +2 -0
- package/src/cli/update-cli.ts +24 -0
- package/src/cli/web-search-cli.ts +2 -5
- package/src/cli.ts +1 -1
- package/src/commands/launch.ts +1 -1
- package/src/commands/ralplan.ts +1 -0
- package/src/config/keybindings.ts +14 -5
- package/src/config/mcp-schema.json +5 -1
- package/src/config/model-profiles.ts +16 -0
- package/src/config/settings-schema.ts +18 -2
- package/src/coordinator-mcp/server.ts +15 -3
- package/src/defaults/gjc/skills/ralplan/SKILL.md +16 -14
- package/src/defaults/gjc-defaults.ts +16 -0
- package/src/discovery/builtin.ts +12 -0
- package/src/discovery/cursor.ts +5 -84
- package/src/discovery/gemini.ts +3 -89
- package/src/discovery/index.ts +4 -1
- package/src/discovery/mcp-json.ts +11 -0
- package/src/discovery/opencode.ts +5 -122
- package/src/discovery/windsurf.ts +4 -82
- package/src/edit/read-file.ts +9 -1
- package/src/extensibility/extensions/runner.ts +2 -1
- package/src/gjc-runtime/launch-tmux.ts +164 -42
- package/src/gjc-runtime/ralplan-runtime.ts +22 -6
- package/src/gjc-runtime/restricted-role-agent-bash.ts +1 -0
- package/src/gjc-runtime/session-state-sidecar.ts +167 -24
- package/src/gjc-runtime/state-runtime.ts +8 -5
- package/src/gjc-runtime/state-writer.ts +5 -5
- package/src/gjc-runtime/team-runtime.ts +56 -51
- package/src/internal-urls/docs-index.generated.ts +8 -7
- package/src/main.ts +2 -2
- package/src/migrate/executor.ts +23 -6
- package/src/modes/components/agent-dashboard.ts +1 -34
- package/src/modes/components/custom-editor.ts +26 -0
- package/src/modes/components/extensions/extension-dashboard.ts +2 -48
- package/src/modes/components/model-selector.ts +64 -4
- package/src/modes/components/session-selector.ts +19 -9
- package/src/modes/components/settings-selector.ts +13 -2
- package/src/modes/components/skill-message.ts +18 -10
- package/src/modes/components/status-line.ts +215 -86
- package/src/modes/components/tree-selector.ts +28 -8
- package/src/modes/components/two-column-body.ts +36 -0
- package/src/modes/components/welcome.ts +171 -35
- package/src/modes/controllers/command-controller.ts +23 -0
- package/src/modes/controllers/event-controller.ts +4 -0
- package/src/modes/controllers/input-controller.ts +192 -39
- package/src/modes/controllers/selector-controller.ts +25 -28
- package/src/modes/interactive-mode.ts +36 -30
- package/src/modes/prompt-action-autocomplete.ts +23 -1
- package/src/modes/rpc/rpc-types.ts +1 -0
- package/src/modes/shared/agent-wire/deep-interview-gate.ts +9 -3
- package/src/modes/shared/agent-wire/workflow-gate-schema.ts +20 -0
- package/src/modes/slash-command-visibility.ts +9 -0
- package/src/modes/types.ts +2 -0
- package/src/modes/utils/hotkeys-markdown.ts +5 -2
- package/src/modes/utils/ui-helpers.ts +76 -3
- package/src/notifications/index.ts +20 -1
- package/src/notifications/lifecycle-control-runtime.ts +12 -3
- package/src/notifications/telegram-daemon.ts +4 -4
- package/src/prompts/agents/architect.md +7 -4
- package/src/prompts/agents/critic.md +15 -6
- package/src/prompts/agents/planner.md +8 -3
- package/src/prompts/system/system-prompt.md +15 -1
- package/src/prompts/tools/bash.md +1 -1
- package/src/runtime-mcp/config-writer.ts +28 -0
- package/src/runtime-mcp/config.ts +7 -0
- package/src/runtime-mcp/loader.ts +3 -0
- package/src/runtime-mcp/manager.ts +3 -0
- package/src/runtime-mcp/types.ts +6 -0
- package/src/sdk.ts +7 -6
- package/src/session/agent-session.ts +81 -18
- package/src/session/session-manager.ts +58 -18
- package/src/slash-commands/builtin-registry.ts +30 -10
- package/src/slash-commands/types.ts +2 -0
- package/src/system-prompt.ts +8 -0
- package/src/task/executor.ts +5 -0
- package/src/tools/ast-grep.ts +10 -7
- package/src/tools/bash.ts +39 -14
- package/src/tools/index.ts +8 -1
- package/src/utils/cmux-workspace.ts +134 -7
- package/src/utils/title-generator.ts +1 -1
- package/src/web/kagi.ts +1 -1
- package/src/web/parallel.ts +2 -2
- package/src/web/search/index.ts +118 -45
- package/src/web/search/provider.ts +65 -0
- package/src/web/search/providers/anthropic.ts +1 -1
- package/src/web/search/providers/brave.ts +1 -1
- package/src/web/search/providers/codex.ts +1 -1
- package/src/web/search/providers/duckduckgo.ts +1 -1
- package/src/web/search/providers/exa.ts +1 -1
- package/src/web/search/providers/gemini.ts +7 -3
- package/src/web/search/providers/jina.ts +1 -1
- package/src/web/search/providers/kimi.ts +6 -1
- package/src/web/search/providers/openai-compatible.ts +1 -1
- package/src/web/search/providers/parallel.ts +1 -1
- package/src/web/search/providers/perplexity.ts +2 -2
- package/src/web/search/providers/searxng.ts +1 -1
- package/src/web/search/providers/synthetic.ts +1 -1
- package/src/web/search/providers/tavily.ts +1 -1
- package/src/web/search/providers/utils.ts +67 -17
- package/src/web/search/providers/xai.ts +1 -1
- package/src/web/search/providers/zai.ts +1 -1
- package/src/workflow/workflow-intent-diff.ts +199 -0
- package/dist/types/discovery/vscode.d.ts +0 -1
- package/src/discovery/vscode.ts +0 -105
|
@@ -196,7 +196,7 @@ async function fetchAndParse(
|
|
|
196
196
|
"Accept-Language": "en-US,en;q=0.9",
|
|
197
197
|
},
|
|
198
198
|
body,
|
|
199
|
-
signal: withHardTimeout(signal),
|
|
199
|
+
signal: withHardTimeout(signal, "api"),
|
|
200
200
|
});
|
|
201
201
|
|
|
202
202
|
// DuckDuckGo signals soft blocks with 202 (which is still response.ok).
|
|
@@ -115,7 +115,7 @@ async function callExaSearch(apiKey: string, params: ExaSearchParams): Promise<E
|
|
|
115
115
|
"x-api-key": apiKey,
|
|
116
116
|
},
|
|
117
117
|
body: JSON.stringify(body),
|
|
118
|
-
signal: withHardTimeout(params.signal),
|
|
118
|
+
signal: withHardTimeout(params.signal, "api"),
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
if (!response.ok) {
|
|
@@ -29,7 +29,11 @@ const ANTIGRAVITY_ENDPOINT_FALLBACKS = [ANTIGRAVITY_DAILY_ENDPOINT, ANTIGRAVITY_
|
|
|
29
29
|
const DEFAULT_MODEL = "gemini-2.5-flash";
|
|
30
30
|
const MAX_RETRIES = 3;
|
|
31
31
|
const BASE_DELAY_MS = 1000;
|
|
32
|
-
|
|
32
|
+
// Retry-delay ceiling for 429/5xx. The web_search chain always terminates in
|
|
33
|
+
// the keyless DuckDuckGo fallback, so a rate-limited Gemini should fail
|
|
34
|
+
// through in seconds instead of parking the chain behind long server-provided
|
|
35
|
+
// retry delays (previously a 5-minute budget).
|
|
36
|
+
const RATE_LIMIT_BUDGET_MS = 30 * 1000;
|
|
33
37
|
|
|
34
38
|
const GEMINI_PROVIDERS = ["google-gemini-cli", "google-antigravity"] as const;
|
|
35
39
|
type GeminiProviderId = (typeof GEMINI_PROVIDERS)[number];
|
|
@@ -230,7 +234,7 @@ async function callGeminiSearch(
|
|
|
230
234
|
...headers,
|
|
231
235
|
},
|
|
232
236
|
body: JSON.stringify(requestBody),
|
|
233
|
-
signal: withHardTimeout(signal),
|
|
237
|
+
signal: withHardTimeout(signal, "llm"),
|
|
234
238
|
});
|
|
235
239
|
const urlFor = (attempt: number) =>
|
|
236
240
|
`${endpoints[Math.min(attempt, endpoints.length - 1)]}/v1internal:streamGenerateContent?alt=sse`;
|
|
@@ -466,7 +470,7 @@ async function searchGeminiViaGenerativeLanguage(params: SearchParams): Promise<
|
|
|
466
470
|
method: "POST",
|
|
467
471
|
headers: { ...(ctx.headers ?? {}), "x-goog-api-key": apiKey, "Content-Type": "application/json" },
|
|
468
472
|
body: JSON.stringify(body),
|
|
469
|
-
signal: withHardTimeout(params.signal),
|
|
473
|
+
signal: withHardTimeout(params.signal, "llm"),
|
|
470
474
|
});
|
|
471
475
|
const text = await response.text();
|
|
472
476
|
if (!response.ok) {
|
|
@@ -41,7 +41,7 @@ async function callJinaSearch(apiKey: string, query: string, signal?: AbortSigna
|
|
|
41
41
|
Accept: "application/json",
|
|
42
42
|
Authorization: `Bearer ${apiKey}`,
|
|
43
43
|
},
|
|
44
|
-
signal: withHardTimeout(signal),
|
|
44
|
+
signal: withHardTimeout(signal, "api"),
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
if (!response.ok) {
|
|
@@ -19,6 +19,11 @@ const KIMI_SEARCH_URL = "https://api.kimi.com/coding/v1/search";
|
|
|
19
19
|
const DEFAULT_NUM_RESULTS = 10;
|
|
20
20
|
const MAX_NUM_RESULTS = 20;
|
|
21
21
|
const DEFAULT_TIMEOUT_SECONDS = 30;
|
|
22
|
+
// Local hard ceiling aligned with the upstream `timeout_seconds` request budget
|
|
23
|
+
// (plus transport headroom) instead of the generic 15s "api" class: Kimi
|
|
24
|
+
// legitimately runs search + page crawling up to its advertised 30s window,
|
|
25
|
+
// and aborting earlier would discard valid in-budget responses.
|
|
26
|
+
const KIMI_HARD_TIMEOUT_MS = (DEFAULT_TIMEOUT_SECONDS + 5) * 1000;
|
|
22
27
|
|
|
23
28
|
export interface KimiSearchParams {
|
|
24
29
|
query: string;
|
|
@@ -87,7 +92,7 @@ async function callKimiSearch(
|
|
|
87
92
|
enable_page_crawling: params.includeContent,
|
|
88
93
|
timeout_seconds: DEFAULT_TIMEOUT_SECONDS,
|
|
89
94
|
}),
|
|
90
|
-
signal: withHardTimeout(params.signal),
|
|
95
|
+
signal: withHardTimeout(params.signal, KIMI_HARD_TIMEOUT_MS),
|
|
91
96
|
});
|
|
92
97
|
|
|
93
98
|
if (!response.ok) {
|
|
@@ -134,7 +134,7 @@ export class OpenAICompatibleSearchProvider extends SearchProvider {
|
|
|
134
134
|
method: "POST",
|
|
135
135
|
headers,
|
|
136
136
|
body: JSON.stringify(payload),
|
|
137
|
-
signal: withHardTimeout(params.signal),
|
|
137
|
+
signal: withHardTimeout(params.signal, "llm"),
|
|
138
138
|
});
|
|
139
139
|
|
|
140
140
|
// Web search is a Responses-API capability: many OpenAI-compatible
|
|
@@ -139,7 +139,7 @@ async function searchWithAuthStorage(
|
|
|
139
139
|
max_chars_per_result: 10_000,
|
|
140
140
|
},
|
|
141
141
|
}),
|
|
142
|
-
signal: withHardTimeout(params.signal),
|
|
142
|
+
signal: withHardTimeout(params.signal, "api"),
|
|
143
143
|
});
|
|
144
144
|
if (!response.ok) {
|
|
145
145
|
throw parseParallelErrorResponse(response.status, await response.text());
|
|
@@ -251,7 +251,7 @@ async function callPerplexityApi(
|
|
|
251
251
|
"Content-Type": "application/json",
|
|
252
252
|
},
|
|
253
253
|
body: JSON.stringify(request),
|
|
254
|
-
signal: withHardTimeout(signal),
|
|
254
|
+
signal: withHardTimeout(signal, "llm"),
|
|
255
255
|
});
|
|
256
256
|
|
|
257
257
|
if (!response.ok) {
|
|
@@ -370,7 +370,7 @@ async function callPerplexityOAuth(
|
|
|
370
370
|
skip_search_enabled: true,
|
|
371
371
|
},
|
|
372
372
|
}),
|
|
373
|
-
signal: withHardTimeout(params.signal),
|
|
373
|
+
signal: withHardTimeout(params.signal, "llm"),
|
|
374
374
|
});
|
|
375
375
|
|
|
376
376
|
if (!response.ok) {
|
|
@@ -96,7 +96,7 @@ async function callTavilySearch(apiKey: string, params: TavilySearchParams): Pro
|
|
|
96
96
|
Authorization: `Bearer ${apiKey}`,
|
|
97
97
|
},
|
|
98
98
|
body: JSON.stringify(buildRequestBody(params)),
|
|
99
|
-
signal: withHardTimeout(params.signal),
|
|
99
|
+
signal: withHardTimeout(params.signal, "api"),
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
if (!response.ok) {
|
|
@@ -44,38 +44,81 @@ export function findCredential(
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* Pure search APIs (brave, exa, jina, tavily, searxng, synthetic, zai)
|
|
53
|
-
* settle far faster in practice; reusing the same ceiling keeps the wiring
|
|
54
|
-
* uniform without compromising correctness.
|
|
47
|
+
* Legacy hard ceiling for a single web-search round-trip, retained as the
|
|
48
|
+
* fallback for call sites that do not declare a timeout class. 300s tolerates
|
|
49
|
+
* pathological cases while still guaranteeing the session unfreezes if Bun's
|
|
50
|
+
* `AbortSignal` fails to propagate on Windows.
|
|
55
51
|
*/
|
|
56
52
|
export const SEARCH_HARD_TIMEOUT_MS = 300_000;
|
|
57
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Hard ceiling for pure search APIs (brave, exa, jina, tavily, kagi,
|
|
56
|
+
* parallel, searxng, synthetic, zai, duckduckgo). These settle in ~1-3s in
|
|
57
|
+
* practice; a hung TCP/TLS connection should fall through to the next
|
|
58
|
+
* provider in seconds, not minutes. Kimi is the exception: it declares an
|
|
59
|
+
* explicit ceiling aligned with its upstream 30s request budget.
|
|
60
|
+
*/
|
|
61
|
+
export const SEARCH_API_TIMEOUT_MS = 15_000;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Hard ceiling for LLM-mediated search providers (anthropic, codex, gemini,
|
|
65
|
+
* perplexity, xai, openai-compatible). These legitimately take tens of
|
|
66
|
+
* seconds because a model performs the search and synthesizes an answer.
|
|
67
|
+
*/
|
|
68
|
+
export const SEARCH_LLM_TIMEOUT_MS = 120_000;
|
|
69
|
+
|
|
70
|
+
/** Timeout class a provider declares for its outbound round-trips. */
|
|
71
|
+
export type SearchTimeoutClass = "api" | "llm";
|
|
72
|
+
|
|
73
|
+
const TIMEOUT_CLASS_MS: Record<SearchTimeoutClass, number> = {
|
|
74
|
+
api: SEARCH_API_TIMEOUT_MS,
|
|
75
|
+
llm: SEARCH_LLM_TIMEOUT_MS,
|
|
76
|
+
};
|
|
77
|
+
|
|
58
78
|
/**
|
|
59
79
|
* Runtime-configurable hard timeout, seeded from the `web_search.timeout`
|
|
60
|
-
* setting via {@link setSearchHardTimeoutMs}.
|
|
61
|
-
*
|
|
80
|
+
* setting via {@link setSearchHardTimeoutMs}. When set, it overrides every
|
|
81
|
+
* class default so users keep a single knob. Unset means class defaults apply.
|
|
62
82
|
*/
|
|
63
|
-
let configuredHardTimeoutMs
|
|
83
|
+
let configuredHardTimeoutMs: number | undefined;
|
|
64
84
|
|
|
65
85
|
/**
|
|
66
86
|
* Override the hard timeout applied to every web-search round-trip.
|
|
67
87
|
*
|
|
68
88
|
* @param ms - Hard timeout in milliseconds. Non-finite or non-positive
|
|
69
|
-
* values
|
|
89
|
+
* values clear the override so per-class defaults apply.
|
|
70
90
|
*/
|
|
71
91
|
export function setSearchHardTimeoutMs(ms: number | undefined): void {
|
|
72
|
-
configuredHardTimeoutMs = typeof ms === "number" && Number.isFinite(ms) && ms > 0 ? ms :
|
|
92
|
+
configuredHardTimeoutMs = typeof ms === "number" && Number.isFinite(ms) && ms > 0 ? ms : undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Structural settings source for {@link applyConfiguredSearchTimeout}. */
|
|
96
|
+
export interface SearchTimeoutSettingSource {
|
|
97
|
+
get(path: "web_search.timeout"): unknown;
|
|
98
|
+
has(path: "web_search.timeout"): boolean;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Install the `web_search.timeout` override from settings — but only when the
|
|
103
|
+
* user explicitly configured it. The settings schema ships a default value
|
|
104
|
+
* (300), and consuming that default via `get()` alone would reinstall a
|
|
105
|
+
* uniform 300s ceiling on every session, silently disabling the per-class
|
|
106
|
+
* timeout defaults. `has()` distinguishes loaded/overridden settings from
|
|
107
|
+
* schema defaults; unset clears any previous override so class defaults apply.
|
|
108
|
+
*/
|
|
109
|
+
export function applyConfiguredSearchTimeout(settings: SearchTimeoutSettingSource): void {
|
|
110
|
+
if (!settings.has("web_search.timeout")) {
|
|
111
|
+
setSearchHardTimeoutMs(undefined);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const value = settings.get("web_search.timeout");
|
|
115
|
+
setSearchHardTimeoutMs(typeof value === "number" && Number.isFinite(value) && value > 0 ? value * 1000 : undefined);
|
|
73
116
|
}
|
|
74
117
|
|
|
75
118
|
/**
|
|
76
119
|
* Compose a caller-supplied {@link AbortSignal} with a hard timeout so an
|
|
77
|
-
* outbound `fetch()` is guaranteed to settle
|
|
78
|
-
*
|
|
120
|
+
* outbound `fetch()` is guaranteed to settle even when the runtime fails to
|
|
121
|
+
* propagate cancellation to the underlying transport.
|
|
79
122
|
*
|
|
80
123
|
* Bun's WinHTTP backend on Windows is known to ignore `AbortSignal` once a
|
|
81
124
|
* TCP/TLS connection stalls (oven-sh/bun#15275, oven-sh/bun#18536); without
|
|
@@ -83,9 +126,16 @@ export function setSearchHardTimeoutMs(ms: number | undefined): void {
|
|
|
83
126
|
* because the user's Esc is never delivered to the native layer.
|
|
84
127
|
*
|
|
85
128
|
* @param signal - Caller cancellation signal, if any.
|
|
86
|
-
* @param
|
|
129
|
+
* @param msOrClass - Explicit timeout in milliseconds, or a
|
|
130
|
+
* {@link SearchTimeoutClass} resolved to its class default. Omitted falls
|
|
131
|
+
* back to the legacy {@link SEARCH_HARD_TIMEOUT_MS} ceiling. A user-set
|
|
132
|
+
* `web_search.timeout` overrides class defaults (but not explicit ms).
|
|
87
133
|
*/
|
|
88
|
-
export function withHardTimeout(signal: AbortSignal | undefined,
|
|
134
|
+
export function withHardTimeout(signal: AbortSignal | undefined, msOrClass?: number | SearchTimeoutClass): AbortSignal {
|
|
135
|
+
const ms =
|
|
136
|
+
typeof msOrClass === "number"
|
|
137
|
+
? msOrClass
|
|
138
|
+
: (configuredHardTimeoutMs ?? (msOrClass ? TIMEOUT_CLASS_MS[msOrClass] : SEARCH_HARD_TIMEOUT_MS));
|
|
89
139
|
const timeout = AbortSignal.timeout(ms);
|
|
90
140
|
return signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
91
141
|
}
|
|
@@ -441,7 +441,7 @@ export async function searchXai(params: XaiSearchParams): Promise<SearchResponse
|
|
|
441
441
|
noInlineCitations: params.no_inline_citations,
|
|
442
442
|
}),
|
|
443
443
|
),
|
|
444
|
-
signal: withHardTimeout(params.signal),
|
|
444
|
+
signal: withHardTimeout(params.signal, "llm"),
|
|
445
445
|
});
|
|
446
446
|
|
|
447
447
|
const text = await response.text();
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
export const WORKFLOW_INTENT_DIFF_CUSTOM_TYPE = "workflow-intent-diff";
|
|
2
|
+
|
|
3
|
+
export type WorkflowIntentRoute = "direct" | "deep-interview" | "ralplan" | "ultragoal" | "team";
|
|
4
|
+
export type DirectTrackingMode = "custom-entry-only" | "not-direct";
|
|
5
|
+
export type RootCausePhaseStatus = "active" | "inactive";
|
|
6
|
+
|
|
7
|
+
export interface WorkflowIntentDiff {
|
|
8
|
+
readonly version: 1;
|
|
9
|
+
readonly route: WorkflowIntentRoute;
|
|
10
|
+
readonly reason: string;
|
|
11
|
+
readonly directTracking: DirectTrackingMode;
|
|
12
|
+
readonly recommendedSkill?: Exclude<WorkflowIntentRoute, "direct">;
|
|
13
|
+
readonly recommendedInvocation?: string;
|
|
14
|
+
readonly triggers: readonly string[];
|
|
15
|
+
readonly rootCausePhase: {
|
|
16
|
+
readonly status: RootCausePhaseStatus;
|
|
17
|
+
readonly triggers: readonly string[];
|
|
18
|
+
};
|
|
19
|
+
readonly promptPreview: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface RouteMatch {
|
|
23
|
+
readonly route: WorkflowIntentRoute;
|
|
24
|
+
readonly reason: string;
|
|
25
|
+
readonly recommendedInvocation?: string;
|
|
26
|
+
readonly triggers: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const PROMPT_PREVIEW_LIMIT = 240;
|
|
30
|
+
|
|
31
|
+
const DURABLE_TRACKING_PATTERNS = [
|
|
32
|
+
/\bultragoal\b/i,
|
|
33
|
+
/\bdurable (?:goal|tracking|ledger|plan)\b/i,
|
|
34
|
+
/\b(?:goal|tracking|plan) ledger\b/i,
|
|
35
|
+
/\bcheckpoint(?:ed|ing)? (?:goal|plan|workflow|release|work)\b/i,
|
|
36
|
+
/\bcheckpoint (?:this|the) (?:goal|plan|workflow|release|work)\b/i,
|
|
37
|
+
] as const;
|
|
38
|
+
|
|
39
|
+
const AMBIGUOUS_REQUIREMENT_PATTERNS = [
|
|
40
|
+
/\bambiguous (?:requirement|requirements|request|requests|scope)\b/i,
|
|
41
|
+
/\bdeep[- ]interview\b/i,
|
|
42
|
+
/\binterview me\b/i,
|
|
43
|
+
/\bdon't assume\b/i,
|
|
44
|
+
/\bnot sure\b/i,
|
|
45
|
+
/\bunclear\b/i,
|
|
46
|
+
/\bvague\b/i,
|
|
47
|
+
] as const;
|
|
48
|
+
|
|
49
|
+
const ARCHITECTURE_SEQUENCE_PATTERNS = [
|
|
50
|
+
/\barchitecture\b/i,
|
|
51
|
+
/\barchitectural\b/i,
|
|
52
|
+
/\bsequence\b/i,
|
|
53
|
+
/\bmigrate\b/i,
|
|
54
|
+
/\bmigration\b/i,
|
|
55
|
+
/\bauth(?:entication|orization)? (?:migration|sequence|rollout|release|refactor|rewrite|transition)\b/i,
|
|
56
|
+
/\bsecurity\b/i,
|
|
57
|
+
/\bcompliance\b/i,
|
|
58
|
+
/\bPII\b/i,
|
|
59
|
+
/\bproduction (?:release|rollout|deployment|migration|incident|data|change|cutover)\b/i,
|
|
60
|
+
/\bdeploy(?:ing)? to production\b/i,
|
|
61
|
+
/\bbreaking change\b/i,
|
|
62
|
+
/\bdata loss\b/i,
|
|
63
|
+
/\bdestructive\b/i,
|
|
64
|
+
] as const;
|
|
65
|
+
|
|
66
|
+
const TEAM_PATTERNS = [
|
|
67
|
+
/\buse (?:a )?team\b/i,
|
|
68
|
+
/\bcoordinated (?:persistent )?workers\b/i,
|
|
69
|
+
/\bpersistent workers\b/i,
|
|
70
|
+
/\bworker coordination\b/i,
|
|
71
|
+
] as const;
|
|
72
|
+
|
|
73
|
+
const ROOT_CAUSE_TRIGGERS = [
|
|
74
|
+
{ name: "contradiction", pattern: /\bcontradict(?:ion|s|ory)?\b/i },
|
|
75
|
+
{ name: "regression", pattern: /\bregression\b/i },
|
|
76
|
+
{
|
|
77
|
+
name: "high-risk transition",
|
|
78
|
+
pattern:
|
|
79
|
+
/\b(?:migrate|migration|auth(?:entication|orization)? (?:migration|sequence|rollout|release|refactor|rewrite|transition)|security|breaking change|data loss|destructive|production (?:release|rollout|deployment|migration|incident|data|change|cutover)|deploy(?:ing)? to production|compliance|PII)\b/i,
|
|
80
|
+
},
|
|
81
|
+
] as const;
|
|
82
|
+
|
|
83
|
+
function matchesAny(text: string, patterns: readonly RegExp[]): boolean {
|
|
84
|
+
return patterns.some(pattern => pattern.test(text));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function withGlobal(pattern: RegExp): RegExp {
|
|
88
|
+
const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
|
|
89
|
+
return new RegExp(pattern.source, flags);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function isNegatedAt(text: string, index: number): boolean {
|
|
93
|
+
const prefix = text.slice(Math.max(0, index - 48), index).toLowerCase();
|
|
94
|
+
const boundary = Math.max(
|
|
95
|
+
prefix.lastIndexOf("."),
|
|
96
|
+
prefix.lastIndexOf(","),
|
|
97
|
+
prefix.lastIndexOf(";"),
|
|
98
|
+
prefix.lastIndexOf(":"),
|
|
99
|
+
prefix.lastIndexOf("?"),
|
|
100
|
+
prefix.lastIndexOf("!"),
|
|
101
|
+
prefix.lastIndexOf("\n"),
|
|
102
|
+
prefix.lastIndexOf(" but "),
|
|
103
|
+
prefix.lastIndexOf(" however "),
|
|
104
|
+
prefix.lastIndexOf(" yet "),
|
|
105
|
+
prefix.lastIndexOf(" then "),
|
|
106
|
+
);
|
|
107
|
+
const localPrefix = boundary >= 0 ? prefix.slice(boundary + 1) : prefix;
|
|
108
|
+
return /(?:^|[\s([{])(?:no|not|without|excluding|exclude|absent|absence of|avoid)\b[^.,!?;:\n]{0,48}$/.test(
|
|
109
|
+
localPrefix,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function matchesAnyNonNegated(text: string, patterns: readonly RegExp[]): boolean {
|
|
114
|
+
return patterns.some(pattern => {
|
|
115
|
+
for (const match of text.matchAll(withGlobal(pattern))) {
|
|
116
|
+
if (!isNegatedAt(text, match.index ?? 0)) return true;
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function collectRootCauseTriggers(text: string): readonly string[] {
|
|
123
|
+
return ROOT_CAUSE_TRIGGERS.filter(trigger => matchesAnyNonNegated(text, [trigger.pattern])).map(
|
|
124
|
+
trigger => trigger.name,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function buildPromptPreview(text: string): string {
|
|
129
|
+
const compact = text.replace(/\s+/g, " ").trim();
|
|
130
|
+
return compact.length > PROMPT_PREVIEW_LIMIT ? `${compact.slice(0, PROMPT_PREVIEW_LIMIT - 3)}...` : compact;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function classifyRoute(text: string): RouteMatch {
|
|
134
|
+
if (matchesAny(text, AMBIGUOUS_REQUIREMENT_PATTERNS)) {
|
|
135
|
+
return {
|
|
136
|
+
route: "deep-interview",
|
|
137
|
+
reason: "ambiguous requirements need clarification",
|
|
138
|
+
recommendedInvocation: "/skill:deep-interview",
|
|
139
|
+
triggers: ["ambiguous requirements"],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (matchesAny(text, DURABLE_TRACKING_PATTERNS)) {
|
|
144
|
+
return {
|
|
145
|
+
route: "ultragoal",
|
|
146
|
+
reason: "durable tracking requested",
|
|
147
|
+
recommendedInvocation: "/skill:ultragoal",
|
|
148
|
+
triggers: ["durable tracking"],
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (matchesAnyNonNegated(text, ARCHITECTURE_SEQUENCE_PATTERNS)) {
|
|
153
|
+
return {
|
|
154
|
+
route: "ralplan",
|
|
155
|
+
reason: "architecture or sequence risk requires deliberate planning",
|
|
156
|
+
recommendedInvocation: "/skill:ralplan --deliberate",
|
|
157
|
+
triggers: ["architecture/sequence risk"],
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (matchesAny(text, TEAM_PATTERNS)) {
|
|
162
|
+
return {
|
|
163
|
+
route: "team",
|
|
164
|
+
reason: "coordinated persistent workers requested",
|
|
165
|
+
recommendedInvocation: "/skill:team",
|
|
166
|
+
triggers: ["coordinated workers"],
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
route: "direct",
|
|
172
|
+
reason: "clear low-risk prompt stays on direct implementation path",
|
|
173
|
+
triggers: ["low-risk direct"],
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function buildWorkflowIntentDiff(text: string): WorkflowIntentDiff | null {
|
|
178
|
+
const promptPreview = buildPromptPreview(text);
|
|
179
|
+
if (!promptPreview) return null;
|
|
180
|
+
|
|
181
|
+
const route = classifyRoute(text);
|
|
182
|
+
const rootCauseTriggers = collectRootCauseTriggers(text);
|
|
183
|
+
const rootCauseActive = rootCauseTriggers.length > 0;
|
|
184
|
+
const direct = route.route === "direct";
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
version: 1,
|
|
188
|
+
route: route.route,
|
|
189
|
+
reason: route.reason,
|
|
190
|
+
directTracking: direct ? "custom-entry-only" : "not-direct",
|
|
191
|
+
...(direct ? {} : { recommendedSkill: route.route, recommendedInvocation: route.recommendedInvocation }),
|
|
192
|
+
triggers: route.triggers,
|
|
193
|
+
rootCausePhase: {
|
|
194
|
+
status: rootCauseActive ? "active" : "inactive",
|
|
195
|
+
triggers: rootCauseTriggers,
|
|
196
|
+
},
|
|
197
|
+
promptPreview,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/src/discovery/vscode.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* VS Code Provider
|
|
3
|
-
*
|
|
4
|
-
* Loads config from `.vscode` directory (project-only).
|
|
5
|
-
* Supports MCP server discovery from `mcp.json` with nested `mcp.servers` structure.
|
|
6
|
-
*/
|
|
7
|
-
import { tryParseJson } from "@gajae-code/utils";
|
|
8
|
-
import { registerProvider } from "../capability";
|
|
9
|
-
import { readFile } from "../capability/fs";
|
|
10
|
-
import { type MCPServer, mcpCapability } from "../capability/mcp";
|
|
11
|
-
import type { LoadContext, LoadResult } from "../capability/types";
|
|
12
|
-
import { createSourceMeta, expandEnvVarsDeep, getProjectPath } from "./helpers";
|
|
13
|
-
|
|
14
|
-
const PROVIDER_ID = "vscode";
|
|
15
|
-
const DISPLAY_NAME = "VS Code";
|
|
16
|
-
const PRIORITY = 20;
|
|
17
|
-
|
|
18
|
-
// =============================================================================
|
|
19
|
-
// MCP Servers
|
|
20
|
-
// =============================================================================
|
|
21
|
-
|
|
22
|
-
registerProvider<MCPServer>(mcpCapability.id, {
|
|
23
|
-
id: PROVIDER_ID,
|
|
24
|
-
displayName: DISPLAY_NAME,
|
|
25
|
-
description: "Load MCP servers from .vscode/mcp.json",
|
|
26
|
-
priority: PRIORITY,
|
|
27
|
-
async load(ctx: LoadContext): Promise<LoadResult<MCPServer>> {
|
|
28
|
-
const items: MCPServer[] = [];
|
|
29
|
-
const warnings: string[] = [];
|
|
30
|
-
|
|
31
|
-
// Project-only (VS Code doesn't support user-level MCP config)
|
|
32
|
-
const projectPath = getProjectPath(ctx, "vscode", "mcp.json");
|
|
33
|
-
if (projectPath) {
|
|
34
|
-
const result = await loadMCPConfig(ctx, projectPath, "project");
|
|
35
|
-
items.push(...result.items);
|
|
36
|
-
if (result.warnings) warnings.push(...result.warnings);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return { items, warnings };
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Load MCP servers from a mcp.json file.
|
|
45
|
-
* VS Code uses nested structure: { "mcp": { "servers": { ... } } }
|
|
46
|
-
*/
|
|
47
|
-
async function loadMCPConfig(
|
|
48
|
-
_ctx: LoadContext,
|
|
49
|
-
path: string,
|
|
50
|
-
level: "user" | "project",
|
|
51
|
-
): Promise<LoadResult<MCPServer>> {
|
|
52
|
-
const items: MCPServer[] = [];
|
|
53
|
-
const warnings: string[] = [];
|
|
54
|
-
|
|
55
|
-
const content = await readFile(path);
|
|
56
|
-
if (!content) {
|
|
57
|
-
warnings.push(`Failed to read ${path}`);
|
|
58
|
-
return { items, warnings };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const parsed = tryParseJson<{ mcp?: { servers?: Record<string, unknown> } }>(content);
|
|
62
|
-
if (!parsed) {
|
|
63
|
-
warnings.push(`Invalid JSON in ${path}`);
|
|
64
|
-
return { items, warnings };
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// VS Code uses nested structure: mcp.servers
|
|
68
|
-
const servers = parsed.mcp?.servers;
|
|
69
|
-
if (!servers || typeof servers !== "object") {
|
|
70
|
-
return { items, warnings };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
for (const [name, config] of Object.entries(servers)) {
|
|
74
|
-
if (!config || typeof config !== "object") {
|
|
75
|
-
warnings.push(`Invalid config for server "${name}" in ${path}`);
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const raw = config as Record<string, unknown>;
|
|
80
|
-
|
|
81
|
-
// Expand environment variables
|
|
82
|
-
const expanded = expandEnvVarsDeep(raw);
|
|
83
|
-
|
|
84
|
-
const server: MCPServer = {
|
|
85
|
-
name,
|
|
86
|
-
command: typeof expanded.command === "string" ? expanded.command : undefined,
|
|
87
|
-
args: Array.isArray(expanded.args) ? (expanded.args as string[]) : undefined,
|
|
88
|
-
env: expanded.env && typeof expanded.env === "object" ? (expanded.env as Record<string, string>) : undefined,
|
|
89
|
-
url: typeof expanded.url === "string" ? expanded.url : undefined,
|
|
90
|
-
headers:
|
|
91
|
-
expanded.headers && typeof expanded.headers === "object"
|
|
92
|
-
? (expanded.headers as Record<string, string>)
|
|
93
|
-
: undefined,
|
|
94
|
-
transport: ["stdio", "sse", "http"].includes(expanded.transport as string)
|
|
95
|
-
? (expanded.transport as "stdio" | "sse" | "http")
|
|
96
|
-
: undefined,
|
|
97
|
-
timeout: typeof expanded.timeout === "number" ? expanded.timeout : undefined,
|
|
98
|
-
_source: createSourceMeta(PROVIDER_ID, path, level),
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
items.push(server);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return { items, warnings };
|
|
105
|
-
}
|