@asterism-app/sdk 1.10.1 → 1.11.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,21 +1,21 @@
1
1
  # Asterism SDK
2
2
 
3
- The SDK defines the shared language between Asterism and plugins: contracts, host capabilities, and contributions.
3
+ The SDK is the shared boundary between Asterism and plugins. It supplies generic hosting capabilities while plugins own the meaning of their resources and workflows. Agent conversation and other paradigm-specific behavior belong to the plugin that implements them.
4
4
 
5
- Pure declarations can be shared across execution environments. Backend interfaces support work and persistence; frontend interfaces support presentation and interaction.
5
+ ## Design against a shared boundary
6
6
 
7
- The SDK describes generic mechanisms. Agent conversation, naming, and other domain behavior belong to the plugin that implements them.
7
+ Use public contracts to share meaning without importing another implementation. Their runtime identity matters as well as their TypeScript shape. Public abstractions should express capabilities consumers need, not reproduce internal decomposition.
8
8
 
9
- Public interfaces should express a capability an author needs. Internal decomposition is not itself a reason to expose another abstraction.
9
+ Keep backend work and frontend presentation separate while making each capability's ownership understandable. The host composes contributions; it does not infer domain behavior from a plugin's private state.
10
10
 
11
- ## Installation
11
+ ## Develop for the target application
12
12
 
13
- Install with `npm install --save-dev --save-exact @asterism-app/sdk@latest` to target the stable application, or `@next` to target the preview application. Declare `@asterism-app/sdk` as a peer dependency with `"*"` in the plugin package.
13
+ Use a compatible SDK version for development and treat the running application as the runtime provider. Development dependencies supply declarations; peer dependencies express the host-provided relationship. Installing a newer SDK does not upgrade the application's capabilities.
14
14
 
15
- The package ships TypeScript source. Asterism compiles plugin entries and supplies its own SDK instance at runtime. Use declarations compatible with the target application; installing a newer SDK does not update the application's APIs.
15
+ Validate both contract agreement and actual integration. Type checking cannot establish that a distributed plugin includes all required assets, works in the intended application, or releases the work it owns.
16
16
 
17
- ## Authoring material
17
+ ## Keep authoring material purposeful
18
18
 
19
- The source package includes `docs/` for plugin development guides and `examples/` for public API usage. `examples/counter/` is a complete starter package; the other examples are focused fragments to compose into a plugin. The application's manual exposes these directories directly.
19
+ The package includes prose guides and maintained source examples. Guides explain mental models, ownership, integration choices, and working principles; public declarations and examples carry concrete interfaces and assembly. The complete counter package provides a small design to adapt, not a required architecture for every plugin.
20
20
 
21
- Examples participate in repository type checking. Internal compile-time counterexamples live in `typechecks/` and are excluded from package contents and the manual. Built-in domain guides and examples belong to `@asterism-app/builtin-api`.
21
+ These materials support software use and plugin development on demand. Runtime tool descriptions, guidelines, and schemas own tool invocation knowledge independently of the manual.
@@ -1,133 +1,61 @@
1
1
  # Manage data and lifecycle
2
2
 
3
- Choose storage from the meaning of the data. Latest values, historical facts, immutable bytes, and running processes have different lifetimes.
3
+ Choose storage from the meaning of the data. Latest values, historical facts, immutable bytes, and running processes answer different questions and need different owners.
4
4
 
5
5
  ## Separate current state from history
6
6
 
7
- Current data records the latest session or object value. Historical records preserve facts needed to understand or reconstruct past work.
7
+ Current data answers what is true now. History explains what happened. Saving a current value is not a promise that browsing history will restore it; restoration needs a domain operation with a defined meaning.
8
8
 
9
- Saving a current value does not automatically create history. Moving to an earlier history position does not restore that value. A resource that supports restoration defines the facts and operations that make restoration meaningful.
9
+ For example, a counter can keep its latest value while recording each increment for explanation. A document editor may instead need a restorable body at each revision. Decide which experience the resource promises before choosing its records and current data.
10
10
 
11
- Plugin-wide private data belongs to the plugin. Temporary interface choices belong to a view or an object-retained view scope, according to how long they should survive.
11
+ Keep plugin-wide private data with the plugin. Keep temporary interface choices with the view unless users need them to survive reopening. A running process is neither saved data nor a historical fact: it needs a live owner and cleanup.
12
12
 
13
- ## Encode data at boundaries
13
+ ## Treat encoding as a domain boundary
14
14
 
15
- Data schemas describe the values used by plugin code and how they are decoded from stored or transported JSON. Writers, resource creation, tool results, and presentations accept the decoded value and encode it before storage or publication. Typed readers and views decode the saved value.
15
+ Use a codec when the value plugin code works with differs from its stored representation. Keep conversion semantics with that declaration rather than scattering normalization through readers and writers. A one-way input transformation and a reversible storage conversion solve different problems.
16
16
 
17
- Use an ordinary Zod schema when both representations are the same. Use a synchronous `z.codec` when they differ. Both the domain value and its encoding remain JSON-compatible. One-way `.transform()` belongs in input preparation or an explicit conversion before writing; Zod cannot encode it in reverse.
17
+ Check meaningful round trips for custom conversions. In particular, reading an old representation and writing a new one should preserve the domain value even when their JSON differs. Compatibility decoding can make an old fact readable without rewriting what was originally recorded.
18
18
 
19
- Resource creation returns a card title and plugin-owned `data`. State can be any JSON value, including arrays, scalars, or `null`; object fields such as `id`, `type`, and `title` retain their business meaning. The host stores resource identity and card title separately. Renaming a card changes its host title, and creating resources from a template gives them new host identities while preserving the encoded plugin state.
19
+ Separate host identity and presentation from business state. A domain field named “title” need not be the card title, and a domain identifier need not be the host resource identity. Conflating them makes renaming and reuse surprising.
20
20
 
21
- Configuration defaults are complete decoded values. Reading an older configuration may fill absent fields through ordinary `.default()` declarations. Configuration updates receive decoded values, and saving an unchanged value preserves a correctly defined codec's domain value. The host handles encoding of configuration files and frontend responses.
21
+ ## Decide what a template can reuse
22
22
 
23
- Codecs own their conversion semantics. Verify meaningful round trips when supplying custom encoders, decoders, or normalization callbacks. Tool results reserve `null` for absent output, so a non-null tool value needs a non-null encoding.
23
+ A data-copy template is appropriate when selected saved values remain meaningful under new host identities. A note can reuse its body; an Agent can reuse configuration without carrying pending work into a new session.
24
24
 
25
- ## Reuse resources in templates
25
+ Treat copying an address differently from cloning what it addresses. A resource that depends on an external account, embedded object identities, or private files may need an explicit domain-specific cloning operation instead of a data-copy template. Such an operation can explain what will be shared, copied, or reconnected.
26
26
 
27
- A resource opts into data-copy templates with `template: { current: [Settings, Content] }` in its implementation. The list contains existing data contracts owned by the resource's plugin. An empty list copies only the resource's creation state. Resources without this declaration remain available for ordinary use and do not appear in the template picker.
27
+ Choose titles according to the same distinction. Preserving a descriptive source title can help users recognize a reusable setup; generating a title can make sense when each instance represents new work.
28
28
 
29
- Templates retain encoded creation state and the listed current values that exist at save time. Unlisted current data, history, private files, and running instances are excluded. Instantiation creates new host identities and remaps host links; it preserves domain values and content references without rewriting embedded resource IDs or duplicating external services. Creation callbacks are not rerun, and ordinary presence lifetimes apply to the new objects.
29
+ ## Commit facts, then observe them
30
30
 
31
- To give each template instance a new title, add a synchronous `createTitle(): string` function to the resource's `template` declaration. Saving then omits the source title, including a user-assigned title. The host calls the function once for each new object when instantiating a template, and uses its result even if an older template contains a title. Saving and previewing templates do not call it. Without this function, templates preserve source titles; a saved entry without a title requires the generator to remain available.
31
+ Complete network and file processing outside synchronous transactions, then commit the resulting state. Keep the commit focused on the facts that must become visible together.
32
32
 
33
- Opt in when those copied values are reusable under new identities. For example, a note can retain its body, and an agent can retain its configuration while leaving submission receipts and drafts behind. Resources needing external cloning, reference mapping, or private-state reconstruction need an explicit domain operation. Historical observation does not perform restoration.
33
+ Use a pending operation record when consumers need to know about work before its result exists. Its identity represents one operation from published input to final outcome. Keep progress transient unless it has lasting domain meaning, and assign responsibility for ending abandoned work to the owner that started it.
34
34
 
35
- The installed resource must still support templates and decode all saved state and selected current data when the template is used. Unsupported or invalid saved entries fail explicitly before a new session is created.
35
+ A snapshot fixes the evidence being read; it does not redirect later writes into the past. Reuse one snapshot for related queries when their conclusions need a common basis. Obtain a fresh one when the question is about current state.
36
36
 
37
- ## Commit and observe
37
+ Notifications are prompts to observe, not substitutes for saved state. A state-driven consumer should subscribe and read the current value, then reread when notified. An occurrence-driven consumer must decide whether missing an event during downtime is acceptable or whether the domain needs durable records.
38
38
 
39
- Use the host's bound read and execution capabilities. Complete network and file processing outside synchronous transactions, then commit the resulting state.
39
+ ## Read history through its owner
40
40
 
41
- A historical snapshot fixes what is observed. A later write acts in the current execution context. Holding a snapshot does not redirect later writes into the past.
41
+ Import the original public record contract rather than interpreting another domain's JSON by convention. Shared decoding keeps the meaning and compatibility policy with the author who owns the fact.
42
42
 
43
- For an operation that other consumers must discover before it finishes, declare an operation record with input and output schemas. Begin it in a synchronous commit to publish the input and obtain its record ID. Complete that ID in a later commit with the output. This fills the result at its original position without moving the cursor. The result can be filled once; input and record identity remain fixed.
43
+ Unreadable evidence is different from absent evidence. Preserve that distinction when reporting or deciding whether to recover. A failed transfer is also not an empty query result. An interface should expose those differences rather than presenting an apparently complete account.
44
44
 
45
- The record's pending flag distinguishes an unresolved operation from a completed operation whose output is null. Existing snapshots keep their original pending observation; read a new snapshot for current results. Every timeline path containing the operation can read its result, even if another path was selected when it completed.
45
+ Distinguish a creation fact from current presence. Reconstructing an object while browsing history does not mean it was just created. Use historical observation to react to committed facts and attachment lifetimes to own work while a resource is present.
46
46
 
47
- An object writer can complete that object's pending records. A session writer can finish records owned by its plugin after the emitting object leaves the current path. Completion emits a separate observer notification, not a new-record notification. Resource implementations retain responsibility for ending abandoned work rather than waiting for a runtime that no longer exists.
47
+ ## Choose between an address and preserved bytes
48
48
 
49
- Transient events announce change. A consumer needing current state establishes its subscription and reads the current value; later notifications prompt another read.
49
+ A file reference is an address interpreted by its source resource. It is useful when a consumer should decide whether and when to read external content. Passing the address does not preserve a version of that content.
50
50
 
51
- The host publishes `SystemResumed` when the operating system resumes from sleep. Subscribe through `plugin.ipc.events` with the plugin lifetime signal when maintaining absolute deadlines or other state affected by elapsed sleep time. Re-evaluate against the current wall clock when handling the event. It is a transient occurrence and is not replayed after application startup.
51
+ Retained immutable content is appropriate when a record, attachment, or export must continue to mean the same bytes. For example, a reference to a working file suits “review the current draft”; a retained attachment suits “explain the draft that was submitted.”
52
52
 
53
- Typed calls describe request and response values with ordinary Zod schemas. The caller supplies the input schema's input; the implementation receives its parsed output, including defaults. The implementation returns JSON accepted by the output schema, and the caller receives that schema's parsed output. These types are inferred from the shared declaration, so a conversion such as string to number does not require separate type annotations.
53
+ Content identifiers alone are not ownership or access. Preserve retained references in the saved encoding, and transfer ownership before closing temporary content scopes. A reference synthesized only while decoding cannot preserve bytes that were never retained.
54
54
 
55
- ## Read typed history
55
+ ## End work with its owner
56
56
 
57
- Public record contracts belong to the package that owns their meaning. The SDK exposes host resource creation, renaming, removal, and link changes. A paradigm's public API supplies its conversation records; a plugin's public package supplies its business records. Import the original contract to decode a record rather than interpreting its JSON fields yourself.
57
+ Bind shared services to the plugin lifetime and object-owned work to the resource lifetime. Register cleanup when creating the work, while its ownership is clear. Pass cancellation into the I/O it controls and wait for actual completion before releasing dependencies that work still uses.
58
58
 
59
- Use `contract.decode(record)` for a single record and `contract.decodeAll(records)` for a commit batch. Batch decoding preserves the supplied order and omits records belonging to other contracts. A matching record returns either `known` with typed `data`, or `unknown` with the original `record` and an invalid-data reason. An unreadable matching record remains visible for reporting and recovery decisions.
59
+ Use timeline activity tracking for work whose writes depend on the current history position. An external service may need to stop when its resource disappears without otherwise preventing history navigation. Choose based on that dependency, not merely on whether the operation is asynchronous.
60
60
 
61
- ```ts
62
- import { ResourceCreated } from "@asterism-app/sdk/contracts";
63
-
64
- for (const created of ResourceCreated.decodeAll(records)) {
65
- if (created.status === "unknown") {
66
- reportUnreadable(created.record);
67
- continue;
68
- }
69
- handleCreation(created.data, created.record.sessionId);
70
- }
71
- ```
72
-
73
- For stored history, use `snapshot.records.query(ResourceCreated, { scope: "timeline" })`; it returns the same decoded result shape. `first` and `last` select the earliest or latest matching record and preserve `unknown` when that selected record is unreadable. `timeline` selects the snapshot's ancestor path; `session` includes other branches within its captured append bound. These reads retain original record identity and do not rewrite stored data.
74
-
75
- Use `records.index` when only identity, ancestry, order, contract, or provenance is needed. It returns metadata without reading bodies. Queries can combine contracts, record IDs, and an emitting resource ID. `source: null` selects records without an emitting resource. `from` includes its anchor and `before` excludes its anchor; both anchors must belong to the selected scope before filters are applied. `limit` selects a bounded page, and `edge: "last"` selects the last matches while still returning them in append order. A preceding page ends before the first record of the current page.
76
-
77
- Query filters intersect, including a typed reader's contract and any supplied contract filter. Repeating a contract or record identity does not duplicate results.
78
-
79
- Runtime snapshots read synchronously. Renderer snapshots share the same query semantics, with synchronous metadata and asynchronous body and resource reads. Await those reads before decoding or projecting data. React views can use `useSessionRead` with a memoized reader to distinguish loading, ready, and error states. Forward its cancellation signal to reads so closing a view stops further pages without cancelling other readers of the same body. A failed transfer is not an empty result or an unreadable record. Reuse the session snapshot across related queries; finalized bodies are shared across views, while pending bodies retain their original observation.
80
-
81
- The reading hook supplies `retry()` for rereading the current query. `keepPrevious` retains visible content while the same logical query refreshes along its timeline. A `key` identifies that query when the reader callback also depends on presentation inputs; changing the selected record or query scope uses a different key so content from the previous selection is not shown.
82
-
83
- A creation record separates resource identity, type, title, and encoded resource state. Its `type` is the resource kind. The nested `data` remains JSON because resource kinds have different state contracts; match the resource kind and decode that state with its resource contract when needed. To read a resource present in a snapshot, use `snapshot.resources.get(resourceContract, id)`. Private current-data entries remain owned by their declaring plugin.
84
-
85
- Creation records include new identities instantiated from templates. Moving through history may make an existing resource appear again without creating a new record. Record observers report committed facts; presence events and attachment lifetimes describe membership in the current resource set. A host-created resource record has a null source, with the associated resource identity in its payload.
86
-
87
- Public history contracts provide typed observation. Create, rename, remove, and link resources through the session operations; plugin record writers retain their existing ownership checks.
88
-
89
- ## Retain file content
90
-
91
- Stage immutable bytes through the content service, then store their reference in persistent data or a record that owns them.
92
-
93
- A `ContentRef` identifies stored immutable content. Copying its identifier does not by itself grant access or retain the bytes. Pass it through the supported operation scope so ownership remains explicit.
94
-
95
- Retention follows references in the JSON actually saved. Preserve content references in that encoding when their bytes must remain available; synthesizing a reference during decoding does not retain content or grant access.
96
-
97
- When completing an operation with attachments from an independent temporary scope, supply that scope's content reader. The host validates access and retains those result references in the same transaction as completion. Input references remain retained. Close the temporary scope after completion has committed.
98
-
99
- ## Pass resource file references
100
-
101
- Use a `FileRef` to pass an address without reading or retaining content. It contains the full source resource identity and a JSON locator interpreted by that resource. Construct it directly and include it in tool results, typed calls, events, or saved state. No registration, content scope, or consumer link is required.
102
-
103
- The source resource implements `openFile` to interpret its locator and produce an asynchronous byte stream. A consumer uses `plugin.files.open(ref, { signal })` and processes chunks as they arrive. Breaking iteration closes the stream. Forward an operation's cancellation signal so its consumption stops with that operation.
104
-
105
- Reuse `fileRefSchema` in contracts that return or accept these addresses. Its description supplies the shared meaning. Describe each operation's own use of the reference without coupling its instructions to particular producer or consumer resource types.
106
-
107
- Discovery returns addresses and descriptive metadata; it need not open files. Each consumption resolves the source anew across sessions, independently of open UI surfaces. The host does not cache bytes or freeze external files. Changed content is read as it exists at consumption, and missing resources, unavailable providers, or failed reads surface as errors. Persisting a file reference preserves its address, not the bytes it once identified. Use immutable content storage when a business operation needs to preserve a particular version.
108
-
109
- ## End asynchronous work
110
-
111
- Bind shared services to the plugin lifetime and object-owned instances to the resource lifetime. Register cleanup when creating the owned work.
112
-
113
- Cancellation requests that work stop. Wait for actual completion before releasing what that work still uses.
114
-
115
- Timeline-dependent operations need the host's activity tracking so history changes and object removal can respect active work.
116
-
117
- ## Evolve stored data
118
-
119
- Persistent file formats need explicit preparation when they change. Keep that preparation independent of ordinary service startup.
120
-
121
- Historical records retain their original payloads. Supporting an older shape through decoding is different from rewriting the original historical fact.
122
-
123
- A codec can accept old and current payload shapes while encoding new writes in the current shape:
124
-
125
- ```ts
126
- const current = z.strictObject({ text: z.string() });
127
- const textSchema = z.codec(z.union([z.string(), current]), current, {
128
- decode: value => typeof value === "string" ? { text: value } : value,
129
- encode: value => value,
130
- });
131
- ```
132
-
133
- This schema reads an old string as a current object. Plugin code writes the object; historical reads leave the original string untouched.
61
+ Prepare changes to persistent file formats independently of ordinary service startup. Historical compatibility, current-state migration, and live service initialization have different failure consequences and should remain understandable separately.
@@ -1,39 +1,31 @@
1
1
  # Prepare for plugin development
2
2
 
3
- A plugin adds resources, tools, views, settings pages, Home entries, or services through Asterism's public software development kit (SDK). Development includes preparing a compatible package, verifying its capabilities and lifecycle in the application, and checking the packaged result before sharing it.
3
+ Plugin development starts with a capability users need, not a complete framework of extension points. Build one useful path through the application, then add other contributions when that path requires them.
4
4
 
5
- ## Prepare a project
5
+ ## Target a real application
6
6
 
7
- Use a TypeScript package and the public SDK compatible with the application you intend to run. A package declaration identifies the plugin and its backend, frontend, and optional storage entries.
7
+ Choose the application release your plugin supports and develop against compatible public packages. Development declarations help the editor and type checker; they do not upgrade the APIs supplied by a running application.
8
8
 
9
- Set the plugin's release version in `package.json.version`. That version identifies distributed releases and updates; it does not affect loading or execution. The runtime definition declares its namespace and behavior. Keep ordinary runtime libraries in `dependencies`; npm or another package manager installs them using its usual dependency and lockfile rules.
9
+ Host-provided public packages are shared boundaries, not private libraries to bundle into a plugin. Use development dependencies for authoring and peer dependencies to express that relationship. Ordinary runtime libraries remain the plugin's dependencies.
10
10
 
11
- Declare host-provided packages such as `@asterism-app/sdk` in `peerDependencies` with `"*"`. The running plugin always uses the host's instance, so a narrower range adds maintenance without changing behavior. Install a version of the SDK compatible with the target application in `devDependencies` for editor support and type checking. Extensions to built-in features can use the same arrangement for `@asterism-app/builtin-api`.
11
+ Preserve imports of original shared contracts. A copied declaration can look identical in TypeScript while no longer identifying the same operation at runtime.
12
12
 
13
- npm distribution tags follow the application's release channels: `latest` matches the newest stable application and `next` matches the newest preview application. Install the tag for the application you target, for example `npm install --save-dev --save-exact @asterism-app/sdk@latest`; add `@asterism-app/builtin-api` with the same tag when using built-in domain APIs. Saving an exact version keeps the declarations stable until an intentional update. The packages include TypeScript source, guides, and examples. Installing a newer package does not update the APIs provided by the running application.
13
+ ## Build a narrow vertical slice
14
14
 
15
- Asterism binds shared public imports to the active host or plugin provider. Dependency ranges do not reject loading; missing modules, missing exports, invalid contributions, and initialization errors produce loading failures. Check the APIs your plugin actually uses with TypeScript and exercise them in the target application.
15
+ Start with the plugin's business state, the operation that changes or reads it, and the smallest presentation needed to use it. Keep shared declarations independent of backend and frontend implementations. This makes the boundary visible without exposing implementation details as public API.
16
16
 
17
- The `asterism` field declares a namespaced `id` and the needed `runtime`, `renderer`, and `storage` entry paths, relative to the package root. Runtime and renderer entries default-export their SDK plugin definitions. The runtime namespace must match the manifest ID. The required `displayName` is the plugin's name wherever the application shows it, including plugin management, settings attribution, and session entries; use a message reference owned by the plugin to localize it. The host reads it from the package without running plugin code, so disabled and failed plugins keep their names.
17
+ Choose a stable plugin identity before sharing the package. Treat its display name and release version as product information, distinct from the contracts and namespace that identify its behavior.
18
18
 
19
- Keep shared declarations separate from executable backend and frontend code. Backend work can use local system capabilities; frontend code works through the host's view and communication facilities.
19
+ Avoid scaffolding unused services, views, and persistence. A small working capability makes ownership and cleanup easier to verify; an empty abstraction says little about whether the plugin works.
20
20
 
21
- The `.test.` filename marker is reserved for tests, such as `count.test.ts` or `card.test.tsx`. Tests can remain alongside implementation files. Automatic shared-module discovery and application/package distribution exclude `*.test.*`; runtime entries and their imports contain application code only. Plugin compilation reports explicit imports of test files or Vitest instead of silently removing dependencies.
21
+ ## Validate distinct boundaries
22
22
 
23
- Start with one capability that demonstrates the plugin's purpose. Add further parts when that capability needs them rather than creating an empty framework in advance.
23
+ Type checking establishes agreement with the declarations. Loading and exercising the plugin in the target application establishes whether its contributions and dependencies work together. Neither replaces the other.
24
24
 
25
- ## Load and verify
25
+ Check the normal path, meaningful invalid input, visible failures, and cleanup when the owning resource or plugin ends. Reopen saved work to distinguish durable state from accidental reliance on a live instance.
26
26
 
27
- Prepare the package and its dependencies, run its type checks, then add its local package directory in Asterism's plugin settings. Restart to load changes.
27
+ ## Verify what users receive
28
28
 
29
- The host compiles TypeScript, TSX, and imported CSS at startup. A separate JavaScript build is optional. Generate CSS with the plugin's own toolchain first when using Tailwind, Sass, or another preprocessor. Source changes take effect after restart.
29
+ Test the distributed package in an installed application, not only the source checkout. Include the entries, generated assets, and dependencies that the plugin actually uses. Files available only on the author's machine should not be necessary.
30
30
 
31
- Check the reported loading state and exercise the capability. Verify its normal result, meaningful errors, and cleanup when an object disappears or the application closes.
32
-
33
- Type checking establishes interface consistency. Actual loading and use establish whether the package works in the intended host.
34
-
35
- ## Prepare for sharing
36
-
37
- Include the entries, assets, and dependencies the package needs. Preserve imports of shared public contracts so the host and consumers use the same declarations.
38
-
39
- Test the resulting package in an installed application. Development files available on the author's machine should not be necessary to use the distributed plugin.
31
+ Update public package versions intentionally and repeat the relevant integration checks. A compatible editor view is useful evidence, but the application remains the provider of runtime capabilities.
package/docs/manual.md CHANGED
@@ -1,38 +1,23 @@
1
- # Expose plugin documentation
1
+ # Publish useful plugin documentation
2
2
 
3
- A plugin can make its documentation and examples available through Asterism's Manual resource. The manual exposes the declared directories directly. The same files remain usable in an editor or another development environment.
3
+ A plugin can expose documentation and source examples through Asterism's Manual resource. This makes authoring material available on demand while keeping the same files usable outside the application.
4
4
 
5
- ## Declare directories
5
+ ## Choose what to publish
6
6
 
7
- Add a `manual` array to the plugin's existing `asterism` manifest:
7
+ Expose directories intended for users learning the software or authors developing an integration. Include that material in the distributed package. Internal fixtures, private working notes, and credentials have different audiences and belong outside the published material.
8
8
 
9
- ```json
10
- {
11
- "asterism": {
12
- "id": "example.bridge",
13
- "manual": ["docs", "examples"]
14
- }
15
- }
16
- ```
9
+ Keep documentation with the domain that owns its meaning. Generic hosting concepts belong to the SDK; a plugin's behavior and extension rationale belong to that plugin or its public API package. A separate public API library can own its authoring material without becoming another executable plugin.
17
10
 
18
- Each entry names an existing package-relative subdirectory using `/` separators. Entries must be normalized, must not overlap, and must resolve inside the package. Include those directories in the package's distributed files. A documentation declaration does not require a runtime entry.
11
+ ## Explain decisions that declarations cannot
19
12
 
20
- Declare only directories intended for readers. Source examples can be exposed alongside prose; internal test fixtures and credentials belong outside the declared directories.
13
+ Use prose for mental models, responsibility boundaries, integration choices, and reasons to prefer one composition over another. Public types express concrete interfaces; maintained source examples demonstrate concrete assembly. Repeating either as a field list creates a second, weaker definition.
21
14
 
22
- A public API library named in the plugin's `asterism.publicPackages` can declare its own `asterism.manual` directories. The library needs no plugin identity or executable entry for this declaration. Its documentation remains inside its own package and is available while its implementation provider is loaded.
15
+ An example is worth discussing when the explanation helps an author adapt it. Explain why a service is shared, why a record is durable, or why a view does not own a task. Let the example's source carry its exact syntax.
23
16
 
24
- ## Read through the manual
17
+ Write each article with enough context to stand alone. Organize it around an author or user question, not a tour of every available method. A reading sequence should not be necessary to understand a capability's purpose.
25
18
 
26
- When the plugin loads successfully, its directories appear under `plugins/<plugin-id>/`. For this example, an article at `docs/usage.md` appears as `plugins/example.bridge/docs/usage.md`. The manual supports directory listing, file discovery, content search, and reading selected lines.
19
+ ## Keep runtime guidance with tools
27
20
 
28
- Public-library directories appear under `plugins/<plugin-id>/public/<package-name>/`. The host exposes the same source catalog through the SDK for plugins that provide another documentation interface.
21
+ Models consult the manual when helping with software use or plugin development. Ordinary tool use should not depend on reading it.
29
22
 
30
- The manual reads current files at their original locations. It creates no copied document tree or index. Source declarations follow the loaded package set: changes to declarations, enabling, disabling, or removing a plugin take effect after restart. Plugins with package, startup, or storage failures do not contribute documents.
31
-
32
- A search at a virtual parent covers the directories below it. Globs apply within each selected physical search directory. Results include the complete virtual path, so identical filenames in different plugins remain distinguishable. Reading a file or following an explicitly selected symbolic link remains within the declared directory.
33
-
34
- ## Write independent articles
35
-
36
- Each article should explain its purpose, relevant concepts, prerequisites, and working method without depending on a reading sequence. Keep the context needed to understand the topic in the article itself. Use examples to clarify operations and leave complete interface definitions to the public types.
37
-
38
- Maintain documentation with the domain that owns its meaning. Generic host capabilities belong to the SDK; a plugin's resource behavior and domain extensions belong to that plugin or its public API package. Documentation is reference material and does not become a system instruction merely by appearing in the manual.
23
+ A tool's descriptions, guidelines, and schemas own its complete invocation contract: purpose, input meaning, result interpretation, and execution boundaries. When a runtime misunderstanding appears, improve that contract rather than adding a manual recipe. Documentation can explain how an author designs such a contract without becoming a second place to maintain it.
package/docs/messaging.md CHANGED
@@ -1,21 +1,31 @@
1
- # Provide and consume messaging
1
+ # Compose external messaging
2
2
 
3
- Messaging connects plugins to external conversation services through configured identities. A provider contribution declares its display name, settings, and asynchronous instance factory. Return it in a module's `messagingProviders` contribution. The host creates an instance for each enabled connection, supplies resolved settings and a connection identity, and manages receiving work.
3
+ External messaging separates a platform connection from the workflows that use it. The provider owns platform communication; consumers decide what incoming information means for their resources and users.
4
4
 
5
- Settings use the shared provider setting kinds: text, choice, and secret. Secret values are supplied to the backend factory and remain absent from configuration snapshots. Required values are always present in the resolved settings, choices hold a declared option, and unset optional values are absent. A provider type may have several independently configured connections. The plugin owns any platform-specific state or persistent data used by those connections; declare `forget` to release a removed connection's data, which the host calls after that connection's receiver has ended.
5
+ ## Share transport, not workflow state
6
6
 
7
- An instance supplies its external identity, an ongoing receive operation, conversation listing, message reading, and sending. Receive accepts a cancellation signal and connection-state callbacks, and publishes typed conversation-discovered and messages-received events. A messages-received event contains an ordered, nonempty batch from one conversation; a single message uses a one-element batch. Call `ready` once the platform has accepted the receiver; the connection then reports connected and its retry backoff resets. A transport that restores its own protocol session calls `reconnecting(error)` during the interruption and `ready()` after recovery, preserving its active receiver. Queries and sends have their own signals. A send carries ordered text and file-reference parts plus an optional reply target. Platforms with a caption field combine the text and deliver the files in order. Resolve each reference with `plugin.files` before contacting the platform, so an unreadable source fails as invalid input without sending anything.
7
+ Treat a configured connection as a shared service rather than creating a receiver for every card or session. Platform authentication, protocol recovery, and provider-specific persistence belong with the provider. Each consumer owns its subscriptions and releases them with its own lifetime.
8
8
 
9
- Received messages also have ordered text and file parts. File parts identify a platform attachment and describe its MIME type, filename, and known size. An instance's optional `openFile` operation streams the bytes selected by conversation, message, and file IDs. Verify that the selected file belongs to that address, refresh temporary platform URLs as needed, and preserve cancellation and download errors. Resource consumers create FileRefs with their own source identity; provider messages do not depend on a particular card or session.
9
+ Keep conversation, message, and attachment identities tied to the platform. Several messages arriving together may be related without becoming one message. Preserving individual identity makes later replies, reads, and attachment access unambiguous.
10
10
 
11
- Keep each platform message's own identity and body. Messages sent together may share a `groupId`; providers can deliver them in one batch while keeping reads, replies, and attachments addressable by their individual message IDs. A read selects either recent messages and cursor continuation or a `messageIds` array. ID queries return found messages in requested order, once per resolved message, and identify unavailable requested IDs in `missingIds`, without returning a cursor. Both query forms respect the conversation and optional topic.
11
+ A consumer's read position should not silently become a shared global position. Independent consumers may need different views of the same conversation; query continuation and business decisions about what has been handled are separate concerns.
12
12
 
13
- The host retries failed creation and receive calls. Throw `MessagingError` with `request_failed` for transient conditions such as network failures, rate limits, and server errors, and set `retryAfterMs` when the platform reports a delay. Errors other than `MessagingError` are also treated as transient. Use `unavailable` for conditions that retrying cannot fix, such as rejected credentials or a conflicting receiver; the connection then stays failed until the user changes its configuration or reconnects. Reject unsupported operations explicitly with `unsupported`.
13
+ ## Make platform differences explicit
14
14
 
15
- Use opaque strings for platform conversation, topic, and message identities. Give every sender a role relative to the connection: `self` for the connection's own identity, `participant` for another party, and `system` for content the platform produced rather than a party authored. Cursors are opaque, reusable query positions scoped by the provider. A query may compare changes with an earlier cursor, but it must not advance a shared read position. Cursor rejection should explain that the supplied position cannot be used.
15
+ Translate platform behavior without pretending that every service has identical capabilities. Reject unsupported operations explicitly. Distinguish recoverable transport interruptions from conditions requiring user action, so recovery belongs to the layer that can actually perform it.
16
16
 
17
- Consumers access `plugin.messaging`. List connection identities, resolve a specific connection to an operation handle, and subscribe to external events and connection changes. Resolve at the consumer's request boundary when configuration must remain fixed across its operations. Each handle retains its captured instance; operations wait for a connection attempt in progress and fail with the attempt's error otherwise. Current external content remains current at handling time.
17
+ Attachments need the same care as text. An address to a platform file is not a permanently available download URL. Resolve it through the provider that understands its identity, and preserve cancellation and download failures.
18
18
 
19
- Provider instances are shared across consumers. A plugin should not create a second receiver for each card or session. Its consumers own their subscriptions and release them with their lifetimes. A listener failure is logged and does not affect other listeners or the provider. Connection removal or provider unavailability prevents new resolutions; provider shutdown cancels its outstanding work.
19
+ When sending has external effects, resolve required input before beginning delivery. If a platform turns one logical submission into several sends, expose failures honestly rather than implying that partial delivery was atomic.
20
20
 
21
- The service has no Agent semantics. A consumer chooses whether an external event updates a view, records a fact, or submits input through a paradigm's public API. Builtin resources use links to select recipients and expose tools. Other plugins may compose the same service differently.
21
+ ## Choose when configuration is captured
22
+
23
+ Resolve a connection at the consumer's request boundary when related operations should use one configuration. Read current external content when handling the operation. Configuration identity and mutable conversation content need not have the same lifetime.
24
+
25
+ Cancellation belongs to the work it controls. Cancelling one consumer's query should not end a receiver shared with other consumers. Conversely, ending the provider must release the work it owns.
26
+
27
+ ## Translate events deliberately
28
+
29
+ A messaging event is not inherently an Agent message. A consumer may update a view, record a durable fact, or submit input through a paradigm's public API. The integration owns that choice and the readable explanation of the event.
30
+
31
+ For example, an issue-tracker bridge can share one platform receiver across sessions while each resource chooses its recipients and records its own processing decisions. The provider understands the platform; the bridge understands the work.
@@ -1,35 +1,27 @@
1
- # Build a small plugin
1
+ # Adapt a small plugin
2
2
 
3
- A counter plugin demonstrates the complete path from shared declarations to backend behavior and a resource card. The SDK includes it as an ordinary package directory under `examples/counter`, with source files, a package manifest, and a TypeScript configuration. Its code is the maintained example; this guide explains how to use and adapt it.
3
+ The SDK's counter package in `examples/counter` is a complete plugin, not a specification for every plugin's structure. Its maintained source shows concrete assembly. Use it to understand ownership and then change the design to fit the capability you need.
4
4
 
5
- ## Prepare the package
5
+ ## Follow one change through the system
6
6
 
7
- Copy the counter directory to a writable development location. Its development dependency selects the SDK version used by the example. Use an Asterism application that provides those APIs. The SDK peer dependency describes a host-provided package, and the host does not use its version range to gate loading. React, React Intl, and Zod are also shared public dependencies supplied by the host when the plugin runs.
7
+ The counter separates a shared declaration, backend work, and a card that presents the result. Backend and frontend import the same contracts; sharing a name or copying a schema would not create the same runtime identity.
8
8
 
9
- Run `npm install` and `npm run typecheck` in the copied directory. The host compiles the TypeScript, TSX, and imported CSS entries, so a separate JavaScript build is optional. Add the package directory in Asterism's plugin settings and restart the application to load it.
9
+ An increment updates the current value and records the change together. That is a deliberate product choice: current data supports use now, while the record explains what happened. The counter does not promise that browsing history restores its value. A different resource may need a different relationship between current state and history.
10
10
 
11
- ## Follow the data
11
+ The card initiates work without becoming its durable owner. This separation matters when a view closes, remounts, or fails while the resource remains present. UI pending state belongs to the interaction; committed results belong to the backend.
12
12
 
13
- Shared declarations identify the counter, its private current value, projected view, change record, creation entry, increment action, read tool, settings, and typed call. Backend and frontend code import the same declarations. Copying a declaration under the same name does not establish shared runtime identity.
13
+ The model-facing read operation exposes an existing capability rather than inventing a second source of truth. Its registration does not itself grant access to the counter. Treat visibility, authorization, and presentation as separate choices.
14
14
 
15
- Creation establishes the object. Incrementing reads the configured step, saves the current value, and appends a historical change in one synchronous commit. The example keeps the latest counter value when browsing history; it does not implement restoration. Network and file work belongs outside synchronous commits.
15
+ ## Adapt ownership before adding features
16
16
 
17
- The card reads projected data and invokes the public increment action. Each button owns its pending state and displays failures. Actions return receipts that the view checks; typed calls and settings saves reject on failure. A settings page edits the step and reads it back through the backend call.
17
+ Choose a distinct plugin identity for a new package. Keep shared contracts independent of executable implementations, but group a capability's code so its state transitions remain understandable together.
18
18
 
19
- The example also contributes a Home entry. It prepares a counter, then initializes a session containing it in one transaction. This entry works with the builtin paradigm disabled and requires no conversation input.
19
+ Decide whether each new piece of state is a current value, a historical fact, a preference, or temporary interaction state. Decide who ends any new asynchronous work. A connection shared by all counters would belong to the plugin; a process meaningful only for one counter would belong to that resource.
20
20
 
21
- The model tool reads the same counter value through its resource implementation. Registering the tool does not grant access: an agent needs a link to the counter, and the operation must be available in its execution environment.
21
+ A Home entry can start a session around the counter without introducing an Agent or a first message. Keep that independence when adapting the example unless conversation is part of the new plugin's domain.
22
22
 
23
- ## Adapt the package
23
+ ## Check the adapted design
24
24
 
25
- Choose a distinct plugin identity before using the example as a new plugin. Keep shared declarations independent of backend and frontend implementations. Add resource behavior through actions and expose an operation as a model tool when the model needs to call it.
25
+ Use a compatible application and public SDK for development. Type checking checks contract agreement; loading the package and exercising it checks the integration.
26
26
 
27
- Imported CSS Modules keep the counter's class names local. Host theme variables provide colors. The storage entry declares the managed configuration format; add consecutive migrations when that format changes. Credentials belong in the secret service, and retained file content uses the content service.
28
-
29
- Object-owned external connections belong to the resource's attachment lifetime. Register their cleanup when opening them. Shared services belong to the plugin lifetime. Managed tasks own asynchronous work and pass cancellation to their I/O.
30
-
31
- ## Verify the result
32
-
33
- Open the plugin settings page, change the step, and read it back. Create a counter, increment it, and verify the card and history. Link the counter to an agent and use its read tool.
34
-
35
- After edits, run type checking and restart Asterism. Verify invalid input, failure messages, cleanup, and reopening saved objects. Type checking establishes interface consistency; loading and using the package establishes its behavior in the host.
27
+ Trace one change from the initiating interface to saved state and history. Then check invalid input, visible failure, reopening saved objects, and cleanup. These checks should test promises your resource makes, not merely confirm that the copied example still has the same controls.
@@ -1,33 +1,29 @@
1
1
  # Organize a plugin
2
2
 
3
- A plugin is the unit of installation, identity, settings, and lifetime. Its internal modules group capabilities that share that ownership.
3
+ A plugin is a unit of installation, identity, settings, and lifetime. Internal modules group capabilities that share that ownership; they need not become separate public abstractions.
4
4
 
5
- ## Separate responsibilities
5
+ ## Separate responsibilities, keep capabilities cohesive
6
6
 
7
- Shared contracts describe transferable data and operations. Backend implementations perform work. Frontend views present state and collect input.
7
+ Shared contracts describe transferable data and operations. Backend implementations own work and persistence. Frontend views present state and collect input. Keep shared declarations independent of libraries that belong only to one implementation environment.
8
8
 
9
- Keep shared declarations independent of backend-only or frontend-only libraries. A view reaches its backend through typed communication rather than importing the backend implementation.
9
+ A view reaches backend behavior through typed communication rather than importing its implementation. Within that boundary, keep a capability's declarations, behavior, and presentation understandable together. Compose capabilities through explicit dependencies instead of exposing internal layers merely because they exist.
10
10
 
11
- Group a capability's declarations, implementation, and presentation so they remain understandable together. Compose capabilities at the plugin entry through explicit dependencies.
11
+ ## Choose a domain boundary
12
12
 
13
- ## Use public extension points
13
+ Use a domain's public extension points when adding to its existing behavior. A plugin with its own resource can instead own that resource's behavior and presentation. Extending an Agent and implementing a new paradigm are different commitments.
14
14
 
15
- The general SDK supplies host services and contribution interfaces. Built-in domain APIs expose extensions specific to existing features, such as Agent interaction.
15
+ A paradigm may define how work starts, how requests are assembled, and how execution is presented. Sessions and host capabilities do not require a conversation card. Choose the composition that fits the workflow rather than treating the bundled paradigm as the host's mandatory object model.
16
16
 
17
- Use a domain extension when adding to that feature. A plugin with its own resource can define its own behavior and presentation.
17
+ ## Publish only what consumers need
18
18
 
19
- A paradigm plugin can own a Home entry, configuration, request assembly, and execution behavior. The host supplies sessions, concrete model access, interactive terminals, command execution, MCP, provider usage, and raw skill and instruction catalogs. Compose these capabilities according to the workflow; an Agent resource or conversation card is optional.
19
+ A public package is useful when multiple plugins need the same declarations or service boundary. Publish capabilities with an intentional meaning for consumers, not a mirror of the provider's internal organization.
20
20
 
21
- ## Share contracts and services
21
+ For a small extension, public exports from the implementation package may be sufficient. A separate API library can make sense when the shared domain has its own authoring surface and should remain independent of implementation imports. Neither choice makes the library a second plugin or gives consumers access to private state.
22
22
 
23
- A public package can expose declarations or services for other plugins. Consumers declare ordinary package dependencies in `package.json` and import the original public values. The host derives initialization and cleanup dependencies from those imports, including imports through intermediate packages.
23
+ Import original public values. Shared contracts carry runtime identity as well as types, so a local copy is not a substitute for the provider's declaration. Development package versions support authoring; the enabled provider supplies the running implementation.
24
24
 
25
- Expose shared values through `./public` in the package's standard exports. Public imports bind to the enabled provider's actual exports, including imports through intermediate npm packages. The host uses the import graph for initialization order and reports missing exports or unavailable providers. Package versions and dependency ranges remain package-management metadata; local development copies do not replace the active provider.
25
+ ## Keep service ownership with the provider
26
26
 
27
- For a separate API library, declare its package name in the implementation plugin's `asterism.publicPackages` array. Install that library as an ordinary dependency and declare its public entry points through standard package exports. Consumers resolve those entries from the enabled provider's installation. Package names cannot be claimed by competing enabled providers across these two declaration forms.
27
+ A provider owns shared initialization and cleanup. Consumers depend on the capability they use and release their own subscriptions or requests without ending services shared by others.
28
28
 
29
- Libraries that depend on native binaries or files relative to their installed module can be listed in `asterism.runtimeExternals`. The host preserves their resolved installed locations instead of relocating their code into the plugin cache.
30
-
31
- A shared declaration has runtime identity as well as a name. Copying it under the same name does not establish shared identity. Backend and frontend environments are separate even when they use the same contract.
32
-
33
- Shared service initialization and cleanup belong to the provider. A consumer should depend on the capability it needs rather than the provider's internal organization.
29
+ Keep that ownership explicit when composing modules. A dependency should explain why a capability is needed, not require consumers to understand the provider's file layout or startup internals.