@repogo/plugins 0.1.29 → 0.1.31

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
@@ -28,6 +28,17 @@ data `<project>.<name>`. A bare name (`todos`) is shared by every plugin that
28
28
  names it, in any project, so they must agree on their collections' schemas.
29
29
  Data stays in place when the project moves. A plugin without collections has no file.
30
30
 
31
+ A plugin for every project goes in `~/.repogo/plugins/<name>/app.ts` instead
32
+ of a project's folder: the same shape, run with `ctx.root` set to whichever
33
+ project calls it. A project plugin of the same name takes precedence. Pages
34
+ beside it (`pages/*.md`) are reachable from any project as
35
+ `~/.repogo/plugins/<name>/pages/<page>.md`, and `~/.repogo/plugins/tab.json`
36
+ lists the pages every project's tab shows.
37
+
38
+ A method may alert the user's phones: `ctx.notify({ title, body, page })`, where
39
+ `page` is a page target a tap opens (`".repogo/tabs/vercel.md?project=a"`), and
40
+ `collapse` lets a repeated alert replace itself.
41
+
31
42
  Add it to `.repogo/plugins/package.json` (`bun add @repogo/plugins`) for types
32
43
  and editor help. The RepoGo host runs plugins with its own copy of this
33
44
  package, the version it shipped with, so a plugin always matches the host.
package/dist/context.d.ts CHANGED
@@ -1,4 +1,13 @@
1
1
  import type { Collection } from "./collections";
2
+ /** An alert for the user's phones: what it says, and the page a tap opens. */
3
+ export type Notice = {
4
+ title: string;
5
+ body: string;
6
+ /** A page target, `.repogo/tabs/vercel.md?project=a`; a tap opens it. */
7
+ page?: string;
8
+ /** Alerts sharing a collapse id replace one another; defaults to the plugin and title. */
9
+ collapse?: string;
10
+ };
2
11
  export type Context = {
3
12
  plugin: string;
4
13
  /** The project's checkout, for a plugin that reads the project's files. */
@@ -6,5 +15,7 @@ export type Context = {
6
15
  db: Record<string, Collection<any>>;
7
16
  call: (method: string, input?: unknown) => Promise<unknown>;
8
17
  emit: (name: string, payload: unknown) => Promise<void>;
18
+ /** Sends an alert to every phone paired with this environment. */
19
+ notify: (notice: Notice) => void;
9
20
  log: (...args: unknown[]) => void;
10
21
  };
package/dist/index.js CHANGED
@@ -33,7 +33,9 @@ function toCallError(error) {
33
33
  const fieldErrors = {};
34
34
  for (const issue of error.issues)
35
35
  fieldErrors["/" + issue.path.join("/")] ??= issue.message;
36
- return { code: "VALIDATION", message: "Check the highlighted fields.", fieldErrors };
36
+ const messages = Object.values(fieldErrors);
37
+ const message = messages.length === 1 ? messages[0] : "Check the highlighted fields.";
38
+ return { code: "VALIDATION", message, fieldErrors };
37
39
  }
38
40
  return { code: "INTERNAL", message: error instanceof Error ? error.message : String(error) };
39
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repogo/plugins",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "description": "Write RepoGo plugins: collections and methods over SQLite that agents and cards call",
5
5
  "type": "module",
6
6
  "exports": {