@acryldev/plugin-context 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/docs/README.md +160 -0
- package/docs/delivery/local-live.md +113 -0
- package/docs/delivery/marketplace.md +16 -0
- package/docs/docs.json +2836 -0
- package/docs/extending/agent-preset.md +37 -0
- package/docs/extending/chat-command.md +28 -0
- package/docs/extending/client-slot.md +135 -0
- package/docs/extending/config-schema.md +7 -0
- package/docs/extending/cordis-core.md +63 -0
- package/docs/extending/desktop-app.md +53 -0
- package/docs/extending/desktop-main.md +25 -0
- package/docs/extending/event-hook.md +14 -0
- package/docs/extending/host-route.md +33 -0
- package/docs/extending/llm-adapter.md +38 -0
- package/docs/extending/packaging.md +53 -0
- package/docs/extending/prompt-contribution.md +9 -0
- package/docs/extending/service.md +13 -0
- package/docs/extending/skill-provider.md +9 -0
- package/docs/extending/state-and-persistence.md +71 -0
- package/docs/extending/three-role-capability.md +33 -0
- package/docs/extending/tool-plugin.md +24 -0
- package/docs/extending/tui-command.md +8 -0
- package/docs/extending/tui-components.md +61 -0
- package/docs/extending/ui-branding.md +43 -0
- package/docs/extending/ui-components.md +56 -0
- package/docs/extending/ui-customization.md +41 -0
- package/docs/extending/ui-library.md +66 -0
- package/docs/extending/ui-theme.md +55 -0
- package/docs/extending/workspace-tab.md +50 -0
- package/docs/maps/events.md +108 -0
- package/docs/maps/mount-points.md +154 -0
- package/docs/maps/slot-contracts.md +3376 -0
- package/docs/maps/taxonomy.md +306 -0
- package/docs/maps/theme-tokens.md +115 -0
- package/docs/maps/ui-components.md +26 -0
- package/docs/reference/cookbook/adding-a-package.md +174 -0
- package/docs/reference/cookbook/adding-a-remote-api.md +199 -0
- package/docs/reference/cookbook/adding-a-settings-card.md +74 -0
- package/docs/reference/cookbook/adding-a-tool.md +103 -0
- package/docs/reference/cookbook/adding-an-llm-adapter.md +45 -0
- package/docs/reference/cookbook/extension-cookbook.md +134 -0
- package/docs/reference/cordis-api/context.md +366 -0
- package/docs/reference/cordis-api/events.md +209 -0
- package/docs/reference/cordis-api/fiber.md +377 -0
- package/docs/reference/cordis-api/inherited.md +40 -0
- package/docs/reference/cordis-api/registry.md +154 -0
- package/docs/reference/cordis-api/service.md +104 -0
- package/docs/reference/cordis-guides/cordis-usage-cheatsheet.md +167 -0
- package/docs/reference/cordis-guides/cordis_system_guide_for_coding_agents.md +4666 -0
- package/docs/reference/cordis-guides/development-canvas-plugin.md +109 -0
- package/docs/reference/cordis-guides/hello-world-plugin-guide.md +517 -0
- package/docs/reference/harness/agent-lifecycle.md +93 -0
- package/docs/reference/harness/architecture.md +168 -0
- package/docs/reference/harness/capability-seams.md +675 -0
- package/docs/reference/harness/config-catalog.md +4523 -0
- package/docs/reference/harness/cordis-primer.md +47 -0
- package/docs/reference/harness/defensive-patterns.md +35 -0
- package/docs/reference/harness/event-producer-consumer.md +111 -0
- package/docs/reference/harness/glossary.md +47 -0
- package/docs/reference/harness/tool-catalog.md +2721 -0
- package/docs/reference/harness/tool-execution-pipeline.md +67 -0
- package/docs/reference/subsystems/README.md +75 -0
- package/docs/reference/subsystems/agent-team.md +233 -0
- package/docs/reference/subsystems/approval.md +172 -0
- package/docs/reference/subsystems/attachment.md +363 -0
- package/docs/reference/subsystems/boot.md +324 -0
- package/docs/reference/subsystems/browser-use.md +69 -0
- package/docs/reference/subsystems/client-modules.md +186 -0
- package/docs/reference/subsystems/client-resources.md +94 -0
- package/docs/reference/subsystems/commands.md +225 -0
- package/docs/reference/subsystems/compaction.md +286 -0
- package/docs/reference/subsystems/computer-use.md +58 -0
- package/docs/reference/subsystems/conversation.md +287 -0
- package/docs/reference/subsystems/core.md +1107 -0
- package/docs/reference/subsystems/credentials.md +497 -0
- package/docs/reference/subsystems/deliverables.md +180 -0
- package/docs/reference/subsystems/extensions.md +386 -0
- package/docs/reference/subsystems/feedback.md +402 -0
- package/docs/reference/subsystems/filesystem.md +532 -0
- package/docs/reference/subsystems/goal.md +315 -0
- package/docs/reference/subsystems/invariants.md +90 -0
- package/docs/reference/subsystems/jobs.md +501 -0
- package/docs/reference/subsystems/llm-streaming.md +1131 -0
- package/docs/reference/subsystems/lsp.md +204 -0
- package/docs/reference/subsystems/mcp.md +141 -0
- package/docs/reference/subsystems/office-to-pdf.md +89 -0
- package/docs/reference/subsystems/otel.md +46 -0
- package/docs/reference/subsystems/permission-presets.md +169 -0
- package/docs/reference/subsystems/persistence.md +418 -0
- package/docs/reference/subsystems/plan.md +89 -0
- package/docs/reference/subsystems/product-telemetry.md +81 -0
- package/docs/reference/subsystems/ptc-runtime.md +234 -0
- package/docs/reference/subsystems/sandbox.md +223 -0
- package/docs/reference/subsystems/schedule.md +545 -0
- package/docs/reference/subsystems/scope.md +61 -0
- package/docs/reference/subsystems/session-projection.md +358 -0
- package/docs/reference/subsystems/session-query.md +511 -0
- package/docs/reference/subsystems/session-reference.md +226 -0
- package/docs/reference/subsystems/session-telemetry.md +214 -0
- package/docs/reference/subsystems/session-title.md +206 -0
- package/docs/reference/subsystems/session.md +1300 -0
- package/docs/reference/subsystems/settings.md +157 -0
- package/docs/reference/subsystems/shell.md +316 -0
- package/docs/reference/subsystems/sidebar-right.md +160 -0
- package/docs/reference/subsystems/skills.md +354 -0
- package/docs/reference/subsystems/slots.md +201 -0
- package/docs/reference/subsystems/spill.md +126 -0
- package/docs/reference/subsystems/ssh.md +137 -0
- package/docs/reference/subsystems/storage.md +262 -0
- package/docs/reference/subsystems/subagent.md +762 -0
- package/docs/reference/subsystems/subprocess.md +323 -0
- package/docs/reference/subsystems/system-prompt.md +226 -0
- package/docs/reference/subsystems/terminal.md +186 -0
- package/docs/reference/subsystems/todo.md +34 -0
- package/docs/reference/subsystems/token-meter.md +108 -0
- package/docs/reference/subsystems/tools.md +749 -0
- package/docs/reference/subsystems/typert.md +489 -0
- package/docs/reference/subsystems/user-questions.md +309 -0
- package/docs/reference/subsystems/voice-input.md +166 -0
- package/docs/reference/subsystems/web-client.md +102 -0
- package/docs/reference/subsystems/web-server.md +228 -0
- package/docs/reference/subsystems/web.md +208 -0
- package/docs/reference/subsystems/webhook.md +72 -0
- package/docs/reference/subsystems/workflow.md +280 -0
- package/docs/reference/subsystems/workspace.md +661 -0
- package/docs/start-here/blueprints.md +33 -0
- package/docs/start-here/this-runtime.md +84 -0
- package/docs/start-here/troubleshooting.md +29 -0
- package/docs/start-here/trust-and-safety.md +39 -0
- package/docs/start-here/verify-before-done.md +46 -0
- package/example-plugins/README.md +45 -0
- package/example-plugins/packages/agent-preset-reviewer/agent.cordis.yml +18 -0
- package/example-plugins/packages/agent-preset-reviewer/preset.yml +3 -0
- package/example-plugins/packages/capability-swap-consumer/cordis.patch.yml +3 -0
- package/example-plugins/packages/capability-swap-consumer/index.js +14 -0
- package/example-plugins/packages/capability-swap-consumer/package.json +25 -0
- package/example-plugins/packages/capability-swap-provider-loud/cordis.patch.yml +3 -0
- package/example-plugins/packages/capability-swap-provider-loud/index.js +20 -0
- package/example-plugins/packages/capability-swap-provider-loud/package.json +25 -0
- package/example-plugins/packages/capability-swap-provider-quiet/cordis.patch.yml +3 -0
- package/example-plugins/packages/capability-swap-provider-quiet/index.js +20 -0
- package/example-plugins/packages/capability-swap-provider-quiet/package.json +25 -0
- package/example-plugins/packages/chat-command-basic/cordis.patch.yml +3 -0
- package/example-plugins/packages/chat-command-basic/index.js +26 -0
- package/example-plugins/packages/chat-command-basic/package.json +25 -0
- package/example-plugins/packages/client-chat-message-action/client.js +46 -0
- package/example-plugins/packages/client-chat-message-action/cordis.patch.yml +3 -0
- package/example-plugins/packages/client-chat-message-action/index.js +9 -0
- package/example-plugins/packages/client-chat-message-action/package.json +31 -0
- package/example-plugins/packages/client-slot-header-action/client.js +57 -0
- package/example-plugins/packages/client-slot-header-action/cordis.patch.yml +3 -0
- package/example-plugins/packages/client-slot-header-action/index.js +13 -0
- package/example-plugins/packages/client-slot-header-action/package.json +31 -0
- package/example-plugins/packages/client-slot-sidebar-tab/client.js +57 -0
- package/example-plugins/packages/client-slot-sidebar-tab/cordis.patch.yml +3 -0
- package/example-plugins/packages/client-slot-sidebar-tab/index.js +9 -0
- package/example-plugins/packages/client-slot-sidebar-tab/package.json +32 -0
- package/example-plugins/packages/client-theme-override/client.js +52 -0
- package/example-plugins/packages/client-theme-override/cordis.patch.yml +3 -0
- package/example-plugins/packages/client-theme-override/index.js +9 -0
- package/example-plugins/packages/client-theme-override/package.json +30 -0
- package/example-plugins/packages/client-tool-view/client.js +47 -0
- package/example-plugins/packages/client-tool-view/cordis.patch.yml +3 -0
- package/example-plugins/packages/client-tool-view/index.js +24 -0
- package/example-plugins/packages/client-tool-view/package.json +34 -0
- package/example-plugins/packages/client-ui-components/client.js +77 -0
- package/example-plugins/packages/client-ui-components/cordis.patch.yml +3 -0
- package/example-plugins/packages/client-ui-components/index.js +9 -0
- package/example-plugins/packages/client-ui-components/package.json +31 -0
- package/example-plugins/packages/client-ui-library/client.js +715 -0
- package/example-plugins/packages/client-ui-library/cordis.patch.yml +3 -0
- package/example-plugins/packages/client-ui-library/index.js +9 -0
- package/example-plugins/packages/client-ui-library/package.json +37 -0
- package/example-plugins/packages/client-workspace-tab/client.js +72 -0
- package/example-plugins/packages/client-workspace-tab/cordis.patch.yml +3 -0
- package/example-plugins/packages/client-workspace-tab/index.js +9 -0
- package/example-plugins/packages/client-workspace-tab/package.json +30 -0
- package/example-plugins/packages/config-schema-basic/cordis.patch.yml +3 -0
- package/example-plugins/packages/config-schema-basic/index.js +19 -0
- package/example-plugins/packages/config-schema-basic/package.json +25 -0
- package/example-plugins/packages/desktop-main-profile-info/cordis.patch.yml +3 -0
- package/example-plugins/packages/desktop-main-profile-info/index.js +22 -0
- package/example-plugins/packages/desktop-main-profile-info/package.json +25 -0
- package/example-plugins/packages/event-hook-basic/cordis.patch.yml +3 -0
- package/example-plugins/packages/event-hook-basic/index.js +17 -0
- package/example-plugins/packages/event-hook-basic/package.json +22 -0
- package/example-plugins/packages/generated-capability-template/cordis.patch.yml +3 -0
- package/example-plugins/packages/generated-capability-template/index.js +16 -0
- package/example-plugins/packages/generated-capability-template/package.json +42 -0
- package/example-plugins/packages/host-route-basic/cordis.patch.yml +3 -0
- package/example-plugins/packages/host-route-basic/index.js +20 -0
- package/example-plugins/packages/host-route-basic/package.json +29 -0
- package/example-plugins/packages/lifecycle-function-basic/cordis.patch.yml +3 -0
- package/example-plugins/packages/lifecycle-function-basic/index.js +12 -0
- package/example-plugins/packages/lifecycle-function-basic/package.json +15 -0
- package/example-plugins/packages/lifecycle-function-hot-shim/cordis.patch.yml +3 -0
- package/example-plugins/packages/lifecycle-function-hot-shim/impl.js +5 -0
- package/example-plugins/packages/lifecycle-function-hot-shim/index.js +18 -0
- package/example-plugins/packages/lifecycle-function-hot-shim/package.json +23 -0
- package/example-plugins/packages/lifecycle-hooks-observer/cordis.patch.yml +3 -0
- package/example-plugins/packages/lifecycle-hooks-observer/index.js +23 -0
- package/example-plugins/packages/lifecycle-hooks-observer/package.json +22 -0
- package/example-plugins/packages/llm-adapter-echo/cordis.patch.yml +3 -0
- package/example-plugins/packages/llm-adapter-echo/index.js +42 -0
- package/example-plugins/packages/llm-adapter-echo/package.json +25 -0
- package/example-plugins/packages/prompt-assemble-hook/cordis.patch.yml +3 -0
- package/example-plugins/packages/prompt-assemble-hook/index.js +22 -0
- package/example-plugins/packages/prompt-assemble-hook/package.json +22 -0
- package/example-plugins/packages/prompt-contribution-basic/cordis.patch.yml +3 -0
- package/example-plugins/packages/prompt-contribution-basic/index.js +18 -0
- package/example-plugins/packages/prompt-contribution-basic/package.json +22 -0
- package/example-plugins/packages/service-consumer-greeter/cordis.patch.yml +3 -0
- package/example-plugins/packages/service-consumer-greeter/index.js +14 -0
- package/example-plugins/packages/service-consumer-greeter/package.json +22 -0
- package/example-plugins/packages/service-provider-greeter/cordis.patch.yml +3 -0
- package/example-plugins/packages/service-provider-greeter/index.js +22 -0
- package/example-plugins/packages/service-provider-greeter/package.json +25 -0
- package/example-plugins/packages/settings-section-basic/cordis.patch.yml +3 -0
- package/example-plugins/packages/settings-section-basic/index.js +34 -0
- package/example-plugins/packages/settings-section-basic/package.json +26 -0
- package/example-plugins/packages/skill-provider-basic/cordis.patch.yml +3 -0
- package/example-plugins/packages/skill-provider-basic/index.js +31 -0
- package/example-plugins/packages/skill-provider-basic/package.json +22 -0
- package/example-plugins/packages/state-host-store/client.js +57 -0
- package/example-plugins/packages/state-host-store/cordis.patch.yml +3 -0
- package/example-plugins/packages/state-host-store/index.js +90 -0
- package/example-plugins/packages/state-host-store/package.json +31 -0
- package/example-plugins/packages/state-workspace-file/cordis.patch.yml +3 -0
- package/example-plugins/packages/state-workspace-file/index.js +52 -0
- package/example-plugins/packages/state-workspace-file/package.json +25 -0
- package/example-plugins/packages/tool-basic/cordis.patch.yml +3 -0
- package/example-plugins/packages/tool-basic/index.js +25 -0
- package/example-plugins/packages/tool-basic/package.json +25 -0
- package/example-plugins/packages/tool-policy-hook/cordis.patch.yml +3 -0
- package/example-plugins/packages/tool-policy-hook/index.js +28 -0
- package/example-plugins/packages/tool-policy-hook/package.json +25 -0
- package/example-plugins/packages/tui-command-basic/cordis.patch.yml +3 -0
- package/example-plugins/packages/tui-command-basic/index.js +24 -0
- package/example-plugins/packages/tui-command-basic/package.json +22 -0
- package/example-plugins/packages/tui-overlay-themed/cordis.patch.yml +3 -0
- package/example-plugins/packages/tui-overlay-themed/index.js +65 -0
- package/example-plugins/packages/tui-overlay-themed/package.json +25 -0
- package/example-plugins/packages/tui-ui-library/cordis.patch.yml +3 -0
- package/example-plugins/packages/tui-ui-library/index.js +73 -0
- package/example-plugins/packages/tui-ui-library/package.json +29 -0
- package/example-plugins/packages/web-page-branding/cordis.patch.yml +3 -0
- package/example-plugins/packages/web-page-branding/index.js +31 -0
- package/example-plugins/packages/web-page-branding/package.json +22 -0
- package/example-plugins/scenarios.json +11 -0
- package/index.js +384 -0
- package/lib/blend-apply.js +107 -0
- package/lib/blend-capture.js +249 -0
- package/lib/blend-ledger.js +76 -0
- package/lib/contract.js +5 -0
- package/lib/install.js +516 -0
- package/lib/lookup.js +67 -0
- package/lib/manifest.js +56 -0
- package/lib/pack-root.js +22 -0
- package/lib/provenance.js +110 -0
- package/lib/publish.js +64 -0
- package/lib/reconcile.js +83 -0
- package/lib/router.js +55 -0
- package/lib/scopes.js +82 -0
- package/lib/skills.js +54 -0
- package/lib/stage.js +157 -0
- package/lib/verify.js +77 -0
- package/package.json +58 -3
- package/scripts/lib/indexes.mjs +45 -0
- package/scripts/lib/manifest.mjs +127 -0
- package/scripts/lib/maps.mjs +482 -0
- package/skills/acryl-add-provider-or-capability/SKILL.md +12 -0
- package/skills/acryl-add-ui/SKILL.md +18 -0
- package/skills/acryl-build-plugin/SKILL.md +21 -0
- package/skills/acryl-change-plugin/SKILL.md +16 -0
- package/skills/acryl-desktop-shell/SKILL.md +12 -0
- package/skills/acryl-diagnose-plugin/SKILL.md +10 -0
- package/skills/acryl-fix-plugin/SKILL.md +12 -0
- package/skills/acryl-improve-ui/SKILL.md +10 -0
- package/skills/acryl-remove-plugin/SKILL.md +11 -0
- package/skills/acryl-restyle-ui/SKILL.md +14 -0
- package/skills/acryl-share-plugin/SKILL.md +23 -0
- package/skills/acryl-tui-ui/SKILL.md +12 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "acryl-example-llm-echo",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Registers an echo LLM provider route (adapter contract demo)",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"cordis.patch.yml"
|
|
16
|
+
],
|
|
17
|
+
"dsh": {
|
|
18
|
+
"bundle": {
|
|
19
|
+
"patch": "./cordis.patch.yml"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@deepseek-ai/dsh-llm": "0.2.0-rc.2"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Example: prompt-assemble-hook.basic
|
|
2
|
+
// Type: event-hook (lifecycle interception: prompt construction)
|
|
3
|
+
// Surfaces: tui web desktop
|
|
4
|
+
// Teaches: hook the moment the system prompt is assembled, the way pi.dev's `before_agent_start` lets an extension customize the prompt. The
|
|
5
|
+
// harness emits `system-prompt/assemble` as a WATERFALL: `ctx.on('system-prompt/assemble', async (assembly, context, next) => ...)`.
|
|
6
|
+
// Call `next()` to get the assembly the rest of the chain built (`{ sections, contexts, tools, variables }`), change what you want, and
|
|
7
|
+
// RETURN it: the returned value is authoritative. A listener that does not call `next()` cuts every other plugin out of the prompt, so
|
|
8
|
+
// always `await next()`. Here we append one section; `@acryldev/system-prompt` uses the same hook to tag every section. Register inside
|
|
9
|
+
// `ctx.effect` so the section leaves with the plugin. Other lifecycle hooks (`agent/pre-step`, `agent/request`, `llm/stream`, session
|
|
10
|
+
// events) are listed in maps/events.md.
|
|
11
|
+
// Expect: row ACTIVE; the assembled prompt gains a section named `example:note`.
|
|
12
|
+
// Docs: extending.event-hook
|
|
13
|
+
// Pattern: plugins/system-prompt/src/index.ts
|
|
14
|
+
export const name = 'acryl-example-prompt-hook'
|
|
15
|
+
export const inject = ['systemPrompt']
|
|
16
|
+
|
|
17
|
+
export function apply(ctx) {
|
|
18
|
+
ctx.effect(() => ctx.on('system-prompt/assemble', async (_assembly, _context, next) => {
|
|
19
|
+
const assembled = await next()
|
|
20
|
+
return { ...assembled, sections: [...assembled.sections, { name: 'example:note', text: '<example_note>\nThis line was added by an example plugin through the system-prompt/assemble hook.\n</example_note>' }] }
|
|
21
|
+
}), 'acryl-example-prompt-hook: assemble listener')
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "acryl-example-prompt-hook",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Adds a section to the system prompt through the harness's system-prompt/assemble waterfall",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"cordis.patch.yml"
|
|
16
|
+
],
|
|
17
|
+
"dsh": {
|
|
18
|
+
"bundle": {
|
|
19
|
+
"patch": "./cordis.patch.yml"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Example: prompt-contribution.basic
|
|
2
|
+
// Type: prompt-contribution
|
|
3
|
+
// Surfaces: tui web desktop
|
|
4
|
+
// Teaches: ctx.systemPrompt.section({name, order, text}) adds a named, ordered section; the return value is its disposer.
|
|
5
|
+
// Expect: ACTIVE; the section appears in the assembled system prompt.
|
|
6
|
+
// Docs: extending.prompt-contribution
|
|
7
|
+
// Pattern: deepseek-harness docs/subsystems/system-prompt.md
|
|
8
|
+
export const name = 'acryl-example-prompt'
|
|
9
|
+
export const inject = ['systemPrompt']
|
|
10
|
+
|
|
11
|
+
export function apply(ctx) {
|
|
12
|
+
// Orders: tools are 1000-2900, SDK 5000, deliverables 9000, local paths 10000+. Keep static text static (it is cacheable).
|
|
13
|
+
ctx.effect(() => ctx.systemPrompt.section({
|
|
14
|
+
name: 'example:house-style',
|
|
15
|
+
order: 9200,
|
|
16
|
+
text: 'House style: answer briefly and show file paths in full.',
|
|
17
|
+
}))
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "acryl-example-prompt",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Adds a section to the agent system prompt",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"cordis.patch.yml"
|
|
16
|
+
],
|
|
17
|
+
"dsh": {
|
|
18
|
+
"bundle": {
|
|
19
|
+
"patch": "./cordis.patch.yml"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Example: service.consumer
|
|
2
|
+
// Type: service-consumer
|
|
3
|
+
// Surfaces: tui web desktop
|
|
4
|
+
// Teaches: `inject` is a HARD dependency: PENDING until a provider exists, ACTIVE by itself when it does. `ctx.get` is the optional form.
|
|
5
|
+
// Expect: PENDING alone; ACTIVE once service-provider-greeter is installed.
|
|
6
|
+
// Docs: extending.service
|
|
7
|
+
// Pattern: handbook part 6
|
|
8
|
+
export const name = 'acryl-example-greeter-consumer'
|
|
9
|
+
export const inject = ['greeter']
|
|
10
|
+
|
|
11
|
+
export function apply(ctx) {
|
|
12
|
+
ctx.logger.info(`[greeter-consumer] ${ctx.greeter.greet('consumer')}`)
|
|
13
|
+
// Optional dependency instead: const g = ctx.get('greeter'); if (g) { ... } (never PENDING)
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "acryl-example-greeter-consumer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Consumes the greeter service",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"cordis.patch.yml"
|
|
16
|
+
],
|
|
17
|
+
"dsh": {
|
|
18
|
+
"bundle": {
|
|
19
|
+
"patch": "./cordis.patch.yml"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Example: service.provider
|
|
2
|
+
// Type: service-provider
|
|
3
|
+
// Surfaces: tui web desktop
|
|
4
|
+
// Teaches: a Service subclass provides a named service; export the class as `apply`.
|
|
5
|
+
// Expect: row ACTIVE; ctx.greeter resolves.
|
|
6
|
+
// Docs: extending.service
|
|
7
|
+
// Pattern: handbook part 6, ch03/ch13 of the cordis tutorial
|
|
8
|
+
import { Service } from '@deepseek-ai/cordis'
|
|
9
|
+
|
|
10
|
+
export const name = 'acryl-example-greeter'
|
|
11
|
+
|
|
12
|
+
export class Greeter extends Service {
|
|
13
|
+
constructor(ctx) {
|
|
14
|
+
super(ctx, 'greeter')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
greet(who) {
|
|
18
|
+
return `Hello, ${who}!`
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { Greeter as apply }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "acryl-example-greeter",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Provides a greeter service (class form)",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"cordis.patch.yml"
|
|
16
|
+
],
|
|
17
|
+
"dsh": {
|
|
18
|
+
"bundle": {
|
|
19
|
+
"patch": "./cordis.patch.yml"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@deepseek-ai/cordis": "4.0.4"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Example: settings-section.basic
|
|
2
|
+
// Type: settings-section
|
|
3
|
+
// Surfaces: tui web desktop
|
|
4
|
+
// Teaches: give a plugin user-editable settings. Export a Schemastery `Config`, then register it as a settings
|
|
5
|
+
// section with `ctx.settings.installSection(ctx, NAMESPACE, Config, config, { validate, setSource, onChange })`
|
|
6
|
+
// inside `ctx.inject(['settings'], ...)` so the plugin still mounts where no settings service exists.
|
|
7
|
+
// `setSource` hands you a function returning the CURRENT value (read it on use, never cache it); `onChange`
|
|
8
|
+
// fires after a user edit; `validate` refuses an invalid write before it is stored. A field with
|
|
9
|
+
// `.role('secret')` never appears in responses. On Web and Desktop the browser settings page can render a card
|
|
10
|
+
// for the namespace on the Plugins page (see extending.client-slot: `plugins.item`); without a card the values are still
|
|
11
|
+
// editable in the user settings document.
|
|
12
|
+
// Expect: row ACTIVE; the namespace "acryl-example-settings" is served by the settings service when it exists.
|
|
13
|
+
// Docs: extending.config-schema
|
|
14
|
+
import Schema from '@deepseek-ai/schemastery'
|
|
15
|
+
|
|
16
|
+
export const name = 'acryl-example-settings-section'
|
|
17
|
+
export const NAMESPACE = 'acryl-example-settings'
|
|
18
|
+
|
|
19
|
+
export const Config = Schema.object({
|
|
20
|
+
greeting: Schema.string().default('Hello'),
|
|
21
|
+
loud: Schema.boolean().default(false),
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
export function apply(ctx, config) {
|
|
25
|
+
let current = () => config
|
|
26
|
+
ctx.inject(['settings'], (scoped) => {
|
|
27
|
+
scoped.settings.installSection(ctx, NAMESPACE, Config, config, {
|
|
28
|
+
validate: value => { if (String(value.greeting).length > 40) throw new Error('greeting is too long (max 40)') },
|
|
29
|
+
setSource: source => { current = source },
|
|
30
|
+
onChange: () => { ctx.logger.info(`[settings-example] now: ${JSON.stringify(current())}`) },
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
ctx.logger.info(`[settings-example] initial: ${JSON.stringify(current())}`)
|
|
34
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "acryl-example-settings-section",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Registers a validated settings section (Web and Desktop settings page, config file on the CLI)",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"cordis.patch.yml"
|
|
16
|
+
],
|
|
17
|
+
"dsh": {
|
|
18
|
+
"bundle": {
|
|
19
|
+
"patch": "./cordis.patch.yml"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@deepseek-ai/cordis": "4.0.4",
|
|
24
|
+
"@deepseek-ai/schemastery": "~3.18.4"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Example: skill-provider.basic
|
|
2
|
+
// Type: skill-provider
|
|
3
|
+
// Surfaces: tui web desktop
|
|
4
|
+
// Teaches: a SkillProvider lists candidates (name + description only) and loads the full body on demand.
|
|
5
|
+
// Expect: ACTIVE; the skill appears in the catalog.
|
|
6
|
+
// Docs: extending.skill-provider
|
|
7
|
+
// Pattern: deepseek-harness packages/skill/skill-badge
|
|
8
|
+
export const name = 'acryl-example-skill'
|
|
9
|
+
export const inject = ['skills']
|
|
10
|
+
|
|
11
|
+
const CANDIDATE = {
|
|
12
|
+
name: 'example-checklist',
|
|
13
|
+
description: 'A short pre-merge checklist. Load it when asked to review or ship a change.',
|
|
14
|
+
invocation: { modelInvocable: true, userInvocable: true },
|
|
15
|
+
provider: 'acryl-example-skill',
|
|
16
|
+
source: 'bundled',
|
|
17
|
+
rank: 600,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const provider = {
|
|
21
|
+
name: 'acryl-example-skill',
|
|
22
|
+
list: () => Promise.resolve([CANDIDATE]),
|
|
23
|
+
get: async () => ({
|
|
24
|
+
...CANDIDATE,
|
|
25
|
+
content: '# Pre-merge checklist\n\n1. Tests pass.\n2. No secrets in the diff.\n3. Docs updated.\n',
|
|
26
|
+
}),
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function apply(ctx) {
|
|
30
|
+
ctx.skills.registerProvider(() => provider)
|
|
31
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "acryl-example-skill",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Provides a bundled skill",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"cordis.patch.yml"
|
|
16
|
+
],
|
|
17
|
+
"dsh": {
|
|
18
|
+
"bundle": {
|
|
19
|
+
"patch": "./cordis.patch.yml"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Example: state.host-store (browser half)
|
|
2
|
+
// Type: client-slot
|
|
3
|
+
// Surfaces: web desktop
|
|
4
|
+
// Teaches: read and write host-side state from the page with `ctx.connection.rpc.call('/api', '<plugin>/<endpoint>', payload)`, answered
|
|
5
|
+
// by the routes index.js registers under `/api`. The component keeps only a view of the data; the host file is the source of truth.
|
|
6
|
+
// Expect: a "Shared notes" button beside Settings; the notes it shows are identical in Web and Desktop.
|
|
7
|
+
// Docs: extending.state-and-persistence
|
|
8
|
+
window.__ModuleLoader__.load({ id: 'acryl-example-state-host', factory: (require) => {
|
|
9
|
+
var module = { exports: {} }; var exports = module.exports;
|
|
10
|
+
|
|
11
|
+
const React = require('react')
|
|
12
|
+
const { Button, Modal, Input } = require('@deepseek-ai/dsh-client-ui-primitives')
|
|
13
|
+
const h = React.createElement
|
|
14
|
+
const ID = 'acryl-example-state-host'
|
|
15
|
+
const PREFIX = 'acryl-example-state-host'
|
|
16
|
+
|
|
17
|
+
function makeSharedNotes(connection) {
|
|
18
|
+
// `rpc.call` resolves to an envelope: `{ ok: true, value }` or `{ ok: false, error: { code, message, details } }` (transport, auth or a
|
|
19
|
+
// handler that threw). Unwrap it once here; the value is whatever the host handler returned.
|
|
20
|
+
const call = async (endpoint, payload) => {
|
|
21
|
+
// Always send an object: the request envelope requires a `payload` key, and `undefined` is dropped by JSON, which the host rejects
|
|
22
|
+
// as "invalid client-request message".
|
|
23
|
+
const result = await connection.rpc.call('/api', `${PREFIX}/${endpoint}`, payload ?? {})
|
|
24
|
+
if (result && result.ok === false) throw new Error(result.error && result.error.message ? result.error.message : 'RPC call failed')
|
|
25
|
+
return result && result.ok === true ? result.value : result
|
|
26
|
+
}
|
|
27
|
+
return function SharedNotes({ wide }) {
|
|
28
|
+
const [open, setOpen] = React.useState(false)
|
|
29
|
+
const [notes, setNotes] = React.useState([])
|
|
30
|
+
const [draft, setDraft] = React.useState('')
|
|
31
|
+
const [error, setError] = React.useState('')
|
|
32
|
+
const apply = result => { setError(''); setNotes(result.notes) }
|
|
33
|
+
// Re-read from the host every time the panel opens: another window may have changed the file.
|
|
34
|
+
React.useEffect(() => { if (open) call('list').then(apply).catch(e => setError(String(e && e.message || e))) }, [open])
|
|
35
|
+
const add = () => { if (draft.trim()) call('add', { text: draft }).then(apply).then(() => setDraft('')).catch(e => setError(String(e && e.message || e))) }
|
|
36
|
+
return h(React.Fragment, null,
|
|
37
|
+
h(Button, { variant: 'ghost', onClick: () => setOpen(true), title: 'Shared notes' }, wide ? 'Shared notes' : 'S'),
|
|
38
|
+
h(Modal, { open, onClose: () => setOpen(false), title: 'Shared notes', closeLabel: 'Close', footer: h(Button, { variant: 'primary', onClick: add }, 'Add') },
|
|
39
|
+
h(Input, { value: draft, placeholder: 'New note', onChange: e => setDraft(e.target.value), onKeyDown: e => { if (e.key === 'Enter') add() } }),
|
|
40
|
+
error ? h('p', { role: 'alert' }, error) : null,
|
|
41
|
+
notes.map(n => h('div', { key: n.id, style: { display: 'flex', gap: 8, alignItems: 'center', margin: '6px 0' } },
|
|
42
|
+
h('span', { style: { flex: 1 } }, n.text),
|
|
43
|
+
h(Button, { variant: 'ghost', size: 'sm', onClick: () => call('remove', { id: n.id }).then(apply) }, 'Delete')))))
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Required services: the slot registry and the connection (the authenticated channel to the host).
|
|
48
|
+
exports.inject = ['slots', 'connection']
|
|
49
|
+
|
|
50
|
+
exports.apply = function apply(ctx) {
|
|
51
|
+
console.info('[' + ID + '] apply: registering shared notes')
|
|
52
|
+
const SharedNotes = makeSharedNotes(ctx.connection)
|
|
53
|
+
ctx.slots.inject('sidebar.footer.action', () =>
|
|
54
|
+
ctx.slots.register({ name: 'sidebar.footer.action', id: ID, order: 60 }, SharedNotes))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return module.exports; } });
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Example: state.host-store (host half)
|
|
2
|
+
// Type: host-route
|
|
3
|
+
// Surfaces: web desktop
|
|
4
|
+
// Teaches: PERSIST STATE ON THE HOST so it survives a browser reset and is shared by every window, browser and surface that uses the same
|
|
5
|
+
// ACRYL home. The client calls `connection.rpc.call('/api', '<plugin>/<endpoint>', payload)` (client.js); the host answers on
|
|
6
|
+
// exact routes under `/api` (`connection.fetch.register` here), in the RPC envelope, so the call is behind connection's
|
|
7
|
+
// browser-auth and Host/Origin fence and works in stock DSH too. The data is a JSON file under the DSH home, written atomically.
|
|
8
|
+
// Not `connection.rpc.handle`: stock DSH's connection row does not declare `webServer`, so a third-party channel fails there with
|
|
9
|
+
// `cannot get property "webServer" without inject` (ACRYL patches that row; spec 044 S11). Not a plain router route
|
|
10
|
+
// either: it would skip that auth fence.
|
|
11
|
+
// Compare: localStorage is per browser origin (Web and Desktop never share it).
|
|
12
|
+
// Expect: ACTIVE on web/desktop in ACRYL and in stock DSH; the client lists, adds and removes notes; the file
|
|
13
|
+
// `<DSH_HOME>/plugin-data/acryl-example-state-host/notes.json` holds them.
|
|
14
|
+
// Docs: extending.state-and-persistence
|
|
15
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
|
|
16
|
+
import { join } from 'node:path'
|
|
17
|
+
|
|
18
|
+
export const name = 'acryl-example-state-host'
|
|
19
|
+
// `connection` serves the routes (under its own `/api` route, so no `webServer` here). `dshHomePath` is declared too: the data directory
|
|
20
|
+
// comes only from the app's home, so in an app without it the plugin waits (PENDING) instead of guessing a folder.
|
|
21
|
+
export const inject = ['connection', 'dshHomePath']
|
|
22
|
+
|
|
23
|
+
/** Endpoints live at `/api/<PREFIX>/<endpoint>`; the client calls them as `connection.rpc.call('/api', '<PREFIX>/<endpoint>', payload)`. */
|
|
24
|
+
const PREFIX = 'acryl-example-state-host'
|
|
25
|
+
const MAX_NOTES = 500
|
|
26
|
+
const MAX_TEXT = 4000
|
|
27
|
+
|
|
28
|
+
/** The plugin's private data directory: `<DSH home>/plugin-data/<name>`. `dshHomePath` is the harness helper for the DSH home. */
|
|
29
|
+
function dataDir(ctx) {
|
|
30
|
+
return ctx.get('dshHomePath')('plugin-data', name)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function apply(ctx) {
|
|
34
|
+
const dir = dataDir(ctx)
|
|
35
|
+
const file = join(dir, 'notes.json')
|
|
36
|
+
|
|
37
|
+
function read() {
|
|
38
|
+
try {
|
|
39
|
+
const parsed = JSON.parse(readFileSync(file, 'utf8'))
|
|
40
|
+
return Array.isArray(parsed) ? parsed.filter(n => n && typeof n.id === 'string' && typeof n.text === 'string') : []
|
|
41
|
+
} catch { return [] } // first run, or a damaged file: start empty rather than crash the plugin
|
|
42
|
+
}
|
|
43
|
+
// Write to a temp file and rename, so a crash mid-write never leaves half a JSON document.
|
|
44
|
+
function write(notes) {
|
|
45
|
+
mkdirSync(dir, { recursive: true })
|
|
46
|
+
const temp = `${file}.tmp`
|
|
47
|
+
writeFileSync(temp, JSON.stringify(notes, null, 2))
|
|
48
|
+
renameSync(temp, file)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// A handler returns the RPC result shape: `{ ok: true, value }` or `{ ok: false, error: { code, message, details } }`. Any other shape is
|
|
52
|
+
// rejected by the connection as "invalid server-response result".
|
|
53
|
+
const fail = message => ({ ok: false, error: { code: 'bad-request', message, details: {} } })
|
|
54
|
+
const done = notes => ({ ok: true, value: { notes } })
|
|
55
|
+
|
|
56
|
+
const handlers = {
|
|
57
|
+
list: () => done(read()),
|
|
58
|
+
add: payload => {
|
|
59
|
+
const text = String(payload?.text ?? '').trim() // validate every input: the page can send anything
|
|
60
|
+
if (text === '') return fail('text is required')
|
|
61
|
+
if (text.length > MAX_TEXT) return fail(`text is too long (max ${MAX_TEXT})`)
|
|
62
|
+
const notes = [{ id: `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`, text, at: new Date().toISOString() }, ...read()].slice(0, MAX_NOTES)
|
|
63
|
+
write(notes)
|
|
64
|
+
return done(notes)
|
|
65
|
+
},
|
|
66
|
+
remove: payload => {
|
|
67
|
+
const notes = read().filter(n => n.id !== String(payload?.id ?? ''))
|
|
68
|
+
write(notes)
|
|
69
|
+
return done(notes)
|
|
70
|
+
},
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// One exact route per endpoint. The request is the RPC envelope `rpc.call` sends ({ type: 'client-request', rpcId, method, payload });
|
|
74
|
+
// the answer echoes its rpcId ({ type: 'server-response', rpcId, result }). Each registration is owned by this plugin and removed with it.
|
|
75
|
+
for (const [endpoint, handler] of Object.entries(handlers)) {
|
|
76
|
+
ctx.connection.fetch.register({
|
|
77
|
+
path: `/api/${PREFIX}/${endpoint}`,
|
|
78
|
+
methods: ['POST'],
|
|
79
|
+
requestBody: 'buffered',
|
|
80
|
+
async fetch(request) {
|
|
81
|
+
let message
|
|
82
|
+
try { message = await request.json() } catch { return new Response('body is not JSON', { status: 400 }) }
|
|
83
|
+
if (message?.type !== 'client-request' || typeof message.rpcId !== 'string') return new Response('not an RPC request', { status: 400 })
|
|
84
|
+
let result
|
|
85
|
+
try { result = handler(message.payload) } catch (cause) { result = fail(String(cause?.message ?? cause)) }
|
|
86
|
+
return Response.json({ type: 'server-response', rpcId: message.rpcId, result })
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "acryl-example-state-host",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Shared notes kept on the host (a JSON file under the DSH home), so Web and Desktop see the same data",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js",
|
|
11
|
+
"./package.json": "./package.json",
|
|
12
|
+
"./client": "./client.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"index.js",
|
|
16
|
+
"cordis.patch.yml",
|
|
17
|
+
"client.js"
|
|
18
|
+
],
|
|
19
|
+
"dsh": {
|
|
20
|
+
"bundle": {
|
|
21
|
+
"patch": "./cordis.patch.yml"
|
|
22
|
+
},
|
|
23
|
+
"client": {
|
|
24
|
+
"inject": [
|
|
25
|
+
"@deepseek-ai/dsh-client-ui-primitives",
|
|
26
|
+
"@deepseek-ai/dsh-client-ui-sidebar"
|
|
27
|
+
],
|
|
28
|
+
"platform": "web"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Example: state.workspace-file
|
|
2
|
+
// Type: tool
|
|
3
|
+
// Surfaces: tui web desktop
|
|
4
|
+
// Teaches: PERSIST STATE IN THE PROJECT as a plain file. Notes live in `<workspace>/.acryl/notes.md`, so they are per project, readable by the
|
|
5
|
+
// agent (with its normal file tools) and by the user, and can be committed to git. The workspace is the session's own directory:
|
|
6
|
+
// `exec.agent.session.header.cwd`. Works on every surface (no browser needed). Compare: host-side state (state.host-store) is
|
|
7
|
+
// per ACRYL home and invisible to the project; localStorage is per browser and invisible to the agent.
|
|
8
|
+
// Expect: ACTIVE; the model can call `notes_add` and `notes_list`; the file appears in the session's workspace.
|
|
9
|
+
// Docs: extending.state-and-persistence
|
|
10
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync } from 'node:fs'
|
|
11
|
+
import { isAbsolute, join } from 'node:path'
|
|
12
|
+
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
13
|
+
|
|
14
|
+
export const name = 'acryl-example-state-workspace'
|
|
15
|
+
export const inject = ['tools']
|
|
16
|
+
|
|
17
|
+
const MAX_TEXT = 2000
|
|
18
|
+
|
|
19
|
+
/** The notes file of the session's workspace; refuses to guess a directory when the session has none. */
|
|
20
|
+
function notesFile(exec) {
|
|
21
|
+
const cwd = exec?.agent?.session?.header?.cwd
|
|
22
|
+
if (typeof cwd !== 'string' || !isAbsolute(cwd)) throw new Error('this session has no workspace directory, so there is nowhere to keep project notes')
|
|
23
|
+
return { dir: join(cwd, '.acryl'), file: join(cwd, '.acryl', 'notes.md') }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function apply(ctx) {
|
|
27
|
+
ctx.tools.register(defineTool({
|
|
28
|
+
name: 'notes_add',
|
|
29
|
+
description: 'Append one note to the project notes file (.acryl/notes.md in the workspace).',
|
|
30
|
+
parameters: { text: { type: 'string', required: true, description: 'The note, one or a few lines' } },
|
|
31
|
+
output: { schema: { type: 'string' }, render: (_args, value) => [{ type: 'text', text: value }] },
|
|
32
|
+
async execute(args, exec) {
|
|
33
|
+
const text = String(args.text).trim()
|
|
34
|
+
if (text === '') throw new Error('text is required')
|
|
35
|
+
if (text.length > MAX_TEXT) throw new Error(`text is too long (max ${MAX_TEXT})`)
|
|
36
|
+
const { dir, file } = notesFile(exec)
|
|
37
|
+
mkdirSync(dir, { recursive: true })
|
|
38
|
+
appendFileSync(file, `- ${new Date().toISOString()} ${text.replace(/\n+/gu, ' ')}\n`) // append-only: concurrent sessions never rewrite each other
|
|
39
|
+
return `Saved to ${file}`
|
|
40
|
+
},
|
|
41
|
+
}))
|
|
42
|
+
ctx.tools.register(defineTool({
|
|
43
|
+
name: 'notes_list',
|
|
44
|
+
description: 'Read the project notes file (.acryl/notes.md in the workspace).',
|
|
45
|
+
parameters: {},
|
|
46
|
+
output: { schema: { type: 'string' }, render: (_args, value) => [{ type: 'text', text: value }] },
|
|
47
|
+
async execute(_args, exec) {
|
|
48
|
+
const { file } = notesFile(exec)
|
|
49
|
+
return existsSync(file) ? readFileSync(file, 'utf8') : '(no notes yet)'
|
|
50
|
+
},
|
|
51
|
+
}))
|
|
52
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "acryl-example-state-workspace",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Project notes kept in the workspace as .acryl/notes.md: readable by the agent and the user, versionable in git",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"cordis.patch.yml"
|
|
16
|
+
],
|
|
17
|
+
"dsh": {
|
|
18
|
+
"bundle": {
|
|
19
|
+
"patch": "./cordis.patch.yml"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@deepseek-ai/dsh-tools": "0.2.0-rc.2"
|
|
24
|
+
}
|
|
25
|
+
}
|