@ory/cline 0.11.1 → 0.12.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.
package/README.md CHANGED
@@ -1,112 +1,136 @@
1
1
  # Ory Agent Plugin: Cline
2
2
 
3
- [Ory](https://ory.com) bundled into [Cline](https://github.com/cline/cline): skills that scaffold Ory authentication into your codebase, a local Ory stack you can spin up in one command, and (when pointed at an Ory project) authentication, authorization, and audit for every tool Cline runs.
3
+ Security and developer experience for [Cline](https://github.com/cline/cline), powered by [Ory](https://ory.com).
4
4
 
5
- You don't need an Ory account or any prior Ory experience to start.
5
+ **Security.** Cline runs real actions on your machine — editing files, running shell commands, calling APIs. The plugin gives every session a verifiable identity (you sign in once; Cline and any sub-agents it spawns each get their own), checks every tool call against permissions you control, and records each decision as an audit trace you can ship to your observability stack. It starts in watch mode so nothing is blocked on day one, and if Ory is ever unreachable it steps aside rather than locking you out.
6
6
 
7
- This integration uses Cline's **file-based hooks** (not the in-process SDK) and is verified against cline@3.0.29.
7
+ **Developer experience.** A single command installs the plugin and walks you through connecting — choose Ory Network, a local Docker stack, or audit-only, and it wires up the project, sign-in client, login, and permissions for you. It also helps you build Ory into your own app: ask in plain language to scaffold login, registration, and recovery pages, run a local Ory, or manage identities and permissions through the bundled MCP server.
8
8
 
9
- ## New to Ory?
9
+ ## What you'll need
10
10
 
11
- [Ory](https://www.ory.com/docs/) is an open-source identity and access platform — login, registration, sessions, social sign-in, multi-factor auth, and fine-grained permissions, so you don't have to build any of that yourself. Two things make it easy to try with no prior experience:
11
+ - [Cline](https://github.com/cline/cline), installed (verified against cline@3.0.29)
12
+ - Node.js **22 or newer**
13
+ - [Docker](https://docs.docker.com/get-docker/) — only if you want to run Ory locally
14
+ - macOS or Linux (Windows works via WSL2)
12
15
 
13
- - **Ory Elements** are prebuilt, themeable UI components for the auth pages. The scaffolding skills wire them into your app for you.
14
- - **The local Ory stack** is a complete Ory running on your laptop in Docker — no account, no signup, no API key.
16
+ ## Get started
15
17
 
16
- ## What this plugin does
18
+ Run one command. It installs the plugin and walks you through connecting:
17
19
 
18
- Two independent things, and you can use either on its own:
19
-
20
- 1. **Build auth into your app.** Have Cline scaffold Ory login, registration, social sign-in, and permissions into the project you're working on, backed by the local stack. This needs nothing but Docker.
21
- 2. **Govern the agent itself.** Authenticate Cline's own session and authorize every tool it runs against Ory Permissions, with a full audit trail. See [Agent security](#agent-security).
20
+ ```bash
21
+ npx -y -p @ory/cline ory-cline install
22
+ ```
22
23
 
23
- ## Prerequisites
24
+ You'll be asked how you want to connect — **press Enter for the default**:
24
25
 
25
- - [Cline](https://github.com/cline/cline) installed
26
- - Node.js **≥ 22**
27
- - [Docker](https://docs.docker.com/get-docker/) (only needed for the local Ory stack)
28
- - macOS or Linux. Windows works via WSL2.
26
+ - **Ory Network** *(default)* — sign in, or create a free account, in your browser. The project, keys, permissions, and login are all set up for you. Nothing to configure by hand.
27
+ - **Local** — run a complete Ory on your laptop with Docker. No account, no signup, no keys. Great for trying it out.
28
+ - **Audit-only** skip Ory entirely and just log what Cline does.
29
29
 
30
- ## Install
30
+ That's it. Confirm everything landed with:
31
31
 
32
32
  ```bash
33
- npx -y -p @ory/cline ory-cline install
33
+ npx -y -p @ory/cline ory-cline status
34
34
  ```
35
35
 
36
- Cline discovers hooks by directory — the presence of an executable script named after the event *is* the registration. `install` writes one thin shell shim per event into the workspace hooks directory `<project>/.clinerules/hooks/` (or `~/.cline/hooks/` with `--global`), `chmod 0755`s each, and materializes the Ory skills. Each shim execs the published hook binary via `npx`.
36
+ `status` is your one-stop check: what's configured, who's signed in, which tools are covered by permissions, and recent activity. Anything not set up yet shows as `(unset)`.
37
37
 
38
- ```bash
39
- npx -y -p @ory/cline ory-cline install --global # install for all projects
40
- npx -y -p @ory/cline ory-cline status # confirm what landed
41
- npx -y -p @ory/cline ory-cline uninstall # remove only the Ory shims + skills
42
- ```
38
+ > Re-run install with `--reconfigure` to change your connection later, or `--no-configure` to skip the wizard and configure by hand. Add `--global` to install for every project (`~/.cline/hooks/`) instead of just this one.
43
39
 
44
- Install and uninstall both respect hook scripts you authored. If an event name is already taken by a script the Ory installer didn't write (matched by a marker comment), install leaves it untouched, skips that event, and prints a warning listing the skipped events — move or remove your script and re-run the install if you want Ory to handle them. Existing Ory shims are refreshed in place, and uninstall removes only the scripts the Ory installer wrote.
40
+ ## What you get
45
41
 
46
- ## Quickstart (≈ 3 minutes)
42
+ Once connected, every task and tool call Cline runs is governed by Ory — three things happen automatically:
47
43
 
48
- From any project where you'd like Ory authentication, inside Cline:
44
+ - **Who's driving.** You sign in once in your browser; Cline gets its own identity too, and registers it automatically on first run — no tokens to copy around. The "who acted on whose behalf" trail stays queryable later.
45
+ - **What it's allowed to do.** Before a tool runs, Ory checks whether it's permitted. It starts in **watch mode** — nothing is blocked, you just *see* what would be — so it never gets in your way on day one.
46
+ - **A record of everything.** Every decision (allowed, denied, skipped) is logged as a trace you can send to Jaeger, Honeycomb, Grafana, or just a file.
49
47
 
50
- 1. **Start a local Ory instance.** Ask Cline *"start the local Ory stack"* or invoke the `ory-local-up` skill. A banner prints the seeded test user's email and password — note them.
51
- 2. **Scaffold Ory into your project.** Ask Cline *"add Ory auth to this app"* (the `ory-auth-setup` skill). It installs Ory Elements, wires the SDK, and generates the login / registration / recovery / settings pages, all targeting the local stack.
52
- 3. **Sign in.** Start your app, visit the login page, and sign in with the seeded credentials. You now have a real Ory session backed by a real Ory stack — locally, offline, zero configuration.
48
+ If Ory is ever unreachable, the plugin gets out of the way and lets Cline keep working so it can't lock you out.
53
49
 
54
- Continue to [Agent security](#agent-security) when you're ready to enforce.
50
+ ### See what's happening
55
51
 
56
- ## How the integration works
52
+ Everything the plugin does is observable out of the box — no configuration required:
57
53
 
58
- Cline runs each hook script as a **subprocess**, passing the event payload as JSON on stdin and reading a JSON decision on stdout. A hook blocks a tool call by returning `{"cancel":true}`. Cline does **not** expose a separate approval-ask hook, so the plugin gates at the tool-call event. Hooks have a 30-second timeout.
54
+ - **Status at a glance.** `npx -y -p @ory/cline ory-cline status` shows what's configured, who's signed in, how many built-in tools your permissions cover, and the most recent tool-call activity.
55
+ - **Live traces.** Every tool call is recorded as an OpenTelemetry-style span. Watch them stream as the agent works:
59
56
 
60
- The hook script filenames are PascalCase (`TaskStart`, `PreToolUse`, …); the payload Cline delivers on stdin carries the matching snake_case event name (`agent_start`, `tool_call`, …) the plugin acts on. The shims wire into these phases:
57
+ ```bash
58
+ npx -y -p @ory/cline ory-cline watch
59
+ ```
61
60
 
62
- - **TaskStart** (`agent_start`) — run the user and agent auth gates.
63
- - **PreToolUse** (`tool_call`) check the tool against Ory Permissions; deny blocks the call (`{"cancel":true}`) in enforce mode.
64
- - **PostToolUse / TaskComplete / TaskCancel / TaskError / UserPromptSubmit / PreCompact / SessionShutdown** — trace-only audit spans.
61
+ Spans are also written to `~/.config/ory-agent-plugins/cline/ory-agent-trace.ndjson` (NDJSON, one span per line) — tail that file, or point `OTEL_EXPORTER_OTLP_ENDPOINT` at a collector to ship them straight to Jaeger, Honeycomb, or Grafana.
62
+ - **Debug log.** For a verbose play-by-play, set `ORY_AGENT_DEBUG=true`; structured logs land in `~/.config/ory-agent-plugins/cline/ory-agent-debug.log`.
65
63
 
66
- The plugin is **fail-open** on its own infrastructure failures (network errors, rate limits, missing config): the agent always starts, and enforcement is only as strong as your permission grants.
64
+ ### Ready to enforce?
67
65
 
68
- ## Agent security
66
+ When the watch-mode logs look right, turn on blocking with one command (setup already granted you the built-in tools):
69
67
 
70
- Once pointed at an Ory project (local or hosted), Cline's task and every tool call can be governed by Ory.
68
+ ```bash
69
+ npx -y -p @ory/cline ory-cline permissions enforce
70
+ ```
71
71
 
72
- - **Authentication.** The human at the keyboard (the **user**) authenticates interactively via Ory Identities when user login is on (`ORY_USER_LOGIN=true`, off by default browser PKCE flow on first session, persisted thereafter). The Cline process (the **agent**) gets its own OAuth2 identity via [Dynamic Client Registration (RFC 7591)](https://datatracker.ietf.org/doc/html/rfc7591) on first run.
73
- - **Authorization.** Before any tool runs, the plugin checks [Ory Permissions](https://www.ory.com/docs/keto) (Zanzibar-style relations) against the user's subject and blocks on `deny`.
74
- - **Audit.** Every decision is recorded as a structured trace span (NDJSON file and/or OTLP export).
72
+ Now a denied tool is actually blocked and Cline shows why. Go back to watch mode anytime with `permissions observe`. Use `permissions status` to see what's covered and `permissions bootstrap` to (re-)grant the built-in tools.
75
73
 
76
- ### Permission modes: observe enforce
74
+ ## Also: add login to your own app
77
75
 
78
- After install the plugin runs in **observe mode**: every tool call is checked, but a deny is recorded as a `permission.observe_deny` audit span and the tool runs anyway.
76
+ Beyond securing Cline, the plugin helps you build Ory into whatever you're working on. Ask Cline *"add Ory login to this app"* and it scaffolds the login, registration, recovery, and settings pages (using [Ory Elements](https://github.com/ory/elements)) wired to a local Ory — no signup or keys needed. These are **skills**: just ask in plain language and the matching one takes over.
79
77
 
80
- ```bash
81
- # Grant the current user `use` on every built-in tool (idempotent):
82
- npx -y -p @ory/cline ory-cline permissions bootstrap
78
+ Start that local Ory with the `ory-local-up` skill (it prints a test email + password to sign in with) and tear it down with `ory-local-down`. It runs the Ory APIs at `http://localhost:4000`, a login UI on `:4455` (not :3000, to avoid Next.js port conflicts), the Ory Console on `:4100`, and Jaeger on `:16686`. More bundled skills cover login flows, social sign-in (Google, GitHub, Apple…), permissions onboarding, and playbooks for wiring Ory into your own agents, E2B sandboxes, or Temporal workers.
83
79
 
84
- # See allowed/denied per tool:
85
- npx -y -p @ory/cline ory-cline permissions status
80
+ ## Configure by hand (CI / advanced)
86
81
 
87
- # Turn on hard blocking once the observe-mode logs look right:
88
- npx -y -p @ory/cline ory-cline permissions enforce
82
+ The guided setup covers most people. For scripted or CI setups, or to point at an existing Ory Network project, configure directly. Settings are saved to `~/.config/ory-agent-plugins/config.json` and shared across all your Ory agent plugins; environment variables win when both are set.
83
+
84
+ ```bash
85
+ npx -y -p @ory/cline ory-cline configure \
86
+ --project-url https://<slug>.projects.oryapis.com \
87
+ --oauth2-client-id <sign-in client id> \
88
+ --user-login
89
89
  ```
90
90
 
91
- Switch back any time with `permissions observe`. To disable Ory entirely (audit logging only), run `ory-cline configure --audit-only`.
91
+ Cline's own identity registers itself automatically on first run — nothing to create. The `--oauth2-client-id` is the one piece browser sign-in needs (a **public sign-in client** registered with the loopback URLs `http://127.0.0.1:47823..47826/callback`); the guided setup makes it for you. For logging-only with no checks, use `--audit-only`. Enable browser sign-in persistently with `--user-login`, or per-session with `ORY_USER_LOGIN=true` (the env var overrides the saved config).
92
92
 
93
- ## Pointing at a real Ory project
93
+ With nothing configured, the plugin still loads and runs in **pass-through mode**: skills and logging work, but no checks run and nothing is blocked. Perfectly fine if you only want the app-building features.
94
94
 
95
- The Quickstart uses the local stack. To point at a hosted [Ory Network](https://console.ory.sh) project:
95
+ <details>
96
+ <summary>How the integration works</summary>
96
97
 
97
- ```bash
98
- npx -y -p @ory/cline ory-cline configure \
99
- --project-url https://<id>.projects.oryapis.com \
100
- --oauth2-client-id <public OAuth2 client id>
98
+ Cline discovers hooks by directory — the presence of an executable script named after the event *is* the registration. `install` writes one thin shell shim per event into the workspace hooks directory `<project>/.clinerules/hooks/` (or `~/.cline/hooks/` with `--global`), makes each executable, and materializes the Ory skills. Each shim execs the published hook binary via `npx`. Install and uninstall respect hook scripts you authored: if an event name is already taken by a script Ory didn't write, install skips it and prints a warning; uninstall removes only the scripts Ory wrote.
99
+
100
+ Cline runs each hook as a **subprocess**, passing the event as JSON on stdin and reading a JSON decision on stdout. A hook blocks a tool call by returning `{"cancel":true}`. Cline does **not** expose a separate approval-ask hook, so the plugin gates at the tool-call event. Hooks have a 30-second timeout.
101
+
102
+ The hook filenames are PascalCase (`TaskStart`, `PreToolUse`, …); the payload Cline delivers carries the matching snake_case event name (`agent_start`, `tool_call`, …) the plugin acts on. The shims wire into these phases:
103
+
104
+ - **TaskStart** (`agent_start`) — signs the user in and gives Cline its identity.
105
+ - **PreToolUse** (`tool_call`) — checks the tool against your permissions; a deny blocks the call in enforce mode.
106
+ - **PostToolUse / TaskComplete / TaskCancel / TaskError / UserPromptSubmit / PreCompact / SessionShutdown** — audit-only trace spans.
107
+
108
+ </details>
109
+
110
+ ## Commands
111
+
112
+ ```
113
+ ory-cline install | uninstall Install/remove; --global for all projects, --reconfigure re-runs setup, --no-configure skips it
114
+ ory-cline status Show configuration, identities, permission coverage, recent activity
115
+ ory-cline watch Tail the live trace stream (OTel spans)
116
+ ory-cline permissions <cmd> status | bootstrap | observe (watch) | enforce (block)
117
+ ory-cline configure <flags> Point at a project by hand (--project-url, --oauth2-client-id, --user-login, --audit-only)
118
+ ory-cline agent <status|unregister> Manage Cline's own auto-created identity
101
119
  ```
102
120
 
103
- `--oauth2-client-id` is required whenever `--project-url` is set — the user PKCE flow needs a public OAuth2 client registered with the four loopback redirect URIs (`http://127.0.0.1:47823..47826/callback`). See the [repo README](../../README.md) and [`AGENTS.md`](../../AGENTS.md) for the full environment-variable reference and permission-mode semantics. Config is shared across every Ory agent plugin at `~/.config/ory-agent-plugins/config.json`.
121
+ All prefixed with `npx -y -p @ory/cline`.
122
+
123
+ ## Troubleshooting
104
124
 
105
- Without configuration the plugin still loads cleanly and runs in **pass-through mode**: skills work, but nothing is blocked.
125
+ - **Local Ory fails to start** make sure Docker is running and ports `4000`, `4100`, `4455`, and `16686` are free.
126
+ - **Browser sign-in loops** — reset with `ory-cline agent unregister` and try again.
127
+ - **`npx` grabbed an old version** — force the latest: `npx -y -p @ory/cline@latest ory-cline …`.
128
+ - **A hook didn't install** — check the install output for a skipped-event warning; move or remove your own script at that event name and re-run install.
129
+ - **Want to see what's happening** — `npx -y -p @ory/cline ory-cline status` for a snapshot, `npx -y -p @ory/cline ory-cline watch` for the live trace stream, or set `ORY_AGENT_DEBUG=true` for a verbose log. Traces and logs live under `~/.config/ory-agent-plugins/cline/` (see [See what's happening](#see-whats-happening)).
106
130
 
107
- ## Links
131
+ ## Learn more
108
132
 
109
- - [Ory documentation](https://www.ory.com/docs/)
133
+ - [Ory documentation](https://www.ory.com/docs/) · [Ory Console](https://console.ory.sh) · [Ory Elements](https://github.com/ory/elements)
110
134
  - [Cline repository](https://github.com/cline/cline)
111
135
  - [Repo README](../../README.md) and [AGENTS.md](../../AGENTS.md) — full env-var and permission-mode reference
112
136
 
package/dist/cli/main.js CHANGED
@@ -56,14 +56,19 @@ function main() {
56
56
  const [command, ...args] = process.argv.slice(2);
57
57
  switch (command) {
58
58
  case "install":
59
+ (0, argus_1.beginDeferNextSteps)();
59
60
  install(args);
60
- postInstallPermissions("ory-cline", "cline").then(() => process.exit(0), (err) => {
61
+ (0, argus_1.runPostInstall)("ory-cline", "cline", args).then(() => process.exit(0), (err) => {
61
62
  console.error(err.message ?? err);
62
63
  process.exit(1);
63
64
  });
64
65
  break;
65
66
  case "uninstall":
66
67
  uninstall(args);
68
+ (0, argus_1.clearCredentialsForUninstall)().then(() => process.exit(0), (err) => {
69
+ console.error(err.message ?? err);
70
+ process.exit(1);
71
+ });
67
72
  break;
68
73
  case "configure":
69
74
  (0, argus_1.runConfigureCommand)("ory-cline", args);
@@ -95,6 +100,9 @@ function main() {
95
100
  process.exit(1);
96
101
  });
97
102
  break;
103
+ case "watch":
104
+ (0, argus_1.runWatchCommand)("cline", args);
105
+ break;
98
106
  case "help":
99
107
  case "--help":
100
108
  case "-h":
@@ -125,12 +133,6 @@ function runSetup(args) {
125
133
  process.argv = ["node", "setup.js", ...args];
126
134
  require("./setup.js");
127
135
  }
128
- async function postInstallPermissions(binName, harness) {
129
- const bootstrapped = await (0, argus_1.maybeAutoBootstrap)(binName, harness);
130
- (0, argus_1.printPermissionsOnboardingHelp)(binName, harness, {
131
- bootstrappedAutomatically: bootstrapped,
132
- });
133
- }
134
136
  async function status() {
135
137
  await (0, argus_1.runStatusCommand)("ory-cline", "cline", {
136
138
  title: "Cline",
@@ -149,7 +151,7 @@ function help() {
149
151
  ory-cline — Ory plugin for Cline
150
152
 
151
153
  Usage:
152
- npx ory-cline <command> [options]
154
+ npx -y -p @ory/cline ory-cline <command> [options]
153
155
 
154
156
  Commands:
155
157
  install [--global] Install the Ory hook scripts into Cline
@@ -159,6 +161,7 @@ Commands:
159
161
  permissions <cmd> Manage permission mode and tool permissions (status, bootstrap, observe, enforce)
160
162
  setup [options] Write hook scripts directly to the hooks directory (fallback)
161
163
  status Show plugin status and configuration
164
+ watch [trace-file] Tail the trace stream (OTel spans) live
162
165
  local <cmd> Manage local Ory dev environment (up, down, status, seed, ...)
163
166
 
164
167
  After installing, the per-event hook scripts wire into these Cline lifecycle events:
@@ -167,10 +170,10 @@ After installing, the per-event hook scripts wire into these Cline lifecycle eve
167
170
  PostToolUse Audit log tool executions
168
171
 
169
172
  Examples:
170
- npx ory-cline install # Install hook scripts into ./.clinerules/hooks
171
- npx ory-cline install --global # Install into ~/.cline/hooks
172
- npx ory-cline status # Check configuration
173
- npx ory-cline uninstall # Remove hook scripts
173
+ npx -y -p @ory/cline ory-cline install # Install hook scripts into ./.clinerules/hooks
174
+ npx -y -p @ory/cline ory-cline install --global # Install into ~/.cline/hooks
175
+ npx -y -p @ory/cline ory-cline status # Check configuration
176
+ npx -y -p @ory/cline ory-cline uninstall # Remove hook scripts
174
177
  `);
175
178
  }
176
179
  main();
package/dist/cli/setup.js CHANGED
@@ -170,6 +170,18 @@ function main() {
170
170
  console.warn("");
171
171
  }
172
172
  console.log(`Ory skills installed to ${path.join(rulesRoot, "skills")}`);
173
- (0, argus_1.printNextSteps)("Cline", "npx ory-cline-setup --uninstall");
173
+ (0, argus_1.printNextSteps)("Cline", "npx -y -p @ory/cline ory-cline-setup --uninstall", {
174
+ binName: "ory-cline",
175
+ harness: "cline",
176
+ });
174
177
  }
175
178
  main();
179
+ // When invoked directly as the `-setup` bin with `--uninstall`, also clear
180
+ // stored Ory credentials. When required by the plugin's main CLI, that
181
+ // command owns the purge, so the `require.main` guard prevents a double run.
182
+ if (require.main === module && process.argv.includes("--uninstall")) {
183
+ (0, argus_1.clearCredentialsForUninstall)().then(() => process.exit(0), (err) => {
184
+ console.error(err.message ?? err);
185
+ process.exit(1);
186
+ });
187
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ory/cline",
3
- "version": "0.11.1",
3
+ "version": "0.12.0",
4
4
  "description": "Ory plugin for Cline: scaffolding skills, a local Ory instance, and authentication, authorization, and audit for every tool call",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://ory.com",
@@ -66,7 +66,7 @@
66
66
  "!dist/**/*.tsbuildinfo"
67
67
  ],
68
68
  "dependencies": {
69
- "@ory/argus": "0.11.1"
69
+ "@ory/argus": "0.12.0"
70
70
  },
71
71
  "devDependencies": {
72
72
  "typescript": "^6.0.2",