From eb99481e22dd819238df4c800d1b81710e0fcfb3 Mon Sep 17 00:00:00 2001 From: Craig Carlyle Date: Tue, 13 Oct 2026 15:13:48 -0700 Subject: [PATCH 1/2] fix(search): accept --offset, which the more-results hint suggests ol search pointed at --offset for the next page of results, then rejected the option. It takes it now, the same way document list does. Co-Authored-By: Claude Opus 5.5 (1M context) --- README.md | 2 +- skills/outline-cli/SKILL.md | 1 + src/commands/commands.test.ts | 20 ++++++++++++++++++++ src/commands/search.ts | 2 ++ src/lib/skills/content.ts | 1 + 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d343d5e..248d25e 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ Self-hosted instances: pass `--base-url` or set `OUTLINE_URL` (you can still pro ```bash # Search -ol search "query" --limit 10 --collection --status published +ol search "query" --limit 10 --offset 10 --collection --status published # Documents (alias: ol doc) ol document list --collection --sort updatedAt --direction DESC diff --git a/skills/outline-cli/SKILL.md b/skills/outline-cli/SKILL.md index 198b965..dfacf21 100644 --- a/skills/outline-cli/SKILL.md +++ b/skills/outline-cli/SKILL.md @@ -41,6 +41,7 @@ Documents can be referenced by: ```bash ol search "query" ol search "query" --limit 10 +ol search "query" --offset 25 # next page of results ol search "query" --collection ol search "query" --status published ol search "query" --json diff --git a/src/commands/commands.test.ts b/src/commands/commands.test.ts index 87b643f..e9437ce 100644 --- a/src/commands/commands.test.ts +++ b/src/commands/commands.test.ts @@ -45,6 +45,26 @@ describe('search command', () => { expect(apiRequest).toHaveBeenCalledWith('documents.search', { query: 'test query', limit: 10, + offset: 0, + }) + }) + + it('passes --offset, which the "more results" hint points to', async () => { + const { apiRequest } = await import('../lib/api.js') + ;(apiRequest as ReturnType).mockResolvedValue({ + data: [], + pagination: { offset: 25, limit: 25 }, + }) + + const { registerSearchCommand } = await import('./search.js') + const program = createTestProgram(registerSearchCommand) + + await program.parseAsync(['node', 'ol', 'search', 'test query', '--offset', '25']) + + expect(apiRequest).toHaveBeenCalledWith('documents.search', { + query: 'test query', + limit: 25, + offset: 25, }) }) diff --git a/src/commands/search.ts b/src/commands/search.ts index f88f68b..1fe1aef 100644 --- a/src/commands/search.ts +++ b/src/commands/search.ts @@ -38,6 +38,7 @@ export function registerSearchCommand(program: Command): void { .command('search ') .description('Search documents') .option('--limit ', 'Max results', '25') + .option('--offset ', 'Pagination offset', '0') .option('--collection ', 'Filter by collection ID') .option('--status ', 'Filter by status (published|draft|archived)') .option('--json', 'Output JSON') @@ -47,6 +48,7 @@ export function registerSearchCommand(program: Command): void { const body: Record = { query, limit: Number(opts.limit), + offset: Number(opts.offset), } if (opts.collection) body.collectionId = opts.collection if (opts.status) body.statusFilter = [opts.status] diff --git a/src/lib/skills/content.ts b/src/lib/skills/content.ts index b1943e2..7980f31 100644 --- a/src/lib/skills/content.ts +++ b/src/lib/skills/content.ts @@ -40,6 +40,7 @@ Documents can be referenced by: \`\`\`bash ol search "query" ol search "query" --limit 10 +ol search "query" --offset 25 # next page of results ol search "query" --collection ol search "query" --status published ol search "query" --json From c5631fa653b77716b91f77ae170c9e4ccff7a430 Mon Sep 17 00:00:00 2001 From: Craig Carlyle Date: Tue, 13 Oct 2026 15:13:49 -0700 Subject: [PATCH 2/2] fix(output): keep the more-results hint out of JSON output With --json the hint was printed to stdout after the JSON, so `ol search --json | jq` failed whenever there was another page. In JSON mode it goes to stderr now. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/lib/output.test.ts | 18 ++++++++++++++++++ src/lib/output.ts | 12 ++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/lib/output.test.ts b/src/lib/output.test.ts index 71af51d..408f515 100644 --- a/src/lib/output.test.ts +++ b/src/lib/output.test.ts @@ -44,6 +44,24 @@ describe('output', () => { ]) }) + it('outputList human mode shows the pagination hint', () => { + outputList([item], formatter, keys, {}, { offset: 0, limit: 1, nextPath: '/next' }) + expect(lines(log).join('\n')).toContain('use --offset 1') + }) + + it('outputList json mode keeps the pagination hint out of stdout', () => { + const error = captureConsole('error') + outputList( + [item], + formatter, + keys, + { json: true }, + { offset: 0, limit: 1, nextPath: '/next' }, + ) + expect(JSON.parse(lines(log).join('\n'))).toEqual([{ id: '1', name: 'Test' }]) + expect(lines(error).join('\n')).toContain('use --offset 1') + }) + it('getOutputOptions parses flags', () => { expect(getOutputOptions({ json: true, full: true, ndjson: false })).toEqual({ json: true, diff --git a/src/lib/output.ts b/src/lib/output.ts index c7b105f..3cc55cd 100644 --- a/src/lib/output.ts +++ b/src/lib/output.ts @@ -66,11 +66,15 @@ export function outputList( } if (pagination?.nextPath && !opts.ndjson) { - console.log( - chalk.dim( - `\n(more results available — use --offset ${pagination.offset + pagination.limit})`, - ), + const hint = chalk.dim( + `\n(more results available — use --offset ${pagination.offset + pagination.limit})`, ) + // In JSON mode stdout holds the JSON itself, so the hint goes to stderr to keep it parseable. + if (opts.json) { + console.error(hint) + } else { + console.log(hint) + } } }