@andorra-labs/code 0.1.17 → 0.1.19
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/dist/src/account-jev-savings.d.ts +4 -0
- package/dist/src/account-jev-savings.js +92 -0
- package/dist/src/acp-agent.js +2 -2
- package/dist/src/agent-execution.js +441 -53
- package/dist/src/agent-mcp.js +7 -1
- package/dist/src/agent-modifiers.js +5 -7
- package/dist/src/analytics.d.ts +19 -1
- package/dist/src/analytics.js +9 -1
- package/dist/src/andorra/entry.js +15 -6
- package/dist/src/andorra/errors.js +3 -0
- package/dist/src/andorra/hosted.d.ts +8 -0
- package/dist/src/andorra/hosted.js +22 -3
- package/dist/src/andorra/streams.d.ts +49 -0
- package/dist/src/andorra/streams.js +98 -0
- package/dist/src/antigravity-acp.d.ts +28 -0
- package/dist/src/antigravity-acp.js +150 -0
- package/dist/src/antigravity-terminal.d.ts +2 -0
- package/dist/src/antigravity-terminal.js +214 -0
- package/dist/src/app-server/adaptive-routing-settings.d.ts +37 -0
- package/dist/src/app-server/adaptive-routing-settings.js +69 -0
- package/dist/src/app-server/artifact.d.ts +14 -0
- package/dist/src/app-server/artifact.js +46 -0
- package/dist/src/app-server/legal-protocol.d.ts +33 -0
- package/dist/src/app-server/legal-protocol.js +16 -0
- package/dist/src/app-server/protocol.d.ts +34 -3
- package/dist/src/app-server/protocol.js +3 -1
- package/dist/src/app-server/telemetry-protocol.d.ts +53 -0
- package/dist/src/app-server/telemetry-protocol.js +2 -0
- package/dist/src/app-server/telemetry.d.ts +38 -0
- package/dist/src/app-server/telemetry.js +163 -0
- package/dist/src/app-server/workspace.d.ts +21 -0
- package/dist/src/app-server/workspace.js +192 -10
- package/dist/src/app-server.d.ts +82 -26
- package/dist/src/app-server.js +1573 -417
- package/dist/src/attachments.d.ts +10 -0
- package/dist/src/attachments.js +102 -7
- package/dist/src/auth/AuthManager.d.ts +11 -2
- package/dist/src/auth/AuthManager.js +56 -13
- package/dist/src/auth/index.d.ts +5 -1
- package/dist/src/auth/index.js +8 -1
- package/dist/src/auth/lifecycle.d.ts +13 -0
- package/dist/src/auth/lifecycle.js +109 -0
- package/dist/src/auth/store.d.ts +1 -0
- package/dist/src/auth/store.js +12 -0
- package/dist/src/auth/types.d.ts +12 -0
- package/dist/src/automation-runner.js +2 -0
- package/dist/src/automation-service.js +7 -2
- package/dist/src/automation-tool.js +2 -1
- package/dist/src/benchmark-scores.d.ts +88 -0
- package/dist/src/benchmark-scores.js +302 -0
- package/dist/src/bridge/command.js +16 -1
- package/dist/src/bridge/control.d.ts +3 -1
- package/dist/src/bridge/control.js +9 -3
- package/dist/src/bridge/engines.d.ts +2 -0
- package/dist/src/bridge/engines.js +9 -0
- package/dist/src/bridge/github.d.ts +108 -0
- package/dist/src/bridge/github.js +378 -0
- package/dist/src/bridge/host-ops.d.ts +3 -3
- package/dist/src/bridge/host-ops.js +14 -2
- package/dist/src/bridge/host.d.ts +2 -0
- package/dist/src/bridge/host.js +70 -16
- package/dist/src/bridge/protocol.d.ts +1 -0
- package/dist/src/bridge/protocol.js +1 -0
- package/dist/src/browser-panel-tool.d.ts +12 -0
- package/dist/src/browser-panel-tool.js +30 -3
- package/dist/src/browser-runner.js +53 -62
- package/dist/src/browser-server.js +10 -4
- package/dist/src/browser-session.d.ts +14 -0
- package/dist/src/browser-session.js +57 -12
- package/dist/src/browser-view.d.ts +40 -1
- package/dist/src/browser-view.js +163 -9
- package/dist/src/browser-window-style.d.ts +27 -0
- package/dist/src/browser-window-style.js +244 -0
- package/dist/src/bug-report-attachments.d.ts +48 -0
- package/dist/src/bug-report-attachments.js +327 -0
- package/dist/src/bug-report.d.ts +23 -3
- package/dist/src/bug-report.js +72 -9
- package/dist/src/claude-provider.d.ts +1 -0
- package/dist/src/claude-provider.js +77 -36
- package/dist/src/cli.d.ts +1 -3
- package/dist/src/cli.js +245 -62
- package/dist/src/codex-provider.d.ts +1 -0
- package/dist/src/codex-provider.js +44 -8
- package/dist/src/coding-tools.d.ts +1 -0
- package/dist/src/coding-tools.js +28 -7
- package/dist/src/command-screens.d.ts +1 -1
- package/dist/src/command-screens.js +2 -2
- package/dist/src/commands.d.ts +9 -2
- package/dist/src/commands.js +69 -64
- package/dist/src/completion.js +13 -7
- package/dist/src/config.d.ts +14 -3
- package/dist/src/config.js +57 -17
- package/dist/src/context-budget.d.ts +11 -2
- package/dist/src/context-budget.js +38 -4
- package/dist/src/context-compaction.d.ts +10 -8
- package/dist/src/context-compaction.js +23 -24
- package/dist/src/deadline.js +1 -1
- package/dist/src/decision/DecisionEngine.d.ts +2 -0
- package/dist/src/decision/DecisionManager.d.ts +16 -0
- package/dist/src/decision/DecisionManager.js +75 -2
- package/dist/src/decision/applyTaskKind.d.ts +8 -0
- package/dist/src/decision/applyTaskKind.js +53 -0
- package/dist/src/decision/applyToolMenu.js +6 -2
- package/dist/src/decision/hostedPolicy.js +6 -3
- package/dist/src/decision/optimizationPolicy.d.ts +10 -0
- package/dist/src/decision/optimizationPolicy.js +23 -3
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +4 -1
- package/dist/src/decision/providers/AndorraDecisionProvider.js +29 -7
- package/dist/src/decision/providers/index.js +1 -1
- package/dist/src/decision/taskKind.d.ts +52 -0
- package/dist/src/decision/taskKind.js +76 -0
- package/dist/src/decision/toolFamilies.js +1 -1
- package/dist/src/decision/types.d.ts +3 -1
- package/dist/src/default-graph.js +1 -1
- package/dist/src/efficiency.d.ts +80 -1
- package/dist/src/efficiency.js +119 -4
- package/dist/src/effort-routing.d.ts +27 -0
- package/dist/src/effort-routing.js +34 -0
- package/dist/src/evidence.d.ts +110 -0
- package/dist/src/evidence.js +195 -0
- package/dist/src/extensions.d.ts +2 -0
- package/dist/src/extensions.js +30 -20
- package/dist/src/github-app/agent-writes.d.ts +1 -1
- package/dist/src/github-app/agent-writes.js +1 -1
- package/dist/src/github-app/client.d.ts +19 -0
- package/dist/src/github-app/client.js +21 -1
- package/dist/src/github-app/event-source.d.ts +0 -5
- package/dist/src/github-app/event-source.js +1 -31
- package/dist/src/github-app/metrics.d.ts +2 -5
- package/dist/src/github-app/metrics.js +2 -14
- package/dist/src/github-app/review-loop.d.ts +5 -5
- package/dist/src/github-app/review-loop.js +1 -1
- package/dist/src/github-app/review-node.d.ts +2 -2
- package/dist/src/github-app/triggers.d.ts +3 -3
- package/dist/src/github-names.d.ts +7 -0
- package/dist/src/github-names.js +7 -0
- package/dist/src/glob-search.d.ts +1 -0
- package/dist/src/glob-search.js +3 -0
- package/dist/src/google-provider.d.ts +5 -28
- package/dist/src/google-provider.js +6 -141
- package/dist/src/graph-editor-session.d.ts +1 -0
- package/dist/src/graph-editor-session.js +2 -0
- package/dist/src/graph-health.js +3 -1
- package/dist/src/graph-preview.d.ts +2 -0
- package/dist/src/graph-preview.js +1 -0
- package/dist/src/graph-runner.js +20 -14
- package/dist/src/graph-selection.d.ts +3 -1
- package/dist/src/graph-selection.js +2 -2
- package/dist/src/graph-server.d.ts +8 -1
- package/dist/src/graph-server.js +49 -12
- package/dist/src/graph-sync.d.ts +2 -1
- package/dist/src/graph-sync.js +13 -0
- package/dist/src/graph-ui/app.js +49 -8
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graphs.d.ts +23 -1
- package/dist/src/graphs.js +58 -7
- package/dist/src/grok-provider.js +17 -14
- package/dist/src/hardened-runtime.js +39 -25
- package/dist/src/jev-savings.d.ts +4 -0
- package/dist/src/jev-savings.js +13 -0
- package/dist/src/legal/client.d.ts +25 -0
- package/dist/src/legal/client.js +47 -0
- package/dist/src/legal/command.d.ts +13 -0
- package/dist/src/legal/command.js +98 -0
- package/dist/src/legal/documents.d.ts +2 -0
- package/dist/src/legal/documents.js +14 -0
- package/dist/src/legal/gate.d.ts +13 -0
- package/dist/src/legal/gate.js +96 -0
- package/dist/src/legal/manifest.d.ts +21 -0
- package/dist/src/legal/manifest.js +23 -0
- package/dist/src/legal/receipt.d.ts +13 -0
- package/dist/src/legal/receipt.js +137 -0
- package/dist/src/legal/release.d.ts +27 -0
- package/dist/src/legal/release.js +28 -0
- package/dist/src/managed-sign-in.d.ts +0 -1
- package/dist/src/managed-sign-in.js +0 -13
- package/dist/src/membership.d.ts +27 -1
- package/dist/src/membership.js +139 -7
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.js +3 -7
- package/dist/src/model-override.d.ts +2 -1
- package/dist/src/model-override.js +9 -0
- package/dist/src/model-pool.d.ts +99 -0
- package/dist/src/model-pool.js +136 -0
- package/dist/src/model-relay/local.js +5 -0
- package/dist/src/model-relay/remote.d.ts +2 -0
- package/dist/src/model-relay/remote.js +4 -0
- package/dist/src/model-tiers.d.ts +16 -1
- package/dist/src/model-tiers.js +31 -7
- package/dist/src/opencode-cli-provider.js +59 -56
- package/dist/src/opencode-provider.js +16 -13
- package/dist/src/permissions.d.ts +5 -0
- package/dist/src/permissions.js +7 -0
- package/dist/src/plan-pass.js +2 -1
- package/dist/src/pool-scores.d.ts +45 -0
- package/dist/src/pool-scores.js +40 -0
- package/dist/src/provider-connection.js +3 -17
- package/dist/src/provider-engine.d.ts +13 -1
- package/dist/src/provider-engine.js +116 -12
- package/dist/src/provider-request-error.d.ts +8 -0
- package/dist/src/provider-request-error.js +12 -0
- package/dist/src/provider-settings.d.ts +1 -1
- package/dist/src/provider-settings.js +36 -18
- package/dist/src/provider-turn-deadline.d.ts +39 -0
- package/dist/src/provider-turn-deadline.js +139 -0
- package/dist/src/providers.d.ts +8 -9
- package/dist/src/providers.js +211 -150
- package/dist/src/pull-request-merge.d.ts +1 -8
- package/dist/src/pull-request-merge.js +0 -4
- package/dist/src/pull-requests.d.ts +83 -57
- package/dist/src/pull-requests.js +266 -225
- package/dist/src/qa/runtime/ProcessManager.d.ts +5 -1
- package/dist/src/qa/runtime/ProcessManager.js +9 -3
- package/dist/src/react-runtime.js +245 -71
- package/dist/src/reasoning-probe-cloud.d.ts +10 -0
- package/dist/src/reasoning-probe-cloud.js +209 -0
- package/dist/src/remote/engine-pool.d.ts +3 -0
- package/dist/src/remote/engine-pool.js +88 -21
- package/dist/src/remote/recovery.d.ts +6 -0
- package/dist/src/remote/recovery.js +37 -0
- package/dist/src/run-records.d.ts +13 -3
- package/dist/src/run-records.js +59 -34
- package/dist/src/runtime.d.ts +47 -2
- package/dist/src/runtime.js +33 -7
- package/dist/src/session-summary.d.ts +8 -0
- package/dist/src/session-summary.js +34 -0
- package/dist/src/sessions.d.ts +32 -0
- package/dist/src/sessions.js +65 -3
- package/dist/src/shell.js +6 -0
- package/dist/src/side-panel.js +36 -2
- package/dist/src/sign-in-detection.d.ts +1 -1
- package/dist/src/sign-in-detection.js +4 -10
- package/dist/src/sign-in-offer.js +1 -1
- package/dist/src/skill-commands.js +1 -1
- package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
- package/dist/src/skills/bundled/graph-manager/SKILL.md +2 -2
- package/dist/src/skills/bundled/graph-manager/patterns.md +13 -19
- package/dist/src/skills/bundled/provenance.json +3 -3
- package/dist/src/subagent-run.js +50 -50
- package/dist/src/subscription-usage.d.ts +50 -0
- package/dist/src/subscription-usage.js +92 -0
- package/dist/src/task-checkout.d.ts +157 -0
- package/dist/src/task-checkout.js +628 -0
- package/dist/src/telemetry/access.d.ts +18 -0
- package/dist/src/telemetry/access.js +43 -0
- package/dist/src/telemetry/aggregate.d.ts +18 -2
- package/dist/src/telemetry/aggregate.js +22 -9
- package/dist/src/telemetry/capture-core.d.ts +33 -14
- package/dist/src/telemetry/capture-core.js +124 -25
- package/dist/src/telemetry/capture.d.ts +3 -2
- package/dist/src/telemetry/capture.js +21 -1
- package/dist/src/telemetry/decision-capture.js +4 -0
- package/dist/src/telemetry/emitter.d.ts +6 -7
- package/dist/src/telemetry/emitter.js +124 -29
- package/dist/src/telemetry/gate.d.ts +41 -2
- package/dist/src/telemetry/gate.js +89 -4
- package/dist/src/telemetry/home.d.ts +1 -0
- package/dist/src/telemetry/home.js +20 -0
- package/dist/src/telemetry/identity.d.ts +6 -3
- package/dist/src/telemetry/identity.js +19 -6
- package/dist/src/telemetry/lifecycle.d.ts +8 -0
- package/dist/src/telemetry/lifecycle.js +76 -0
- package/dist/src/telemetry/outbox.d.ts +13 -8
- package/dist/src/telemetry/outbox.js +68 -12
- package/dist/src/telemetry/permission-command.d.ts +38 -0
- package/dist/src/telemetry/permission-command.js +208 -0
- package/dist/src/telemetry/permission.d.ts +168 -0
- package/dist/src/telemetry/permission.js +662 -0
- package/dist/src/telemetry/record-installation.d.ts +1 -0
- package/dist/src/telemetry/record-installation.js +9 -0
- package/dist/src/telemetry/region-data.d.ts +12 -0
- package/dist/src/telemetry/region-data.js +1314 -0
- package/dist/src/telemetry/region.d.ts +34 -0
- package/dist/src/telemetry/region.js +87 -0
- package/dist/src/telemetry/run-privacy.d.ts +11 -0
- package/dist/src/telemetry/run-privacy.js +165 -0
- package/dist/src/telemetry/schema.d.ts +27 -6
- package/dist/src/telemetry/schema.js +109 -14
- package/dist/src/telemetry/state.d.ts +11 -7
- package/dist/src/telemetry/state.js +39 -6
- package/dist/src/telemetry/surface.d.ts +20 -3
- package/dist/src/telemetry/surface.js +71 -15
- package/dist/src/telemetry/uploader.d.ts +6 -11
- package/dist/src/telemetry/uploader.js +72 -46
- package/dist/src/telemetry/uploads.d.ts +5 -1
- package/dist/src/telemetry/uploads.js +25 -6
- package/dist/src/telemetry/version.d.ts +5 -0
- package/dist/src/telemetry/version.js +34 -0
- package/dist/src/telemetry/workspace.d.ts +4 -1
- package/dist/src/telemetry/workspace.js +18 -3
- package/dist/src/terminal-ui.d.ts +3 -0
- package/dist/src/terminal-ui.js +48 -6
- package/dist/src/test-edit-guard.d.ts +30 -0
- package/dist/src/test-edit-guard.js +167 -2
- package/dist/src/thinking-level-detect.d.ts +13 -0
- package/dist/src/thinking-level-detect.js +52 -0
- package/dist/src/thinking-levels.d.ts +30 -0
- package/dist/src/thinking-levels.js +131 -0
- package/dist/src/timers.d.ts +3 -0
- package/dist/src/todos.d.ts +2 -1
- package/dist/src/todos.js +24 -4
- package/dist/src/tool-argument-coercion.d.ts +7 -0
- package/dist/src/tool-argument-coercion.js +49 -0
- package/dist/src/tool-catalog.d.ts +2 -2
- package/dist/src/tool-catalog.js +1 -1
- package/dist/src/tools.js +67 -22
- package/dist/src/transcript.js +3 -2
- package/dist/src/types.d.ts +48 -1
- package/dist/src/update.js +4 -0
- package/dist/src/usage-analytics.d.ts +7 -0
- package/dist/src/usage-analytics.js +85 -13
- package/dist/telemetry-consent-v1 +1 -0
- package/package.json +97 -96
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Config } from '../config.js';
|
|
2
|
+
import { type TelemetryPermissionStatus } from '../telemetry/permission.js';
|
|
3
|
+
import { type TelemetryLocationSignals } from '../telemetry/region.js';
|
|
4
|
+
import type { TelemetryAccess } from '../telemetry/access.js';
|
|
5
|
+
import type { TelemetryStatusResult, TelemetrySetConsentResult } from './telemetry-protocol.js';
|
|
6
|
+
/** Strict, bounded transport. Errors never echo raw location hints. */
|
|
7
|
+
export declare function rendererTelemetryHints(value: unknown): TelemetryLocationSignals;
|
|
8
|
+
/** Purpose-limited shared run-file read; a blocked read never gets an analytics subtree. */
|
|
9
|
+
export declare function readTelemetryRunRecord(home: string, path: string, access?: TelemetryAccess): Promise<Record<string, unknown>>;
|
|
10
|
+
/** One execution process's transient protective context; never a second permission store. */
|
|
11
|
+
export declare class AppServerTelemetry {
|
|
12
|
+
readonly home: string;
|
|
13
|
+
private readonly changed;
|
|
14
|
+
private readonly invalidated;
|
|
15
|
+
private renderer?;
|
|
16
|
+
private lastStatus?;
|
|
17
|
+
private watcher?;
|
|
18
|
+
private permissionKey?;
|
|
19
|
+
private polling;
|
|
20
|
+
private watchEpoch;
|
|
21
|
+
constructor(home: string, changed: (result: TelemetryStatusResult) => void, invalidated?: () => void);
|
|
22
|
+
readonly signals: () => import("../telemetry/region.js").TelemetryRegionSignals;
|
|
23
|
+
private protectProcess;
|
|
24
|
+
private addRenderer;
|
|
25
|
+
permission(): Promise<TelemetryPermissionStatus>;
|
|
26
|
+
snapshot(): Promise<TelemetryStatusResult & {
|
|
27
|
+
analytics?: Config['analytics'] & {
|
|
28
|
+
plan: 'paid' | 'free' | 'legacy' | 'unknown';
|
|
29
|
+
canOptOut: boolean;
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
32
|
+
private publish;
|
|
33
|
+
status(params: Record<string, unknown>): Promise<TelemetryStatusResult>;
|
|
34
|
+
setConsent(params: Record<string, unknown>): Promise<TelemetrySetConsentResult>;
|
|
35
|
+
private poll;
|
|
36
|
+
watch(): void;
|
|
37
|
+
close(): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { getAuthStatus } from '../auth/index.js';
|
|
3
|
+
import { telemetryStatusGate } from '../telemetry/gate.js';
|
|
4
|
+
import { TELEMETRY_NOTICE, TELEMETRY_NOTICE_VERSION, TelemetryPrivacyError, setTelemetryConsent, telemetryPermission, withTelemetryAdmission } from '../telemetry/permission.js';
|
|
5
|
+
import { readLocalTelemetrySignals, resolveTelemetryRegion } from '../telemetry/region.js';
|
|
6
|
+
import { scrubRuns, functionalRunRecord } from '../run-records.js';
|
|
7
|
+
import { admittedRunRecord } from '../telemetry/run-privacy.js';
|
|
8
|
+
/** Strict, bounded transport. Errors never echo raw location hints. */
|
|
9
|
+
export function rendererTelemetryHints(value) {
|
|
10
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
11
|
+
throw new TelemetryPrivacyError('invalid-params', 'renderer must be an object');
|
|
12
|
+
const hints = value;
|
|
13
|
+
if (Object.keys(hints).some(key => key !== 'timeZone' && key !== 'locales'))
|
|
14
|
+
throw new TelemetryPrivacyError('invalid-params', 'renderer accepts only timeZone and locales');
|
|
15
|
+
const signal = (entry) => typeof entry === 'string' && entry.length <= 128 && !/[\u0000-\u001f\u007f]/.test(entry);
|
|
16
|
+
if (hints.timeZone !== undefined && !signal(hints.timeZone))
|
|
17
|
+
throw new TelemetryPrivacyError('invalid-params', 'timeZone must be a string of at most 128 characters');
|
|
18
|
+
if (hints.locales !== undefined && (!Array.isArray(hints.locales) || hints.locales.length > 4 || !hints.locales.every(signal)))
|
|
19
|
+
throw new TelemetryPrivacyError('invalid-params', 'locales must contain at most four strings of at most 128 characters');
|
|
20
|
+
return { ...(hints.timeZone === undefined ? {} : { timeZone: hints.timeZone }), ...(hints.locales === undefined ? {} : { locales: [...hints.locales] }) };
|
|
21
|
+
}
|
|
22
|
+
function wireStatus(permission) {
|
|
23
|
+
const { permitted, reason, ...status } = permission;
|
|
24
|
+
return { ...status, report: permitted, reason: reason === 'outside-policy' ? 'included-with-plan' : reason };
|
|
25
|
+
}
|
|
26
|
+
/** Purpose-limited shared run-file read; a blocked read never gets an analytics subtree. */
|
|
27
|
+
export async function readTelemetryRunRecord(home, path, access) {
|
|
28
|
+
const read = async () => JSON.parse(await readFile(path, 'utf8'));
|
|
29
|
+
const admitted = await withTelemetryAdmission({ home, signals: access?.signals }, async (admission) => admittedRunRecord(await read(), admission.lease), access?.lease);
|
|
30
|
+
return admitted ?? functionalRunRecord(await read());
|
|
31
|
+
}
|
|
32
|
+
/** One execution process's transient protective context; never a second permission store. */
|
|
33
|
+
export class AppServerTelemetry {
|
|
34
|
+
home;
|
|
35
|
+
changed;
|
|
36
|
+
invalidated;
|
|
37
|
+
renderer;
|
|
38
|
+
lastStatus;
|
|
39
|
+
watcher;
|
|
40
|
+
permissionKey;
|
|
41
|
+
polling = false;
|
|
42
|
+
watchEpoch = 0;
|
|
43
|
+
constructor(home, changed, invalidated = () => { }) {
|
|
44
|
+
this.home = home;
|
|
45
|
+
this.changed = changed;
|
|
46
|
+
this.invalidated = invalidated;
|
|
47
|
+
// Must run before recovery, membership, configuration or any producer. Missing transport is
|
|
48
|
+
// normal for CLI hosts. Malformed supplied transport is not evidence for an outside waiver.
|
|
49
|
+
const raw = process.env.ANDORRA_TELEMETRY_RENDERER_HINTS;
|
|
50
|
+
// Consume the transport before parsing: even malformed hints must not reach tools, MCP or PTYs.
|
|
51
|
+
delete process.env.ANDORRA_TELEMETRY_RENDERER_HINTS;
|
|
52
|
+
if (raw !== undefined) {
|
|
53
|
+
try {
|
|
54
|
+
if (raw.length > 4096)
|
|
55
|
+
throw new Error();
|
|
56
|
+
this.addRenderer(rendererTelemetryHints(JSON.parse(raw)));
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
this.protectProcess();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
signals = () => readLocalTelemetrySignals({ renderer: this.renderer });
|
|
64
|
+
protectProcess() {
|
|
65
|
+
// Some functional membership/graph helpers own their own nested telemetry calls. The process-
|
|
66
|
+
// local, one-way ask policy protects those too, and is inherited before any child can start.
|
|
67
|
+
// This is NOT a shell export, a persisted hint or affirmative permission. Never restore auto.
|
|
68
|
+
process.env.ANDORRA_TELEMETRY_POLICY = 'ask';
|
|
69
|
+
}
|
|
70
|
+
addRenderer(hints) {
|
|
71
|
+
// Keep only a bounded protective representative, not an accumulating location history.
|
|
72
|
+
if (resolveTelemetryRegion({ renderer: hints }).region === 'in') {
|
|
73
|
+
this.renderer = hints;
|
|
74
|
+
this.protectProcess();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
permission() { return telemetryPermission({ home: this.home, signals: this.signals }); }
|
|
78
|
+
async snapshot() {
|
|
79
|
+
const gate = await telemetryStatusGate({ home: this.home, signals: this.signals, subject: async () => {
|
|
80
|
+
const auth = await getAuthStatus(undefined, { readOnly: true }).catch(() => undefined); // no refresh or recovery write
|
|
81
|
+
return auth?.signedIn ? auth.subject : undefined;
|
|
82
|
+
} });
|
|
83
|
+
this.permissionKey = JSON.stringify(gate.permission);
|
|
84
|
+
return { status: { ...wireStatus(gate.permission), report: gate.report, canChange: gate.canOptOut,
|
|
85
|
+
reason: gate.permission.permissionRequired ? wireStatus(gate.permission).reason : gate.plan === 'paid' ? 'paid-preference' : 'included-with-plan' },
|
|
86
|
+
notice: TELEMETRY_NOTICE,
|
|
87
|
+
...(!gate.permission.permissionRequired ? { analytics: { ...gate.savedAnalytics, plan: gate.plan, canOptOut: gate.canOptOut } } : {}) };
|
|
88
|
+
}
|
|
89
|
+
publish(result) {
|
|
90
|
+
const key = JSON.stringify(result);
|
|
91
|
+
if (this.lastStatus !== key) {
|
|
92
|
+
this.lastStatus = key;
|
|
93
|
+
this.changed(result);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async status(params) {
|
|
97
|
+
if (Object.keys(params).some(key => key !== 'renderer'))
|
|
98
|
+
throw new TelemetryPrivacyError('invalid-params', 'telemetry.status accepts only renderer');
|
|
99
|
+
if (Object.hasOwn(params, 'renderer'))
|
|
100
|
+
this.addRenderer(rendererTelemetryHints(params.renderer));
|
|
101
|
+
const { status, notice } = await this.snapshot();
|
|
102
|
+
const result = { status, notice };
|
|
103
|
+
this.publish(result);
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
async setConsent(params) {
|
|
107
|
+
const { answer, expectedRevision, noticeVersion } = params;
|
|
108
|
+
if (Object.keys(params).some(key => !['answer', 'expectedRevision', 'noticeVersion'].includes(key)) || (answer !== 'yes' && answer !== 'no')
|
|
109
|
+
|| !Number.isSafeInteger(expectedRevision) || expectedRevision < 0 || noticeVersion !== TELEMETRY_NOTICE_VERSION) {
|
|
110
|
+
throw new TelemetryPrivacyError('invalid-params', 'answer, a nonnegative expectedRevision and the current noticeVersion are required');
|
|
111
|
+
}
|
|
112
|
+
const current = await this.permission();
|
|
113
|
+
if (!current.permissionRequired)
|
|
114
|
+
throw new TelemetryPrivacyError('invalid-params', 'Outside protected policy, use the saved analytics preference');
|
|
115
|
+
// Avoid cancelling live work for an already-known stale refusal. The store still performs
|
|
116
|
+
// the authoritative CAS under its barrier; a race after this read remains fail-closed.
|
|
117
|
+
if (expectedRevision !== current.revision && !(answer === 'no' && current.answer === 'no')) {
|
|
118
|
+
return { saved: false, conflict: true, status: wireStatus(current), notice: TELEMETRY_NOTICE };
|
|
119
|
+
}
|
|
120
|
+
const update = await setTelemetryConsent({ home: this.home, signals: this.signals }, { action: answer === 'yes' ? 'allow' : 'deny', expectedRevision: expectedRevision, noticeVersion: noticeVersion }, scrubRuns);
|
|
121
|
+
const result = { ...update, status: wireStatus(update.status), notice: TELEMETRY_NOTICE };
|
|
122
|
+
this.publish({ status: result.status, notice: result.notice });
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
async poll(epoch) {
|
|
126
|
+
if (this.polling)
|
|
127
|
+
return;
|
|
128
|
+
this.polling = true;
|
|
129
|
+
try {
|
|
130
|
+
// A display poll never resolves a subject, reads analytics config/cache, or takes auth's
|
|
131
|
+
// machine-wide lock. Only explicit status/config reads need those outside-plan details.
|
|
132
|
+
const permission = await this.permission();
|
|
133
|
+
if (!this.watcher || epoch !== this.watchEpoch)
|
|
134
|
+
return;
|
|
135
|
+
const key = JSON.stringify(permission);
|
|
136
|
+
if (key === this.permissionKey)
|
|
137
|
+
return;
|
|
138
|
+
this.permissionKey = key;
|
|
139
|
+
if (permission.permissionRequired)
|
|
140
|
+
this.publish({ status: wireStatus(permission), notice: TELEMETRY_NOTICE });
|
|
141
|
+
else
|
|
142
|
+
this.invalidated(); // request a real display refresh; never invent outside plan/reporting
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
this.polling = false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
watch() {
|
|
149
|
+
if (this.watcher)
|
|
150
|
+
return;
|
|
151
|
+
const epoch = ++this.watchEpoch;
|
|
152
|
+
// Missing privacy/ is normal. No mkdir/prompt election, no overlapping reads, and a slower
|
|
153
|
+
// necessary-state poll. Local writes and desktop focus/status already refresh immediately.
|
|
154
|
+
this.watcher = setInterval(() => { void this.poll(epoch).catch(() => { }); }, 2000);
|
|
155
|
+
this.watcher.unref();
|
|
156
|
+
}
|
|
157
|
+
close() {
|
|
158
|
+
if (this.watcher)
|
|
159
|
+
clearInterval(this.watcher);
|
|
160
|
+
this.watcher = undefined;
|
|
161
|
+
this.watchEpoch++;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -24,6 +24,27 @@ export declare function readWorkspaceFile(root: string, name: unknown): Promise<
|
|
|
24
24
|
hash?: string;
|
|
25
25
|
notUtf8?: true;
|
|
26
26
|
}>;
|
|
27
|
+
/** The largest image the Files tab previews; a larger one keeps the binary note. */
|
|
28
|
+
export declare const MAX_IMAGE_BYTES: number;
|
|
29
|
+
export declare function imageTypeOf(path: string): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* A project image's bytes, base64, for the Files tab's preview (`workspace.image`). `tooLarge` past 10 MB, with no
|
|
32
|
+
* bytes. The type comes from the extension only: the desktop draws it in an <img>, which never runs an SVG's script.
|
|
33
|
+
*/
|
|
34
|
+
export declare function readWorkspaceImage(root: string, name: unknown, options?: {
|
|
35
|
+
outside?: boolean;
|
|
36
|
+
}): Promise<{
|
|
37
|
+
mimeType: string;
|
|
38
|
+
size: number;
|
|
39
|
+
dataBase64?: string;
|
|
40
|
+
tooLarge?: true;
|
|
41
|
+
}>;
|
|
42
|
+
export declare function globMatches(path: string, glob: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* A glob list's problems ripgrep would refuse, said before a search: an unclosed `{`, or so many alternatives or
|
|
45
|
+
* `**` that matching could take seconds.
|
|
46
|
+
*/
|
|
47
|
+
export declare function globProblem(glob: string): string | undefined;
|
|
27
48
|
/** The most a save from the Files tab may write. */
|
|
28
49
|
export declare const MAX_WRITE_BYTES: number;
|
|
29
50
|
/** `workspace.write`'s checked parameters: the file, as a project-relative path with `/`, and the bytes to save. */
|
|
@@ -3,9 +3,11 @@ import { createHash } from 'node:crypto';
|
|
|
3
3
|
import { createReadStream } from 'node:fs';
|
|
4
4
|
import { opendir, open, readFile, readdir, realpath, stat } from 'node:fs/promises';
|
|
5
5
|
import { StringDecoder } from 'node:string_decoder';
|
|
6
|
-
import { dirname, isAbsolute, join,
|
|
6
|
+
import { dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path';
|
|
7
|
+
import { readTelemetryRunRecord } from './telemetry.js';
|
|
7
8
|
import { runRecordPath, runRecordsDirectory, sessionHasOpenRun } from '../run-records.js';
|
|
8
9
|
import { validSavedSession } from '../sessions.js';
|
|
10
|
+
import { decodeDoubleEscapedSummary, stripEchoedEnvelope } from '../completion.js';
|
|
9
11
|
import { listBundles } from '../extensions.js';
|
|
10
12
|
import { builtinSkillEntries } from '../skills/invocable-skills.js';
|
|
11
13
|
const SKIP_NAMES = new Set(['.git', '.andorracode']);
|
|
@@ -162,6 +164,165 @@ export async function readWorkspaceFile(root, name) {
|
|
|
162
164
|
await handle.close();
|
|
163
165
|
}
|
|
164
166
|
}
|
|
167
|
+
/** The image types the Files tab previews (`workspace.image`), by extension. */
|
|
168
|
+
const IMAGE_TYPES = {
|
|
169
|
+
'.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.gif': 'image/gif', '.webp': 'image/webp',
|
|
170
|
+
'.bmp': 'image/bmp', '.ico': 'image/x-icon', '.svg': 'image/svg+xml',
|
|
171
|
+
};
|
|
172
|
+
/** The largest image the Files tab previews; a larger one keeps the binary note. */
|
|
173
|
+
export const MAX_IMAGE_BYTES = 10 * 1024 * 1024;
|
|
174
|
+
export function imageTypeOf(path) {
|
|
175
|
+
return IMAGE_TYPES[extname(path).toLowerCase()];
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* An image path for the chat's preview of a Read, which may have looked at an image anywhere on this machine: resolved
|
|
179
|
+
* from the project, links followed, and not held to the project. The caller still accepts only an image file, judged
|
|
180
|
+
* by the followed path's extension, so a link named `.png` cannot reach a file of another kind.
|
|
181
|
+
*/
|
|
182
|
+
async function resolveImageAnywhere(root, name) {
|
|
183
|
+
if (typeof name !== 'string' || !name || name.length > 4096 || name.includes('\0'))
|
|
184
|
+
throw new Error('An image path must be a string of up to 4096 characters');
|
|
185
|
+
const candidate = resolve(root, name);
|
|
186
|
+
return realpath(candidate).catch((error) => {
|
|
187
|
+
if (error.code === 'ENOENT')
|
|
188
|
+
return candidate;
|
|
189
|
+
throw error;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* A project image's bytes, base64, for the Files tab's preview (`workspace.image`). `tooLarge` past 10 MB, with no
|
|
194
|
+
* bytes. The type comes from the extension only: the desktop draws it in an <img>, which never runs an SVG's script.
|
|
195
|
+
*/
|
|
196
|
+
export async function readWorkspaceImage(root, name, options = {}) {
|
|
197
|
+
const path = options.outside ? await resolveImageAnywhere(root, name) : await resolveInside(root, name);
|
|
198
|
+
const mimeType = imageTypeOf(path);
|
|
199
|
+
if (!mimeType)
|
|
200
|
+
throw new Error('This file is not an image the Files tab can show');
|
|
201
|
+
const info = await stat(path);
|
|
202
|
+
if (!info.isFile())
|
|
203
|
+
throw new Error('Only files can be opened');
|
|
204
|
+
if (info.size > MAX_IMAGE_BYTES)
|
|
205
|
+
return { mimeType, size: info.size, tooLarge: true };
|
|
206
|
+
const bytes = await readFile(path);
|
|
207
|
+
if (bytes.length > MAX_IMAGE_BYTES)
|
|
208
|
+
return { mimeType, size: bytes.length, tooLarge: true };
|
|
209
|
+
return { mimeType, size: bytes.length, dataBase64: bytes.toString('base64') };
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Whether a project path matches a glob as ripgrep's `--glob` does: `*` and `?` stay inside one folder, `**` crosses
|
|
213
|
+
* folders, `{a,b}` and `[…]` work, and a leading dot is matched like any other character (Node's matcher skips
|
|
214
|
+
* dotfiles, so the built-in search's globs missed `.eslintrc.js` and `.github/…`).
|
|
215
|
+
*/
|
|
216
|
+
/** A path and each folder above it: `a/b/c.ts`, `a/b`, `a`. */
|
|
217
|
+
function withAncestors(path) {
|
|
218
|
+
const parts = path.split('/');
|
|
219
|
+
return parts.map((_, index) => parts.slice(0, parts.length - index).join('/'));
|
|
220
|
+
}
|
|
221
|
+
export function globMatches(path, glob) {
|
|
222
|
+
return globRegExp(glob).test(path);
|
|
223
|
+
}
|
|
224
|
+
const globCache = new Map();
|
|
225
|
+
const GLOB_CACHE_LIMIT = 500;
|
|
226
|
+
function globRegExp(raw) {
|
|
227
|
+
const cached = globCache.get(raw);
|
|
228
|
+
if (cached)
|
|
229
|
+
return cached;
|
|
230
|
+
// A leading slash anchors at the project, as every glob here already is; repeated `**/` mean one.
|
|
231
|
+
const glob = raw.replace(/^\/+/, '').replace(/(\*\*\/){2,}/g, '**/');
|
|
232
|
+
let out = '';
|
|
233
|
+
let braces = 0;
|
|
234
|
+
for (let index = 0; index < glob.length; index += 1) {
|
|
235
|
+
const char = glob[index];
|
|
236
|
+
if (char === '*') {
|
|
237
|
+
if (glob[index + 1] === '*') {
|
|
238
|
+
// `**` crosses folders only as a whole path part (`**/`, `/**`, or alone in an alternative); elsewhere, as in
|
|
239
|
+
// ripgrep, it is two `*`.
|
|
240
|
+
const before = index === 0 ? '/' : glob[index - 1];
|
|
241
|
+
const after = glob[index + 2] ?? '';
|
|
242
|
+
const whole = (before === '/' || (braces > 0 && (before === '{' || before === ','))) && (after === '' || after === '/' || (braces > 0 && (after === '}' || after === ',')));
|
|
243
|
+
if (whole && after === '/') {
|
|
244
|
+
out += '(?:.*/)?';
|
|
245
|
+
index += 2;
|
|
246
|
+
}
|
|
247
|
+
else if (whole) {
|
|
248
|
+
out += '.*';
|
|
249
|
+
index += 1;
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
out += '[^/]*';
|
|
253
|
+
index += 1;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
else
|
|
257
|
+
out += '[^/]*';
|
|
258
|
+
}
|
|
259
|
+
else if (char === '?')
|
|
260
|
+
out += '[^/]';
|
|
261
|
+
else if (char === '{') {
|
|
262
|
+
out += '(?:';
|
|
263
|
+
braces += 1;
|
|
264
|
+
}
|
|
265
|
+
else if (char === '}' && braces > 0) {
|
|
266
|
+
out += ')';
|
|
267
|
+
braces -= 1;
|
|
268
|
+
}
|
|
269
|
+
else if (char === ',' && braces > 0)
|
|
270
|
+
out += '|';
|
|
271
|
+
else if (char === '[') {
|
|
272
|
+
const end = glob.indexOf(']', index + 2);
|
|
273
|
+
if (end < 0) {
|
|
274
|
+
out += '\\[';
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
let body = glob.slice(index + 1, end);
|
|
278
|
+
if (body.startsWith('!'))
|
|
279
|
+
body = `^${body.slice(1)}`;
|
|
280
|
+
out += `[${body.replace(/\\/g, '\\\\')}]`;
|
|
281
|
+
index = end;
|
|
282
|
+
}
|
|
283
|
+
else if (char === '\\' && index + 1 < glob.length) {
|
|
284
|
+
out += glob[index + 1].replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
|
|
285
|
+
index += 1;
|
|
286
|
+
}
|
|
287
|
+
else
|
|
288
|
+
out += char.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
|
|
289
|
+
}
|
|
290
|
+
let pattern;
|
|
291
|
+
// Case-sensitive everywhere, as ripgrep's --glob is.
|
|
292
|
+
try {
|
|
293
|
+
pattern = new RegExp(`^${out}$`);
|
|
294
|
+
}
|
|
295
|
+
catch {
|
|
296
|
+
pattern = /(?!)/;
|
|
297
|
+
}
|
|
298
|
+
if (globCache.size >= GLOB_CACHE_LIMIT)
|
|
299
|
+
globCache.clear();
|
|
300
|
+
globCache.set(raw, pattern);
|
|
301
|
+
return pattern;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* A glob list's problems ripgrep would refuse, said before a search: an unclosed `{`, or so many alternatives or
|
|
305
|
+
* `**` that matching could take seconds.
|
|
306
|
+
*/
|
|
307
|
+
export function globProblem(glob) {
|
|
308
|
+
let depth = 0;
|
|
309
|
+
for (let index = 0; index < glob.length; index += 1) {
|
|
310
|
+
const char = glob[index];
|
|
311
|
+
if (char === '\\') {
|
|
312
|
+
index += 1;
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
if (char === '{')
|
|
316
|
+
depth += 1;
|
|
317
|
+
else if (char === '}' && depth > 0)
|
|
318
|
+
depth -= 1;
|
|
319
|
+
}
|
|
320
|
+
if (depth > 0)
|
|
321
|
+
return `The glob "${glob}" has an unclosed {`;
|
|
322
|
+
if ((glob.match(/\{/g) ?? []).length > 8 || (glob.match(/\*\*/g) ?? []).length > 8)
|
|
323
|
+
return `The glob "${glob}" is too complex to search with`;
|
|
324
|
+
return undefined;
|
|
325
|
+
}
|
|
165
326
|
/** The most a save from the Files tab may write. */
|
|
166
327
|
export const MAX_WRITE_BYTES = 16 * 1024 * 1024;
|
|
167
328
|
/** `workspace.write`'s checked parameters: the file, as a project-relative path with `/`, and the bytes to save. */
|
|
@@ -560,12 +721,12 @@ async function readJournalTail(path, limit) {
|
|
|
560
721
|
await handle?.close().catch(() => { });
|
|
561
722
|
}
|
|
562
723
|
}
|
|
563
|
-
//
|
|
564
|
-
//
|
|
565
|
-
// newest events: a long run's entry node went missing that way.
|
|
724
|
+
// Keep graph and subagent metadata and answered questions from before the journal tail.
|
|
725
|
+
// The desktop uses these to restore the graph outline and inline question history.
|
|
566
726
|
const OUTLINE_TYPES = [
|
|
567
727
|
'graph.started', 'graph.node.started', 'graph.node.completed', 'graph.finalization.resumed', 'graph.completed', 'graph.stopped',
|
|
568
728
|
'graph.todos.updated', 'graph.widgets.updated', 'subagent.started', 'subagent.completed', 'subagent.change',
|
|
729
|
+
'agent.clarification.answered',
|
|
569
730
|
];
|
|
570
731
|
// Journal lines are written as {"type":"…",…}, so a line is matched on its opening bytes.
|
|
571
732
|
const OUTLINE_PREFIXES = OUTLINE_TYPES.map(type => Buffer.from(`{"type":"${type}"`));
|
|
@@ -672,11 +833,11 @@ async function readJournalOutline(path, end, collector) {
|
|
|
672
833
|
}
|
|
673
834
|
}
|
|
674
835
|
// `events` is the newest part of the journal. When older events were left out, `outline` carries
|
|
675
|
-
//
|
|
676
|
-
// which nodes and subagents ran.
|
|
836
|
+
// selected graph, node, subagent and clarification events among them, in journal order.
|
|
677
837
|
export async function readRun(directory, id) {
|
|
678
838
|
const path = runRecordPath(directory, id, 'json');
|
|
679
|
-
const result =
|
|
839
|
+
const result = await readTelemetryRunRecord(directory, path);
|
|
840
|
+
displayRunCompletion(result);
|
|
680
841
|
const journal = runRecordPath(directory, id, 'jsonl');
|
|
681
842
|
const { lines, start, truncated } = await readJournalTail(journal, MAX_RUN_EVENTS);
|
|
682
843
|
const parsed = [];
|
|
@@ -704,6 +865,20 @@ export async function readRun(directory, id) {
|
|
|
704
865
|
const outline = collector.events();
|
|
705
866
|
return { result, events, truncated, ...(outline.length > 0 ? { outline } : {}) };
|
|
706
867
|
}
|
|
868
|
+
/** The record's completion summary is display text: restore line breaks its JSON escaped away, as saved sessions do. */
|
|
869
|
+
function displayRunCompletion(result) {
|
|
870
|
+
if (!result || typeof result !== 'object')
|
|
871
|
+
return;
|
|
872
|
+
const completion = result.completion;
|
|
873
|
+
if (!completion || typeof completion !== 'object')
|
|
874
|
+
return;
|
|
875
|
+
const record = completion;
|
|
876
|
+
if (typeof record.summary !== 'string')
|
|
877
|
+
return;
|
|
878
|
+
const summary = stripEchoedEnvelope(decodeDoubleEscapedSummary(record.summary), typeof record.outcome === 'string' ? record.outcome : undefined);
|
|
879
|
+
if (summary !== record.summary)
|
|
880
|
+
record.summary = summary;
|
|
881
|
+
}
|
|
707
882
|
export async function runRecordFile(directory, id) {
|
|
708
883
|
const path = resolve(runRecordPath(directory, id, 'json'));
|
|
709
884
|
let raw;
|
|
@@ -1035,7 +1210,13 @@ export function globList(value) {
|
|
|
1035
1210
|
current += char;
|
|
1036
1211
|
}
|
|
1037
1212
|
parts.push(current);
|
|
1038
|
-
|
|
1213
|
+
const globs = parts.map(part => part.trim()).filter(Boolean);
|
|
1214
|
+
for (const glob of globs) {
|
|
1215
|
+
const problem = globProblem(glob);
|
|
1216
|
+
if (problem)
|
|
1217
|
+
throw new Error(problem);
|
|
1218
|
+
}
|
|
1219
|
+
return globs;
|
|
1039
1220
|
}
|
|
1040
1221
|
export function searchOptions(params) {
|
|
1041
1222
|
const query = params.query;
|
|
@@ -1219,7 +1400,7 @@ async function searchBuiltIn(root, options, signal) {
|
|
|
1219
1400
|
const include = globList(options.include);
|
|
1220
1401
|
const exclude = globList(options.exclude);
|
|
1221
1402
|
// A glob without a folder matches the file's name anywhere, as ripgrep's --glob does.
|
|
1222
|
-
const matchesGlob = (path, glob) =>
|
|
1403
|
+
const matchesGlob = (path, glob) => globMatches(path, glob) || (!glob.includes('/') && globMatches(posix.basename(path), glob));
|
|
1223
1404
|
const collected = new SearchCollector();
|
|
1224
1405
|
const deadline = Date.now() + SEARCH_TIME_MS;
|
|
1225
1406
|
let incomplete;
|
|
@@ -1234,7 +1415,8 @@ async function searchBuiltIn(root, options, signal) {
|
|
|
1234
1415
|
continue;
|
|
1235
1416
|
if (include.length && !include.some(glob => matchesGlob(file.path, glob)))
|
|
1236
1417
|
continue;
|
|
1237
|
-
|
|
1418
|
+
// An exclude that names a folder leaves out everything in it, as ripgrep's does.
|
|
1419
|
+
if (exclude.some(glob => withAncestors(file.path).some(path => matchesGlob(path, glob))))
|
|
1238
1420
|
continue;
|
|
1239
1421
|
if (scanned >= SEARCH_FALLBACK_FILES) {
|
|
1240
1422
|
incomplete = `Search stopped at ${SEARCH_FALLBACK_FILES.toLocaleString('en-US')} files`;
|