diff --git a/README.md b/README.md index e7023e3..c3ee63c 100644 --- a/README.md +++ b/README.md @@ -775,7 +775,7 @@ Agent VMs keep using the peer integration (§6 of docs/DEPLOY_EXE.md). `lore mcp` serves the query surface over stdio: `lore_grep`, `lore_read`, `lore_recall`, `lore_sync_now`, `lore_source_list`, `lore_remember`, `lore_sow_add`, `lore_doc_add`, `lore_source_add` (widen what is synced — a -repo, channel, folder, page, design file, board, or mailbox — on explicit +repo, channel, folder, page, design file, board, Linear team, or mailbox — on explicit instruction; identifiers only, credentials stay on the host), and the tracker verbs `lore_work_add`, `lore_work_promote`, `lore_work_move`, `lore_work_set` (each requires a reason), and `lore_work_push` (write ticket state to Jira, @@ -866,7 +866,7 @@ cites sources, never pins uninvited); run them with | `lore sow list [--json]` | attached SOWs | | `lore doc add [--title t] [--from who] [--date d] [--source url] [--as email] [--by who]` | add a document (Google Doc/Slides/Sheet, Drive PDF/text, or local .md/.txt/.pdf) to the `docs` stream — raw material, folded like email; commits + pushes | | `lore doc list [--json]` | documents in the `docs` stream | -| `lore source add [scope...] [--site url] [--by who]` | add a source or widen its scope on an existing client — `github owner/repo`, `slack "#chan"`, `granola "Folder"`, `notion `, `figma `, `jira KEY\|board:id`, `gmail [emails\|all]`; identifiers only (proxy `api_base` from `~/.lore/config.json` or `env:` refs), validated, audited, commits + pushes; the host backfills the new scope; prints the human steps left | +| `lore source add [scope...] [--site url] [--api-base url --uploads-base url] [--by who]` | add a source or widen its scope on an existing client — `github owner/repo`, `slack "#chan"`, `granola "Folder"`, `notion `, `figma `, `jira KEY\|board:id`, `linear TEAM`, `gmail [emails\|all]`; identifiers only (proxy `api_base` from `~/.lore/config.json` or `env:` refs; a new self-hosted `linear` block takes the client's own proxies via `--api-base`/`--uploads-base`, since each Linear key is one workspace), validated, audited, commits + pushes; the host backfills the new scope; prints the human steps left | | `lore source list [--json]` | configured sources with scope, auth mode, and freshness (`ok` / `stale ` / `never` / `disabled`) with last success and last error | | `lore gdoc export --as [--json]` | export a Google Doc (Slides, Sheet, Drive-hosted PDF/text) as text via the service account (used by `sow add` / `doc add` on the host) | | `lore mcp` | MCP server over stdio | diff --git a/plugins/lore/skills/lore-mcp/SKILL.md b/plugins/lore/skills/lore-mcp/SKILL.md index fe58567..d036785 100644 --- a/plugins/lore/skills/lore-mcp/SKILL.md +++ b/plugins/lore/skills/lore-mcp/SKILL.md @@ -1,6 +1,6 @@ --- name: lore-mcp -description: Query project memory through the lore MCP server (lore_grep, lore_read, lore_recall, lore_load, lore_load_all, lore_sync_now, lore_source_list, lore_remember, lore_sow_add, lore_doc_add, lore_source_add, lore_work_add/promote/move/set/push) — or connect it if it isn't. Use when asked what a client said, asked, or decided; what is open, in progress, blocked, or done; what happened in a meeting; project history or status; when asked to "remember" a fact for the project; when asked to add a document, spec, or brief the client sent to project memory; when asked to add a GitHub repo, Slack channel, Granola folder, Notion page, Figma file, Jira board, or mailbox to lore ("sync X too"), or which sources are synced; when asked to track, ticket, move, close, prioritise, or assign work, or what a ticket's history is; when asked to push or sync tickets to Jira; when asked for activity counts or a load report for one or all projects; when asked why something is missing from memory or why a source looks out of date; or when asked to hook an agent up to lore. +description: Query project memory through the lore MCP server (lore_grep, lore_read, lore_recall, lore_load, lore_load_all, lore_sync_now, lore_source_list, lore_remember, lore_sow_add, lore_doc_add, lore_source_add, lore_work_add/promote/move/set/push) — or connect it if it isn't. Use when asked what a client said, asked, or decided; what is open, in progress, blocked, or done; what happened in a meeting; project history or status; when asked to "remember" a fact for the project; when asked to add a document, spec, or brief the client sent to project memory; when asked to add a GitHub repo, Slack channel, Granola folder, Notion page, Figma file, Jira board, Linear team, or mailbox to lore ("sync X too"), or which sources are synced; when asked to track, ticket, move, close, prioritise, or assign work, or what a ticket's history is; when asked to push or sync tickets to Jira; when asked for activity counts or a load report for one or all projects; when asked why something is missing from memory or why a source looks out of date; or when asked to hook an agent up to lore. --- # Using lore over MCP @@ -371,7 +371,7 @@ next extract (`lore_sync_now` with `fold: true` if they want it sooner). The document is raw material, never authoritative — a commitment goes through `lore_sow_add`, a fact through `lore_remember`. -## Adding a source — a repo, channel, folder, page, design file, board, or mailbox +## Adding a source — a repo, channel, folder, page, design file, board, Linear team, or mailbox Memory only covers what `sources` in the client's config names. When a teammate tells you to widen it — "add inputlogic/merrin to lore", "sync @@ -379,7 +379,7 @@ teammate tells you to widen it — "add inputlogic/merrin to lore", "sync 293" — call `lore_source_add` with the `kind` and the identifiers **exactly as given** (`scope`: `"owner/repo"`, `"#channel"`, a Granola folder title, a Notion page URL, a Figma design/FigJam URL or key, a Jira key or -`"board:293"`, mailboxes or `"all"`; `site` for a new Jira source). Check +`"board:293"`, a Linear team key like `"MAR2"`, mailboxes or `"all"`; `site` for a new Jira source). A client with no Linear source yet cannot get one from here on the self-hosted host — its key needs its own proxy, so say that is a human step (`lore source add linear TEAM --api-base … --uploads-base …`). Check `lore_source_list` first so you can say "already synced" instead of adding a duplicate (the tool reports `already` too). Never guess or "correct" a name, and never add a scope because you saw it mentioned in a stream — a person diff --git a/plugins/lore/skills/lore-onboard/SKILL.md b/plugins/lore/skills/lore-onboard/SKILL.md index 3e3ed42..9d0897e 100644 --- a/plugins/lore/skills/lore-onboard/SKILL.md +++ b/plugins/lore/skills/lore-onboard/SKILL.md @@ -102,13 +102,14 @@ relay the human steps, and verify before declaring success. ## Widening an existing client A client already onboarded gets a new repo, channel, folder, Notion page, -Figma file, Jira board, or mailbox with one command — no hand edit of +Figma file, Jira board, Linear team, or mailbox with one command — no hand edit of lore.json: ```sh lore source add github inputlogic/merrin -p merrin # or: slack "#merrin-dev" · granola "Merrin" · notion lore source add figma "https://www.figma.com/design//…" -p merrin lore source add jira board:293 --site https://input-logic.atlassian.net -p jointly +lore source add linear MAR2 -p marble-collective # widen; a NEW linear source also needs --api-base/--uploads-base (the client's own key proxies) lore source list -p merrin # scope, auth mode, last success / last error per source ``` diff --git a/src/cli.ts b/src/cli.ts index 316c274..bd833e5 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -456,17 +456,19 @@ contextual( }) contextual(work.command('show').description('one item with its full history').argument('').option('--json', 'machine-readable output')).action((key: string, o) => void workShow(root, key, o)) -const source = program.command('source').description('what memory is synced from — add a repo, channel, folder, page, design file, board, or mailbox to an existing client (identifiers only; credentials stay in proxies / env)') +const source = program.command('source').description('what memory is synced from — add a repo, channel, folder, page, design file, board, Linear team, or mailbox to an existing client (identifiers only; credentials stay in proxies / env)') contextual( source .command('add') .description('add a source or widen its scope; validates lore.json, audits, commits and pushes — the host backfills the new scope on its next sync') - .argument('', 'slack | github | granola | notion | figma | jira | gmail') - .argument('[scope...]', '"#channel" · "owner/repo" · Granola folder title · Notion page URL/id · Figma file URL/key · Jira key or board: · mailboxes or "all" (gmail with none = team contacts)') + .argument('', 'slack | github | granola | notion | figma | jira | linear | gmail') + .argument('[scope...]', '"#channel" · "owner/repo" · Granola folder title · Notion page URL/id · Figma file URL/key · Jira key or board: · Linear team key · mailboxes or "all" (gmail with none = team contacts)') .option('--site ', 'jira: https://.atlassian.net, for permalinks') + .option('--api-base ', "linear, new block only: this client's GraphQL proxy (each Linear key is one workspace)") + .option('--uploads-base ', "linear, new block only: this client's uploads.linear.app proxy") .option('--by ', 'who is adding this (defaults to OS username)'), ).action(async (kind: string, scope: string[], o) => { - await sourceAdd(root, { kind, scope, site: o.site }, o) + await sourceAdd(root, { kind, scope, site: o.site, apiBase: o.apiBase, uploadsBase: o.uploadsBase }, o) }) contextual(source.command('list').description('configured sources with scope, auth mode, and sync health').option('--json', 'machine-readable output')).action((o) => void sourceList(root, o)) diff --git a/src/commands/mcp.ts b/src/commands/mcp.ts index 76a8657..9a558a1 100644 --- a/src/commands/mcp.ts +++ b/src/commands/mcp.ts @@ -373,7 +373,7 @@ export function createServer(ctx: ResolvedContext, rememberOpts: { cwd: string; { description: label + - `What ${ctx.config.project}'s memory is synced from: each configured source (slack, github, granola, notion, figma, jira, gmail) with its scope in its own terms (channels, repos, folders, roots, files, projects/boards, mailboxes), whether it is disabled, how the host authenticates, and its last successful sync / last error. Use it to answer "which repos/channels are synced", to check a scope before adding to it, and to explain a source that is failing.`, + `What ${ctx.config.project}'s memory is synced from: each configured source (slack, github, granola, notion, figma, jira, linear, gmail) with its scope in its own terms (channels, repos, folders, roots, files, projects/boards, teams, mailboxes), whether it is disabled, how the host authenticates, and its last successful sync / last error. Use it to answer "which repos/channels are synced", to check a scope before adding to it, and to explain a source that is failing.`, inputSchema: {}, }, async () => { @@ -387,12 +387,12 @@ export function createServer(ctx: ResolvedContext, rememberOpts: { cwd: string; { description: archived ? 'Unavailable: this client is archived and its memory is read-only.' - : 'Add a source to project memory, or widen one: a GitHub repo, a Slack channel, a Granola folder, a Notion page, a Figma design file, a Jira project/board, or Gmail mailboxes. Use ONLY on explicit instruction from a teammate ("add the mobile repo to lore", "sync #acme-dev too"), with the identifiers exactly as given — never guess a repo name, channel, or folder, and never add a scope you merely saw mentioned. Credentials are never part of this: the config records identifiers only, and the host authenticates through its proxies. The result lists what was added, what was already there, and `next`: the steps only a person can do (invite the bot to the channel, attach the GitHub integration, share the Notion page) — relay those verbatim, because the host cannot read the new scope until they are done. The new scope backfills automatically on the host\'s next sync (or lore_sync_now). Scope is never removed here; that is a human edit.', + : 'Add a source to project memory, or widen one: a GitHub repo, a Slack channel, a Granola folder, a Notion page, a Figma design file, a Jira project/board, a Linear team, or Gmail mailboxes. Use ONLY on explicit instruction from a teammate ("add the mobile repo to lore", "sync #acme-dev too"), with the identifiers exactly as given — never guess a repo name, channel, or folder, and never add a scope you merely saw mentioned. Credentials are never part of this: the config records identifiers only, and the host authenticates through its proxies. The result lists what was added, what was already there, and `next`: the steps only a person can do (invite the bot to the channel, attach the GitHub integration, share the Notion page) — relay those verbatim, because the host cannot read the new scope until they are done. The new scope backfills automatically on the host\'s next sync (or lore_sync_now). Scope is never removed here; that is a human edit.', inputSchema: { - kind: z.enum(KNOWN_SOURCES as [string, ...string[]]).describe('slack | github | granola | notion | figma | jira | gmail'), + kind: z.enum(KNOWN_SOURCES as [string, ...string[]]).describe('slack | github | granola | notion | figma | jira | linear | gmail'), scope: z .array(z.string().min(1)) - .describe('in the source\'s own terms: "#channel"; "owner/repo"; a Granola folder title; a Notion page/database URL or id; a Figma file URL or key (not a Slides deck); a Jira project key (ACM) or "board:293"; mailboxes as emails, or "all" for every Workspace mailbox (gmail: an empty list means the team-side contacts\' inboxes)'), + .describe('in the source\'s own terms: "#channel"; "owner/repo"; a Granola folder title; a Notion page/database URL or id; a Figma file URL or key (not a Slides deck); a Jira project key (ACM) or "board:293"; a Linear team key (PRP — the prefix on its issue ids; widening only when the client has no Linear source yet on a self-hosted install, since each client needs its own key proxy); mailboxes as emails, or "all" for every Workspace mailbox (gmail: an empty list means the team-side contacts\' inboxes)'), site: z.string().optional().describe('jira only: https://.atlassian.net, for permalinks'), }, }, diff --git a/src/commands/source.ts b/src/commands/source.ts index 516790e..373a6ad 100644 --- a/src/commands/source.ts +++ b/src/commands/source.ts @@ -25,12 +25,20 @@ import { authorizeWrite } from '../write.js' */ export interface SourceAddInput { - /** slack | github | granola | notion | figma | jira | gmail */ + /** slack | github | granola | notion | figma | jira | linear | gmail */ kind: string - /** Identifiers in the source's own terms: channels, owner/repo, folder titles, Notion page URLs/ids, Figma file URLs/keys, Jira keys / board:, mailboxes ("all"). */ + /** Identifiers in the source's own terms: channels, owner/repo, folder titles, Notion page URLs/ids, Figma file URLs/keys, Jira keys / board:, Linear team keys, mailboxes ("all"). */ scope: string[] /** Jira only: https://.atlassian.net, for permalinks (and the API when no proxy). */ site?: string + /** + * Linear only, when creating the block: the client's GraphQL proxy and its + * uploads proxy. Each Linear key belongs to one client's workspace, so there + * is no machine-wide proxy to default to (Purposely's is `linear`, Marble's + * `linear-marble`); self-hosted, a new Linear block needs these. + */ + apiBase?: string + uploadsBase?: string } export interface SourceAddOptions extends ResolveOptions { @@ -77,6 +85,8 @@ export interface SourceSummary { const REPO_RE = /^[\w.-]+\/[\w.-]+$/ const EMAIL_RE = /^[^@\s]+@[^@\s]+\.[^@\s]+$/ const JIRA_KEY_RE = /^[A-Z][A-Z0-9_]+$/ +/** Matches the config schema's Linear team key rule. */ +const LINEAR_TEAM_RE = /^[A-Z][A-Z0-9]{0,9}$/ const FIGMA_URL_RE = /^(?:https?:\/\/)?(?:www\.)?figma\.com\/(design|file|board|deck|slides|proto)\/([A-Za-z0-9]{8,})(?:[/?#]|$)/ /** Sources whose credential is a token the host cannot hold in its environment on a self-hosted install. */ @@ -86,6 +96,8 @@ const NEEDS_PROXY: Record | und notion: 'notion', figma: 'figma', jira: 'jira', + // Per-client keys: a new block takes its proxy from --api-base, not ~/.lore/config.json. + linear: undefined, granola: undefined, gmail: undefined, } @@ -103,7 +115,7 @@ export async function sourceAdd(cwd: string, input: SourceAddInput, opts: Source const existing = sources[kind] const global = readGlobalConfig() - const plan = applyScope(kind as SourceName, existing, input.scope, input.site, global) + const plan = applyScope(kind as SourceName, existing, input.scope, input.site, global, { apiBase: input.apiBase, uploadsBase: input.uploadsBase }) if (plan.added.length === 0 && !plan.reenabled && !plan.changed) { return { source: kind as SourceName, @@ -179,7 +191,14 @@ interface Plan { * Pure: the new source block for `kind` given the existing one (if any) and * the scope entries to add. Exported for tests; `sourceAdd` does the I/O. */ -export function applyScope(kind: SourceName, existing: Record | undefined, scope: string[], site: string | undefined, global: GlobalConfig): Plan { +export function applyScope( + kind: SourceName, + existing: Record | undefined, + scope: string[], + site: string | undefined, + global: GlobalConfig, + bases: { apiBase?: string; uploadsBase?: string } = {}, +): Plan { if (kind === 'github_projects') throw new Error('source: configure sources.github_projects in lore.json with owner, number, and an explicit status_map; see docs/GITHUB_PROJECTS_SOURCE.md') const entries = scope.map((s) => s.trim()).filter(Boolean) const proxy = global.proxy ?? {} @@ -297,6 +316,32 @@ export function applyScope(kind: SourceName, existing: Record | if (res.added.length) next.push('the Jira account behind the host\'s credentials must be able to browse the project/board') break } + case 'linear': { + const teams = entries.map((t) => t.toUpperCase()) + if (!teams.length) throw new Error('source: linear needs at least one team key, e.g. PRP') + for (const t of teams) if (!LINEAR_TEAM_RE.test(t)) throw new Error(`source: "${t}" is not a Linear team key (uppercase, e.g. PRP — the prefix on its issue ids)`) + res = merge('teams', teams) + const { apiBase, uploadsBase } = bases + if ((apiBase || uploadsBase) && existing) { + // Re-pointing a working block at another key is a human edit, not a scope change. + if ((apiBase && apiBase !== block.api_base) || (uploadsBase && uploadsBase !== block.uploads_base)) { + throw new Error('source: sources.linear already says how it authenticates — change api_base / uploads_base in lore.json by hand') + } + } + if (!existing) { + if (apiBase) { + block.api_base = apiBase + if (uploadsBase) block.uploads_base = uploadsBase + else next.push('no --uploads-base: files pasted into issues will not import until sources.linear.uploads_base points at a proxy for uploads.linear.app with the same key') + } else if (global.remote) { + throw new Error( + "source: a Linear key belongs to one client's workspace, so the self-hosted host needs this client's own proxies — create them (`ssh exe.dev integrations add http-proxy --name linear- --target https://api.linear.app --header Authorization: --attach tag:lore`, and the same for https://uploads.linear.app), then pass --api-base https://linear-.int.exe.xyz/graphql --uploads-base https://linear-uploads-.int.exe.xyz", + ) + } else block.token = 'env:LINEAR_API_KEY' + } + if (res.added.length) next.push(`the Linear user behind the key must be a member of ${res.added.join(', ')} (private teams are invisible otherwise); until then the sync reports the team as not found`) + break + } case 'gmail': { const lower = entries.map((e) => e.toLowerCase()) const all = lower.includes('all') @@ -384,6 +429,8 @@ export function scopeOf(name: string, c: Record): string[] { return [...list(c.files), ...list(c.projects).map((p) => `project:${p}`)] case 'jira': return [...list(c.projects), ...list(c.boards).map((b) => `board:${b}`)] + case 'linear': + return list(c.teams) case 'gmail': return c.users === 'all' ? ['all mailboxes'] : list(c.users).length ? list(c.users) : ['team contacts'] default: diff --git a/test/source.test.ts b/test/source.test.ts index dd61a67..1affb50 100644 --- a/test/source.test.ts +++ b/test/source.test.ts @@ -121,6 +121,41 @@ test('applyScope: jira merges projects and boards and can set the site later; gm assert.deepEqual(covered.block, { users: 'all', admin: 'o@x.com' }) }) +test('applyScope: linear widens teams; a new self-hosted block needs this client\'s own proxies, never a machine-wide one', () => { + const marble = { teams: ['MDEV', 'MDES'], api_base: 'https://linear-marble.int.exe.xyz/graphql', uploads_base: 'https://linear-uploads-marble.int.exe.xyz' } + const hosted = { remote: 'exedev@lore-host:/srv/lore/repos', proxy: PROXY } + const w = applyScope('linear', marble, ['mar2', 'MDEV'], undefined, hosted) + assert.deepEqual(w.block, { ...marble, teams: ['MDEV', 'MDES', 'MAR2'] }) + assert.deepEqual(w.added, ['MAR2']) + assert.deepEqual(w.already, ['MDEV']) + assert.match(w.next[0], /member of MAR2/) + assert.deepEqual(scopeOf('linear', w.block), ['MDEV', 'MDES', 'MAR2']) + + assert.throws(() => applyScope('linear', marble, ['MAR-2'], undefined, hosted), /not a Linear team key/) + assert.throws(() => applyScope('linear', marble, [], undefined, hosted), /at least one team key/) + assert.throws(() => applyScope('linear', marble, ['MAR2'], undefined, hosted, { apiBase: 'https://linear.int.exe.xyz/graphql' }), /by hand/) + // Passing the bases the block already has is harmless. + assert.deepEqual(applyScope('linear', marble, ['MAR2'], undefined, hosted, { apiBase: marble.api_base }).added, ['MAR2']) + + assert.throws(() => applyScope('linear', undefined, ['PRP'], undefined, hosted), /--api-base/) + const fresh = applyScope('linear', undefined, ['prp'], undefined, hosted, { apiBase: 'https://linear-acme.int.exe.xyz/graphql', uploadsBase: 'https://linear-uploads-acme.int.exe.xyz' }) + assert.deepEqual(fresh.block, { teams: ['PRP'], api_base: 'https://linear-acme.int.exe.xyz/graphql', uploads_base: 'https://linear-uploads-acme.int.exe.xyz' }) + assert.match(applyScope('linear', undefined, ['PRP'], undefined, hosted, { apiBase: 'https://l.example/graphql' }).next[0], /--uploads-base/) + // Not self-hosted: the env ref, as `lore setup` writes it. + assert.deepEqual(applyScope('linear', undefined, ['PRP'], undefined, {}).block, { teams: ['PRP'], token: 'env:LINEAR_API_KEY' }) +}) + +test('source add: linear end to end — validated against the schema, written, audited', async () => { + const root = makeContextRepo() + const r = await sourceAdd(root, { kind: 'linear', scope: ['PRP'] }, { context: root }) + assert.equal(r.created, true) + assert.deepEqual(readConfig(root).sources.linear, { teams: ['PRP'], token: 'env:LINEAR_API_KEY' }) + const r2 = await sourceAdd(root, { kind: 'linear', scope: ['MAR2'] }, { context: root }) + assert.deepEqual(r2.added, ['MAR2']) + assert.deepEqual(readConfig(root).sources.linear.teams, ['PRP', 'MAR2']) + assert.deepEqual(readAudit(root).map((a) => a.source), ['PRP', 'MAR2']) +}) + test('source list: every source with its scope, auth mode, and health from state.json', async () => { const root = makeContextRepo( { 'state.json': JSON.stringify({ cursors: {}, sources: { slack: { lastAttempt: 't', lastSuccess: '2026-09-18T10:00:00Z' }, github: { lastAttempt: 't', lastError: { at: '2026-09-18T10:00:00Z', message: 'repo x/y not found' } } } }) },