@capybara-hq/kernel 0.1.0-rc.93 → 0.1.0-rc.94
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/admin/login-sources.controller.d.ts +30 -0
- package/dist/admin/login-sources.controller.js +77 -0
- package/dist/admin/login-sources.schemas.d.ts +25 -0
- package/dist/admin/login-sources.schemas.js +49 -0
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/config/schema.d.ts +0 -2
- package/dist/config/schema.js +0 -28
- package/dist/ctx/create-ctx.d.ts +5 -1
- package/dist/ctx/create-ctx.js +13 -2
- package/dist/device-access/device-access.service.d.ts +27 -4
- package/dist/device-access/device-access.service.js +180 -30
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +10 -0
- package/dist/extensions/instance.js +3 -1
- package/dist/http/api.module.js +2 -0
- package/dist/identity/auth.controller.d.ts +2 -0
- package/dist/identity/auth.controller.js +1 -1
- package/dist/identity/external.d.ts +78 -40
- package/dist/identity/external.js +157 -72
- package/dist/identity/identity.module.js +9 -0
- package/dist/identity/linked-accounts.d.ts +42 -0
- package/dist/identity/linked-accounts.js +78 -0
- package/dist/identity/login-sources.d.ts +160 -0
- package/dist/identity/login-sources.js +403 -0
- package/dist/identity/sso-decisions.d.ts +75 -0
- package/dist/identity/sso-decisions.js +42 -0
- package/dist/identity/sso-link.d.ts +61 -0
- package/dist/identity/sso-link.js +157 -0
- package/dist/identity/sso.controller.d.ts +98 -14
- package/dist/identity/sso.controller.js +222 -28
- package/dist/identity/sso.d.ts +75 -30
- package/dist/identity/sso.js +129 -70
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/infra/config/kernel-config.service.js +0 -3
- package/dist/infra/throttler/named-throttlers.d.ts +1 -1
- package/dist/infra/throttler/named-throttlers.js +1 -1
- package/dist/platform/exclusions.js +15 -0
- package/dist/platform/operation.js +4 -0
- package/dist/platform/ops/admin.ops.d.ts +3 -1
- package/dist/platform/ops/admin.ops.js +106 -2
- package/dist/platform/ops/extensions-admin.ops.d.ts +24 -2
- package/dist/platform/ops/extensions-admin.ops.js +54 -6
- package/dist/platform/route-schemas.js +2 -0
- package/dist/tools/builtins/sandbox/glob.js +7 -4
- package/dist/tools/builtins/sandbox/grep.d.ts +8 -1
- package/dist/tools/builtins/sandbox/grep.js +27 -33
- package/dist/tools/builtins/sandbox/search-command.d.ts +43 -0
- package/dist/tools/builtins/sandbox/search-command.js +86 -0
- package/dist/tools/call-scope.d.ts +19 -6
- package/dist/tools/call-scope.js +29 -0
- package/dist/tools/pipeline.d.ts +3 -2
- package/dist/tools/pipeline.js +29 -10
- package/dist/tools/questions.service.d.ts +2 -2
- package/dist/tools/questions.service.js +1 -1
- package/package.json +3 -3
|
@@ -13,12 +13,14 @@ import { DeploymentSettingsBody, PurposeParams } from "../../admin/admin.schemas
|
|
|
13
13
|
import { AuditListQuery } from "../../admin/audit.schemas.js";
|
|
14
14
|
import { AuditLogService } from "../../admin/audit-log.service.js";
|
|
15
15
|
import { AdminHealthService } from "../../admin/health.service.js";
|
|
16
|
+
import { LoginSourceBody, LoginSourceParams, LoginSourcesOrderBody, } from "../../admin/login-sources.schemas.js";
|
|
16
17
|
import { UsageQuery } from "../../admin/overview.schemas.js";
|
|
17
18
|
import { AdminOverviewService } from "../../admin/overview.service.js";
|
|
18
19
|
import { AdminUsageService } from "../../admin/usage.service.js";
|
|
19
20
|
import { ApiError } from "../../errors.js";
|
|
20
21
|
import { ExtensionDisplayNames } from "../../extensions/display-name.js";
|
|
21
22
|
import { ExtensionRegistry } from "../../extensions/registry.js";
|
|
23
|
+
import { LoginSourcesService } from "../../identity/login-sources.js";
|
|
22
24
|
import { DEPLOYMENT_SETTINGS_PATCH, SettingsService } from "../../identity/settings.js";
|
|
23
25
|
import { ModelDisabledPatch, ModelProviderParams } from "../../models/enablement.controller.js";
|
|
24
26
|
import { ModelEnablement } from "../../models/enablement.js";
|
|
@@ -52,6 +54,34 @@ const SettingsInput = DEPLOYMENT_SETTINGS_PATCH.pick({
|
|
|
52
54
|
promptSuggestions: true,
|
|
53
55
|
htmlRenderCdnAllowlist: true,
|
|
54
56
|
}).strict();
|
|
57
|
+
/** `login-sources.update`: the source and the fields to change. */
|
|
58
|
+
const LoginSourceUpdateInput = z
|
|
59
|
+
.object({ ...LoginSourceParams.shape, ...LoginSourceBody.shape })
|
|
60
|
+
.strict()
|
|
61
|
+
.refine((i) => Object.keys(i).length > 1, {
|
|
62
|
+
message: "give at least one of enabled, signUp or trustedTenants",
|
|
63
|
+
});
|
|
64
|
+
/** The bilingual card lines of a `login-sources.update` input. */
|
|
65
|
+
function loginSourceChanges(i) {
|
|
66
|
+
const zh = [];
|
|
67
|
+
const en = [];
|
|
68
|
+
if (i.enabled !== undefined) {
|
|
69
|
+
zh.push(i.enabled ? "在登录页显示" : "不在登录页显示");
|
|
70
|
+
en.push(i.enabled ? "offered on the login page" : "no longer offered on the login page");
|
|
71
|
+
}
|
|
72
|
+
if (i.signUp !== undefined) {
|
|
73
|
+
zh.push(i.signUp === "link" ? "未绑定的账号去绑定页" : "未绑定的账号自动注册新账号");
|
|
74
|
+
en.push(i.signUp === "link"
|
|
75
|
+
? "unlinked accounts go to the link page"
|
|
76
|
+
: "unlinked accounts create a new account");
|
|
77
|
+
}
|
|
78
|
+
if (i.trustedTenants !== undefined) {
|
|
79
|
+
const list = i.trustedTenants.map(named).join(", ");
|
|
80
|
+
zh.push(i.trustedTenants.length === 0 ? "不信任任何租户" : `可信租户:${list}`);
|
|
81
|
+
en.push(i.trustedTenants.length === 0 ? "no trusted tenants" : `trusted tenants: ${list}`);
|
|
82
|
+
}
|
|
83
|
+
return { zh: zh.join(";"), en: en.join("; ") };
|
|
84
|
+
}
|
|
55
85
|
const ProviderId = ModelProviderParams.shape.provider.describe("The model provider (models.platform-list), e.g. the plugin name of its extension.");
|
|
56
86
|
/** `provider/model` of a purpose target, or null. */
|
|
57
87
|
const refOf = (t) => t === null ? null : `${t.model.provider}/${t.model.model}`;
|
|
@@ -126,7 +156,8 @@ let AdminOperations = class AdminOperations {
|
|
|
126
156
|
overview;
|
|
127
157
|
health;
|
|
128
158
|
usage;
|
|
129
|
-
|
|
159
|
+
loginSources;
|
|
160
|
+
constructor(registry, settings, providers, displayNames, extensionRegistry, enablement, prices, purposes, themes, audit, overview, health, usage, loginSources) {
|
|
130
161
|
this.registry = registry;
|
|
131
162
|
this.settings = settings;
|
|
132
163
|
this.providers = providers;
|
|
@@ -140,6 +171,7 @@ let AdminOperations = class AdminOperations {
|
|
|
140
171
|
this.overview = overview;
|
|
141
172
|
this.health = health;
|
|
142
173
|
this.usage = usage;
|
|
174
|
+
this.loginSources = loginSources;
|
|
143
175
|
}
|
|
144
176
|
assertProvider(provider) {
|
|
145
177
|
if (!this.extensionRegistry.list("model-provider").some((e) => e.plugin === provider)) {
|
|
@@ -338,6 +370,77 @@ let AdminOperations = class AdminOperations {
|
|
|
338
370
|
// a person turns the platform's auto mode on, never an agent (auto mode spec §4.3)
|
|
339
371
|
{ onlyNarrows: true }),
|
|
340
372
|
}),
|
|
373
|
+
defineOperation({
|
|
374
|
+
id: "login-sources.list",
|
|
375
|
+
description: "The third-party sign-in methods of the login page (super admin): every loaded identity-source extension and every stored entry, the enabled ones first in login page order. Each item has plugin, label, tenant (what a tenant id is for this platform: label, pattern, placeholder, neverTrusted), enabled (offered on the login page), signUp (link: an unlinked external account goes to the link page to sign in with a password; create: it creates a new account), trustedTenants (tenants whose verified emails link to the existing account with that email), available (the extension is loaded), needsConfig (its deployment config is incomplete, so it cannot be turned on) and callbackUrl (the redirect URI to register at the identity provider; null while the deployment's public URL is unset).",
|
|
376
|
+
input: z.object({}).strict(),
|
|
377
|
+
example: {},
|
|
378
|
+
authz: { superAdmin: true },
|
|
379
|
+
mirrors: ["GET /api/v1/admin/login-sources"],
|
|
380
|
+
confirm: "read",
|
|
381
|
+
run: async () => ({ items: await this.loginSources.overview() }),
|
|
382
|
+
}),
|
|
383
|
+
defineOperation({
|
|
384
|
+
id: "login-sources.update",
|
|
385
|
+
description: "Change one third-party sign-in method (super admin); give only the fields to change: enabled (true offers it on the login page at once, placed last in the order; false removes it from the login page), signUp (link or create: what signing in with an external account nobody has linked does) and trustedTenants (the whole list of tenant ids whose verified emails link to the existing account with that email; read the current list with login-sources.list first). Returns the item as login-sources.list shows it.",
|
|
386
|
+
input: LoginSourceUpdateInput,
|
|
387
|
+
example: { plugin: "slack", enabled: true },
|
|
388
|
+
authz: { superAdmin: true },
|
|
389
|
+
mirrors: ["PUT /api/v1/admin/login-sources/:plugin"],
|
|
390
|
+
confirm: "platform",
|
|
391
|
+
errors: [
|
|
392
|
+
{
|
|
393
|
+
code: "login_sources.unknown_plugin",
|
|
394
|
+
next: "Check the plugin name with login-sources.list; the extension must be installed and provide identity-source@1.",
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
code: "login_sources.invalid_tenant",
|
|
398
|
+
next: "Fix the tenant id as the message says: it must match the format in the item's tenant (login-sources.list) and not be one of its neverTrusted tenants.",
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
code: "login_sources.needs_config",
|
|
402
|
+
next: "Its deployment config is incomplete: fill in the deployment config with extensions.platform-set-config, following extensions.platform-guides, then turn it on again.",
|
|
403
|
+
},
|
|
404
|
+
],
|
|
405
|
+
summary: (i) => {
|
|
406
|
+
const c = loginSourceChanges(i);
|
|
407
|
+
return {
|
|
408
|
+
zh: `修改登录方式「${named(i.plugin)}」:${c.zh}`,
|
|
409
|
+
en: `Change the sign-in method "${named(i.plugin)}": ${c.en}`,
|
|
410
|
+
};
|
|
411
|
+
},
|
|
412
|
+
run: async ({ plugin, ...patch }, ctx) => {
|
|
413
|
+
await this.loginSources.update(plugin, patch, ctx.actorAccountId, {
|
|
414
|
+
detail: viaAgent("login-sources.update", ctx),
|
|
415
|
+
});
|
|
416
|
+
return this.loginSources.view(plugin);
|
|
417
|
+
},
|
|
418
|
+
}),
|
|
419
|
+
defineOperation({
|
|
420
|
+
id: "login-sources.reorder",
|
|
421
|
+
description: "Set the order of the sign-in buttons on the login page (super admin): plugins lists every enabled sign-in method exactly once (login-sources.list shows them), first shown first.",
|
|
422
|
+
input: LoginSourcesOrderBody.strict(),
|
|
423
|
+
example: { plugins: ["slack", "google"] },
|
|
424
|
+
authz: { superAdmin: true },
|
|
425
|
+
mirrors: ["PUT /api/v1/admin/login-sources/order"],
|
|
426
|
+
confirm: "platform",
|
|
427
|
+
errors: [
|
|
428
|
+
{
|
|
429
|
+
code: "validation_failed",
|
|
430
|
+
next: "List every enabled sign-in method exactly once (the enabled items of login-sources.list).",
|
|
431
|
+
},
|
|
432
|
+
],
|
|
433
|
+
summary: (i) => {
|
|
434
|
+
const list = i.plugins.map(named).join(", ");
|
|
435
|
+
return { zh: `登录页的登录方式顺序:${list}`, en: `Login page sign-in order: ${list}` };
|
|
436
|
+
},
|
|
437
|
+
run: async (input, ctx) => {
|
|
438
|
+
await this.loginSources.reorder(input.plugins, ctx.actorAccountId, {
|
|
439
|
+
detail: viaAgent("login-sources.reorder", ctx),
|
|
440
|
+
});
|
|
441
|
+
return { items: await this.loginSources.overview() };
|
|
442
|
+
},
|
|
443
|
+
}),
|
|
341
444
|
defineOperation({
|
|
342
445
|
id: "models.platform-list",
|
|
343
446
|
description: "The platform's model catalog (super admin). Without provider: one row per model provider with its state (ok, error with the reason, org_configured: each org configures it), its plugin and how many models it lists and how many the platform disabled. With provider: that provider's models, one row each (id, name, kind, disabled), paged by 50 (pass the returned next as params.cursor).",
|
|
@@ -575,6 +678,7 @@ AdminOperations = __decorate([
|
|
|
575
678
|
__param(9, Inject(AuditLogService)),
|
|
576
679
|
__param(10, Inject(AdminOverviewService)),
|
|
577
680
|
__param(11, Inject(AdminHealthService)),
|
|
578
|
-
__param(12, Inject(AdminUsageService))
|
|
681
|
+
__param(12, Inject(AdminUsageService)),
|
|
682
|
+
__param(13, Inject(LoginSourcesService))
|
|
579
683
|
], AdminOperations);
|
|
580
684
|
export { AdminOperations };
|
|
@@ -4,7 +4,8 @@ import { ExtensionAdminOps } from "../../extensions/admin-ops.js";
|
|
|
4
4
|
import { ExtensionAdmin } from "../../extensions/admin-view.js";
|
|
5
5
|
import { type DeploymentConfigView, ExtensionDeploymentConfigService } from "../../extensions/deployment-config.js";
|
|
6
6
|
import { ExtensionInstalls } from "../../extensions/installs.js";
|
|
7
|
-
import { PluginGuides } from "../../extensions/plugin-guides.js";
|
|
7
|
+
import { PluginGuides, type RenderedSetupGuide } from "../../extensions/plugin-guides.js";
|
|
8
|
+
import { LoginSourcesService } from "../../identity/login-sources.js";
|
|
8
9
|
import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
|
|
9
10
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
10
11
|
import { SetupChecksService } from "../../setup/setup-checks.service.js";
|
|
@@ -19,6 +20,26 @@ import { PlatformOperations } from "../registry.js";
|
|
|
19
20
|
* route's `extension.config_readonly`, so the person never types a value the write would refuse.
|
|
20
21
|
*/
|
|
21
22
|
export declare function deploymentPersonFields(v: DeploymentConfigView, named?: readonly string[], values?: Readonly<Record<string, unknown>>): PersonFieldTarget;
|
|
23
|
+
/**
|
|
24
|
+
* What `extensions.platform-config` adds to the config view: the extension's platform setup guides
|
|
25
|
+
* as a short list (id and title, no body), and a next step naming `extensions.platform-guides` when
|
|
26
|
+
* a guide exists and the config needs setting up (invalid, or a required field without a value).
|
|
27
|
+
*/
|
|
28
|
+
export declare function configGuides(v: DeploymentConfigView, guides: readonly Pick<RenderedSetupGuide, "id" | "title">[]): {
|
|
29
|
+
guides: {
|
|
30
|
+
id: string;
|
|
31
|
+
title: string;
|
|
32
|
+
}[];
|
|
33
|
+
next?: string;
|
|
34
|
+
};
|
|
35
|
+
/** The login next step of an identity-source@1 extension (login extensions spec §3). */
|
|
36
|
+
export declare const LOGIN_SOURCE_NEXT = "Its sign-in is turned on and its trusted tenants set with login-sources.update.";
|
|
37
|
+
/**
|
|
38
|
+
* The `next` of `extensions.platform-config`: the setup guides' step, then, for an extension that
|
|
39
|
+
* provides identity-source@1, where its sign-in is switched on (its switch is not part of its
|
|
40
|
+
* config); absent when neither applies.
|
|
41
|
+
*/
|
|
42
|
+
export declare function platformConfigNext(setupNext: string | undefined, isLoginSource: boolean): string | undefined;
|
|
22
43
|
/**
|
|
23
44
|
* The super admin's extension operations of the `Platform` tool (spec §14.2 "admin console",
|
|
24
45
|
* §14.5 item 1): the deployment's extensions (list, read), enable, disable and uninstall, and
|
|
@@ -37,7 +58,8 @@ export declare class ExtensionsAdminOperations implements OnModuleInit {
|
|
|
37
58
|
private readonly installs;
|
|
38
59
|
private readonly guides;
|
|
39
60
|
private readonly checks;
|
|
40
|
-
|
|
61
|
+
private readonly loginSources;
|
|
62
|
+
constructor(registry: PlatformOperations, admin: ExtensionAdmin, ops: ExtensionAdminOps, config: KernelConfigService, kdb: KernelDb, catalog: CatalogService, deploymentConfigs: ExtensionDeploymentConfigService, installs: ExtensionInstalls, guides: Pick<PluginGuides, "deploymentGuides">, checks: Pick<SetupChecksService, "deploymentStates" | "deploymentRun">, loginSources: Pick<LoginSourcesService, "providesIdentitySource">);
|
|
41
63
|
/** The view of `name` for a precheck, or the refusal (unknown, startup-declared). */
|
|
42
64
|
private viewFor;
|
|
43
65
|
onModuleInit(): void;
|
|
@@ -19,6 +19,7 @@ import { ExtensionInstalls } from "../../extensions/installs.js";
|
|
|
19
19
|
import { PluginGuides } from "../../extensions/plugin-guides.js";
|
|
20
20
|
import { SINGLE_PROVIDER_ENABLED, SINGLE_PROVIDER_REQUIRED, singleProviderMessage, } from "../../extensions/single-provider.js";
|
|
21
21
|
import { unavailableReason } from "../../extensions/unavailable.js";
|
|
22
|
+
import { LoginSourcesService } from "../../identity/login-sources.js";
|
|
22
23
|
import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
|
|
23
24
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
24
25
|
import { DeploymentCheckPathParams, DeploymentCheckRunBody, DeploymentGuidePathParams, DeploymentGuidesPathParams, DeploymentGuidesQuery, } from "../../setup/setup-checks.schemas.js";
|
|
@@ -72,6 +73,42 @@ export function deploymentPersonFields(v, named = [], values) {
|
|
|
72
73
|
],
|
|
73
74
|
};
|
|
74
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* What `extensions.platform-config` adds to the config view: the extension's platform setup guides
|
|
78
|
+
* as a short list (id and title, no body), and a next step naming `extensions.platform-guides` when
|
|
79
|
+
* a guide exists and the config needs setting up (invalid, or a required field without a value).
|
|
80
|
+
*/
|
|
81
|
+
export function configGuides(v, guides) {
|
|
82
|
+
const list = guides.map((g) => ({ id: g.id, title: g.title }));
|
|
83
|
+
if (list.length === 0 || !needsSetup(v))
|
|
84
|
+
return { guides: list };
|
|
85
|
+
return {
|
|
86
|
+
guides: list,
|
|
87
|
+
next: "Required fields are unset or the config is invalid, and the extension ships platform setup guides (guides): read them with extensions.platform-guides, walk the person through their steps, then save the fields with extensions.platform-set-config.",
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** The login next step of an identity-source@1 extension (login extensions spec §3). */
|
|
91
|
+
export const LOGIN_SOURCE_NEXT = "Its sign-in is turned on and its trusted tenants set with login-sources.update.";
|
|
92
|
+
/**
|
|
93
|
+
* The `next` of `extensions.platform-config`: the setup guides' step, then, for an extension that
|
|
94
|
+
* provides identity-source@1, where its sign-in is switched on (its switch is not part of its
|
|
95
|
+
* config); absent when neither applies.
|
|
96
|
+
*/
|
|
97
|
+
export function platformConfigNext(setupNext, isLoginSource) {
|
|
98
|
+
const next = [setupNext, isLoginSource ? LOGIN_SOURCE_NEXT : undefined]
|
|
99
|
+
.filter((s) => s !== undefined)
|
|
100
|
+
.join(" ");
|
|
101
|
+
return next === "" ? undefined : next;
|
|
102
|
+
}
|
|
103
|
+
/** Whether a deployment config is invalid or leaves a required field without a value. */
|
|
104
|
+
function needsSetup(v) {
|
|
105
|
+
if (!v.valid || v.orgMustConfigure.length > 0)
|
|
106
|
+
return true;
|
|
107
|
+
const required = v.schema?.required;
|
|
108
|
+
if (!Array.isArray(required))
|
|
109
|
+
return false;
|
|
110
|
+
return v.fields.some((f) => required.includes(f.path) && (f.secret ? f.set !== true : f.source === "unset"));
|
|
111
|
+
}
|
|
75
112
|
/** The English name of an extension as next steps name it. */
|
|
76
113
|
const enName = (v) => localized(v.displayName, v.name).en;
|
|
77
114
|
/** Why an extension does not run, and the super admin's next step (absent when it runs). */
|
|
@@ -148,7 +185,8 @@ let ExtensionsAdminOperations = class ExtensionsAdminOperations {
|
|
|
148
185
|
installs;
|
|
149
186
|
guides;
|
|
150
187
|
checks;
|
|
151
|
-
|
|
188
|
+
loginSources;
|
|
189
|
+
constructor(registry, admin, ops, config, kdb, catalog, deploymentConfigs, installs, guides, checks, loginSources) {
|
|
152
190
|
this.registry = registry;
|
|
153
191
|
this.admin = admin;
|
|
154
192
|
this.ops = ops;
|
|
@@ -159,6 +197,7 @@ let ExtensionsAdminOperations = class ExtensionsAdminOperations {
|
|
|
159
197
|
this.installs = installs;
|
|
160
198
|
this.guides = guides;
|
|
161
199
|
this.checks = checks;
|
|
200
|
+
this.loginSources = loginSources;
|
|
162
201
|
}
|
|
163
202
|
/** The view of `name` for a precheck, or the refusal (unknown, startup-declared). */
|
|
164
203
|
async viewFor(name, orgId) {
|
|
@@ -510,11 +549,12 @@ let ExtensionsAdminOperations = class ExtensionsAdminOperations {
|
|
|
510
549
|
}),
|
|
511
550
|
defineOperation({
|
|
512
551
|
id: "extensions.platform-config",
|
|
513
|
-
description: "Read an extension's deployment config (super admin): each field's source (env, file or nacos: read-only here; db: saved here; default; unset), the effective value of non-secret fields, whether each secret field is set (never its value), the form's JSON Schema (secret fields carry x-secret), whether the config is valid and the problems (paths only),
|
|
514
|
-
input: NameInput,
|
|
515
|
-
example:
|
|
552
|
+
description: "Read an extension's deployment config (super admin): each field's source (env, file or nacos: read-only here; db: saved here; default; unset), the effective value of non-secret fields, whether each secret field is set (never its value), the form's JSON Schema (secret fields carry x-secret), whether the config is valid and the problems (paths only), the overridable fields every org must fill in itself (orgMustConfigure), and the platform setup guides the extension ships (guides: id and title in locale, the person's language; read them with extensions.platform-guides). next names that operation when a guide exists and the config needs setting up; for an identity-source@1 extension, next also points to login-sources.update.",
|
|
553
|
+
input: NameInput.extend(DeploymentGuidesQuery.shape).strict(),
|
|
554
|
+
example: { name: "slack", locale: "en" },
|
|
516
555
|
authz: { superAdmin: true },
|
|
517
556
|
mirrors: ["GET /api/v1/admin/extensions/:name/config"],
|
|
557
|
+
extras: ["locale"],
|
|
518
558
|
confirm: "read",
|
|
519
559
|
errors: [
|
|
520
560
|
{
|
|
@@ -524,7 +564,14 @@ let ExtensionsAdminOperations = class ExtensionsAdminOperations {
|
|
|
524
564
|
],
|
|
525
565
|
run: async (input, ctx) => {
|
|
526
566
|
await assertExtensionNotOtherOrgs(this.kdb.db, input.name, ctx.orgId);
|
|
527
|
-
|
|
567
|
+
const [view, guides, login] = await Promise.all([
|
|
568
|
+
this.deploymentConfigs.view(input.name),
|
|
569
|
+
this.guides.deploymentGuides(input.name, { locale: input.locale }),
|
|
570
|
+
this.loginSources.providesIdentitySource(input.name),
|
|
571
|
+
]);
|
|
572
|
+
const setup = configGuides(view, guides);
|
|
573
|
+
const next = platformConfigNext(setup.next, login);
|
|
574
|
+
return { ...view, ...setup, ...(next !== undefined ? { next } : {}) };
|
|
528
575
|
},
|
|
529
576
|
}),
|
|
530
577
|
defineOperation({
|
|
@@ -713,6 +760,7 @@ ExtensionsAdminOperations = __decorate([
|
|
|
713
760
|
__param(6, Inject(ExtensionDeploymentConfigService)),
|
|
714
761
|
__param(7, Inject(ExtensionInstalls)),
|
|
715
762
|
__param(8, Inject(PluginGuides)),
|
|
716
|
-
__param(9, Inject(SetupChecksService))
|
|
763
|
+
__param(9, Inject(SetupChecksService)),
|
|
764
|
+
__param(10, Inject(LoginSourcesService))
|
|
717
765
|
], ExtensionsAdminOperations);
|
|
718
766
|
export { ExtensionsAdminOperations };
|
|
@@ -2,6 +2,7 @@ import { ADMIN_ROUTES } from "../admin/admin.schemas.js";
|
|
|
2
2
|
import { ADMIN_ITEM_ROUTES } from "../admin/admin-items.schemas.js";
|
|
3
3
|
import { AUDIT_ROUTES } from "../admin/audit.schemas.js";
|
|
4
4
|
import { ADMIN_EXTENSION_ROUTES } from "../admin/extensions.schemas.js";
|
|
5
|
+
import { LOGIN_SOURCE_ROUTES } from "../admin/login-sources.schemas.js";
|
|
5
6
|
import { ORG_NETWORK_ROUTES } from "../admin/org-network.schemas.js";
|
|
6
7
|
import { OUTBOX_DEAD_ROUTES } from "../admin/outbox-dead.schemas.js";
|
|
7
8
|
import { OVERVIEW_ROUTES } from "../admin/overview.schemas.js";
|
|
@@ -100,6 +101,7 @@ export const ROUTE_SCHEMAS = [
|
|
|
100
101
|
...OUTBOX_DEAD_ROUTES,
|
|
101
102
|
// org network allowances (plugin safe fetch spec)
|
|
102
103
|
...ORG_NETWORK_ROUTES,
|
|
104
|
+
...LOGIN_SOURCE_ROUTES,
|
|
103
105
|
// shares of conversation files (file sharing spec §10)
|
|
104
106
|
...SHARE_ROUTES,
|
|
105
107
|
];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ToolError } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { checkPathShape, checkToolPath, clip, display, inToolSandbox, sandboxBaseTimeoutMs, searchTimeoutMs, unavailableWhenNoSandbox, withNotices, } from "./common.js";
|
|
3
3
|
import { compileGlob, GlobPatternError } from "./glob-match.js";
|
|
4
|
+
import { listFilesCommand } from "./search-command.js";
|
|
4
5
|
/** 最多列出的文件数。 */
|
|
5
6
|
const MAX_RESULTS = 1000;
|
|
6
|
-
/**
|
|
7
|
+
/** The most file listing output read, in bytes. */
|
|
7
8
|
const MAX_FIND_BYTES = 8 * 1024 * 1024;
|
|
8
9
|
const SPEC = {
|
|
9
10
|
name: "Glob",
|
|
@@ -13,7 +14,9 @@ const SPEC = {
|
|
|
13
14
|
'locate files by name, e.g. pattern "**/*.py" for all Python files. The pattern is matched ' +
|
|
14
15
|
"against paths relative to path (default: the workspace directory): * matches within one directory, ** " +
|
|
15
16
|
"matches across directories, ? matches one character, {a,b} matches either. Returns absolute " +
|
|
16
|
-
"paths sorted by name, up to 1000.
|
|
17
|
+
"paths sorted by name, up to 1000. Skips .git and node_modules directories and, where the " +
|
|
18
|
+
"device supports it, files ignored by .gitignore, .ignore or .rgignore files; to list files " +
|
|
19
|
+
"inside a skipped directory, pass that directory as path. To search file contents, use Grep. " +
|
|
17
20
|
"In auto mode paths may be anywhere on the machine.",
|
|
18
21
|
inputSchema: {
|
|
19
22
|
type: "object",
|
|
@@ -70,7 +73,7 @@ export function sandboxGlobTool(deps) {
|
|
|
70
73
|
if (!st?.isDir)
|
|
71
74
|
throw new ToolError(notDirectory(dir, s.workingRoot));
|
|
72
75
|
const r = await p.exec(h, {
|
|
73
|
-
command:
|
|
76
|
+
command: listFilesCommand(),
|
|
74
77
|
cwd: dir,
|
|
75
78
|
timeoutMs: searchTimeoutMs(deps.config.get(), startedAt, Date.now(), ctx.runDeadline),
|
|
76
79
|
maxOutputBytes: MAX_FIND_BYTES,
|
|
@@ -78,7 +81,7 @@ export function sandboxGlobTool(deps) {
|
|
|
78
81
|
});
|
|
79
82
|
if (r.timedOut || r.exitCode === null)
|
|
80
83
|
throw new ToolError(FIND_FAILED);
|
|
81
|
-
// -
|
|
84
|
+
// NUL-separated: a file name may contain newlines; the last part (incomplete when truncated) is dropped
|
|
82
85
|
const names = r.stdout.split("\0");
|
|
83
86
|
names.pop();
|
|
84
87
|
if (r.truncated)
|
|
@@ -8,5 +8,12 @@ import { type SandboxToolDeps } from "./common.js";
|
|
|
8
8
|
* A newline in a file name shows as `\n`. An incomplete last entry (truncated output) is dropped.
|
|
9
9
|
*/
|
|
10
10
|
export declare function parseGrepNull(stdout: string, base: string, numbered?: boolean): string[];
|
|
11
|
-
/**
|
|
11
|
+
/** `grep -l --null` output: the matching files, each followed by NUL. */
|
|
12
|
+
export declare function parseFileList(stdout: string, base: string): string[];
|
|
13
|
+
/**
|
|
14
|
+
* `grep -c` output as `<path>:<count>` for the files with at least one matching line. GNU grep
|
|
15
|
+
* with `--null` writes `<file>\0<count>\n`; other implementations write `<file>:<count>`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseCounts(stdout: string, base: string): string[];
|
|
18
|
+
/** The builtin tool `Grep`: searches file contents with a regular expression (read-only). */
|
|
12
19
|
export declare function sandboxGrepTool(deps: SandboxToolDeps): BuiltinTool;
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { ToolError } from "@capybara-hq/plugin-sdk";
|
|
2
|
-
import { checkPathShape, checkToolPath, clip, display, inToolSandbox, sandboxBaseTimeoutMs, searchTimeoutMs,
|
|
2
|
+
import { checkPathShape, checkToolPath, clip, display, inToolSandbox, sandboxBaseTimeoutMs, searchTimeoutMs, unavailableWhenNoSandbox, withNotices, } from "./common.js";
|
|
3
|
+
import { grepCommand } from "./search-command.js";
|
|
3
4
|
/** The most output entries (lines, files or counts) returned in one call, whatever `head_limit` says. */
|
|
4
5
|
const MAX_MATCHES = 500;
|
|
5
6
|
/** `head_limit` when the model gives none. */
|
|
6
7
|
const DEFAULT_HEAD_LIMIT = 250;
|
|
7
|
-
/**
|
|
8
|
+
/** The most characters shown per output line. */
|
|
8
9
|
const MAX_LINE_CHARS = 500;
|
|
9
|
-
/**
|
|
10
|
+
/** The most search output read, in bytes. */
|
|
10
11
|
const MAX_GREP_BYTES = 4 * 1024 * 1024;
|
|
11
12
|
const MODES = ["content", "files_with_matches", "count"];
|
|
12
13
|
const SPEC = {
|
|
13
14
|
name: "Grep",
|
|
14
15
|
// Display only (the tool row; not in the fingerprint, never sent to the model).
|
|
15
16
|
keyArgs: ["pattern", "path"],
|
|
16
|
-
description: "Search file contents in this conversation's sandbox with a regular expression (
|
|
17
|
-
|
|
18
|
-
"
|
|
17
|
+
description: "Search file contents in this conversation's sandbox with a regular expression (extended " +
|
|
18
|
+
'syntax as in grep -E, e.g. "log.*Error" or "def (load|save)"; no backreferences or ' +
|
|
19
|
+
"look-around). Use it to find where something is defined or mentioned. Searches path (a " +
|
|
20
|
+
"file, or a directory recursively; default: the workspace directory). A directory search " +
|
|
21
|
+
"skips binary files, .git and node_modules directories and, where the device supports it, " +
|
|
22
|
+
"files ignored by .gitignore, .ignore or .rgignore files; to search inside a skipped " +
|
|
23
|
+
"directory, pass that directory or a file in it as path. glob limits " +
|
|
19
24
|
'the files searched by name, e.g. "*.py". output_mode picks what comes back: ' +
|
|
20
25
|
'"files_with_matches" (default) lists the paths of files that match, "content" returns the ' +
|
|
21
26
|
"matching lines as <path>:<line>:<text> (with -A, -B or -C lines of context around them), " +
|
|
@@ -29,7 +34,7 @@ const SPEC = {
|
|
|
29
34
|
pattern: {
|
|
30
35
|
type: "string",
|
|
31
36
|
minLength: 1,
|
|
32
|
-
description: 'Regular expression (
|
|
37
|
+
description: 'Regular expression (extended syntax), e.g. "def [a-z_]+\\(" or "TODO".',
|
|
33
38
|
},
|
|
34
39
|
path: {
|
|
35
40
|
type: "string",
|
|
@@ -83,7 +88,7 @@ const SPEC = {
|
|
|
83
88
|
annotations: { readOnlyHint: true },
|
|
84
89
|
};
|
|
85
90
|
const notFound = (path) => `${clip(path, 200)} does not exist; check the path with Glob.`;
|
|
86
|
-
const failed = (stderr) => `
|
|
91
|
+
const failed = (stderr) => `The search failed: ${clip(stderr, 300)}. Check the pattern (extended regular expression; no backreferences or look-around) and retry.`;
|
|
87
92
|
const GREP_TIMEOUT = "The search did not finish in time; pass a narrower path or a glob and retry.";
|
|
88
93
|
/**
|
|
89
94
|
* Parses the output of `grep -H --null` (with `-n` when `numbered`): each entry is
|
|
@@ -117,7 +122,7 @@ export function parseGrepNull(stdout, base, numbered = true) {
|
|
|
117
122
|
}
|
|
118
123
|
const displayName = (raw) => (raw.startsWith("./") ? raw.slice(2) : raw).replace(/\n/g, "\\n");
|
|
119
124
|
/** `grep -l --null` output: the matching files, each followed by NUL. */
|
|
120
|
-
function parseFileList(stdout, base) {
|
|
125
|
+
export function parseFileList(stdout, base) {
|
|
121
126
|
const parts = stdout.split("\0");
|
|
122
127
|
// the last part is empty, or an incomplete name when the output was truncated: dropped
|
|
123
128
|
parts.pop();
|
|
@@ -127,7 +132,7 @@ function parseFileList(stdout, base) {
|
|
|
127
132
|
* `grep -c` output as `<path>:<count>` for the files with at least one matching line. GNU grep
|
|
128
133
|
* with `--null` writes `<file>\0<count>\n`; other implementations write `<file>:<count>`.
|
|
129
134
|
*/
|
|
130
|
-
function parseCounts(stdout, base) {
|
|
135
|
+
export function parseCounts(stdout, base) {
|
|
131
136
|
const out = [];
|
|
132
137
|
if (stdout.includes("\0")) {
|
|
133
138
|
for (const l of parseGrepNull(stdout, base, false)) {
|
|
@@ -147,7 +152,7 @@ function parseCounts(stdout, base) {
|
|
|
147
152
|
}
|
|
148
153
|
return out;
|
|
149
154
|
}
|
|
150
|
-
/**
|
|
155
|
+
/** The builtin tool `Grep`: searches file contents with a regular expression (read-only). */
|
|
151
156
|
export function sandboxGrepTool(deps) {
|
|
152
157
|
return {
|
|
153
158
|
spec: SPEC,
|
|
@@ -175,27 +180,16 @@ export function sandboxGrepTool(deps) {
|
|
|
175
180
|
const cwd = st.isDir ? path : path.slice(0, slash) || "/";
|
|
176
181
|
const target = st.isDir ? "." : path.slice(slash + 1);
|
|
177
182
|
const base = cwd === "/" ? "" : cwd;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
:
|
|
187
|
-
|
|
188
|
-
// --null:文件名后跟 NUL 而不是 `:`,文件名里有换行或冒号也能解析
|
|
189
|
-
"grep",
|
|
190
|
-
...modeFlags,
|
|
191
|
-
...(g["-i"] === true ? ["-i"] : []),
|
|
192
|
-
...context,
|
|
193
|
-
...(glob !== undefined ? [`--include=${shellQuote(glob)}`] : []),
|
|
194
|
-
"-e",
|
|
195
|
-
shellQuote(pattern),
|
|
196
|
-
"--",
|
|
197
|
-
shellQuote(target),
|
|
198
|
-
].join(" ");
|
|
183
|
+
const command = grepCommand({
|
|
184
|
+
mode,
|
|
185
|
+
pattern,
|
|
186
|
+
target,
|
|
187
|
+
directory: st.isDir,
|
|
188
|
+
numbered,
|
|
189
|
+
ignoreCase: g["-i"] === true,
|
|
190
|
+
context: { A: g["-A"], B: g["-B"], C: g["-C"] },
|
|
191
|
+
...(glob !== undefined ? { glob } : {}),
|
|
192
|
+
});
|
|
199
193
|
const r = await p.exec(h, {
|
|
200
194
|
command,
|
|
201
195
|
cwd,
|
|
@@ -225,7 +219,7 @@ export function sandboxGrepTool(deps) {
|
|
|
225
219
|
const limit = headLimit === 0 ? MAX_MATCHES : Math.min(headLimit, MAX_MATCHES);
|
|
226
220
|
const page = entries.slice(offset, offset + limit);
|
|
227
221
|
const shown = page.map((l) => l.length > MAX_LINE_CHARS ? `${l.slice(0, MAX_LINE_CHARS)}…` : l);
|
|
228
|
-
const note = warning !== null ? `\n[
|
|
222
|
+
const note = warning !== null ? `\n[the search also reported errors: ${warning}]` : "";
|
|
229
223
|
let text;
|
|
230
224
|
if (total === 0) {
|
|
231
225
|
text = `No matches for ${pattern} in ${path}.${note}`;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directories `Grep` and `Glob` never walk into, whatever the ignore files say: version control
|
|
3
|
+
* metadata and installed packages. A path given explicitly is still searched (only directories
|
|
4
|
+
* met while walking are skipped).
|
|
5
|
+
*/
|
|
6
|
+
export declare const ALWAYS_SKIPPED_DIRS: readonly [".git", ".hg", ".svn", ".jj", "node_modules"];
|
|
7
|
+
export type GrepMode = "content" | "files_with_matches" | "count";
|
|
8
|
+
export interface GrepCommandOptions {
|
|
9
|
+
mode: GrepMode;
|
|
10
|
+
pattern: string;
|
|
11
|
+
/** What to search, relative to the command's cwd: `.` for a directory, else a file name. */
|
|
12
|
+
target: string;
|
|
13
|
+
/** Whether `target` is a directory (searched recursively) or a single file. */
|
|
14
|
+
directory: boolean;
|
|
15
|
+
/** Content mode: prefix line numbers. */
|
|
16
|
+
numbered: boolean;
|
|
17
|
+
ignoreCase: boolean;
|
|
18
|
+
/** Content mode: `-A` / `-B` / `-C` lines of context. */
|
|
19
|
+
context: {
|
|
20
|
+
A?: number | undefined;
|
|
21
|
+
B?: number | undefined;
|
|
22
|
+
C?: number | undefined;
|
|
23
|
+
};
|
|
24
|
+
glob?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The shell command `Grep` runs. Every branch prints what `grep -H --null` prints: the file name,
|
|
28
|
+
* NUL, then `<line number>:<line>` (content), `<count>` (count) or nothing (files with matches;
|
|
29
|
+
* the NUL ends the name), and `--` between context groups.
|
|
30
|
+
*
|
|
31
|
+
* A directory is searched with ripgrep when the device has it (it skips what the `.gitignore`,
|
|
32
|
+
* `.ignore` and `.rgignore` files ignore, and binary files), sorted by path so `offset` pages
|
|
33
|
+
* over a stable order; otherwise with `grep -r` skipping {@link ALWAYS_SKIPPED_DIRS}. A single
|
|
34
|
+
* file is always searched with grep: there is nothing to walk, and `grep -I` treats a binary file
|
|
35
|
+
* as not matching where ripgrep would print a "binary file matches" line.
|
|
36
|
+
*/
|
|
37
|
+
export declare function grepCommand(o: GrepCommandOptions): string;
|
|
38
|
+
/**
|
|
39
|
+
* The shell command `Glob` runs in the directory to search: every file below it as `./<path>`,
|
|
40
|
+
* each followed by NUL. With ripgrep when the device has it (skipping what the ignore files
|
|
41
|
+
* ignore), else `find` skipping {@link ALWAYS_SKIPPED_DIRS}. Neither follows symbolic links.
|
|
42
|
+
*/
|
|
43
|
+
export declare function listFilesCommand(): string;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { shellQuote } from "./common.js";
|
|
2
|
+
/**
|
|
3
|
+
* Directories `Grep` and `Glob` never walk into, whatever the ignore files say: version control
|
|
4
|
+
* metadata and installed packages. A path given explicitly is still searched (only directories
|
|
5
|
+
* met while walking are skipped).
|
|
6
|
+
*/
|
|
7
|
+
export const ALWAYS_SKIPPED_DIRS = [".git", ".hg", ".svn", ".jj", "node_modules"];
|
|
8
|
+
/**
|
|
9
|
+
* Runs `rg` when the device has it, else `fallback`, in one shell command (no extra round trip
|
|
10
|
+
* to find out). Both branches print the same format, so the caller parses either the same way.
|
|
11
|
+
*/
|
|
12
|
+
const preferRg = (rg, fallback) => `if command -v rg >/dev/null 2>&1; then ${rg}; else ${fallback}; fi`;
|
|
13
|
+
/**
|
|
14
|
+
* The ripgrep options shared by both tools: no user config file (`RIPGREP_CONFIG_PATH` could
|
|
15
|
+
* change the output format), hidden files included like grep and find (the ignore files and the
|
|
16
|
+
* skipped directories decide what is left out), the always-skipped directories excluded.
|
|
17
|
+
*/
|
|
18
|
+
const RG_BASE = ["rg", "--no-config", "--hidden"];
|
|
19
|
+
const RG_SKIP = ALWAYS_SKIPPED_DIRS.map((d) => `--glob=${shellQuote(`!${d}`)}`);
|
|
20
|
+
/**
|
|
21
|
+
* The shell command `Grep` runs. Every branch prints what `grep -H --null` prints: the file name,
|
|
22
|
+
* NUL, then `<line number>:<line>` (content), `<count>` (count) or nothing (files with matches;
|
|
23
|
+
* the NUL ends the name), and `--` between context groups.
|
|
24
|
+
*
|
|
25
|
+
* A directory is searched with ripgrep when the device has it (it skips what the `.gitignore`,
|
|
26
|
+
* `.ignore` and `.rgignore` files ignore, and binary files), sorted by path so `offset` pages
|
|
27
|
+
* over a stable order; otherwise with `grep -r` skipping {@link ALWAYS_SKIPPED_DIRS}. A single
|
|
28
|
+
* file is always searched with grep: there is nothing to walk, and `grep -I` treats a binary file
|
|
29
|
+
* as not matching where ripgrep would print a "binary file matches" line.
|
|
30
|
+
*/
|
|
31
|
+
export function grepCommand(o) {
|
|
32
|
+
const context = o.mode === "content"
|
|
33
|
+
? ["A", "B", "C"].flatMap((f) => o.context[f] !== undefined ? [`-${f}`, String(o.context[f])] : [])
|
|
34
|
+
: [];
|
|
35
|
+
const ignoreCase = o.ignoreCase ? ["-i"] : [];
|
|
36
|
+
const tail = ["-e", shellQuote(o.pattern), "--", shellQuote(o.target)];
|
|
37
|
+
// --null: a NUL instead of `:` after the file name, so names with newlines or colons parse
|
|
38
|
+
const grepMode = o.mode === "files_with_matches"
|
|
39
|
+
? ["-rlIE", "--null"]
|
|
40
|
+
: o.mode === "count"
|
|
41
|
+
? ["-rcHIE", "--null"]
|
|
42
|
+
: [o.numbered ? "-rnHIE" : "-rHIE", "--null"];
|
|
43
|
+
const grep = [
|
|
44
|
+
"grep",
|
|
45
|
+
...grepMode,
|
|
46
|
+
...ignoreCase,
|
|
47
|
+
...context,
|
|
48
|
+
...(o.glob !== undefined ? [`--include=${shellQuote(o.glob)}`] : []),
|
|
49
|
+
// only for a directory: GNU grep also applies the excludes to the names on the command line
|
|
50
|
+
...(o.directory ? ALWAYS_SKIPPED_DIRS.map((d) => `--exclude-dir=${shellQuote(d)}`) : []),
|
|
51
|
+
...tail,
|
|
52
|
+
].join(" ");
|
|
53
|
+
if (!o.directory)
|
|
54
|
+
return grep;
|
|
55
|
+
const rgMode = o.mode === "files_with_matches"
|
|
56
|
+
? ["-l"]
|
|
57
|
+
: o.mode === "count"
|
|
58
|
+
? ["-c"]
|
|
59
|
+
: [o.numbered ? "-n" : "-N", "--no-heading"];
|
|
60
|
+
const rg = [
|
|
61
|
+
...RG_BASE,
|
|
62
|
+
"--color=never",
|
|
63
|
+
"--sort=path",
|
|
64
|
+
"--null",
|
|
65
|
+
"-H",
|
|
66
|
+
...rgMode,
|
|
67
|
+
...ignoreCase,
|
|
68
|
+
...context,
|
|
69
|
+
// the user's glob before the exclusions: a later --glob wins in ripgrep
|
|
70
|
+
...(o.glob !== undefined ? [`--glob=${shellQuote(o.glob)}`] : []),
|
|
71
|
+
...RG_SKIP,
|
|
72
|
+
...tail,
|
|
73
|
+
].join(" ");
|
|
74
|
+
return preferRg(rg, grep);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The shell command `Glob` runs in the directory to search: every file below it as `./<path>`,
|
|
78
|
+
* each followed by NUL. With ripgrep when the device has it (skipping what the ignore files
|
|
79
|
+
* ignore), else `find` skipping {@link ALWAYS_SKIPPED_DIRS}. Neither follows symbolic links.
|
|
80
|
+
*/
|
|
81
|
+
export function listFilesCommand() {
|
|
82
|
+
const rg = [...RG_BASE, ...RG_SKIP, "--files", "--null", "--", "."].join(" ");
|
|
83
|
+
const prune = ALWAYS_SKIPPED_DIRS.map((d) => `-name ${shellQuote(d)}`).join(" -o ");
|
|
84
|
+
const find = `find . \\( ${prune} \\) -prune -o -type f -print0`;
|
|
85
|
+
return preferRg(rg, find);
|
|
86
|
+
}
|