@lanes-sh/link 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +20 -9
  2. package/instructions/agents/lanes-link-scout.md +14 -3
  3. package/instructions/skills/lanes-link/SKILL.md +80 -3
  4. package/package.json +2 -2
  5. package/src/cli/argv.ts +7 -0
  6. package/src/cli/commands/connect/index.ts +9 -6
  7. package/src/cli/commands/connection.ts +298 -0
  8. package/src/cli/commands/operate/inspect.ts +53 -22
  9. package/src/cli/commands/operate/migrate.ts +100 -0
  10. package/src/cli/commands/operate/serve.ts +21 -0
  11. package/src/cli/commands/owner/assets.ts +132 -0
  12. package/src/cli/commands/owner/shared.ts +28 -4
  13. package/src/cli/commands/owner/tasks.ts +194 -0
  14. package/src/cli/commands/owner.ts +9 -4
  15. package/src/cli/config-edit.ts +33 -7
  16. package/src/cli/config-migrate.ts +251 -0
  17. package/src/cli/config-repair.ts +115 -11
  18. package/src/cli/dispatch-owner.ts +49 -8
  19. package/src/cli/lanes.ts +1 -1
  20. package/src/cli/main.ts +22 -3
  21. package/src/cli/provider-marks.ts +1 -1
  22. package/src/cli/runtime/registry.ts +10 -2
  23. package/src/cli/selection.ts +18 -0
  24. package/src/cli/usage.ts +20 -2
  25. package/src/connectivity/mail/attachments.ts +5 -1
  26. package/src/connectivity/mail/index.ts +6 -1
  27. package/src/connectivity/manifest/provider.ts +15 -2
  28. package/src/deployments/deploy.ts +3 -2
  29. package/src/deployments/prepare.ts +1 -1
  30. package/src/deployments/servable.ts +1 -1
  31. package/src/deployments/upload.ts +0 -53
  32. package/src/profile/index.ts +4 -0
  33. package/src/profile/load.ts +135 -1
  34. package/src/providers/assets/provider.ts +337 -0
  35. package/src/providers/assets/store.ts +167 -0
  36. package/src/providers/google/index.ts +1 -1
  37. package/src/providers/google/tasks/index.ts +3 -3
  38. package/src/providers/google/tasks/redact.ts +21 -11
  39. package/src/providers/index.ts +3 -3
  40. package/src/providers/owner.ts +39 -19
  41. package/src/providers/setup/plan.ts +17 -1
  42. package/src/providers/tasks/provider.ts +370 -0
  43. package/src/providers/tasks/store.ts +248 -0
  44. package/src/server/mcp/build.ts +1 -1
  45. package/src/server/mcp/instructions.ts +67 -8
@@ -7,12 +7,14 @@ import { loadProfileProviders } from '#providers/custom/index.ts';
7
7
  import { loadProfileSkills, type LoadedSkill } from '#providers/skills/store.ts';
8
8
  import { exampleProvider } from '#providers/example/provider.ts';
9
9
  import {
10
+ assetsProvider,
10
11
  createIdentityProvider,
11
12
  createMemoryVaultStore,
12
13
  createSetupProvider,
13
14
  createSkillsProvider,
14
15
  createVaultProvider,
15
16
  memoryProvider,
17
+ tasksProvider,
16
18
  type IdentityProviderOptions,
17
19
  type SetupProviderOptions,
18
20
  type VaultStore,
@@ -84,8 +86,8 @@ export interface OwnerLayerOptions {
84
86
  * Statically imported for now; the registry does not care where a manifest came
85
87
  * from, which is what lets workspace YAML register alongside these.
86
88
  *
87
- * `allowReserved` is what admits `memory`, `skills`, `vault`, `setup`, and
88
- * `identity`. The guard
89
+ * `allowReserved` is what admits `memory`, `tasks`, `assets`, `skills`, `vault`,
90
+ * `setup`, and `identity`. The guard
89
91
  * stays rather than being retired: it exists so a *third-party* provider cannot
90
92
  * claim a namespace whose policy rules would then silently mean something else,
91
93
  * and that reason survives the owner layer shipping. Only this one construction
@@ -95,7 +97,13 @@ export function buildRegistry(owner: OwnerLayerOptions = {}): ProviderRegistry {
95
97
  const registry = new ProviderRegistry({ allowReserved: true });
96
98
 
97
99
  registry.register(exampleProvider);
100
+ // The three that hold what the owner keeps. All module-level constants rather
101
+ // than factories: each reads and writes through `context.storage`, which core
102
+ // scopes per call, so there is nothing to hand in at construction time and
103
+ // nothing for `OwnerLayerOptions` to carry.
98
104
  registry.register(memoryProvider);
105
+ registry.register(tasksProvider);
106
+ registry.register(assetsProvider);
99
107
  registry.register(skillsProviderFor(owner));
100
108
  registry.register(
101
109
  createVaultProvider({
@@ -111,6 +111,11 @@ export const SELECTION: Record<string, Requires> = {
111
111
  'identity list': 'profile',
112
112
 
113
113
  connect: 'profile+target',
114
+ // Both edit the profile config, and `disconnect` also opens the target's
115
+ // credential store to delete from it. Same requirement as `connect` for the
116
+ // same reasons.
117
+ disconnect: 'profile+target',
118
+ relabel: 'profile+target',
114
119
  // Its own row rather than an inheritance from `connect`. Both need the same
115
120
  // two things, but the row is what makes `selectionKey` return the two-word
116
121
  // key — and that is what keeps thirty declaration flags off
@@ -153,6 +158,8 @@ export const SELECTION: Record<string, Requires> = {
153
158
  'mcp add': 'profile+target',
154
159
  'mcp stdio': 'profile+target',
155
160
  memory: 'profile+target',
161
+ tasks: 'profile+target',
162
+ assets: 'profile+target',
156
163
  skills: 'profile+target',
157
164
  vault: 'profile+target',
158
165
  // Both halves open the target's adapters — `show` counts what is in the
@@ -181,6 +188,8 @@ const SUBCOMMANDS: Record<string, readonly string[]> = {
181
188
  config: ['show'],
182
189
  setup: ['plan'],
183
190
  memory: ['list', 'get', 'write', 'forget'],
191
+ tasks: ['list', 'get', 'add', 'update', 'remove'],
192
+ assets: ['list', 'get', 'add', 'remove'],
184
193
  skills: ['list', 'show', 'add', 'remove'],
185
194
  vault: ['list', 'get', 'set', 'remove', 'key'],
186
195
  mcp: ['skill', 'add', 'stdio', 'list'],
@@ -310,6 +319,12 @@ const ACCEPTS: Record<string, readonly string[]> = {
310
319
  // `removalPlan`, and was refused here — the flag existed everywhere except in
311
320
  // the list that decides whether it may be typed.
312
321
  'profile remove': ['dry-run', 'yes', 'target'],
322
+ disconnect: ['yes', 'keep-credential'],
323
+ // The one repair `doctor` can apply rather than only name. Narrow on purpose:
324
+ // it undoes a provider rename this project shipped, and every other finding
325
+ // there is something only the operator can decide.
326
+ doctor: ['fix'],
327
+ relabel: [],
313
328
  'target list': ['urls', 'target'],
314
329
  'target show': ['target'],
315
330
  'token show': ['show', 'raw'],
@@ -332,6 +347,9 @@ const ACCEPTS: Record<string, readonly string[]> = {
332
347
  update: ['check'],
333
348
  'identity add': ['note'],
334
349
  memory: ['connection', 'title', 'description', 'file', 'tag'],
350
+ // `--yes` on both, because both have a delete that asks first.
351
+ tasks: ['connection', 'title', 'status', 'due', 'tag', 'yes'],
352
+ assets: ['connection', 'name', 'content-type', 'yes'],
335
353
  skills: ['connection', 'title', 'description', 'file'],
336
354
  vault: ['connection'],
337
355
  // `no-migrate` is listed beside `migrate` because they are three states
package/src/cli/usage.ts CHANGED
@@ -16,7 +16,7 @@ import { style } from './output.ts';
16
16
  /** How this CLI is invoked — the `link` area of the `lanes` command. */
17
17
  export const PROGRAM = 'lanes link';
18
18
 
19
- export const USAGE = `${style.bold(PROGRAM)} — a self-hostable MCP gateway for all your connections, memory, skills, and secrets
19
+ export const USAGE = `${style.bold(PROGRAM)} — a self-hostable MCP gateway for all your connections, memory, tasks, files, and secrets
20
20
 
21
21
  ${style.bold('Everyday')}
22
22
  ${PROGRAM} setup plan [--json] what each provider needs, and which are connected
@@ -26,6 +26,9 @@ ${style.bold('Everyday')}
26
26
  ${PROGRAM} connect <...> --replace ask for the stored password or key again
27
27
  ${PROGRAM} connect <...> --auth <method> pick how, where there is a choice
28
28
  ${PROGRAM} connect <...> --non-interactive [--json]
29
+ ${PROGRAM} disconnect <provider>.<id> remove an account, and delete its credential
30
+ ${PROGRAM} disconnect <...> --keep-credential leave the credential in the store
31
+ ${PROGRAM} relabel <provider>.<id> <name> rename what an account is called
29
32
  ${PROGRAM} connect custom <id> --connector <kind> --auth <method>
30
33
  declare a service that is not built in, and connect it.
31
34
  kinds: mcp, http, imap, dav, fs. Omit a value and it is
@@ -78,6 +81,18 @@ ${style.bold('Your own context')}
78
81
  ${PROGRAM} memory write <id> --title <t> [--tag t] body on stdin
79
82
  ${PROGRAM} memory forget <id>
80
83
 
84
+ ${PROGRAM} tasks list [--status s] what is outstanding; --status all for everything
85
+ ${PROGRAM} tasks get <id>
86
+ ${PROGRAM} tasks add <title> [--status s] [--due d] [--tag t] notes on stdin
87
+ ${PROGRAM} tasks update <id> --status <s> closing one is an update, not a remove
88
+ ${PROGRAM} tasks remove <id>
89
+ statuses: in_progress open blocked muted done dropped
90
+
91
+ ${PROGRAM} assets list files kept in this profile
92
+ ${PROGRAM} assets get <name> the bytes, to stdout — redirect them
93
+ ${PROGRAM} assets add <file> [--name n] [--content-type t]
94
+ ${PROGRAM} assets remove <name>
95
+
81
96
  ${PROGRAM} skills list the procedures agents can invoke
82
97
  ${PROGRAM} skills show <name>
83
98
  ${PROGRAM} skills add <name> [--file f] document on stdin
@@ -112,6 +127,8 @@ ${style.bold('Deploying')}
112
127
  ${style.bold('Inspection')}
113
128
  ${PROGRAM} check static validation, no external calls
114
129
  ${PROGRAM} doctor [--json] credentials resolve, stores reachable
130
+ ${PROGRAM} doctor --fix apply a repair it can make itself, such as
131
+ a provider this project renamed under you
115
132
  ${PROGRAM} tools [--json] what the endpoint advertises to a client
116
133
  ${PROGRAM} plan what reconcile would change
117
134
  ${PROGRAM} audit tail [--limit N] [--denied-only] [--format md]
@@ -131,7 +148,8 @@ ${style.bold('Naming what a command acts on')}
131
148
  command that names neither refuses and lists what exists.
132
149
 
133
150
  ${style.bold('Other flags')}
134
- --connection <id> which memory/skills/vault connection, if a profile has several
151
+ --connection <id> which memory/tasks/assets/skills/vault connection, where
152
+ a profile has several of one kind
135
153
  --yes skip the confirmation a destructive command would ask for
136
154
  --json machine-readable output, where a command offers it
137
155
  --non-interactive never prompt: connect refuses with what to store,
@@ -362,7 +362,11 @@ const CONTENT_TYPES: Readonly<Record<string, string>> = {
362
362
  // opens by extension anyway. Adding them back will fail the suite.
363
363
  };
364
364
 
365
- function guessContentType(filename: string): string {
365
+ /**
366
+ * Exported because `assets` needs exactly this and the table above must not be
367
+ * copied — its `.pages`/`.numbers` note is a rule the copy would not carry.
368
+ */
369
+ export function guessContentType(filename: string): string {
366
370
  const extension = filename.split('.').pop()?.toLowerCase();
367
371
  return (extension ? CONTENT_TYPES[extension] : undefined) ?? 'application/octet-stream';
368
372
  }
@@ -21,7 +21,12 @@ export { receiptFor } from './message.ts';
21
21
  export { composeMime } from './compose.ts';
22
22
 
23
23
  export type { AttachmentRef, MailboxAttachmentSource, ResolveOptions } from './attachments.ts';
24
- export { attachmentRefSchema, attachmentsJsonSchema, resolveAttachments } from './attachments.ts';
24
+ export {
25
+ attachmentRefSchema,
26
+ attachmentsJsonSchema,
27
+ guessContentType,
28
+ resolveAttachments,
29
+ } from './attachments.ts';
25
30
 
26
31
  export type { StagedFile, StagedMetadata } from './staging.ts';
27
32
  export {
@@ -64,8 +64,21 @@ export const providerManifestSchema = z.object({
64
64
 
65
65
  export type ProviderManifest = z.infer<typeof providerManifestSchema>;
66
66
 
67
- /** Provider ids reserved for the owner layer. */
68
- export const RESERVED_PROVIDER_IDS: readonly string[] = ['memory', 'skills', 'vault', 'setup', 'identity'];
67
+ /**
68
+ * Provider ids reserved for the owner layer.
69
+ *
70
+ * The order is read: `#server/mcp`'s instructions emit one paragraph per
71
+ * reachable id in this sequence, so it is the order an agent meets them in.
72
+ */
73
+ export const RESERVED_PROVIDER_IDS: readonly string[] = [
74
+ 'memory',
75
+ 'tasks',
76
+ 'assets',
77
+ 'skills',
78
+ 'vault',
79
+ 'setup',
80
+ 'identity',
81
+ ];
69
82
 
70
83
  /**
71
84
  * Validate a manifest, with the cross-field rules the schema alone cannot
@@ -7,7 +7,8 @@ import { resolveTarget, vaultEnv } from './bootstrap.ts';
7
7
  import { printSteps, runSteps } from './steps.ts';
8
8
  import { driverFor } from './drivers.ts';
9
9
  import { prepareSecrets, readableRefs, rotatableRefs } from './prepare.ts';
10
- import { deployedWorkspace, repairSetupSurface, uploadWorkspace } from './upload.ts';
10
+ import { repairOwnerLayer } from '#cli/config-repair.ts';
11
+ import { deployedWorkspace, uploadWorkspace } from './upload.ts';
11
12
  import { unservableProfiles, unservableRefusal } from './servable.ts';
12
13
  import { collidingRefs, collisionRefusal, servingProfiles } from './serving.ts';
13
14
  import { healthLine, reachability, registerLine, reportUnauthorised } from './report.ts';
@@ -255,7 +256,7 @@ export async function deploy(flags: DeployFlags): Promise<void> {
255
256
  throw new ConfigError(unservableRefusal(unservable, target));
256
257
  }
257
258
 
258
- await repairSetupSurface(resolution.workspaceRoot, serving);
259
+ await repairOwnerLayer(resolution.workspaceRoot, serving);
259
260
 
260
261
  // Before the rollout, so the revision that comes up finds a config to read.
261
262
  // Uploading after would leave a window where the service is serving and the
@@ -46,7 +46,7 @@ export interface PrepareResult {
46
46
  * path derives from the manifest and has never read config for. Sharing one list
47
47
  * would silently pick one answer for both.
48
48
  *
49
- * **Scoped exactly as the upload is**, for the reason `repairSetupSurface`
49
+ * **Scoped exactly as the upload is**, for the reason `repairOwnerLayer`
50
50
  * states and one more: a profile this deploy sends is a profile the endpoint may
51
51
  * serve, and a connection whose secret nobody bound fails an hour after the
52
52
  * revision reports healthy. The asymmetry decides it — an extra binding is a
@@ -30,7 +30,7 @@ export interface Unservable {
30
30
  /**
31
31
  * The profiles this deploy would send that the revision could not open.
32
32
  *
33
- * Scoped exactly as `uploadWorkspace` and `repairSetupSurface` are — by the
33
+ * Scoped exactly as `uploadWorkspace` and `repairOwnerLayer` are — by the
34
34
  * `--profile` flag, absent meaning the whole workspace — because the set that
35
35
  * gets uploaded is the set that gets served, and checking a different one would
36
36
  * be checking the wrong question.
@@ -7,8 +7,6 @@ import {
7
7
  type Config,
8
8
  type TargetConfig,
9
9
  } from '#profile';
10
- import { ConfigDocument } from '#cli/config-edit.ts';
11
- import { ensureSetupConnection, repairLines, repaired } from '#cli/config-repair.ts';
12
10
  import { ok, print, style, warn } from '#cli/output.ts';
13
11
 
14
12
  /**
@@ -100,57 +98,6 @@ function authoredAreaOwner(key: string): string | null {
100
98
  return area === layout.skills(owner) || area === layout.providers(owner) ? owner : null;
101
99
  }
102
100
 
103
- /**
104
- * Give every profile about to be uploaded its setup surface.
105
- *
106
- * **Scoped exactly as the upload is**, because a profile this deploy sends is a
107
- * profile the endpoint will serve: repairing a narrower set would leave a served
108
- * profile without the surface, which is this bug one profile over. Note what
109
- * `flags.profile` does not mean — it is the flag alone, so a profile resolved
110
- * from `LANES_LINK_PROFILE` leaves it undefined and both this and the upload
111
- * read that as the whole workspace. Surprising, pre-existing in the upload, and
112
- * fixed there rather than here so the two cannot drift apart.
113
- *
114
- * *Which files are profiles* comes from `listProfiles`, never from
115
- * `isWorkspaceConfig`: the allowlist decides what is safe to *copy*, so it
116
- * happily sends a committed `personal.example.yaml` and a nested
117
- * `profiles/archive/old.yaml` as bytes, while this opens and validates what it
118
- * is handed — which turned that template into a `ConfigError` aborting the
119
- * deploy after provisioning had already made cloud resources.
120
- *
121
- * A profile that cannot be read is warned about rather than fatal: the repair is
122
- * a courtesy on the way past, and the upload still sends the file. Not silent,
123
- * though — nothing else here widens a policy without being asked.
124
- */
125
- export async function repairSetupSurface(
126
- workspaceRoot: string,
127
- profiles: readonly string[] | undefined,
128
- ): Promise<void> {
129
- const wanted = profiles === undefined ? undefined : new Set(profiles);
130
-
131
- for (const name of await listProfiles(workspaceRoot)) {
132
- if (wanted !== undefined && !wanted.has(name)) continue;
133
-
134
- try {
135
- const document = await ConfigDocument.open(workspaceRoot, name);
136
- const repair = ensureSetupConnection(document);
137
- if (!repaired(repair)) continue;
138
-
139
- await document.save();
140
-
141
- print(ok(`gave ${style.bold(name)} the setup surface`));
142
- for (const change of repairLines(repair)) print(` ${style.dim(change)}`);
143
- print(` ${style.dim('an agent can now see what is connected here, instead of guessing')}`);
144
- } catch (error) {
145
- print(
146
- warn(
147
- `could not give ${name} the setup surface: ${error instanceof Error ? error.message.split('\n')[0] : String(error)}`,
148
- ),
149
- );
150
- }
151
- }
152
- }
153
-
154
101
  /**
155
102
  * Copy the workspace's config up.
156
103
  */
@@ -38,10 +38,14 @@ export {
38
38
 
39
39
  export {
40
40
  ConfigError,
41
+ RENAMED_PROVIDERS,
41
42
  loadConfigFile,
42
43
  parseConfig,
44
+ renamedProviderFor,
43
45
  validateConfig,
46
+ validateConfigShape,
44
47
  type LoadedConfig,
48
+ type ProviderRename,
45
49
  } from './load.ts';
46
50
 
47
51
  export {
@@ -40,6 +40,25 @@ export interface LoadedConfig {
40
40
  * 4. Referential integrity, which needs a well-formed document to check.
41
41
  */
42
42
  export function validateConfig(raw: unknown, source = '<config>'): Config {
43
+ const config = validateConfigShape(raw, source);
44
+ assertReferentialIntegrity(config, source);
45
+ return config;
46
+ }
47
+
48
+ /**
49
+ * The first three steps, without the fourth.
50
+ *
51
+ * Only one caller, and it is the repair: `migrateRenamedProviders` has to open
52
+ * the credential store of a config that referential integrity has just refused,
53
+ * because whether a credential is stored is the evidence deciding which of two
54
+ * readings a row gets. A shape-valid document is enough to name a target's
55
+ * adapter, and nothing here trusts the part that failed.
56
+ *
57
+ * Not exported as a way to *load* a config. Everything that acts on one goes
58
+ * through `validateConfig`, and the split exists so that the one command whose
59
+ * job is to fix a refusal is not blocked by it.
60
+ */
61
+ export function validateConfigShape(raw: unknown, source = '<config>'): Config {
43
62
  if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
44
63
  throw new ConfigError(`${source}: expected a YAML mapping at the top level`);
45
64
  }
@@ -59,7 +78,6 @@ export function validateConfig(raw: unknown, source = '<config>'): Config {
59
78
  throw new ConfigError(`${source}:\n${formatZodIssues(parsed.error)}`);
60
79
  }
61
80
 
62
- assertReferentialIntegrity(parsed.data, source);
63
81
  return parsed.data;
64
82
  }
65
83
 
@@ -107,6 +125,119 @@ function formatZodIssues(error: z.ZodError): string {
107
125
  * left to resolve silently it grants nothing, which looks identical to a
108
126
  * working rule until the day someone relies on it.
109
127
  */
128
+ /**
129
+ * A connection naming a provider whose id has moved out from under it.
130
+ *
131
+ * There is exactly one, and it is the reason this function exists: `tasks` was
132
+ * Google Tasks until the built-in task list took the plain noun (ADR-051). A row
133
+ * left saying `provider: tasks` does not fail — it resolves to the *built-in*,
134
+ * `reconcile` marks it active because a provider needing no credential is
135
+ * authorized by construction, and the operator is left with their Google Tasks
136
+ * tools gone, a task list wearing their old label, and nothing anywhere saying
137
+ * why. Refusing is the only outcome that names the fix.
138
+ *
139
+ * **The rule is a positive assertion, not a guess at what a vendor row looks
140
+ * like.** The built-in's row is written in exactly one spelling, by
141
+ * `newProfileTemplate` and by `ensureReservedConnection`: `account: Tasks`. So
142
+ * any other label on a `tasks` row is either a pre-rename Google Tasks row or a
143
+ * hand-edited built-in one, and the message names both fixes because either is
144
+ * one word.
145
+ *
146
+ * It was very nearly a guess, and the guess was wrong. The first version keyed
147
+ * on an `@` in the account, reasoning that `connect tasks` recorded the address
148
+ * the operator typed — Google Tasks publishes no identity, so `connect` asks.
149
+ * But what it asks for is a *label*: the real profile this was written for holds
150
+ * `account: personal`, so the check would have passed it and rebound their Google
151
+ * Tasks to the built-in in silence. That is the exact failure this exists to
152
+ * prevent, missed by one heuristic.
153
+ *
154
+ * Deliberately not a check on the connection *id*. Several task lists in one
155
+ * profile is a legitimate thing to want, exactly as several memory connections
156
+ * are, and keying on `id !== 'main'` would refuse a valid profile forever to
157
+ * catch a one-release migration. Labelling both `Tasks` is consistent with what
158
+ * the accountless providers already do — every memory connection is `Memory`.
159
+ *
160
+ * **The refusal names a command, because it is a refusal at load.** Every
161
+ * command opens the config, so this one takes `status`, `start` and `doctor`
162
+ * down together and leaves hand-editing YAML as the only way back — for a state
163
+ * an upgrade put the operator in, without asking. `doctor --fix` is that way
164
+ * back, and it is named here because this is the only place anyone sees.
165
+ */
166
+ export interface ProviderRename {
167
+ /** What a row naming the old id should say instead. */
168
+ readonly to: string;
169
+ /** The account label that means this row is the built-in, not a vendor one. */
170
+ readonly keeps: string;
171
+ /** What the plain noun now names, for the sentence below. */
172
+ readonly becomes: string;
173
+ /** What it used to name. */
174
+ readonly was: string;
175
+ /** The built-in, in the operator's words. */
176
+ readonly noun: string;
177
+ }
178
+
179
+ /**
180
+ * Provider ids that have moved, and everything two places need to agree on.
181
+ *
182
+ * `renamedProviderFor` refuses a row still naming the old id; `#cli`'s
183
+ * `migrateRenamedProviders` rewrites one. A rename landing in one and not the
184
+ * other is a refusal with no fix, or a fix nothing asks for — which is why the
185
+ * pair reads from one table rather than each knowing the rename itself.
186
+ *
187
+ * `keeps` is the single spelling `newProfileTemplate` and `ensureReservedConnection`
188
+ * write for the built-in's row. Keep it in step with `RESERVED_SURFACES` there.
189
+ */
190
+ export const RENAMED_PROVIDERS: Readonly<Record<string, ProviderRename>> = {
191
+ tasks: {
192
+ to: 'google_tasks',
193
+ keeps: 'Tasks',
194
+ becomes: 'the built-in task list',
195
+ was: 'Google Tasks',
196
+ noun: 'task list',
197
+ },
198
+ };
199
+
200
+ /**
201
+ * The repair, spelled with the selection it will refuse without.
202
+ *
203
+ * Both flags come off the document being validated rather than off the command
204
+ * that is running: nothing has resolved anything yet, and the profile is written
205
+ * in the file. A profile declaring one target names it; one declaring several
206
+ * cannot be guessed at, and a placeholder is more honest than picking.
207
+ */
208
+ function repairCommand(config: Config): string {
209
+ const targets = Object.keys(config.targets);
210
+ const target = targets.length === 1 ? targets[0] : `<${targets.join('|') || 'target'}>`;
211
+ return `lanes link doctor --fix --profile ${config.instance.profile} --target ${target}`;
212
+ }
213
+
214
+ /** The rename a row is owed, or `null` when it is owed none. */
215
+ export function renamedProviderFor(connection: {
216
+ provider: string;
217
+ account: string;
218
+ }): ProviderRename | null {
219
+ const moved = RENAMED_PROVIDERS[connection.provider];
220
+ if (!moved || connection.account === moved.keeps) return null;
221
+ return moved;
222
+ }
223
+
224
+ function renamedProvider(
225
+ connection: { provider: string; account: string },
226
+ repair: string,
227
+ ): string | null {
228
+ const moved = renamedProviderFor(connection);
229
+ if (!moved) return null;
230
+
231
+ return (
232
+ `"${connection.provider}" is now ${moved.becomes}, and this row is labelled ` +
233
+ `"${connection.account}" rather than "${moved.keeps}".\n` +
234
+ ` If it was ${moved.was}: set provider to ${moved.to} here, and rename any ` +
235
+ `"${connection.provider}.*" policy rule.\n` +
236
+ ` If it is your own ${moved.noun}: set account to ${moved.keeps}.\n` +
237
+ ` ${repair} applies the first, where a stored credential proves it.`
238
+ );
239
+ }
240
+
110
241
  function assertReferentialIntegrity(config: Config, source: string): void {
111
242
  const problems: string[] = [];
112
243
 
@@ -142,6 +273,9 @@ function assertReferentialIntegrity(config: Config, source: string): void {
142
273
  problems.push(`connections[${index}]: duplicate connection "${key}"`);
143
274
  }
144
275
  connectionKeys.add(key);
276
+
277
+ const renamed = renamedProvider(connection, repairCommand(config));
278
+ if (renamed) problems.push(`connections[${index}]: ${renamed}`);
145
279
  });
146
280
 
147
281
  // Same reason as a duplicate connection: two entries with the same kind and