@repogo/plugins 0.1.38 → 0.1.40

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.
Files changed (2) hide show
  1. package/README.md +66 -9
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -69,6 +69,14 @@ Pages beside an environment plugin (`pages/*.ui`, or `pages/*.md`) open from
69
69
  any project as `~/.repogo/plugins/<name>/pages/<page>.ui`. A
70
70
  `.ui` page is card markup with no fence; a `.md` page is writing with cards.
71
71
 
72
+ In the full iOS app, `~/.repogo/plugins/plugin.ui` supplies a shared Plugins
73
+ tab. A project’s `.repogo/plugin.ui` overrides the entire page for that
74
+ project; entries are not merged. If neither exists, the tab is absent.
75
+ Both are plain card markup without a code fence. Read and preserve existing
76
+ entries, and link to plugin pages with `page:` actions.
77
+
78
+ A user-facing plugin needs both its saved page and a link from the applicable `plugin.ui`. Saving a file in `.repogo/tabs` or naming it `index.ui` does not register a project tab. Plugin discovery can list a page without a navigation entry; verify the effective `plugin.ui` links to the existing page.
79
+
72
80
  ## Methods
73
81
 
74
82
  ```ts
@@ -161,14 +169,14 @@ plugin, another plugin, or another project.
161
169
 
162
170
  `namespace` names where a plugin's data lives: the folder
163
171
  `~/.repogo/plugin-data/<namespace>/`, holding `data.db` and its streams' and
164
- buckets' files. A plugin that keeps data (any collection, kv, stream or bucket)
165
- must name one, or it fails to load. Plugins naming the same namespace share its
172
+ buckets' files. A plugin with any collection, kv, stream, bucket, cached method
173
+ or workflow must name one, or it fails to load. Plugins naming the same namespace share its
166
174
  data, in any project, so they must declare the same schemas.
167
175
 
168
176
  By convention a project's own data is `<project>.<name>` (`myproject.notes`),
169
177
  and data meant for every project a bare name (`todos`). That's only a
170
178
  convention: the same namespace is the same data. Data stays put when a project
171
- moves. A plugin with no data has no folder.
179
+ moves. A plugin without storage, cached methods or workflows needs no data folder.
172
180
 
173
181
  ### Collections
174
182
 
@@ -664,16 +672,25 @@ in `?`), and every line of `~/.repogo/crons.json` with how it's going.
664
672
  `plugins` with `plugin` set answers that plugin in full: each method's input
665
673
  and output JSON Schema and confirm, its `storage` (each bucket's and stream's
666
674
  folder), the pages that show its methods, and the cron lines naming it.
667
- `plugin_call` runs one. Call a new method once before a card names it.
675
+ `plugin_call` runs one. Inspect a method's schema before naming it in a card.
676
+ Verify query fields with a read-only call. Do not execute mutations just to
677
+ check a card; run them only when the user's task calls for that action.
668
678
 
669
679
  **Cards** name methods as `plugin:<plugin>.<method>`. A `Data` element runs a
670
- query, or follows a stream, and redraws when its data changes; a `Button` or
671
- `Item` action runs a mutation:
680
+ query, or follows a stream, and redraws when its data changes. `Button`,
681
+ `Item` and `Swipe` actions call methods; on iOS, `Toggle` can call one on a
682
+ user flip. `Upload` calls a plugin method with staged files. Params must match
683
+ the discovered input schema. These fragments assume `q` and `note` are supplied
684
+ by the enclosing card:
672
685
 
673
686
  ```xml
674
687
  <Data name="photos" method="plugin:gallery.photos.search">
675
688
  <Param name="query" value="{{q}}"/>
676
- <Each in="photos" as="p"><Item label="{{p.name}}" subtitle="{{p.meta.caption}}"/></Each>
689
+ <List>
690
+ <Section label="Photos">
691
+ <Each in="photos" as="p"><Item label="{{p.name}}" subtitle="{{p.meta.caption}}"/></Each>
692
+ </Section>
693
+ </List>
677
694
  </Data>
678
695
  <Button label="Mark done" action="plugin:notes.notes.update">
679
696
  <Param name="id" value="{{note.id}}"/>
@@ -681,6 +698,46 @@ query, or follows a stream, and redraws when its data changes; a `Button` or
681
698
  </Button>
682
699
  ```
683
700
 
701
+ ### Saving from a switch
702
+
703
+ Prefer SDK storage for plugin-owned data. A storage declaration generates
704
+ methods; ordinary saves do not need a custom mutation. For example:
705
+
706
+ ```ts
707
+ // .repogo/plugins/preferences/app.ts
708
+ import { definePlugin, z } from "@repogo/plugins";
709
+
710
+ export default definePlugin({
711
+ namespace: "myproject.preferences",
712
+ kv: { flags: z.boolean() },
713
+ });
714
+ ```
715
+
716
+ On iOS this card saves through the generated `preferences.flags.set` method:
717
+
718
+ ```xml
719
+ <Toggle name="alerts" label="Notifications" value="false"
720
+ action="plugin:preferences.flags.set">
721
+ <Param name="key" value="alerts"/>
722
+ <Param name="value" value="{{alerts}}" type="boolean"/>
723
+ </Toggle>
724
+ ```
725
+
726
+ The example starts at a literal `false`; it does not load a saved value.
727
+ `Toggle.value` is not a data binding. A page parameter with the declared state
728
+ name can supply an initial value; read existing settings before opening the
729
+ page with that parameter. User edits then take precedence.
730
+
731
+ Only a user flip calls the method, with the new value. The switch is disabled
732
+ while saving or awaiting confirmation. Failure or cancelled confirmation rolls
733
+ back its own edit; a newer edit is preserved. Errors appear beside the control.
734
+ An optional local `then` runs after success. Without `action`, a Toggle stays
735
+ local. Toggle source actions are not yet implemented by the Android/web renderers.
736
+
737
+ Inside plugin code, `ctx.kv.flags.set("alerts", true)` saves the same value.
738
+ The generated `preferences.flags.get({ key: "alerts" })` returns an entry with
739
+ `value` and timestamps, while `ctx.kv.flags.get("alerts")` returns the value alone.
740
+
684
741
  ## Errors and confirmations
685
742
 
686
743
  Throw `new MethodError(code, message)` for a failure the caller should read:
@@ -690,8 +747,8 @@ schema answers `VALIDATION` with a message per field. Anything else thrown is
690
747
 
691
748
  A method's `confirm` is asked before a card's tap runs it. An agent's
692
749
  `plugin_call` gets it back as a `CONFIRM` error until it calls again with
693
- `confirmed: true`, once the user agrees. Only `ctx.call` from plugin code skips
694
- it. Give one to anything that can't be undone. `{{field}}` in the question is
750
+ `confirmed: true`, once the user agrees. Ordinary `ctx.call` from plugin code skips
751
+ it; an unattended workflow refuses confirmation-gated methods. Give one to anything that can't be undone. `{{field}}` in the question is
695
752
  filled from the call's input, so it can say what it acts on:
696
753
  `confirm: "Restart {{machine}}?"`.
697
754
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repogo/plugins",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "description": "Write RepoGo plugins: collections and methods over SQLite that agents and cards call",
5
5
  "type": "module",
6
6
  "exports": {