@doist/outline-cli 1.8.0 → 1.10.0

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 (38) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/commands/account.d.ts +2 -0
  3. package/dist/commands/account.js +107 -0
  4. package/dist/commands/account.js.map +1 -0
  5. package/dist/commands/auth.d.ts +0 -12
  6. package/dist/commands/auth.js +63 -28
  7. package/dist/commands/auth.js.map +1 -1
  8. package/dist/index.js +19 -4
  9. package/dist/index.js.map +1 -1
  10. package/dist/lib/api.js +20 -9
  11. package/dist/lib/api.js.map +1 -1
  12. package/dist/lib/auth-output.d.ts +21 -0
  13. package/dist/lib/auth-output.js +38 -0
  14. package/dist/lib/auth-output.js.map +1 -0
  15. package/dist/lib/auth-provider.d.ts +43 -17
  16. package/dist/lib/auth-provider.js +104 -36
  17. package/dist/lib/auth-provider.js.map +1 -1
  18. package/dist/lib/auth.d.ts +32 -11
  19. package/dist/lib/auth.js +54 -13
  20. package/dist/lib/auth.js.map +1 -1
  21. package/dist/lib/errors.d.ts +1 -1
  22. package/dist/lib/errors.js.map +1 -1
  23. package/dist/lib/global-args.d.ts +25 -0
  24. package/dist/lib/global-args.js +50 -1
  25. package/dist/lib/global-args.js.map +1 -1
  26. package/dist/lib/outline-account.d.ts +7 -1
  27. package/dist/lib/outline-account.js +10 -0
  28. package/dist/lib/outline-account.js.map +1 -1
  29. package/dist/lib/skills/content.d.ts +1 -1
  30. package/dist/lib/skills/content.js +23 -0
  31. package/dist/lib/skills/content.js.map +1 -1
  32. package/dist/lib/user-records.d.ts +8 -1
  33. package/dist/lib/user-records.js +17 -1
  34. package/dist/lib/user-records.js.map +1 -1
  35. package/dist/lib/user-ref-store.d.ts +16 -0
  36. package/dist/lib/user-ref-store.js +37 -0
  37. package/dist/lib/user-ref-store.js.map +1 -0
  38. package/package.json +2 -2
@@ -1,4 +1,5 @@
1
- import { createAccessibleGate, createGlobalArgsStore, createSpinnerGate } from '@doist/cli-core';
1
+ import { createAccessibleGate, createGlobalArgsStore, createSpinnerGate, parseGlobalArgs, stripUserFlag, } from '@doist/cli-core';
2
+ import { CliError } from './errors.js';
2
3
  const store = createGlobalArgsStore();
3
4
  export const getGlobalArgs = store.get;
4
5
  export const resetGlobalArgs = store.reset;
@@ -14,4 +15,52 @@ export function isJsonMode() {
14
15
  const args = store.get();
15
16
  return args.json || args.ndjson;
16
17
  }
18
+ /**
19
+ * Pre-subcommand `ol --user <ref>` selector. cli-core's `parseGlobalArgs`
20
+ * already extracts it from argv; `applyUserSelector` strips the flag before
21
+ * Commander parses, so this reads the value off the warmed cache.
22
+ */
23
+ export function getRequestedUserRef() {
24
+ return store.get().user;
25
+ }
26
+ /**
27
+ * Guard a root `--user` against the two common footguns before it's stripped:
28
+ * a value-less flag (`--user`, `--user=`) and a forgotten value where the next
29
+ * token is actually a command (`ol --user document list`). Pure — pass the
30
+ * pre-strip argv and the set of registered command names. Silent when `--user`
31
+ * is absent, or when it appears *after* a command (a late flag is left for
32
+ * Commander to reject as an unknown option, matching what `stripUserFlag`
33
+ * leaves in argv).
34
+ */
35
+ export function validateRootUserFlag(argv, knownCommands) {
36
+ const userIdx = argv.findIndex((a) => a === '--user' || a.startsWith('--user='));
37
+ if (userIdx === -1)
38
+ return;
39
+ const firstCmdIdx = argv.findIndex((a) => knownCommands.has(a));
40
+ if (firstCmdIdx !== -1 && userIdx > firstCmdIdx)
41
+ return;
42
+ const ref = parseGlobalArgs(argv).user;
43
+ if (!ref) {
44
+ throw new CliError('INVALID_USER_FLAG', '--user requires a value: <id|name>.', [
45
+ 'Example: ol --user scott@example.com document list',
46
+ ]);
47
+ }
48
+ if (knownCommands.has(ref)) {
49
+ throw new CliError('INVALID_USER_FLAG', `--user requires a value: got "${ref}", which looks like a command — did you forget the value?`, [`Example: ol --user scott@example.com ${ref}`]);
50
+ }
51
+ }
52
+ /**
53
+ * Entrypoint wiring for the global `--user` selector, kept here so the
54
+ * validate → warm-cache → strip order is exercised by tests rather than living
55
+ * untested in `src/index.ts`. Validates the root flag, warms the global-args
56
+ * cache off the *original* argv (so the ref survives), then rewrites
57
+ * `process.argv` with the flag stripped for Commander. Throws `INVALID_USER_FLAG`
58
+ * on a malformed root flag.
59
+ */
60
+ export function applyUserSelector(knownCommands) {
61
+ const original = process.argv.slice(2);
62
+ validateRootUserFlag(original, knownCommands);
63
+ getRequestedUserRef();
64
+ process.argv = [process.argv[0], process.argv[1], ...stripUserFlag(original)];
65
+ }
17
66
  //# sourceMappingURL=global-args.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"global-args.js","sourceRoot":"","sources":["../../src/lib/global-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAEhG,MAAM,KAAK,GAAG,qBAAqB,EAAE,CAAA;AAErC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,GAAG,CAAA;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,KAAK,CAAA;AAE1C,MAAM,CAAC,MAAM,YAAY,GAAG,oBAAoB,CAAC;IAC7C,MAAM,EAAE,eAAe;IACvB,OAAO,EAAE,KAAK,CAAC,GAAG;CACrB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;IAClD,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,KAAK,CAAC,GAAG;CACrB,CAAC,CAAA;AAEF,MAAM,UAAU,UAAU;IACtB,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAA;IACxB,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAA;AACnC,CAAC"}
1
+ {"version":3,"file":"global-args.js","sourceRoot":"","sources":["../../src/lib/global-args.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,e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AAW;QAAE,OAAM;IAEvD,MAAM,GAAG,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,CAAA;IACtC,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,MAAM,IAAI,QAAQ,CAAC,mBAAmB,EAAE,qCAAqC,EAAE;YAC3E,oDAAoD;SACvD,CAAC,CAAA;IACN,CAAC;IACD,IAAI,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,QAAQ,CACd,mBAAmB,EACnB,iCAAiC,GAAG,2DAA2D,EAC/F,CAAC,wCAAwC,GAAG,EAAE,CAAC,CAClD,CAAA;IACL,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,aAAkC;IAChE,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACtC,oBAAoB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAA;IAC7C,mBAAmB,EAAE,CAAA;IACrB,OAAO,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAA;AACjF,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { AuthAccount } from '@doist/cli-core/auth';
1
+ import type { AccountRef, AuthAccount } from '@doist/cli-core/auth';
2
2
  /**
3
3
  * Narrow account shape persisted by the keyring-backed token store.
4
4
  *
@@ -24,3 +24,9 @@ export declare function makeOutlineAccount(input: {
24
24
  oauthClientId?: string;
25
25
  teamName?: string;
26
26
  }): OutlineAccount;
27
+ /**
28
+ * Accepts the Outline user UUID or display name. Id matches are
29
+ * case-sensitive (UUIDs are canonical); label matches are case-insensitive
30
+ * so users can pass the name they see in `auth status`.
31
+ */
32
+ export declare function matchOutlineAccount(account: OutlineAccount, ref: AccountRef): boolean;
@@ -9,4 +9,14 @@ export function makeOutlineAccount(input) {
9
9
  teamName: input.teamName,
10
10
  };
11
11
  }
12
+ /**
13
+ * Accepts the Outline user UUID or display name. Id matches are
14
+ * case-sensitive (UUIDs are canonical); label matches are case-insensitive
15
+ * so users can pass the name they see in `auth status`.
16
+ */
17
+ export function matchOutlineAccount(account, ref) {
18
+ if (account.id === ref)
19
+ return true;
20
+ return account.label.toLowerCase() === ref.toLowerCase();
21
+ }
12
22
  //# sourceMappingURL=outline-account.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"outline-account.js","sourceRoot":"","sources":["../../src/lib/outline-account.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,MAAM,gBAAgB,GAAG,4BAA4B,CAAA;AAE5D,yEAAyE;AACzE,MAAM,UAAU,kBAAkB,CAAC,KAMlC;IACG,OAAO;QACH,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,gBAAgB;QAC1C,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,EAAE;QACxC,QAAQ,EAAE,KAAK,CAAC,QAAQ;KAC3B,CAAA;AACL,CAAC"}
1
+ {"version":3,"file":"outline-account.js","sourceRoot":"","sources":["../../src/lib/outline-account.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,MAAM,gBAAgB,GAAG,4BAA4B,CAAA;AAE5D,yEAAyE;AACzE,MAAM,UAAU,kBAAkB,CAAC,KAMlC;IACG,OAAO;QACH,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,gBAAgB;QAC1C,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,EAAE;QACxC,QAAQ,EAAE,KAAK,CAAC,QAAQ;KAC3B,CAAA;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAuB,EAAE,GAAe;IACxE,IAAI,OAAO,CAAC,EAAE,KAAK,GAAG;QAAE,OAAO,IAAI,CAAA;IACnC,OAAO,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE,CAAA;AAC5D,CAAC"}
@@ -1,3 +1,3 @@
1
1
  export declare const SKILL_NAME = "outline-cli";
2
2
  export declare const SKILL_DESCRIPTION = "Search and manage Outline wiki documents and collections via the ol CLI";
3
- export declare const SKILL_CONTENT = "# Outline CLI (ol)\n\nUse this skill when the user wants to interact with their Outline wiki/knowledge base.\n\n## Quick Reference\n\n- `ol search \"query\"` - Search documents\n- `ol doc list` - List documents\n- `ol doc get <id>` - Read a document\n- `ol doc open <id>` - Open document in browser\n- `ol doc create --title \"Title\" --collection <id>` - Create document\n- `ol col list` - List collections\n\n## Output Formats\n\nAll list commands support:\n- `--json` - JSON output (essential fields)\n- `--ndjson` - Newline-delimited JSON (streaming)\n- `--full` - Include all fields in JSON\n\n## Document References\n\nDocuments can be referenced by:\n- URL ID (the slug suffix after the last hyphen)\n- Full Outline URL (auto-extracted)\n- Document ID\n\n## Commands\n\n### Search\n```bash\nol search \"query\"\nol search \"query\" --limit 10\nol search \"query\" --collection <id>\nol search \"query\" --status published\nol search \"query\" --json\n```\n\n### Documents\n```bash\nol doc list --collection <id> --limit 25\nol doc list --sort title --direction ASC\nol doc get <id> # Rendered markdown\nol doc get <id> --raw # Raw markdown\nol doc get <id> --json\nol doc open <id> # Open in browser\nol doc create --title \"Title\" --collection <id> --text \"# Content\"\nol doc create --title \"Title\" --parent <ref> --text \"# Content\" # Nest under parent (collection inferred)\nol doc create --title \"Title\" --collection <id> --file ./doc.md\nol doc update <id> --title \"New Title\"\nol doc update <id> --file ./updated.md\nol doc move <id> --collection <target-id> # Move to collection root\nol doc move <id> --parent <ref> # Nest under parent (collection inferred)\nol doc archive <id>\nol doc unarchive <id>\nol doc delete <id> --confirm\n```\n\n### Collections\n```bash\nol col list\nol col get <id>\nol col create --name \"Name\" --description \"Desc\" --color \"#hex\"\nol col create --name \"Private\" --private\nol col update <id> --name \"New Name\"\nol col delete <id> --confirm\n```\n\n### Authentication\n```bash\nol auth login # OAuth login (opens browser); prompts for base URL + client ID if needed\nol auth login --base-url <url> # Specify Outline base URL for this login (saved for future use)\nol auth login --client-id <id> # Specify OAuth client ID for this login (saved for future use)\nol auth login --callback-port <port> # Override local OAuth callback port\nol auth login --read-only # Request read-only scopes (where supported by the Outline instance)\nol auth login --json | --ndjson # Machine-readable success envelope\nol auth status # Show current auth state\nol auth status --json | --ndjson # Machine-readable status envelope ({id, team, baseUrl, source})\nol auth logout # Clear saved credentials\nol auth logout --json | --ndjson # Machine-readable logout envelope ({ok: true}; --ndjson is silent)\n```\n\n### Update & Changelog\n```bash\nol update # Update CLI to latest version\nol update --check # Check for updates without installing, show channel\nol update --check --json # Check for updates as a JSON envelope\nol update --check --ndjson # Check for updates as NDJSON output\nol update --channel # Show current update channel\nol update switch --stable # Switch to stable release channel\nol update switch --pre-release # Switch to pre-release (next) channel\nol changelog # Show recent changelog entries\nol changelog -n 3 # Show last 3 versions\n```\n\n## Examples\n\n### Find and read a document\n```bash\nol search \"onboarding\" --json | jq '.[0].document.urlId'\nol doc get <urlId>\n```\n\n### Create a document from a file\n```bash\nol doc create --title \"Meeting Notes\" --collection <id> --file ./notes.md --publish\n```\n\n### List all collections and their documents\n```bash\nol col list --json\nol doc list --collection <id> --sort title --direction ASC\n```\n\n### Bulk export with ndjson\n```bash\nol doc list --ndjson --full | jq -r '.title'\n```\n";
3
+ export declare const SKILL_CONTENT = "# Outline CLI (ol)\n\nUse this skill when the user wants to interact with their Outline wiki/knowledge base.\n\n## Quick Reference\n\n- `ol search \"query\"` - Search documents\n- `ol doc list` - List documents\n- `ol doc get <id>` - Read a document\n- `ol doc open <id>` - Open document in browser\n- `ol doc create --title \"Title\" --collection <id>` - Create document\n- `ol col list` - List collections\n- `ol account` - List stored accounts; `ol account use <id|name>` sets the default\n\n## Output Formats\n\nAll list commands support:\n- `--json` - JSON output (essential fields)\n- `--ndjson` - Newline-delimited JSON (streaming)\n- `--full` - Include all fields in JSON\n\n## Global Options\n\n- `--user <id|name>` - Act as a specific stored account, matched by Outline user ID or display name. Each `ol auth login` stores an account (accounts can live on different Outline instances), and `--user` selects which one a command runs as; the token, base URL, and OAuth client ID all resolve from that account. Must be placed **before** the command, e.g. `ol --user scott@example.com doc list`. Omitted, commands use the default account. Overridden by `OUTLINE_API_TOKEN` when set.\n\n## Document References\n\nDocuments can be referenced by:\n- URL ID (the slug suffix after the last hyphen)\n- Full Outline URL (auto-extracted)\n- Document ID\n\n## Commands\n\n### Search\n```bash\nol search \"query\"\nol search \"query\" --limit 10\nol search \"query\" --collection <id>\nol search \"query\" --status published\nol search \"query\" --json\n```\n\n### Documents\n```bash\nol doc list --collection <id> --limit 25\nol doc list --sort title --direction ASC\nol doc get <id> # Rendered markdown\nol doc get <id> --raw # Raw markdown\nol doc get <id> --json\nol doc open <id> # Open in browser\nol doc create --title \"Title\" --collection <id> --text \"# Content\"\nol doc create --title \"Title\" --parent <ref> --text \"# Content\" # Nest under parent (collection inferred)\nol doc create --title \"Title\" --collection <id> --file ./doc.md\nol doc update <id> --title \"New Title\"\nol doc update <id> --file ./updated.md\nol doc move <id> --collection <target-id> # Move to collection root\nol doc move <id> --parent <ref> # Nest under parent (collection inferred)\nol doc archive <id>\nol doc unarchive <id>\nol doc delete <id> --confirm\n```\n\n### Collections\n```bash\nol col list\nol col get <id>\nol col create --name \"Name\" --description \"Desc\" --color \"#hex\"\nol col create --name \"Private\" --private\nol col update <id> --name \"New Name\"\nol col delete <id> --confirm\n```\n\n### Authentication\n```bash\nol auth login # OAuth login (opens browser); prompts for base URL + client ID if needed\nol auth login --base-url <url> # Specify Outline base URL for this login (saved for future use)\nol auth login --client-id <id> # Specify OAuth client ID for this login (saved for future use)\nol auth login --callback-port <port> # Override local OAuth callback port\nol auth login --read-only # Request read-only scopes (where supported by the Outline instance)\nol auth login --json | --ndjson # Machine-readable success envelope\nol auth status # Show current auth state\nol auth status --json | --ndjson # Machine-readable status envelope ({id, team, baseUrl, source})\nol auth logout # Clear saved credentials\nol auth logout --json | --ndjson # Machine-readable logout envelope ({ok: true}; --ndjson is silent)\nol auth token <token> # Save a personal API token (validates via auth.info, resolves identity)\nol auth token <token> --base-url <url> # Save a token for a specific Outline instance\nol auth token # Prompt for the token (hidden input; errors in non-interactive shells)\nol auth token view # Print the bare stored token to stdout for scripts (no newline when piped; refuses when OUTLINE_API_TOKEN is set)\nol --user <id|name> auth token view # Print a specific stored account's token (--user is a root flag, before the command)\n```\n\n### Accounts\n```bash\nol account # List stored accounts (default subcommand)\nol account list # List stored accounts, default marked\nol account list --json | --ndjson # Machine-readable list ({accounts, default}; --ndjson streams one per line)\nol account current # Show the active account (honours --user and OUTLINE_API_TOKEN)\nol account current --json | --ndjson # Discriminated by source: {source:\"stored\", account:{id, label, teamName, baseUrl, isDefault}} | {source:\"env\"} | {source:\"legacy\"}\nol account use <id|name> # Set the default account used when --user is omitted\nol account use <id|name> --json # Machine-readable envelope ({ok: true, default: <id>}; --ndjson is silent)\nol account remove <id|name> # Remove a stored account (clears keyring + config entry)\nol account remove <id|name> --json # Machine-readable envelope ({ok: true, removed: <id>}; --ndjson is silent)\n```\n\n### Update & Changelog\n```bash\nol update # Update CLI to latest version\nol update --check # Check for updates without installing, show channel\nol update --check --json # Check for updates as a JSON envelope\nol update --check --ndjson # Check for updates as NDJSON output\nol update --channel # Show current update channel\nol update switch --stable # Switch to stable release channel\nol update switch --pre-release # Switch to pre-release (next) channel\nol changelog # Show recent changelog entries\nol changelog -n 3 # Show last 3 versions\n```\n\n## Examples\n\n### Find and read a document\n```bash\nol search \"onboarding\" --json | jq '.[0].document.urlId'\nol doc get <urlId>\n```\n\n### Create a document from a file\n```bash\nol doc create --title \"Meeting Notes\" --collection <id> --file ./notes.md --publish\n```\n\n### List all collections and their documents\n```bash\nol col list --json\nol doc list --collection <id> --sort title --direction ASC\n```\n\n### Bulk export with ndjson\n```bash\nol doc list --ndjson --full | jq -r '.title'\n```\n";
@@ -12,6 +12,7 @@ Use this skill when the user wants to interact with their Outline wiki/knowledge
12
12
  - \`ol doc open <id>\` - Open document in browser
13
13
  - \`ol doc create --title "Title" --collection <id>\` - Create document
14
14
  - \`ol col list\` - List collections
15
+ - \`ol account\` - List stored accounts; \`ol account use <id|name>\` sets the default
15
16
 
16
17
  ## Output Formats
17
18
 
@@ -20,6 +21,10 @@ All list commands support:
20
21
  - \`--ndjson\` - Newline-delimited JSON (streaming)
21
22
  - \`--full\` - Include all fields in JSON
22
23
 
24
+ ## Global Options
25
+
26
+ - \`--user <id|name>\` - Act as a specific stored account, matched by Outline user ID or display name. Each \`ol auth login\` stores an account (accounts can live on different Outline instances), and \`--user\` selects which one a command runs as; the token, base URL, and OAuth client ID all resolve from that account. Must be placed **before** the command, e.g. \`ol --user scott@example.com doc list\`. Omitted, commands use the default account. Overridden by \`OUTLINE_API_TOKEN\` when set.
27
+
23
28
  ## Document References
24
29
 
25
30
  Documents can be referenced by:
@@ -80,6 +85,24 @@ ol auth status # Show current auth state
80
85
  ol auth status --json | --ndjson # Machine-readable status envelope ({id, team, baseUrl, source})
81
86
  ol auth logout # Clear saved credentials
82
87
  ol auth logout --json | --ndjson # Machine-readable logout envelope ({ok: true}; --ndjson is silent)
88
+ ol auth token <token> # Save a personal API token (validates via auth.info, resolves identity)
89
+ ol auth token <token> --base-url <url> # Save a token for a specific Outline instance
90
+ ol auth token # Prompt for the token (hidden input; errors in non-interactive shells)
91
+ ol auth token view # Print the bare stored token to stdout for scripts (no newline when piped; refuses when OUTLINE_API_TOKEN is set)
92
+ ol --user <id|name> auth token view # Print a specific stored account's token (--user is a root flag, before the command)
93
+ \`\`\`
94
+
95
+ ### Accounts
96
+ \`\`\`bash
97
+ ol account # List stored accounts (default subcommand)
98
+ ol account list # List stored accounts, default marked
99
+ ol account list --json | --ndjson # Machine-readable list ({accounts, default}; --ndjson streams one per line)
100
+ ol account current # Show the active account (honours --user and OUTLINE_API_TOKEN)
101
+ ol account current --json | --ndjson # Discriminated by source: {source:"stored", account:{id, label, teamName, baseUrl, isDefault}} | {source:"env"} | {source:"legacy"}
102
+ ol account use <id|name> # Set the default account used when --user is omitted
103
+ ol account use <id|name> --json # Machine-readable envelope ({ok: true, default: <id>}; --ndjson is silent)
104
+ ol account remove <id|name> # Remove a stored account (clears keyring + config entry)
105
+ ol account remove <id|name> --json # Machine-readable envelope ({ok: true, removed: <id>}; --ndjson is silent)
83
106
  \`\`\`
84
107
 
85
108
  ### Update & Changelog
@@ -1 +1 @@
1
- {"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/lib/skills/content.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAA;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAC1B,yEAAyE,CAAA;AAE7E,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsH5B,CAAA"}
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/lib/skills/content.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAA;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAC1B,yEAAyE,CAAA;AAE7E,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6I5B,CAAA"}
@@ -1,4 +1,4 @@
1
- import type { UserRecord, UserRecordStore } from '@doist/cli-core/auth';
1
+ import type { AccountRef, UserRecord, UserRecordStore } from '@doist/cli-core/auth';
2
2
  import { type Config } from './config.js';
3
3
  import { type OutlineAccount } from './outline-account.js';
4
4
  /**
@@ -12,3 +12,10 @@ export declare function createOutlineUserRecordStore(): UserRecordStore<OutlineA
12
12
  * Returns `null` when no users are stored.
13
13
  */
14
14
  export declare function getDefaultUserRecord(config: Partial<Config>): UserRecord<OutlineAccount> | null;
15
+ /**
16
+ * Resolve a `UserRecord` by `--user` ref (UUID or display name). Falls back to
17
+ * the default-or-first record when `ref` is absent, so callers can pass the
18
+ * global selector straight through. Returns `null` when no users are stored or
19
+ * an explicit ref matches nothing.
20
+ */
21
+ export declare function recordForRef(config: Partial<Config>, ref?: AccountRef): UserRecord<OutlineAccount> | null;
@@ -1,5 +1,5 @@
1
1
  import { getConfig, updateConfig } from './config.js';
2
- import { makeOutlineAccount } from './outline-account.js';
2
+ import { makeOutlineAccount, matchOutlineAccount } from './outline-account.js';
3
3
  /**
4
4
  * `UserRecordStore` adapter over `config.users[]`. `StoredUser.token` is
5
5
  * surfaced as `fallbackToken` — cli-core's name for the plaintext copy
@@ -54,6 +54,22 @@ export function getDefaultUserRecord(config) {
54
54
  const user = (defaultId && users.find((u) => u.id === defaultId)) || users[0];
55
55
  return toRecord(user);
56
56
  }
57
+ /**
58
+ * Resolve a `UserRecord` by `--user` ref (UUID or display name). Falls back to
59
+ * the default-or-first record when `ref` is absent, so callers can pass the
60
+ * global selector straight through. Returns `null` when no users are stored or
61
+ * an explicit ref matches nothing.
62
+ */
63
+ export function recordForRef(config, ref) {
64
+ if (ref === undefined)
65
+ return getDefaultUserRecord(config);
66
+ for (const user of config.users ?? []) {
67
+ const record = toRecord(user);
68
+ if (matchOutlineAccount(record.account, ref))
69
+ return record;
70
+ }
71
+ return null;
72
+ }
57
73
  function toRecord(user) {
58
74
  const account = makeOutlineAccount({
59
75
  id: user.id,
@@ -1 +1 @@
1
- {"version":3,"file":"user-records.js","sourceRoot":"","sources":["../../src/lib/user-records.ts"],"names":[],"mapp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QAAQ,CAAA;IACrE,MAAM,KAAK,GAAG,MAAM,CAAC,aAAa,EAAE,IAAI,EAAE,CAAA;IAC1C,IAAI,KAAK;QAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IAC7B,2EAA2E;IAC3E,yEAAyE;IACzE,0EAA0E;IAC1E,2EAA2E;IAC3E,8EAA8E;IAC9E,IAAI,MAAM,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QAC5C,IAAI,CAAC,uBAAuB,GAAG,MAAM,CAAC,oBAAoB,CAAA;IAC9D,CAAC;IACD,IAAI,MAAM,CAAC,qBAAqB,KAAK,SAAS,EAAE,CAAC;QAC7C,IAAI,CAAC,wBAAwB,GAAG,MAAM,CAAC,qBAAqB,CAAA;IAChE,CAAC;IACD,IAAI,MAAM,CAAC,eAAe,KAAK,SAAS;QAAE,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,eAAe,CAAA;IACzF,OAAO,IAAI,CAAA;AACf,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { OutlineTokenStore } from './auth-provider.js';
2
+ /**
3
+ * Bridge the global `ol --user <ref>` selector — stripped from argv before
4
+ * Commander parses (see `applyUserSelector`) — into store reads that make no
5
+ * explicit ref. An explicit `ref` argument always wins; only a missing one
6
+ * falls back to the global selector. Used by both the request path
7
+ * (`auth.ts` `tokenStore()`) and cli-core's auth attachers (`auth status` /
8
+ * `auth logout`), so a `--user` placed before any command is honoured
9
+ * everywhere.
10
+ *
11
+ * Existence is checked via `activeAccount(ref)` rather than `list()` so the
12
+ * check is both token-free (a keyring-offline account can still be cleared by
13
+ * `auth logout`) and legacy-aware (`list()` only exposes v2 records, but a
14
+ * pending v1→v2 migration can still resolve its single legacy account).
15
+ */
16
+ export declare function withUserRefAware(store: OutlineTokenStore): OutlineTokenStore;
@@ -0,0 +1,37 @@
1
+ import { CliError } from './errors.js';
2
+ import { getRequestedUserRef } from './global-args.js';
3
+ /**
4
+ * Bridge the global `ol --user <ref>` selector — stripped from argv before
5
+ * Commander parses (see `applyUserSelector`) — into store reads that make no
6
+ * explicit ref. An explicit `ref` argument always wins; only a missing one
7
+ * falls back to the global selector. Used by both the request path
8
+ * (`auth.ts` `tokenStore()`) and cli-core's auth attachers (`auth status` /
9
+ * `auth logout`), so a `--user` placed before any command is honoured
10
+ * everywhere.
11
+ *
12
+ * Existence is checked via `activeAccount(ref)` rather than `list()` so the
13
+ * check is both token-free (a keyring-offline account can still be cleared by
14
+ * `auth logout`) and legacy-aware (`list()` only exposes v2 records, but a
15
+ * pending v1→v2 migration can still resolve its single legacy account).
16
+ */
17
+ export function withUserRefAware(store) {
18
+ async function resolveRef(ref) {
19
+ const target = ref ?? getRequestedUserRef();
20
+ if (target === undefined)
21
+ return undefined;
22
+ if (!(await store.activeAccount(target))) {
23
+ throw new CliError('ACCOUNT_NOT_FOUND', `No stored account matches "${target}".`, [
24
+ 'Check the account id or display name, or run `ol auth login` to add it.',
25
+ ]);
26
+ }
27
+ return target;
28
+ }
29
+ return {
30
+ ...store,
31
+ active: async (ref) => store.active(await resolveRef(ref)),
32
+ activeBundle: async (ref) => store.activeBundle(await resolveRef(ref)),
33
+ activeAccount: async (ref) => store.activeAccount(await resolveRef(ref)),
34
+ clear: async (ref) => store.clear(await resolveRef(ref)),
35
+ };
36
+ }
37
+ //# sourceMappingURL=user-ref-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-ref-store.js","sourceRoot":"","sources":["../../src/lib/user-ref-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAEtD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAwB;IACrD,KAAK,UAAU,UAAU,CAAC,GAAgB;QACtC,MAAM,MAAM,GAAG,GAAG,IAAI,mBAAmB,EAAE,CAAA;QAC3C,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,SAAS,CAAA;QAC1C,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,QAAQ,CAAC,mBAAmB,EAAE,8BAA8B,MAAM,IAAI,EAAE;gBAC9E,yEAAyE;aAC5E,CAAC,CAAA;QACN,CAAC;QACD,OAAO,MAAM,CAAA;IACjB,CAAC;IAED,OAAO;QACH,GAAG,KAAK;QACR,MAAM,EAAE,KAAK,EAAE,GAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;QACvE,YAAY,EAAE,KAAK,EAAE,GAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;QACnF,aAAa,EAAE,KAAK,EAAE,GAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;QACrF,KAAK,EAAE,KAAK,EAAE,GAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;KACxE,CAAA;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/outline-cli",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "description": "CLI for the Outline wiki/knowledge base API",
5
5
  "type": "module",
6
6
  "bin": {
@@ -48,7 +48,7 @@
48
48
  "node": ">=20.18.1"
49
49
  },
50
50
  "dependencies": {
51
- "@doist/cli-core": "0.19.0",
51
+ "@doist/cli-core": "0.24.0",
52
52
  "chalk": "5.6.2",
53
53
  "commander": "14.0.2",
54
54
  "marked": "18.0.3",