@repogo/plugins 0.1.25 → 0.1.27

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
@@ -10,6 +10,7 @@ import { definePlugin, method, z } from "@repogo/plugins";
10
10
 
11
11
  export default definePlugin({
12
12
  description: "Notes for this project",
13
+ db: "myproject.notes",
13
14
  collections: { notes: z.object({ text: z.string() }) },
14
15
  methods: {
15
16
  search: method(z.object({ text: z.string() }), async ({ text }, ctx) =>
@@ -21,6 +22,12 @@ export default definePlugin({
21
22
  });
22
23
  ```
23
24
 
25
+ `db` names the SQLite file the collections live in, `~/.repogo/plugin-data/<db>.db`
26
+ on the environment; left out, it is the plugin's folder name. Name a project's own
27
+ data `<project>.<name>`. A bare name (`todos`) is shared by every plugin that
28
+ names it, in any project, so they must agree on their collections' schemas.
29
+ Data stays in place when the project moves. A plugin without collections has no file.
30
+
24
31
  Add it to `.repogo/plugins/package.json` (`bun add @repogo/plugins`) for types
25
32
  and editor help. The RepoGo host runs plugins with its own copy of this
26
33
  package, the version it shipped with, so a plugin always matches the host.
@@ -20,11 +20,12 @@ export declare class Collection<S extends z.ZodObject> {
20
20
  private schema;
21
21
  private table;
22
22
  readonly tag: string;
23
- /** Writes run one at a time, so an update's read and write can't interleave with another's. */
23
+ /** This Worker's writes run one at a time; the transaction holds off other Workers. */
24
24
  private writes;
25
- constructor(sql: SQL, events: EventBus, plugin: string, name: string, schema: S);
25
+ constructor(sql: SQL, events: EventBus, plugin: string, db: string, name: string, schema: S);
26
26
  setup(): Promise<void>;
27
27
  private serial;
28
+ private transaction;
28
29
  create(input: z.input<S>): Promise<Record_<z.infer<S>>>;
29
30
  get(id: string): Promise<Record_<z.infer<S>> | null>;
30
31
  update(id: string, patch: Partial<z.input<S>>): Promise<Record_<z.infer<S>>>;
package/dist/define.d.ts CHANGED
@@ -24,6 +24,12 @@ export type Handler = (payload: any, ctx: Context) => unknown | Promise<unknown>
24
24
  export type PluginDefinition = {
25
25
  /** One line, shown to the agent in the index of plugins. */
26
26
  description?: string;
27
+ /**
28
+ * The data file the collections live in, `<db>.db` in the data dir; the
29
+ * plugin's folder name when left out. A project's own data is `<project>.<name>`
30
+ * (`repogo.plans`); a bare name (`todos`) is shared by every plugin that names it.
31
+ */
32
+ db?: string;
27
33
  collections?: Collections;
28
34
  methods?: Record<string, Method<any, any>>;
29
35
  on?: Record<string, Handler>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repogo/plugins",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "description": "Write RepoGo plugins: collections and methods over SQLite that agents and cards call",
5
5
  "type": "module",
6
6
  "exports": {