acrylblends 0.4.0 → 0.4.1

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 (45) hide show
  1. package/dist/index.js +56 -2
  2. package/dist/index.js.map +1 -1
  3. package/docs/framework/LICENSE +23 -0
  4. package/docs/framework/README.md +63 -0
  5. package/docs/framework/UPSTREAM.md +3 -0
  6. package/docs/framework/api-summary.md +138 -0
  7. package/docs/framework/concepts.md +105 -0
  8. package/docs/framework/context.md +129 -0
  9. package/docs/framework/getting-started.md +146 -0
  10. package/docs/framework/helpers.md +118 -0
  11. package/docs/framework/middleware.md +154 -0
  12. package/docs/framework/migration-from-0-3.md +108 -0
  13. package/docs/framework/migration-from-dsh-webserver.md +103 -0
  14. package/docs/framework/node-server.md +75 -0
  15. package/docs/framework/plugin-lifecycle.md +111 -0
  16. package/docs/framework/request.md +106 -0
  17. package/docs/framework/routing.md +188 -0
  18. package/docs/framework/surfaces.md +71 -0
  19. package/docs/framework/upstream.json +9 -0
  20. package/docs/framework/validation.md +135 -0
  21. package/package.json +4 -2
  22. package/plugins/acryl-inspect/src/report.ts +15 -10
  23. package/plugins/acryl-inspect/tests/report.spec.ts +9 -3
  24. package/plugins/acryl-inspect/upstream.json +2 -2
  25. package/plugins/acryl-node-server/upstream.json +1 -1
  26. package/plugins/acryl-router/src/middleware/index.ts +1 -1
  27. package/plugins/acryl-router/src/middleware/loopback-only.ts +34 -1
  28. package/plugins/acryl-router/src/service.ts +9 -3
  29. package/plugins/acryl-router/tests/loopback-only.spec.ts +80 -0
  30. package/plugins/acryl-router/tests/service.spec.ts +17 -0
  31. package/plugins/acryl-router/upstream.json +2 -2
  32. package/plugins/acryl-router-http/upstream.json +1 -1
  33. package/plugins/acryl-state/upstream.json +1 -1
  34. package/plugins/builder/script.ts +1 -1
  35. package/plugins/extensions/index.ts +4 -3
  36. package/plugins/openai/prompt.ts +2 -2
  37. package/shared/AGENTS.core.md +54 -0
  38. package/templates/agent/AGENTS.md +6 -0
  39. package/templates/agent/README.md +2 -2
  40. package/templates/agent/blend.yaml +1 -1
  41. package/templates/blank/AGENTS.md +5 -0
  42. package/templates/blank/README.md +1 -1
  43. package/templates/todo/AGENTS.md +5 -0
  44. package/templates/todo/src/todo.ts +4 -2
  45. package/templates/todo/upstream.json +2 -2
@@ -1,6 +1,6 @@
1
1
  # The app as data, in ACRYL's Blend format (blends.acryl.dev/v1alpha1): which plugins it mounts, in what order, with what config.
2
2
  # Edit this, not app.ts, to switch a plugin off (disabled: true) or change its config. `npm run lock` records what the app is built from.
3
- # Order matters: http comes before extensions, because installed extensions start again at boot and may add routes.
3
+ # Order matters: acryl-router comes before extensions, because installed extensions start again at boot and may add routes.
4
4
  apiVersion: blends.acryl.dev/v1alpha1
5
5
  kind: Blueprint
6
6
  metadata:
@@ -0,0 +1,5 @@
1
+
2
+ ## This app (blank)
3
+
4
+ `src/routes.ts` is the app's own plugin: add routes to its `App`. `blend.yaml` lists the plugins that are mounted. `acrylblends add <plugin>` copies
5
+ another library plugin (for example `acryl-state`) into `src/plugins/`.
@@ -15,7 +15,7 @@ npm run check # type-check
15
15
  one off with `disabled: true`. `npm run lock` writes `blend.lock.json`: the manifest's digest and a digest of
16
16
  every plugin folder, so a diff of the lock shows what changed.
17
17
  - `src/app.ts` holds the registry of plugins the code provides, and mounts the manifest's rows.
18
- - `src/routes.ts` is your own plugin: routes added inside `ctx.effect`.
18
+ - `src/routes.ts` is your own plugin: it builds an `App` (`import { App } from './plugins/acryl-router/src/index.ts'`) and mounts it with `ctx.router.route(prefix, app)`. Routes added to the app after it is mounted are not served. A page mounted at `/x` answers `/x`, not `/x/` (trailing slashes are strict). The router API is documented at https://acrylblends.github.io/docs/framework/the-acryl-framework and in `docs/framework` of the acrylblends repository.
19
19
  - `src/plugins/` holds the plugins copied from the ACRYLBLENDS library. They are yours now; edit them freely.
20
20
  Add more with `acrylblends add <plugin>`.
21
21
 
@@ -0,0 +1,5 @@
1
+
2
+ ## This app (todo)
3
+
4
+ `src/todo.ts` is the whole feature: a plugin that mounts an `App` (CRUD, a page, a server-sent stream) and keeps the list in a state cell that it
5
+ also writes to a file in the app's home. Use it as the reference for a new plugin, and keep its tests passing when you change it.
@@ -7,7 +7,7 @@ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
7
7
  import { dirname } from 'node:path'
8
8
  import type { Context } from '@deepseek-ai/cordis'
9
9
  import { App, HTTPException } from './plugins/acryl-router/src/index.ts'
10
- import { bodyLimit, loopbackOnly } from './plugins/acryl-router/src/middleware/index.ts'
10
+ import { bodyLimit, loopbackOnly, trimTrailingSlash } from './plugins/acryl-router/src/middleware/index.ts'
11
11
  import { schemaValidator, streamSSE, type StandardSchema } from './plugins/acryl-router/src/helpers/index.ts'
12
12
  import type {} from './plugins/acryl-state/src/index.ts'
13
13
  import { PAGE } from './page.ts'
@@ -84,8 +84,10 @@ export function apply(ctx: Context, config: Config = {}): void {
84
84
  return todo
85
85
  }
86
86
 
87
+ // `/todo/` is what people type: trimTrailingSlash answers a GET for an unknown path ending in `/` with a 301 to the path without it,
88
+ // so the page is found either way while each route keeps one canonical path (the router itself treats `/a` and `/a/` as different).
87
89
  const api = new App()
88
- .use(loopbackOnly({ inProcess: 'allow' }), bodyLimit({ maxSize: MAX_BODY_BYTES }))
90
+ .use(loopbackOnly({ inProcess: 'allow' }), bodyLimit({ maxSize: MAX_BODY_BYTES }), trimTrailingSlash())
89
91
  .get('/', c => c.html(PAGE))
90
92
  .get('/api', c => c.json(todos.get()))
91
93
  .post('/api', schemaValidator('json', NewTodo), c => {
@@ -5,8 +5,8 @@
5
5
  "examples/acryl-todo/src/index.ts": "src/todo.ts",
6
6
  "examples/acryl-todo/src/page.ts": "src/page.ts"
7
7
  },
8
- "commit": "df79b188398b6d4f8cceda35a72b88300a10a9ce"
8
+ "commit": "64e7c9d2e787f74b2da82492644fbbb46a601074"
9
9
  },
10
10
  "rewrittenSpecifiers": 4,
11
- "digest": "sha256:c4efede39387681003c6d2f0f2858e157a84bcaaf9ae94ebe23d10f72a538ffd"
11
+ "digest": "sha256:b62b5167344084f7ac03c8286923f92419a4ab41c5d8235adb3247d983807aca"
12
12
  }