@denizokcu/haze 0.11.0 → 1.0.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 +23 -0
- package/README.md +23 -14
- package/SECURITY.md +3 -3
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/chatMetrics.d.ts +2 -2
- package/dist/cli/chat/chatMetrics.js +1 -1
- package/dist/cli/chat/fileMentionSuggestions.js +1 -1
- package/dist/cli/chat/inputSuggestions.d.ts +8 -16
- package/dist/cli/chat/inputSuggestions.js +9 -41
- package/dist/cli/chat/messages.d.ts +0 -2
- package/dist/cli/chat/messages.js +2 -2
- package/dist/cli/chat/sessionLifecycle.d.ts +2 -1
- package/dist/cli/chat/turnState.d.ts +1 -1
- package/dist/cli/chat/wizardDispatch.d.ts +90 -28
- package/dist/cli/chat/wizardDispatch.js +250 -133
- package/dist/cli/commands/chat.js +14 -72
- package/dist/cli/commands/chatModes.d.ts +8 -1
- package/dist/cli/commands/chatModes.js +9 -44
- package/dist/cli/commands/doctor.js +1 -1
- package/dist/cli/commands/formatters.d.ts +3 -3
- package/dist/cli/commands/formatters.js +6 -25
- package/dist/cli/commands/providerWizard.js +2 -3
- package/dist/cli/commands/runCommand.js +1 -1
- package/dist/cli/commands/serverWizard.d.ts +34 -0
- package/dist/cli/commands/{mcpWizard.js → serverWizard.js} +44 -2
- package/dist/cli/commands/skillsWizard.d.ts +41 -0
- package/dist/cli/commands/{skillWizard.js → skillsWizard.js} +33 -11
- package/dist/cli/commands/streaming/abortCause.d.ts +2 -1
- package/dist/cli/commands/streaming/agentAttempt.d.ts +43 -0
- package/dist/cli/commands/streaming/agentAttempt.js +79 -0
- package/dist/cli/commands/streaming/attemptLifecycle.d.ts +56 -0
- package/dist/cli/commands/streaming/attemptLifecycle.js +110 -0
- package/dist/cli/commands/streaming/attemptOutcome.d.ts +96 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +206 -0
- package/dist/cli/commands/streaming/attemptSetup.d.ts +78 -0
- package/dist/cli/commands/streaming/attemptSetup.js +167 -0
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +1 -1
- package/dist/cli/commands/streaming/goalCheckpoint.js +2 -2
- package/dist/cli/commands/streaming/goalSupervisor.js +9 -6
- package/dist/cli/commands/streaming/stallRecovery.d.ts +94 -0
- package/dist/cli/commands/streaming/stallRecovery.js +105 -0
- package/dist/cli/commands/streaming/streamLoop.d.ts +72 -0
- package/dist/cli/commands/streaming/streamLoop.js +448 -0
- package/dist/cli/commands/streaming/toolCallRecovery.d.ts +14 -0
- package/dist/cli/commands/streaming/toolCallRecovery.js +56 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +2 -1
- package/dist/cli/commands/streaming/turnRuntime.d.ts +4 -0
- package/dist/cli/commands/streaming/turnRuntime.js +6 -0
- package/dist/cli/commands/streaming.d.ts +14 -25
- package/dist/cli/commands/streaming.js +43 -754
- package/dist/cli/commands/wizardFlow.d.ts +334 -0
- package/dist/cli/commands/wizardFlow.js +377 -0
- package/dist/cli/contextReport.js +3 -0
- package/dist/cli/index.js +1 -1
- package/dist/config/contextFiles.js +9 -3
- package/dist/config/inputHistory.d.ts +0 -1
- package/dist/config/inputHistory.js +1 -1
- package/dist/config/modelDiscovery.d.ts +0 -15
- package/dist/config/modelDiscovery.js +1 -1
- package/dist/config/settings.d.ts +7 -0
- package/dist/config/settings.js +3 -0
- package/dist/config/skillSettings.js +4 -4
- package/dist/config/updateCheck.d.ts +0 -1
- package/dist/config/updateCheck.js +1 -1
- package/dist/core/agent/budgets.d.ts +63 -1
- package/dist/core/agent/budgets.js +84 -1
- package/dist/core/agent/compaction.js +1 -1
- package/dist/core/agent/completionController.d.ts +7 -13
- package/dist/core/agent/completionController.js +17 -8
- package/dist/core/agent/contextBudget.d.ts +0 -4
- package/dist/core/agent/contextBudget.js +3 -3
- package/dist/core/agent/errors.d.ts +0 -1
- package/dist/core/agent/errors.js +1 -1
- package/dist/core/agent/events.d.ts +5 -1
- package/dist/core/{goal/completionPolicy.d.ts → agent/goalPolicy.d.ts} +18 -0
- package/dist/core/agent/goalPolicy.js +106 -0
- package/dist/core/agent/requestAssembly.d.ts +2 -2
- package/dist/core/agent/requestAssembly.js +16 -4
- package/dist/core/agent/toolCapabilities.d.ts +2 -2
- package/dist/core/agent/toolCapabilities.js +5 -5
- package/dist/core/agent/toolOutputStore.js +1 -1
- package/dist/core/agent/toolResults.js +1 -1
- package/dist/core/agent/workState.d.ts +6 -3
- package/dist/core/agent/workState.js +62 -7
- package/dist/core/attachments/imageAttachments.js +90 -42
- package/dist/core/deadline.d.ts +0 -6
- package/dist/core/deadline.js +1 -1
- package/dist/core/io/boundedRead.js +1 -1
- package/dist/core/limits.d.ts +51 -0
- package/dist/core/limits.js +51 -0
- package/dist/core/log/llmLog.js +1 -1
- package/dist/core/process/backgroundRegistry.d.ts +2 -3
- package/dist/core/process/backgroundRegistry.js +10 -6
- package/dist/core/process/userShell.d.ts +16 -0
- package/dist/core/process/userShell.js +59 -0
- package/dist/core/safety/shellClassifier.d.ts +11 -0
- package/dist/core/safety/{bashClassifier.js → shellClassifier.js} +5 -3
- package/dist/core/safety/urlGuard.d.ts +1 -1
- package/dist/core/session/sessionSlimming.d.ts +0 -3
- package/dist/core/session/sessionSlimming.js +2 -3
- package/dist/core/session/sessionStore.d.ts +1 -0
- package/dist/core/session/sessionStore.js +39 -20
- package/dist/core/{bashOutput → shellOutput}/lineFilter.js +8 -2
- package/dist/core/{bashOutput → shellOutput}/reducers/search.d.ts +0 -1
- package/dist/core/{bashOutput → shellOutput}/reducers/search.js +1 -1
- package/dist/core/shellOutput/registry.d.ts +2 -0
- package/dist/core/{bashOutput → shellOutput}/registry.js +3 -3
- package/dist/core/{bashOutput → shellOutput}/types.d.ts +6 -5
- package/dist/core/subagent/contracts.d.ts +2 -14
- package/dist/core/subagent/contracts.js +3 -3
- package/dist/core/subagent/executionProfiles.js +2 -2
- package/dist/core/subagent/subagentRunner.js +3 -4
- package/dist/core/toolOutput/reduction.d.ts +0 -12
- package/dist/core/toolOutput/reduction.js +1 -1
- package/dist/core/validation/outputParser.d.ts +2 -2
- package/dist/llm/client.js +5 -1
- package/dist/llm/hazeTools.d.ts +139 -124
- package/dist/llm/hazeTools.js +14 -11
- package/dist/llm/initPrompt.js +1 -1
- package/dist/llm/lsp/client.d.ts +45 -0
- package/dist/llm/lsp/client.js +195 -0
- package/dist/llm/lsp/pool.d.ts +23 -0
- package/dist/llm/lsp/pool.js +86 -0
- package/dist/llm/lsp/protocol.d.ts +64 -0
- package/dist/llm/lsp/protocol.js +128 -0
- package/dist/llm/lsp/requests.d.ts +94 -0
- package/dist/llm/lsp/requests.js +119 -0
- package/dist/llm/lspTools.d.ts +3824 -570
- package/dist/llm/lspTools.js +65 -1
- package/dist/llm/openaiCodex.d.ts +0 -2
- package/dist/llm/openaiCodex.js +0 -4
- package/dist/llm/openaiCodexOAuth.d.ts +0 -3
- package/dist/llm/openaiCodexOAuth.js +6 -3
- package/dist/llm/requestContext.d.ts +5 -1
- package/dist/llm/requestContext.js +25 -2
- package/dist/llm/systemPrompt.d.ts +1 -0
- package/dist/llm/systemPrompt.js +13 -6
- package/dist/llm/toolResultTypes.d.ts +0 -14
- package/dist/llm/toolResultTypes.js +1 -4
- package/dist/llm/tools/editMatch.d.ts +0 -9
- package/dist/llm/tools/editMatch.js +1 -1
- package/dist/llm/tools/fetchTool.js +1 -1
- package/dist/llm/tools/fileToolShared.d.ts +4 -2
- package/dist/llm/tools/fileToolShared.js +9 -5
- package/dist/llm/tools/gitIgnore.d.ts +25 -32
- package/dist/llm/tools/gitIgnore.js +216 -98
- package/dist/llm/tools/grepParse.d.ts +2 -1
- package/dist/llm/tools/grepRunner.d.ts +1 -1
- package/dist/llm/tools/grepRunner.js +2 -2
- package/dist/llm/tools/outputCap.d.ts +2 -7
- package/dist/llm/tools/outputCap.js +3 -3
- package/dist/llm/tools/processTool.d.ts +16 -16
- package/dist/llm/tools/processTool.js +1 -1
- package/dist/llm/tools/readRecovery.d.ts +0 -2
- package/dist/llm/tools/readRecovery.js +2 -2
- package/dist/llm/tools/{bashTool.d.ts → shellTool.d.ts} +123 -107
- package/dist/llm/tools/{bashTool.js → shellTool.js} +15 -14
- package/dist/llm/tools/toolContext.js +5 -5
- package/dist/llm/tools/workspaceFile.d.ts +0 -1
- package/dist/llm/tools/workspaceFile.js +1 -6
- package/dist/llm/webFetch.d.ts +1 -1
- package/dist/skills/SkillLoader.d.ts +1 -11
- package/dist/skills/SkillLoader.js +1 -2
- package/dist/skills/types.d.ts +2 -1
- package/dist/utils/buildInfo.d.ts +6 -13
- package/dist/utils/buildInfo.js +6 -15
- package/dist/utils/fs.d.ts +7 -5
- package/dist/utils/fs.js +5 -2
- package/dist/utils/path.d.ts +0 -1
- package/dist/utils/path.js +1 -1
- package/package.json +6 -4
- package/dist/cli/commands/lspWizard.d.ts +0 -14
- package/dist/cli/commands/lspWizard.js +0 -44
- package/dist/cli/commands/mcpWizard.d.ts +0 -15
- package/dist/cli/commands/skillConfirmRemove.d.ts +0 -11
- package/dist/cli/commands/skillConfirmRemove.js +0 -20
- package/dist/cli/commands/skillCreation.d.ts +0 -12
- package/dist/cli/commands/skillCreation.js +0 -14
- package/dist/cli/commands/skillWizard.d.ts +0 -17
- package/dist/cli/commands/streaming/idleTimer.d.ts +0 -26
- package/dist/cli/commands/streaming/idleTimer.js +0 -24
- package/dist/cli/commands/streaming/turnOutcome.d.ts +0 -27
- package/dist/cli/commands/streaming/turnOutcome.js +0 -29
- package/dist/cli/commands/wizardActions.d.ts +0 -47
- package/dist/cli/commands/wizardActions.js +0 -47
- package/dist/cli/commands/wizardInput.d.ts +0 -4
- package/dist/cli/commands/wizardInput.js +0 -19
- package/dist/cli/commands/wizardPrompts.d.ts +0 -22
- package/dist/cli/commands/wizardPrompts.js +0 -58
- package/dist/cli/commands/wizardSuggestions.d.ts +0 -31
- package/dist/cli/commands/wizardSuggestions.js +0 -190
- package/dist/cli/commands/wizardTransition.d.ts +0 -37
- package/dist/cli/commands/wizardTransition.js +0 -43
- package/dist/core/agent/toolExecutionBudget.d.ts +0 -35
- package/dist/core/agent/toolExecutionBudget.js +0 -49
- package/dist/core/agent/turnBudget.d.ts +0 -35
- package/dist/core/agent/turnBudget.js +0 -27
- package/dist/core/bashOutput/ansi.d.ts +0 -1
- package/dist/core/bashOutput/ansi.js +0 -7
- package/dist/core/bashOutput/registry.d.ts +0 -4
- package/dist/core/goal/completionPolicy.js +0 -43
- package/dist/core/goal/requestClassifier.d.ts +0 -3
- package/dist/core/goal/requestClassifier.js +0 -18
- package/dist/core/goal/sessionGoal.d.ts +0 -8
- package/dist/core/goal/sessionGoal.js +0 -30
- package/dist/core/limits/byteBudgets.d.ts +0 -20
- package/dist/core/limits/byteBudgets.js +0 -20
- package/dist/core/limits/textBudgets.d.ts +0 -25
- package/dist/core/limits/textBudgets.js +0 -25
- package/dist/core/safety/bashClassifier.d.ts +0 -10
- package/dist/llm/lsp.d.ts +0 -149
- package/dist/llm/lsp.js +0 -368
- package/dist/ui/components/ErrorView.d.ts +0 -4
- package/dist/ui/components/ErrorView.js +0 -7
- package/dist/utils/yaml.d.ts +0 -2
- package/dist/utils/yaml.js +0 -8
- package/examples/skills/files/SKILL.md +0 -16
- package/examples/skills/files/examples/file-editing.md +0 -3
- /package/dist/core/{bashOutput → shellOutput}/command.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/command.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/lineFilter.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/content.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/content.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/gh.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/gh.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/git.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/git.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/validation.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/validation.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/types.js +0 -0
package/dist/llm/lspTools.js
CHANGED
|
@@ -3,7 +3,8 @@ import { tool } from 'ai';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { readSettings } from '../config/settings.js';
|
|
5
5
|
import { configuredLspServers } from '../config/lspSettings.js';
|
|
6
|
-
import {
|
|
6
|
+
import { pickLspServer } from './lsp/pool.js';
|
|
7
|
+
import { lspDefinition, lspDiagnostics, lspDocumentSymbols, lspImplementation, lspReferences, lspTypeDefinition, lspWorkspaceSymbols } from './lsp/requests.js';
|
|
7
8
|
async function serverFor(filePath) {
|
|
8
9
|
const servers = configuredLspServers(await readSettings()).filter(server => server.enabled !== false);
|
|
9
10
|
return pickLspServer(servers, filePath);
|
|
@@ -119,5 +120,68 @@ export function buildLspTools(pool) {
|
|
|
119
120
|
}
|
|
120
121
|
},
|
|
121
122
|
}),
|
|
123
|
+
lspTypeDefinition: tool({
|
|
124
|
+
description: 'Use a configured language server to find the type definition (e.g. interface, type alias, class) for the symbol at a 1-based line/column. Read-only. Useful for generics and annotated values where lspDefinition lands on the annotated name instead of its type.',
|
|
125
|
+
inputSchema: z.object({
|
|
126
|
+
path: z.string().min(1).describe('Workspace-relative source file path'),
|
|
127
|
+
line: z.number().int().positive().describe('1-based line number'),
|
|
128
|
+
column: z.number().int().positive().describe('1-based column/character number'),
|
|
129
|
+
maxResults: z.number().int().positive().max(50).default(20).describe('Maximum locations to return'),
|
|
130
|
+
}),
|
|
131
|
+
execute: async ({ path: filePath, line, column, maxResults }) => {
|
|
132
|
+
const server = await serverFor(filePath);
|
|
133
|
+
if (!server)
|
|
134
|
+
return noServer(filePath);
|
|
135
|
+
try {
|
|
136
|
+
const locations = await lspTypeDefinition(server, filePath, line, column, maxResults, pool);
|
|
137
|
+
return { ok: true, server: server.name, path: filePath, locations, truncated: locations.length >= maxResults };
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
return lspFailure(error);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
}),
|
|
144
|
+
lspImplementation: tool({
|
|
145
|
+
description: 'Use a configured language server to find implementations of an interface, abstract member, or generic signature at a 1-based line/column. Read-only.',
|
|
146
|
+
inputSchema: z.object({
|
|
147
|
+
path: z.string().min(1).describe('Workspace-relative source file path'),
|
|
148
|
+
line: z.number().int().positive().describe('1-based line number'),
|
|
149
|
+
column: z.number().int().positive().describe('1-based column/character number'),
|
|
150
|
+
maxResults: z.number().int().positive().max(100).default(50).describe('Maximum locations to return'),
|
|
151
|
+
}),
|
|
152
|
+
execute: async ({ path: filePath, line, column, maxResults }) => {
|
|
153
|
+
const server = await serverFor(filePath);
|
|
154
|
+
if (!server)
|
|
155
|
+
return noServer(filePath);
|
|
156
|
+
try {
|
|
157
|
+
const locations = await lspImplementation(server, filePath, line, column, maxResults, pool);
|
|
158
|
+
return { ok: true, server: server.name, path: filePath, locations, truncated: locations.length >= maxResults };
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
return lspFailure(error);
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
}),
|
|
165
|
+
lspDiagnostics: tool({
|
|
166
|
+
description: 'Use a configured language server to get diagnostics (errors/warnings) for one source file. Read-only. Best for a quick post-edit check of a single touched file; prefer the relevant build/test command for authoritative whole-project validation.',
|
|
167
|
+
inputSchema: z.object({
|
|
168
|
+
path: z.string().min(1).describe('Workspace-relative source file path'),
|
|
169
|
+
maxResults: z.number().int().positive().max(100).default(50).describe('Maximum diagnostics to return'),
|
|
170
|
+
}),
|
|
171
|
+
execute: async ({ path: filePath, maxResults }) => {
|
|
172
|
+
const server = await serverFor(filePath);
|
|
173
|
+
if (!server)
|
|
174
|
+
return noServer(filePath);
|
|
175
|
+
try {
|
|
176
|
+
const result = await lspDiagnostics(server, filePath, maxResults, pool);
|
|
177
|
+
if (!result.ok)
|
|
178
|
+
return { ok: false, error: result.error };
|
|
179
|
+
return { ok: true, server: server.name, path: filePath, diagnostics: result.diagnostics, truncated: result.diagnostics.length >= maxResults };
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
return lspFailure(error);
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
}),
|
|
122
186
|
};
|
|
123
187
|
}
|
package/dist/llm/openaiCodex.js
CHANGED
|
@@ -41,7 +41,3 @@ export function createChatGptCodexFetch(providerName, fetchImpl = fetch) {
|
|
|
41
41
|
return fetchImpl(CHATGPT_CODEX_RESPONSES_URL, { ...init, headers: authenticatedHeaders(init, auth) });
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
/** Test-only reset for process-global refresh deduplication. */
|
|
45
|
-
export function clearChatGptRefreshes() {
|
|
46
|
-
refreshes.clear();
|
|
47
|
-
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { OAuthProviderAuth } from '../config/providerAuth.js';
|
|
2
|
-
export declare const CHATGPT_OAUTH_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
3
|
-
export declare const CHATGPT_OAUTH_ISSUER = "https://auth.openai.com";
|
|
4
2
|
export declare const CHATGPT_CODEX_BASE_URL = "https://chatgpt.com/backend-api/codex";
|
|
5
3
|
export declare const CHATGPT_CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
|
|
6
|
-
export declare const CHATGPT_OAUTH_CALLBACK_PORT = 1455;
|
|
7
4
|
interface PkceCodes {
|
|
8
5
|
verifier: string;
|
|
9
6
|
challenge: string;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
import { createServer } from 'node:http';
|
|
3
3
|
import { openPath } from '../utils/openPath.js';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const CHATGPT_OAUTH_CLIENT_ID = 'app_EMoamEEZ73f0CkXaXp7hrann';
|
|
5
|
+
const CHATGPT_OAUTH_ISSUER = 'https://auth.openai.com';
|
|
6
6
|
export const CHATGPT_CODEX_BASE_URL = 'https://chatgpt.com/backend-api/codex';
|
|
7
7
|
export const CHATGPT_CODEX_RESPONSES_URL = `${CHATGPT_CODEX_BASE_URL}/responses`;
|
|
8
8
|
// Fixed by the registered ChatGPT OAuth client: the redirect_uri must match
|
|
9
9
|
// exactly. Do not switch to an ephemeral port — the auth server would reject
|
|
10
10
|
// the callback.
|
|
11
|
-
|
|
11
|
+
const CHATGPT_OAUTH_CALLBACK_PORT = 1455;
|
|
12
12
|
const CALLBACK_PATH = '/auth/callback';
|
|
13
13
|
const DEFAULT_TIMEOUT_MS = 5 * 60 * 1000;
|
|
14
14
|
function base64UrlEncode(value) {
|
|
@@ -114,6 +114,8 @@ export async function startChatGptBrowserLogin(options = {}) {
|
|
|
114
114
|
const port = options.port ?? CHATGPT_OAUTH_CALLBACK_PORT;
|
|
115
115
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
116
116
|
const fetchImpl = options.fetchImpl ?? fetch;
|
|
117
|
+
// RFC 8252 loopback redirects intentionally use HTTP: traffic never leaves
|
|
118
|
+
// the host, while PKCE and the random state protect the authorization code.
|
|
117
119
|
const redirectUri = `http://localhost:${port}${CALLBACK_PATH}`;
|
|
118
120
|
const pkce = await generatePkce();
|
|
119
121
|
const state = base64UrlEncode(crypto.randomBytes(32));
|
|
@@ -177,6 +179,7 @@ export async function startChatGptBrowserLogin(options = {}) {
|
|
|
177
179
|
});
|
|
178
180
|
await new Promise((resolve, reject) => {
|
|
179
181
|
server.once('error', reject);
|
|
182
|
+
// Bind only to the loopback hostname registered in redirectUri.
|
|
180
183
|
server.listen(port, 'localhost', resolve);
|
|
181
184
|
}).catch(error => {
|
|
182
185
|
controller.abort();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ToolSet } from 'ai';
|
|
2
|
-
import { LspPool } from './lsp.js';
|
|
2
|
+
import { LspPool } from './lsp/pool.js';
|
|
3
3
|
import { type PromptSession } from './systemPrompt.js';
|
|
4
4
|
import { readSettings } from '../config/settings.js';
|
|
5
5
|
import { type ModelRuntimeSelection } from './client.js';
|
|
@@ -21,6 +21,8 @@ export interface TurnExecutionScope {
|
|
|
21
21
|
coordinator: SubagentCoordinator;
|
|
22
22
|
mutationPolicy: WorkspaceMutationPolicy;
|
|
23
23
|
}
|
|
24
|
+
/** Keep the common coding path lean while preserving explicitly relevant capabilities. */
|
|
25
|
+
export declare function selectToolsForRequest(tools: ToolSet, request?: string): ToolSet;
|
|
24
26
|
export interface AssembledRequestContext {
|
|
25
27
|
systemPrompt: string;
|
|
26
28
|
availableTools: ToolSet;
|
|
@@ -48,6 +50,8 @@ export declare function assembleRequestContext(input: {
|
|
|
48
50
|
onSubagentEvent?: (event: CoordinatorEvent) => void;
|
|
49
51
|
abortSignal?: AbortSignal;
|
|
50
52
|
executionScope?: TurnExecutionScope;
|
|
53
|
+
/** Current user request, used only to omit irrelevant heavyweight built-ins. */
|
|
54
|
+
request?: string;
|
|
51
55
|
/** Pre-read settings so a turn performs a single settings read (CR-024). */
|
|
52
56
|
settings?: Awaited<ReturnType<typeof readSettings>>;
|
|
53
57
|
}): Promise<AssembledRequestContext>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hazeTools } from './hazeTools.js';
|
|
2
2
|
import { buildLspTools } from './lspTools.js';
|
|
3
|
-
import { LspPool } from './lsp.js';
|
|
3
|
+
import { LspPool } from './lsp/pool.js';
|
|
4
4
|
import { buildSystemPrompt } from './systemPrompt.js';
|
|
5
5
|
import { readSettings } from '../config/settings.js';
|
|
6
6
|
import { resolveWorkerRuntime } from './client.js';
|
|
@@ -16,6 +16,22 @@ import { buildSkillTools } from '../skills/skillTools.js';
|
|
|
16
16
|
import { isSkillEnabled } from '../config/skillSettings.js';
|
|
17
17
|
import { createSubagentTool } from '../core/subagent/subagentRunner.js';
|
|
18
18
|
import { addCapabilityTools } from './capabilities.js';
|
|
19
|
+
const ALWAYS_AVAILABLE_TOOLS = new Set(['listFiles', 'readFile', 'grep', 'replaceLines', 'writeFile', 'editFile', 'shell', 'writeTasks', 'readToolOutput', 'skill']);
|
|
20
|
+
/** Keep the common coding path lean while preserving explicitly relevant capabilities. */
|
|
21
|
+
export function selectToolsForRequest(tools, request) {
|
|
22
|
+
if (request === undefined)
|
|
23
|
+
return tools;
|
|
24
|
+
const lower = request.toLowerCase();
|
|
25
|
+
const includeFetch = /https?:\/\/|\b(web|online|fetch|current docs?|api docs?|library docs?|research)\b/.test(lower);
|
|
26
|
+
const includeProcess = /\b(background|server|serve|daemon|watch(?:er)?|long-running|process|dev server)\b/.test(lower);
|
|
27
|
+
const includeSubagent = /\b(subagents?|agents?|fleet|parallel|delegate|orchestrat\w*|multi-agent|review|audit|compare)\b/.test(lower) || request.length > 1_200;
|
|
28
|
+
return Object.fromEntries(Object.entries(tools).filter(([name]) => ALWAYS_AVAILABLE_TOOLS.has(name)
|
|
29
|
+
|| (name === 'fetch' && includeFetch)
|
|
30
|
+
|| (name === 'process' && includeProcess)
|
|
31
|
+
|| (name === 'subagent' && includeSubagent)
|
|
32
|
+
// Configured LSP/MCP tools are explicit user capabilities and remain available.
|
|
33
|
+
|| !['fetch', 'process', 'subagent'].includes(name)));
|
|
34
|
+
}
|
|
19
35
|
/**
|
|
20
36
|
* Assemble the system prompt and full tool set (built-in + LSP + subagent +
|
|
21
37
|
* skills + MCP) for a model request. This is the single source of truth shared
|
|
@@ -79,9 +95,16 @@ export async function assembleRequestContext(input) {
|
|
|
79
95
|
if (loadedMcp && Object.keys(loadedMcp.tools).length > 0) {
|
|
80
96
|
addCapabilityTools({ availableTools, toolCategories, loaded: { category: 'mcp', tools: loadedMcp.tools }, skipCollisions: true });
|
|
81
97
|
}
|
|
98
|
+
const selectedTools = selectToolsForRequest(availableTools, input.request);
|
|
99
|
+
for (const name of Object.keys(availableTools)) {
|
|
100
|
+
if (!(name in selectedTools)) {
|
|
101
|
+
delete availableTools[name];
|
|
102
|
+
toolCategories.delete(name);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
82
105
|
const mcpAvailable = Boolean(loadedMcp && Object.keys(loadedMcp.tools).length > 0);
|
|
83
106
|
const skillErrors = (skillRegistry.errors ?? []).map(error => `${error.source ? `${error.source}/` : ''}${error.directory}: ${error.message}`);
|
|
84
107
|
const model = input.modelRuntime?.config ? { provider: input.modelRuntime.config.providerName, name: input.modelRuntime.config.modelName } : undefined;
|
|
85
|
-
const systemPrompt = `${buildSystemPrompt(input.contextFiles, input.session, { lspAvailable: hasInstalledLsp, mcpAvailable, model })}${skillErrors.length ? `\n\n<skill-load-errors>\nInvalid skills were isolated:\n${skillErrors.map(error => `- ${error}`).join('\n')}\n</skill-load-errors>` : ''}`;
|
|
108
|
+
const systemPrompt = `${buildSystemPrompt(input.contextFiles, input.session, { lspAvailable: hasInstalledLsp, mcpAvailable, model, availableTools: new Set(Object.keys(availableTools)) })}${skillErrors.length ? `\n\n<skill-load-errors>\nInvalid skills were isolated:\n${skillErrors.map(error => `- ${error}`).join('\n')}\n</skill-load-errors>` : ''}`;
|
|
86
109
|
return { systemPrompt, availableTools, toolCategories, loadedMcp, lspPool, executionScope };
|
|
87
110
|
}
|
|
@@ -18,6 +18,7 @@ export declare function buildSystemPrompt(contextFiles?: ContextFile[], session?
|
|
|
18
18
|
provider: string;
|
|
19
19
|
name: string;
|
|
20
20
|
};
|
|
21
|
+
availableTools?: ReadonlySet<string>;
|
|
21
22
|
}): string;
|
|
22
23
|
export declare function buildSubagentPrompt(contextFiles?: ContextFile[], session?: PromptSession, mode?: 'inspect' | 'research' | 'implement' | 'validate', budget?: {
|
|
23
24
|
maxToolCalls: number;
|
package/dist/llm/systemPrompt.js
CHANGED
|
@@ -14,12 +14,21 @@ export function buildSystemPrompt(contextFiles = [], session, options = {}) {
|
|
|
14
14
|
const date = (session?.start ?? new Date()).toISOString().slice(0, 10);
|
|
15
15
|
const cwd = (session?.cwd ?? process.cwd()).replace(/\\/g, '/');
|
|
16
16
|
const lspToolRule = options.lspAvailable
|
|
17
|
-
? '- When LSP tools are available for a file type, prefer them for semantic code navigation. For a named symbol, try lspWorkspaceSymbols first; if it reports no project, returns no useful result, or the workspace may not be indexed, do not inspect config repeatedly — use grep/listFiles to find likely files, then lspSymbols on those files. Treat lspSymbols results as definitions when they contain the named symbol. Use lspDefinition/lspReferences only when you have an exact line/column at a real symbol occurrence. Fall back to grep/readFile when LSP is unavailable or text search is the better fit.\n'
|
|
17
|
+
? '- When LSP tools are available for a file type, prefer them for semantic code navigation. For a named symbol, try lspWorkspaceSymbols first; if it reports no project, returns no useful result, or the workspace may not be indexed, do not inspect config repeatedly — use grep/listFiles to find likely files, then lspSymbols on those files. Treat lspSymbols results as definitions when they contain the named symbol. Use lspDefinition/lspTypeDefinition/lspImplementation/lspReferences only when you have an exact line/column at a real symbol occurrence. lspDiagnostics is a quick read-only check of one touched file; the relevant build/test command remains the authoritative validation. Fall back to grep/readFile when LSP is unavailable or text search is the better fit.\n'
|
|
18
18
|
: '';
|
|
19
19
|
const mcpToolRule = options.mcpAvailable
|
|
20
20
|
? '- MCP server tools (e.g. Context7 docs lookup) are available when configured via /mcp. They extend the toolset with external capabilities; use them when the user asks for up-to-date docs or library info those tools expose, instead of guessing from memory.\n'
|
|
21
21
|
: '';
|
|
22
22
|
const modelLine = options.model ? `\nActive model: ${options.model.provider}/${options.model.name}` : '';
|
|
23
|
+
const hasTool = (name) => options.availableTools?.has(name) ?? true;
|
|
24
|
+
const processRule = hasTool('process') ? ', inspect them with process/readToolOutput, and kill every process you start when done' : '';
|
|
25
|
+
const fetchRule = hasTool('fetch')
|
|
26
|
+
? '- fetch reads a public URL and returns readable content (markdown for docs, pretty JSON, or text); use it for current docs, API references, and error lookups instead of guessing from memory. Private/loopback/metadata hosts and non-http(s) schemes are blocked; oversize output is retrievable with readToolOutput.\n'
|
|
27
|
+
: '';
|
|
28
|
+
const subagentRule = hasTool('subagent')
|
|
29
|
+
? '- Use subagent as a context-isolation boundary. Delegate an independent, self-contained task when its private reads/searches/tool output will likely be much larger than the compact deliverable needed here; one substantial task is sufficient. Keep trivial, conversation-coupled, user-interactive, sequentially dependent, or uncertain shared-mutation work here. Give a precise objective, deliverable, mode, and path scope—never paste chat history or file contents. Submit genuinely independent tasks together and let runtime limits schedule them.\n'
|
|
30
|
+
: '';
|
|
31
|
+
const coordinationRule = `${hasTool('skill') ? 'skill loads one installed workflow by name. ' : ''}${hasTool('writeTasks') ? 'writeTasks is for substantial work, normally five or more steps; update it only at meaningful phase changes, blockers, or completion.' : ''}`.trim();
|
|
23
32
|
return `You are haze, an autonomous coding assistant in a terminal. Infer the requested outcome, inspect only what is relevant, make the smallest correct change, validate it when practical, and report status honestly.
|
|
24
33
|
|
|
25
34
|
## Operating rules
|
|
@@ -34,10 +43,8 @@ export function buildSystemPrompt(contextFiles = [], session, options = {}) {
|
|
|
34
43
|
${lspToolRule}${mcpToolRule}- ${UNTRUSTED_TOOL_OUTPUT_RULE}
|
|
35
44
|
- grep locates text patterns and non-semantic matches. listFiles discovers structure. readFile returns bounded numbered lines with nextOffset for pagination.
|
|
36
45
|
- editFile performs unique replacements. If an edit fails, read that exact file again before retrying; use replaceLines when current line numbers are safer.
|
|
37
|
-
- writeFile creates files and only overwrites when explicitly requested. Keep each content payload within the tool's byte limit; for larger files, write the first chunk normally and continue the same file with append=true. Never split one logical file into imported part files merely to bypass the limit.
|
|
38
|
-
|
|
39
|
-
- Use subagent as a context-isolation boundary. Delegate an independent, self-contained task when its private reads/searches/tool output will likely be much larger than the compact deliverable needed here; one substantial task is sufficient. Keep trivial, conversation-coupled, user-interactive, sequentially dependent, or uncertain shared-mutation work here. Give a precise objective, deliverable, mode, and path scope—never paste chat history or file contents. Submit genuinely independent tasks together and let runtime limits schedule them.
|
|
40
|
-
- skill loads one installed workflow by name. writeTasks is for substantial work, normally five or more steps; update it only at meaningful phase changes, blockers, or completion.
|
|
46
|
+
- writeFile creates files and only overwrites when explicitly requested. Before a complete rewrite of a requested path that may already exist, read it, then use overwriteExisting=true. Keep each content payload within the tool's byte limit; for larger files, write the first chunk normally and continue the same file with append=true. Never split one logical file into imported part files merely to bypass the limit. shell runs inspection, scripts, and validation; set purpose=validation for custom assertion/check commands so their real exit result counts as completion evidence. Use background=true only when managed process tools are available${processRule}. readToolOutput retrieves omitted oversized command output.
|
|
47
|
+
${fetchRule}${subagentRule}${coordinationRule ? `- ${coordinationRule}\n` : ''}
|
|
41
48
|
- Prefer targeted reads and checks. Do not repeat unchanged reads or failing validation without a relevant change. When several independent files are already known, read them together instead of discovering them one model step at a time.
|
|
42
49
|
- Ignored files require explicit need. Keep file mutations separate from validation commands when practical.
|
|
43
50
|
- File tools may surface scoped AGENTS.md/CLAUDE.md instructions for the target path. Review newly surfaced instructions before mutating that path; prefer the more specific path, and at the same scope AGENTS.md overrides CLAUDE.md.
|
|
@@ -46,7 +53,7 @@ ${lspToolRule}${mcpToolRule}- ${UNTRUSTED_TOOL_OUTPUT_RULE}
|
|
|
46
53
|
|
|
47
54
|
## Completion
|
|
48
55
|
- If you declared a task list with writeTasks, its pending and in-progress items are commitments for the current goal: complete them, or update the list when scope genuinely changes, before your final synthesis. A "next unfinished action" line is a runtime-forced progress checkpoint that haze continues from automatically — it never ends the goal by itself.
|
|
49
|
-
- After edits, run the smallest relevant test, typecheck, lint, or build command you can identify.
|
|
56
|
+
- After edits, run the smallest relevant test, typecheck, lint, or build command you can identify. For custom shell checks, set purpose=validation; ordinary inspection commands do not count as validation.
|
|
50
57
|
- If explicit requirements still lack coverage and a lightweight check would add confidence, test those cases together in one focused check. Confirm that a failing assertion measures the intended requirement before changing otherwise working code. Do not create repeated ad hoc validation rounds.
|
|
51
58
|
- After fixing a real validation failure, rerun the authoritative relevant check. Stop when the requested outcome and relevant validation are satisfied; do not reread unchanged code solely for reassurance.
|
|
52
59
|
- Never claim a command passed unless it ran successfully in this turn.
|
|
@@ -28,18 +28,4 @@ export type ValidationSummary = {
|
|
|
28
28
|
suggestedNextStep?: string;
|
|
29
29
|
rawOutputTruncated: boolean;
|
|
30
30
|
};
|
|
31
|
-
export type StructuredToolFailure = {
|
|
32
|
-
ok: false;
|
|
33
|
-
toolName: string;
|
|
34
|
-
path?: string;
|
|
35
|
-
error: string;
|
|
36
|
-
reasonCode?: ToolFailureReasonCode;
|
|
37
|
-
recoverable: boolean;
|
|
38
|
-
suggestedNextStep: string;
|
|
39
|
-
recoveryTool?: string;
|
|
40
|
-
recoveryInput?: unknown;
|
|
41
|
-
suggestedPaths?: string[];
|
|
42
|
-
};
|
|
43
|
-
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
44
|
-
export declare function isStructuredToolFailure(value: unknown): value is StructuredToolFailure;
|
|
45
31
|
export declare function isValidationSummary(value: unknown): value is ValidationSummary;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
function isObject(value) {
|
|
2
2
|
return typeof value === 'object' && value != null;
|
|
3
3
|
}
|
|
4
|
-
export function isStructuredToolFailure(value) {
|
|
5
|
-
return isObject(value) && value.ok === false && typeof value.toolName === 'string';
|
|
6
|
-
}
|
|
7
4
|
export function isValidationSummary(value) {
|
|
8
5
|
return isObject(value) && typeof value.summaryText === 'string' && Array.isArray(value.diagnostics);
|
|
9
6
|
}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import type { ToolDiffLine } from '../toolResultTypes.js';
|
|
2
|
-
/**
|
|
3
|
-
* Pure text-matching and diff helpers for the `editFile` / `replaceLines` tools.
|
|
4
|
-
*
|
|
5
|
-
* `findEditRange` locates `oldText` within a file, tolerating readFile
|
|
6
|
-
* line-number prefixes and trailing-whitespace-only differences (only when the
|
|
7
|
-
* match stays unique). Diff helpers render compact before/after line views.
|
|
8
|
-
*/
|
|
9
|
-
/** Strip a readFile-style ` 123 | ` prefix from each line. */
|
|
10
|
-
export declare function stripLineNumberPrefixes(text: string): string;
|
|
11
2
|
/**
|
|
12
3
|
* Locate `oldText` in `original`. Tries an exact match first, then a
|
|
13
4
|
* line-number-prefix-stripped match, finally a trailing-whitespace-tolerant
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* match stays unique). Diff helpers render compact before/after line views.
|
|
7
7
|
*/
|
|
8
8
|
/** Strip a readFile-style ` 123 | ` prefix from each line. */
|
|
9
|
-
|
|
9
|
+
function stripLineNumberPrefixes(text) {
|
|
10
10
|
return text.replace(/^\s*\d+\s+\| ?/gm, '');
|
|
11
11
|
}
|
|
12
12
|
/** Character offsets of the start of each line (for mapping offsets back to lines). */
|
|
@@ -4,7 +4,7 @@ import { reductionMetrics } from '../../core/toolOutput/reduction.js';
|
|
|
4
4
|
import { fetchUrlContent, BlockedUrlError } from '../webFetch.js';
|
|
5
5
|
import { structuredToolFailure } from './failures.js';
|
|
6
6
|
import { compactStoredOutput } from './outputCap.js';
|
|
7
|
-
import { MAX_OUTPUT_CHARS } from '../../core/limits
|
|
7
|
+
import { MAX_OUTPUT_CHARS } from '../../core/limits.js';
|
|
8
8
|
import { hazeToolContextSchema, runDedupedTool } from './toolContext.js';
|
|
9
9
|
export const fetchTool = tool({
|
|
10
10
|
description: 'Fetch a public http(s) URL and return readable content. Use for current docs, API references, error lookups, or CI logs. Private/loopback/metadata hosts are blocked.',
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { MAX_OUTPUT_CHARS } from '../../core/limits
|
|
1
|
+
import { MAX_OUTPUT_CHARS } from '../../core/limits.js';
|
|
2
2
|
import { isGitIgnored } from './gitIgnore.js';
|
|
3
3
|
export { MAX_OUTPUT_CHARS };
|
|
4
4
|
export declare const DEFAULT_READ_LINES = 300;
|
|
5
5
|
/** Maximum real diff rows shown inline; larger diffs retain a head/tail preview and retrieval handle. */
|
|
6
6
|
export declare const INLINE_DIFF_LINE_LIMIT = 8;
|
|
7
7
|
export { isGitIgnored };
|
|
8
|
-
export declare function assertNotIgnored(absolutePath: string, inputPath: string, allowIgnored?: boolean
|
|
8
|
+
export declare function assertNotIgnored(absolutePath: string, inputPath: string, allowIgnored?: boolean, options?: {
|
|
9
|
+
operation?: 'read' | 'mutation';
|
|
10
|
+
}): Promise<void>;
|
|
9
11
|
export declare function sourceOutlineEntries(lines: string[], startLine: number): {
|
|
10
12
|
lineNumber: number;
|
|
11
13
|
text: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MAX_OUTPUT_CHARS } from '../../core/limits
|
|
1
|
+
import { MAX_OUTPUT_CHARS } from '../../core/limits.js';
|
|
2
2
|
import { HazeToolError } from './failures.js';
|
|
3
3
|
import { checkGitIgnored, isGitIgnored } from './gitIgnore.js';
|
|
4
4
|
export { MAX_OUTPUT_CHARS };
|
|
@@ -8,18 +8,22 @@ export const INLINE_DIFF_LINE_LIMIT = 8;
|
|
|
8
8
|
// Re-exported so existing import sites keep a single source for ignore checks
|
|
9
9
|
// while traversal uses the batched classifier in `gitIgnore.ts` (RH-001).
|
|
10
10
|
export { isGitIgnored };
|
|
11
|
-
export async function assertNotIgnored(absolutePath, inputPath, allowIgnored) {
|
|
11
|
+
export async function assertNotIgnored(absolutePath, inputPath, allowIgnored, options) {
|
|
12
12
|
if (allowIgnored)
|
|
13
13
|
return;
|
|
14
14
|
// Mutations fail closed when ignore status cannot be verified (F-05): reads
|
|
15
15
|
// failing open is right, but silently proceeding into a possibly-ignored
|
|
16
|
-
// path because
|
|
16
|
+
// path because the ignore file is unreadable is the unsafe direction for
|
|
17
|
+
// writes. Reads themselves also fail open on 'unknown' (AGENTS contract:
|
|
18
|
+
// "reads fail open, mutation guards fail closed") — a workspace without
|
|
19
|
+
// ignore files must not block reads; only 'ignored' is a definite verdict
|
|
20
|
+
// that stops a read.
|
|
17
21
|
const status = await checkGitIgnored(absolutePath);
|
|
18
22
|
if (status === 'ignored') {
|
|
19
23
|
throw new HazeToolError(`Path is ignored by .gitignore: ${inputPath}. Set allowIgnored=true only if you explicitly need to access ignored files.`, 'ignored_path', { recoveryTool: 'listFiles' });
|
|
20
24
|
}
|
|
21
|
-
if (status === 'unknown') {
|
|
22
|
-
throw new HazeToolError(`Could not verify git-ignore status for ${inputPath} (
|
|
25
|
+
if (status === 'unknown' && options?.operation !== 'read') {
|
|
26
|
+
throw new HazeToolError(`Could not verify git-ignore status for ${inputPath} (an ignore file exists but is unreadable). Set allowIgnored=true to proceed anyway.`, 'ignore_check_unavailable', { recoveryTool: 'listFiles' });
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
29
|
const SOURCE_OUTLINE_PATTERNS = [
|
|
@@ -1,49 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* entries into O(batches) subprocesses instead of one process per path
|
|
5
|
-
* (RH-001). 256 candidates comfortably fits a typical directory frontier.
|
|
6
|
-
*/
|
|
7
|
-
export declare const GIT_IGNORE_BATCH = 256;
|
|
8
|
-
export interface IgnoreClassification {
|
|
9
|
-
/** Subset of the submitted paths Git reports as ignored. */
|
|
1
|
+
export type GitIgnoreStatus = 'ignored' | 'not-ignored' | 'unknown';
|
|
2
|
+
interface IgnoreClassification {
|
|
3
|
+
/** Subset of the submitted paths the ignore rules report as ignored. */
|
|
10
4
|
ignored: Set<string>;
|
|
11
5
|
/**
|
|
12
|
-
* False when
|
|
13
|
-
* Reads treat that as "nothing
|
|
14
|
-
* it as un-verifiable and fail
|
|
6
|
+
* False when an ignore file somewhere in the evaluated chains exists but
|
|
7
|
+
* could not be read (e.g. permission denied). Reads treat that as "nothing
|
|
8
|
+
* ignored" (fail open); mutation guards treat it as un-verifiable and fail
|
|
9
|
+
* closed instead (F-05).
|
|
15
10
|
*/
|
|
16
11
|
checked: boolean;
|
|
17
12
|
}
|
|
13
|
+
/** A candidate path plus optional walker metadata; omitted fields are derived. */
|
|
14
|
+
export type IgnoreCandidate = {
|
|
15
|
+
path: string;
|
|
16
|
+
absolutePath?: string;
|
|
17
|
+
isDirectory?: boolean;
|
|
18
|
+
};
|
|
18
19
|
export interface IgnoreClassifier {
|
|
19
20
|
/**
|
|
20
|
-
* Classify
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* here is ignored" so workspace reads are never blocked by ignore checks.
|
|
21
|
+
* Classify candidate paths. Returns the subset the ignore rules report as
|
|
22
|
+
* ignored. Fails open: candidates whose rules cannot be read are not
|
|
23
|
+
* reported, so workspace reads are never blocked by ignore checks.
|
|
24
24
|
*/
|
|
25
|
-
classify(
|
|
25
|
+
classify(candidates: readonly (string | IgnoreCandidate)[]): Promise<Set<string>>;
|
|
26
26
|
/** Like `classify`, but distinguishes "checked" from "could not check" (F-05). */
|
|
27
|
-
classifyChecked(
|
|
28
|
-
/** Number of `git check-ignore` subprocesses started by this classifier. */
|
|
29
|
-
readonly invocationCount: number;
|
|
27
|
+
classifyChecked(candidates: readonly (string | IgnoreCandidate)[]): Promise<IgnoreClassification>;
|
|
30
28
|
}
|
|
31
29
|
/**
|
|
32
|
-
* Create
|
|
33
|
-
*
|
|
34
|
-
*
|
|
30
|
+
* Create an ignore classifier rooted at `root` (defaults to the workspace
|
|
31
|
+
* root). One classifier should own an entire listing operation: it memoizes
|
|
32
|
+
* compiled rule files by mtime, so a walk stats each `.gitignore` once per
|
|
33
|
+
* mtime change instead of re-reading it per entry. Nothing is cached across
|
|
34
|
+
* classifier instances, so external edits are always picked up.
|
|
35
35
|
*/
|
|
36
36
|
export declare function createIgnoreClassifier(root?: string): IgnoreClassifier;
|
|
37
|
-
/** Classify a set of
|
|
37
|
+
/** Classify a set of root-relative paths. */
|
|
38
38
|
export declare function classifyGitIgnored(relativePaths: readonly string[], root?: string): Promise<Set<string>>;
|
|
39
|
-
/** Distinguish "checked and not ignored" from "could not check" (F-05). */
|
|
40
|
-
export type GitIgnoreStatus = 'ignored' | 'not-ignored' | 'unknown';
|
|
41
|
-
/**
|
|
42
|
-
* Single-path ignore classification (used by mutating-tool guards and other
|
|
43
|
-
* one-off checks). Built on the batch primitive so the fail-open read contract
|
|
44
|
-
* stays identical to batched traversal; `unknown` means Git could not be run
|
|
45
|
-
* at all, so callers that must not fail open (mutations) can fail closed.
|
|
46
|
-
*/
|
|
47
39
|
export declare function isGitIgnored(absolutePath: string): Promise<boolean>;
|
|
48
40
|
/** Tri-state single-path check: mutation guards key off `unknown` (F-05). */
|
|
49
41
|
export declare function checkGitIgnored(absolutePath: string): Promise<GitIgnoreStatus>;
|
|
42
|
+
export {};
|