Skip to content

docs: document credential injection and the fork's npm package - #5

Merged
ajay-bhargava merged 1 commit into
mainfrom
docs/token-injection
Jul 27, 2026
Merged

docs: document credential injection and the fork's npm package#5
ajay-bhargava merged 1 commit into
mainfrom
docs/token-injection

Conversation

@ajay-bhargava

@ajay-bhargava ajay-bhargava commented Jul 27, 2026

Copy link
Copy Markdown
Member

AGENTS.md — token mode was undocumented

Credential injection is the reason this fork exists, but AGENTS.md had no entry for it. Added to Key Design Decisions, focused on the invariants that are easy to break silently:

  • pure consumer of an injected delegated Graph token — no keyring, no account files, no refresh, no persistence, process-scoped lifetime (with the why: a container-local keyring leaks a durable credential and races Microsoft's refresh-token rotation across concurrent containers)
  • newTokenMode() fails closed before any network call or credential-store access
  • expiry → exit 77 via the errTokenExpired sentinel; must not collapse into exit 1
  • nominalTokenLifetime (30 min) exists because a zero expiry makes the Azure SDK refuse to send the request
  • auth login|logout|clean|list refuse to run in this mode; --account rejected, --mailbox still works
  • the token must never reach output, errors, verbose logs, or MCP argv — token_test.go asserts it

Also records token.go in the project structure, token_test.go in the coverage list, and the test-bootstrap-npm.sh coverage in the CI section. Corrects the stale 0.9.5-pm.1 example to 1.10.0-pm.1 and notes that all seven npm names now exist.

README — pointed at the wrong package

The npm section said npm install -g olkcli / npx olkcli, which installs upstream's package. Now documents @planmonster/olkcli, notes the -pm.N suffix and the need to pin an exact version in an agent runner, and explains that only one platform binary is downloaded (~23 MB compressed, not all six).

Adds an ephemeral-runner example to the access-token section: npx plus environment-injected credentials, token deliberately kept out of argv, and an exit-code table an orchestrator can branch on:

Exit Meaning Action
0 success parse stdout
77 token expired, no request made mint fresh token, retry
80 usage error fix invocation, do not retry
1 runtime failure inspect stderr

docs/npm-publishing.md — troubleshooting

Documents the three real failures from the bootstrap: npm view 404 for ~3.5 min after publish (packument is the slowest read path — do not re-publish, check dist-tags or search instead), the git-shorthand misparse of a bare relative tarball path, and the prerelease dist-tag rule.

Testing

Docs-only, but the full gate set was run: go build, go test -race on internal/cmd, golangci-lint run (0 issues), test-npm-package.sh PASS, test-bootstrap-npm.sh PASS.


View with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is enabled.

AGENTS.md had no entry for token mode, even though it is the fork's reason to
exist. Adds it to Key Design Decisions, covering the parts an agent or
contributor can break without noticing:

- olk is a pure consumer of an injected delegated Graph token: no keyring, no
  account files, no refresh, no persistence; process-scoped lifetime. The reason
  is stated (a container-local keyring leaks a durable credential and races
  Microsoft's refresh-token rotation across concurrent containers).
- newTokenMode() fails closed before any network call or credential-store access.
- Expiry maps to exit 77 via the errTokenExpired sentinel; do not fold it into
  the generic exit 1.
- nominalTokenLifetime (30 min) exists because a zero expiry makes the Azure SDK
  refuse to send the request.
- auth login|logout|clean|list refuse to run in this mode; --account is rejected
  and --mailbox still works.
- The token must never reach output, errors, verbose logs, or MCP argv;
  token_test.go asserts it.

Also records token.go in the project structure, token_test.go in the coverage
list, and the test-bootstrap-npm.sh coverage in the CI section.

README's npm section pointed at upstream's unscoped `olkcli`, so a reader of
this fork would install the wrong package. It now documents
@planmonster/olkcli, notes the -pm.N suffix and the need to pin an exact
version in an agent runner, and explains that only one platform binary is
downloaded.

Adds an ephemeral-runner example to the access-token section: npx plus
environment-injected credentials, with the token kept out of argv, and an exit
code table (0, 77, 80, 1) an orchestrator can branch on.

docs/npm-publishing.md gains a troubleshooting section for the three failures
hit during the real bootstrap: npm view 404 for ~3.5 min after publish (the
packument is the slowest read path; do not re-publish), the git-shorthand
misparse of a bare relative tarball path, and the prerelease dist-tag rule.
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Documentation updates cover token-mode rules, forked npm installation and publishing constraints, ephemeral npx execution, and npm troubleshooting guidance.

Changes

Token Mode and npm Distribution

Layer / File(s) Summary
Token mode and repository guidance
AGENTS.md
Repository guidance documents token-mode behavior, coverage, CI checks, and forked npm distribution rules.
Fork installation and ephemeral execution
README.md
Installation uses @planmonster/olkcli, with examples for npx, injected tokens, exit-code handling, and MCP execution.
npm publishing troubleshooting
docs/npm-publishing.md
Publishing guidance covers npm replication delays, tarball paths, and explicit prerelease dist-tags.

Comment @coderabbitai help to get the list of available commands.

@ajay-bhargava
ajay-bhargava merged commit f3a6121 into main Jul 27, 2026
4 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7e2351bd-0a1c-457c-b581-d4c8a949766e

📥 Commits

Reviewing files that changed from the base of the PR and between 5ead2cb and c635c83.

📒 Files selected for processing (3)
  • AGENTS.md
  • README.md
  • docs/npm-publishing.md

Comment thread README.md
Comment on lines +270 to +278
Read the JSON envelope from stdout; `stderr` carries human hints only. Exit codes
an orchestrator should branch on:

| Exit | Meaning | Orchestrator action |
|------|---------|---------------------|
| `0` | success | parse stdout |
| `77` | injected token expired, **no request was made** | mint a fresh token, retry |
| `80` | usage error (bad flag or command) | fix the invocation; do not retry |
| `1` | runtime failure (Graph error, network) | inspect stderr, retry if transient |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Qualify exit code 77 as explicit-expiry validation only.

The implementation maps code 77 to an already-passed OLK_ACCESS_TOKEN_EXPIRES_AT; tokens without supplied expiry use the nominal lifetime and a later Graph 401 can remain a runtime failure. Update the table so orchestrators do not assume every expired token produces 77.

Proposed wording
-| `77` | injected token expired, **no request was made** | mint a fresh token, retry |
+| `77` | supplied token expiry was already passed; **no request was made** | mint a fresh token, retry |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Read the JSON envelope from stdout; `stderr` carries human hints only. Exit codes
an orchestrator should branch on:
| Exit | Meaning | Orchestrator action |
|------|---------|---------------------|
| `0` | success | parse stdout |
| `77` | injected token expired, **no request was made** | mint a fresh token, retry |
| `80` | usage error (bad flag or command) | fix the invocation; do not retry |
| `1` | runtime failure (Graph error, network) | inspect stderr, retry if transient |
Read the JSON envelope from stdout; `stderr` carries human hints only. Exit codes
an orchestrator should branch on:
| Exit | Meaning | Orchestrator action |
|------|---------|---------------------|
| `0` | success | parse stdout |
| `77` | supplied token expiry was already passed; **no request was made** | mint a fresh token, retry |
| `80` | usage error (bad flag or command) | fix the invocation; do not retry |
| `1` | runtime failure (Graph error, network) | inspect stderr, retry if transient |

Comment thread README.md
Comment on lines +280 to +285
For a tool-calling agent, run the MCP server instead — read-only by default, with
untrusted-content wrapping forced on:

```bash
npx -y @planmonster/olkcli@1.10.0-pm.1 mcp
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Pass token and safety variables to the MCP example.

The preceding env ... npx assignment applies only to that one process. This standalone command therefore does not inject OLK_ACCESS_TOKEN or the documented guard variables, so it may use stored-account/keyring mode instead of the promised ephemeral token mode.

Repeat the environment block here or provide a wrapper command that preserves it.

@ajay-bhargava
ajay-bhargava deleted the docs/token-injection branch July 28, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant