ochreui 0.0.1 → 0.0.2

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
@@ -18,6 +18,7 @@
18
18
  <a href="https://www.npmjs.com/package/ochreui"><img src="https://img.shields.io/npm/v/ochreui?label=npm&color=4f46e5" alt="npm version"></a>
19
19
  <img src="https://img.shields.io/badge/Angular-22%2B-4f46e5" alt="Angular 22 or later">
20
20
  <img src="https://img.shields.io/badge/dependencies-0-4f46e5" alt="Zero dependencies">
21
+ <a href="https://socket.dev/npm/package/ochreui"><img src="https://badge.socket.dev/npm/package/ochreui" alt="Socket badge"></a>
21
22
  <a href="https://github.com/ochreui/ochre/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-4f46e5" alt="MIT license"></a>
22
23
  </p>
23
24
 
@@ -132,6 +133,8 @@ Dark mode follows the system, or set `data-ui-theme="dark"` on `<html>`. More in
132
133
 
133
134
  Options: `--project`, `--path`, `--dry-run`, `--overwrite`, `--cwd`. Details in [Installation](https://ochreui.dev/docs/installation).
134
135
 
136
+ The CLI sends anonymous usage data (the command, component names, versions, OS family). Turn it off with `npx ochreui@latest telemetry off`, `OCHRE_TELEMETRY=0` or `DO_NOT_TRACK=1`; it's always off in CI. [What is sent](https://ochreui.dev/docs/telemetry).
137
+
135
138
  ## Ochre Pro
136
139
 
137
140
  Everything in this repo is free and MIT, and stays that way. [Ochre Pro](https://ochreui.dev/pricing) adds Pro components, full app screens and blocks for a one-time payment, installed with the same CLI.
package/cli/ochreui.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { createHash } from 'node:crypto';
2
+ import { createHash, randomUUID } from 'node:crypto';
3
3
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
4
4
  import { homedir } from 'node:os';
5
5
  import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
@@ -8,7 +8,9 @@ import { fileURLToPath } from 'node:url';
8
8
  const REGISTRY = process.env.OCHREUI_REGISTRY ?? join(dirname(fileURLToPath(import.meta.url)), '..', 'registry');
9
9
  const CONFIG = 'ochre.json';
10
10
  const API = (process.env.OCHREUI_API ?? 'https://ochreui.dev').replace(/\/+$/, '');
11
- const KEY_FILE = join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'ochreui', 'key');
11
+ const CONFIG_DIR = join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'ochreui');
12
+ const KEY_FILE = join(CONFIG_DIR, 'key');
13
+ const TELEMETRY_FILE = join(CONFIG_DIR, 'telemetry.json');
12
14
  const tty = process.stdout.isTTY && !process.env.NO_COLOR;
13
15
  const paint = (code) => (s) => (tty ? `\x1b[${code}m${s}\x1b[0m` : s);
14
16
  const bold = paint(1);
@@ -28,6 +30,7 @@ ${bold('Usage')}
28
30
  npx ochreui@latest add skill Add the Ochre skill for Claude Code and other agents
29
31
  npx ochreui@latest diff <component> Show what changed upstream since your copy
30
32
  npx ochreui@latest update [component...] Update copies you haven't edited
33
+ npx ochreui@latest telemetry [on|off] Show or change anonymous usage data
31
34
 
32
35
  ${bold('Options')}
33
36
  --project <name> Angular project to use (default: the first application)
@@ -41,6 +44,10 @@ ${bold('Pro components')}
41
44
  Set OCHRE_KEY to your access key, or save it in ~/.config/ochreui/key.
42
45
  Create a key at https://ochreui.dev/account.
43
46
 
47
+ ${bold('Telemetry')}
48
+ Anonymous usage data (command, component names, versions, OS). Off: ochreui telemetry off,
49
+ OCHRE_TELEMETRY=0 or DO_NOT_TRACK=1. Always off in CI. https://ochreui.dev/docs/telemetry
50
+
44
51
  Docs: https://ochreui.dev/docs/installation`;
45
52
 
46
53
  function parseArgs(argv) {
@@ -123,9 +130,12 @@ function accessKey() {
123
130
  const SAFE_FILE = /^[a-z0-9][a-z0-9/_.-]*$/;
124
131
 
125
132
  /** Downloads a Pro item with its file contents. Null when the server has no such item. */
126
- async function fetchPro(name) {
133
+ async function fetchPro(name, plan = 'pro') {
127
134
  const key = accessKey();
128
- if (!key) throw new CliError(`${name} is a Pro component. Set OCHRE_KEY to your access key, or save it in ${KEY_FILE}. Create one at https://ochreui.dev/account.`);
135
+ if (!key) {
136
+ const where = plan === 'complete' ? 'part of Ochre Complete' : 'an Ochre Pro item';
137
+ throw new CliError(`${name} is ${where}. Get it at https://ochreui.dev/pricing, then create an access key at https://ochreui.dev/account and set OCHRE_KEY (or save it in ${KEY_FILE}).`);
138
+ }
129
139
  let res;
130
140
  try {
131
141
  res = await fetch(`${API}/api/pro/registry/${encodeURIComponent(name)}`, { headers: { authorization: `Bearer ${key}`, accept: 'application/json' }, signal: AbortSignal.timeout(20_000) });
@@ -134,6 +144,7 @@ async function fetchPro(name) {
134
144
  }
135
145
  const body = await res.json().catch(() => null);
136
146
  if (res.status === 401) throw new CliError(`Your access key was refused: ${body?.error?.message ?? 'check it on https://ochreui.dev/account.'}`);
147
+ if (res.status === 403 && body?.error?.code === 'complete_required') throw new CliError(body.error.message);
137
148
  if (res.status === 403) throw new CliError(`${name} is a Pro component, and the account behind your key has no active Pro licence. See https://ochreui.dev/pricing.`);
138
149
  if (res.status === 404) return null;
139
150
  if (!res.ok || !Array.isArray(body?.item?.files)) throw new CliError(`Downloading ${name} failed (HTTP ${res.status}). Try again later.`);
@@ -151,7 +162,7 @@ async function withPro(registry, names) {
151
162
  const local = registry.byName.get(name);
152
163
  if (local && !local.pro) continue;
153
164
  if (!local && !accessKey()) continue;
154
- const item = await fetchPro(name);
165
+ const item = await fetchPro(name, local?.plan);
155
166
  if (item) registry.byName.set(name, item);
156
167
  else if (local) throw new CliError(`${local.title ?? name} is not available for download yet.`);
157
168
  }
@@ -466,16 +477,99 @@ async function update(names, flags) {
466
477
  if (!flags.dryRun) writeJson(ctx.configFile, ctx.config);
467
478
  }
468
479
 
480
+
481
+ /** Why telemetry is off, or null when it is on. */
482
+ function telemetryOff() {
483
+ const env = (k) => String(process.env[k] ?? '').trim().toLowerCase();
484
+ if (['0', 'false', 'off', 'no'].includes(env('OCHRE_TELEMETRY'))) return 'OCHRE_TELEMETRY is set';
485
+ if (env('DO_NOT_TRACK') && !['0', 'false'].includes(env('DO_NOT_TRACK'))) return 'DO_NOT_TRACK is set';
486
+ if (env('CI') && !['0', 'false'].includes(env('CI'))) return 'this looks like CI';
487
+ if (readTelemetryFile()?.enabled === false) return 'you turned it off';
488
+ return null;
489
+ }
490
+
491
+ function readTelemetryFile() {
492
+ try {
493
+ return JSON.parse(readFileSync(TELEMETRY_FILE, 'utf8'));
494
+ } catch {
495
+ return null;
496
+ }
497
+ }
498
+
499
+ function writeTelemetryFile(data) {
500
+ mkdirSync(CONFIG_DIR, { recursive: true });
501
+ writeFileSync(TELEMETRY_FILE, JSON.stringify(data, null, 2) + '\n');
502
+ }
503
+
504
+ /** The random install id, created (with a one-time notice) on the first run that sends anything. */
505
+ function installId() {
506
+ const file = readTelemetryFile();
507
+ if (file?.id) return file.id;
508
+ const id = randomUUID();
509
+ try {
510
+ writeTelemetryFile({ enabled: true, id });
511
+ } catch {
512
+ return null;
513
+ }
514
+ console.error(dim('Ochre counts which components get added, anonymously, to know what to improve. No paths, no code, nothing about you. Opt out anytime: npx ochreui telemetry off'));
515
+ return id;
516
+ }
517
+
518
+ /** Major version of @angular/core in the app at `cwd`, or undefined. */
519
+ function angularMajor(cwd) {
520
+ try {
521
+ const pkg = readJson(join(findWorkspace(cwd), 'package.json'));
522
+ const major = Number(String(pkg.dependencies?.['@angular/core'] ?? pkg.devDependencies?.['@angular/core'] ?? '').match(/\d+/)?.[0]);
523
+ return major > 0 && major < 100 ? major : undefined;
524
+ } catch {
525
+ return undefined;
526
+ }
527
+ }
528
+
529
+ /** Sends one anonymous event. Never throws, never waits more than a second. */
530
+ function track(event, items, flags) {
531
+ if (telemetryOff() || flags.dryRun) return Promise.resolve();
532
+ const id = installId();
533
+ if (!id) return Promise.resolve();
534
+ let cli;
535
+ try {
536
+ cli = loadRegistry().index.version;
537
+ } catch {
538
+ return Promise.resolve();
539
+ }
540
+ const os = ['darwin', 'linux', 'win32'].includes(process.platform) ? process.platform : 'other';
541
+ const body = { event, cli, angular: angularMajor(flags.cwd), os, id, items: items.filter((n) => /^[a-z0-9][a-z0-9-]{0,63}$/.test(n)).slice(0, 50) };
542
+ return fetch(`${API}/api/telemetry`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body), signal: AbortSignal.timeout(1000) })
543
+ .then(() => undefined)
544
+ .catch(() => undefined);
545
+ }
546
+
547
+ function telemetry([choice]) {
548
+ if (choice === 'off' || choice === 'on') {
549
+ const file = readTelemetryFile() ?? {};
550
+ writeTelemetryFile({ ...file, enabled: choice === 'on', id: file.id ?? randomUUID() });
551
+ console.log(choice === 'off' ? `${green('✓')} Telemetry is off. Nothing will be sent.` : `${green('✓')} Telemetry is on. Thanks: it shows which components to improve.`);
552
+ return;
553
+ }
554
+ if (choice) throw new CliError(`Use ochreui telemetry on, off, or no argument to see the status.`);
555
+ const off = telemetryOff();
556
+ console.log(off ? `Telemetry is off (${off}).` : 'Telemetry is on.');
557
+ console.log(dim(' Sent: the command, component names, the CLI and Angular major versions, the OS family and a random install id.'));
558
+ console.log(dim(' Never sent: file paths, project names, code, environment variables. https://ochreui.dev/docs/telemetry'));
559
+ }
560
+
469
561
  try {
470
562
  const { command, names, flags } = parseArgs(process.argv.slice(2));
471
563
  switch (command) {
472
564
  case 'add':
473
565
  await add(names, flags);
566
+ await track('add', names, flags);
474
567
  break;
475
568
  case 'init': {
476
569
  const ctx = context(flags);
477
570
  ctx.wasConfigured = !!ctx.config;
478
571
  init(ctx, loadRegistry(), flags);
572
+ await track('init', [], flags);
479
573
  break;
480
574
  }
481
575
  case 'list':
@@ -483,9 +577,14 @@ try {
483
577
  break;
484
578
  case 'diff':
485
579
  await diff(names, flags);
580
+ await track('diff', names, flags);
486
581
  break;
487
582
  case 'update':
488
583
  await update(names, flags);
584
+ await track('update', names, flags);
585
+ break;
586
+ case 'telemetry':
587
+ telemetry(names);
489
588
  break;
490
589
  case 'help':
491
590
  console.log(HELP);
package/mcp/docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.1",
2
+ "version": "0.0.2",
3
3
  "setup": "# Setup\n\nAdd a component: `npx ochreui@latest add <name>` (also pnpm dlx, yarn dlx, bunx). It copies the component as one file into `src/app/ui/<name>.ts`, and the first time also copies `ochre.css` (tokens and shared classes) into `src/styles/`, lists it first in the `styles` of angular.json, and writes `ochre.json`. Import from the copied file, e.g. `./ui/<name>`.\nThe files belong to the app. `ochreui diff <name>` shows upstream changes; `ochreui update` updates files that weren't edited and keeps edited ones unless `--force`.\nManual: download `/registry/ochre.css` into `src/styles/` and list it first in `styles`, then copy `/registry/<name>.ts` into `src/app/ui/`.\nRequirements: Angular 22+, standalone components; works with zone.js, zoneless and SSR. No other dependencies.\n\nTheming: every visual value is a `--ui-*` CSS variable. Override them on `:root` (and under `[data-ui-theme='dark']` for colors).\nScopes on <html> or any container: `data-ui-theme=\"light|dark\"` (no attribute = follow the system), `data-ui-density=\"comfortable|compact\"`, `data-ui-look=\"flat|tray\"`.\n`UiTheme` (`npx ochreui@latest add theme`, then import from `./ui/theme`) is an injectable with signals `mode`, `density`, `look` and a `toggle()` method; it applies and remembers the choice.\n\n## ochreui rules\n\n- Add components with `npx ochreui@latest add <name>`. It copies one file to `src/app/ui/<name>.ts` (the path in `ochre.json`); import from there, e.g. `import { … } from './ui/<name>'`. `UiTheme` comes from `add theme`.\n- Add components to the standalone component's `imports`. Selectors start with `ui-`.\n- Inputs are signals: bind with `[input]=\"value\"`, and use `[(x)]` for model inputs.\n- Components never change your data. Handle their outputs and update your own signals with new arrays and objects.\n- Style with `--ui-*` tokens and the component's own `--ui-<component>-*` variables. Never use `::ng-deep`. Prefer inputs and variables over editing the copied file, so `ochreui update` can keep it current.\n- No hard-coded colors next to Ochre: use `var(--ui-text)`, `var(--ui-bg-surface)`, `var(--ui-accent)` and the other tokens.\n- Dark mode: set `data-ui-theme` on `<html>` or inject `UiTheme`. Don't write per-theme component styles.\n- Give icon-only controls an `aria-label`. Pass translated strings through the `labels` input.\n- Before using a component, read its API with the Ochre MCP server (`get_component`) or its JSON file.",
4
4
  "components": [
5
5
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ochreui",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "license": "MIT",
5
5
  "peerDependencies": {
6
6
  "@angular/common": "^22.1.0",
@@ -29,6 +29,14 @@
29
29
  "types": "./types/ochreui.d.ts",
30
30
  "default": "./fesm2022/ochreui.mjs"
31
31
  },
32
+ "./agent-checkpoints": {
33
+ "types": "./types/ochreui-agent-checkpoints.d.ts",
34
+ "default": "./fesm2022/ochreui-agent-checkpoints.mjs"
35
+ },
36
+ "./agent-cursors": {
37
+ "types": "./types/ochreui-agent-cursors.d.ts",
38
+ "default": "./fesm2022/ochreui-agent-cursors.mjs"
39
+ },
32
40
  "./agent-team": {
33
41
  "types": "./types/ochreui-agent-team.d.ts",
34
42
  "default": "./fesm2022/ochreui-agent-team.mjs"
@@ -57,6 +65,10 @@
57
65
  "types": "./types/ochreui-change-summary.d.ts",
58
66
  "default": "./fesm2022/ochreui-change-summary.mjs"
59
67
  },
68
+ "./chat-composer": {
69
+ "types": "./types/ochreui-chat-composer.d.ts",
70
+ "default": "./fesm2022/ochreui-chat-composer.mjs"
71
+ },
60
72
  "./checkbox": {
61
73
  "types": "./types/ochreui-checkbox.d.ts",
62
74
  "default": "./fesm2022/ochreui-checkbox.mjs"
@@ -69,6 +81,10 @@
69
81
  "types": "./types/ochreui-color-picker.d.ts",
70
82
  "default": "./fesm2022/ochreui-color-picker.mjs"
71
83
  },
84
+ "./command-menu": {
85
+ "types": "./types/ochreui-command-menu.d.ts",
86
+ "default": "./fesm2022/ochreui-command-menu.mjs"
87
+ },
72
88
  "./comment-thread": {
73
89
  "types": "./types/ochreui-comment-thread.d.ts",
74
90
  "default": "./fesm2022/ochreui-comment-thread.mjs"
@@ -237,6 +253,10 @@
237
253
  "types": "./types/ochreui-resizable.d.ts",
238
254
  "default": "./fesm2022/ochreui-resizable.mjs"
239
255
  },
256
+ "./response-stream": {
257
+ "types": "./types/ochreui-response-stream.d.ts",
258
+ "default": "./fesm2022/ochreui-response-stream.mjs"
259
+ },
240
260
  "./scroll-area": {
241
261
  "types": "./types/ochreui-scroll-area.d.ts",
242
262
  "default": "./fesm2022/ochreui-scroll-area.mjs"
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.1",
2
+ "version": "0.0.2",
3
3
  "items": [
4
4
  {
5
5
  "name": "tokens",
@@ -2074,6 +2074,51 @@
2074
2074
  "name": "region-map.ts"
2075
2075
  }
2076
2076
  ]
2077
+ },
2078
+ {
2079
+ "name": "agent-checkpoints",
2080
+ "type": "component",
2081
+ "title": "Agent Checkpoints",
2082
+ "description": "An agent run as a line of checkpoints. Rewind to any of them and a new attempt branches out, while the old path stays visible.",
2083
+ "pro": true,
2084
+ "plan": "pro",
2085
+ "files": []
2086
+ },
2087
+ {
2088
+ "name": "command-menu",
2089
+ "type": "component",
2090
+ "title": "Command Menu",
2091
+ "description": "Search and run anything from one field: tool actions with logos and ⌘1–⌘5, everyday commands with icons, an \"Ask assistant\" row for anything else, and a gliding highlight. Inline, or in a dialog for ⌘K.",
2092
+ "pro": true,
2093
+ "plan": "pro",
2094
+ "files": []
2095
+ },
2096
+ {
2097
+ "name": "chat-composer",
2098
+ "type": "component",
2099
+ "title": "Chat Composer",
2100
+ "description": "The main input of an assistant that acts on tools: your own textarea, a plus menu, an approval mode, a model picker, voice input and send, over a tray with a folder picker and app connections.",
2101
+ "pro": true,
2102
+ "plan": "pro",
2103
+ "files": []
2104
+ },
2105
+ {
2106
+ "name": "agent-cursors",
2107
+ "type": "component",
2108
+ "title": "Agent Cursors",
2109
+ "description": "A shared document where AI agents work like teammates: live pointers with name flags, suggestions typed letter by letter, comment pins in the margin and faces you can follow.",
2110
+ "pro": true,
2111
+ "plan": "pro",
2112
+ "files": []
2113
+ },
2114
+ {
2115
+ "name": "response-stream",
2116
+ "type": "component",
2117
+ "title": "Response Stream",
2118
+ "description": "One agent answer through its whole life: words blur in behind a breathing caret, stop and continue from the exact word, retry after a failure, copy and regenerate when done, with steer and queued messages above it.",
2119
+ "pro": true,
2120
+ "plan": "pro",
2121
+ "files": []
2077
2122
  }
2078
2123
  ]
2079
2124
  }