@codeworksh/plugin 0.0.1-dev.20260922103030

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 (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +111 -0
  3. package/error-ClDISWlT.d.mts +11 -0
  4. package/event-rIZpnOTo.d.mts +895 -0
  5. package/event.d.mts +2 -0
  6. package/event.mjs +125 -0
  7. package/event.mjs.map +1 -0
  8. package/filesystem-Cp-KapCE.d.mts +142 -0
  9. package/ids-CHjmAdTc.d.mts +43 -0
  10. package/ids.d.mts +2 -0
  11. package/ids.mjs +48 -0
  12. package/ids.mjs.map +1 -0
  13. package/index.d.mts +3 -0
  14. package/index.mjs +3 -0
  15. package/io-BYs7hbiY.d.mts +497 -0
  16. package/location-D4hAfuXF.d.mts +61 -0
  17. package/location.d.mts +2 -0
  18. package/location.mjs +48 -0
  19. package/location.mjs.map +1 -0
  20. package/package.json +200 -0
  21. package/plugin/prompt.d.mts +2 -0
  22. package/plugin/prompt.mjs +7 -0
  23. package/plugin/prompt.mjs.map +1 -0
  24. package/plugin/tool.d.mts +2 -0
  25. package/plugin/tool.mjs +29 -0
  26. package/plugin/tool.mjs.map +1 -0
  27. package/plugin-DbJEpY3M.d.mts +140 -0
  28. package/plugin-lorpq7Oi.mjs +41 -0
  29. package/plugin-lorpq7Oi.mjs.map +1 -0
  30. package/plugin.d.mts +4 -0
  31. package/plugin.mjs +4 -0
  32. package/posix.d.mts +6 -0
  33. package/posix.mjs +8 -0
  34. package/posix.mjs.map +1 -0
  35. package/project-CLGsIFD-.d.mts +21 -0
  36. package/project.d.mts +2 -0
  37. package/project.mjs +22 -0
  38. package/project.mjs.map +1 -0
  39. package/prompt-BcpagjGh.d.mts +10 -0
  40. package/repo.d.mts +42 -0
  41. package/repo.mjs +46 -0
  42. package/repo.mjs.map +1 -0
  43. package/rolldown-runtime-D7D4PA-g.mjs +13 -0
  44. package/sandbox/driver.d.mts +2 -0
  45. package/sandbox/driver.mjs +63 -0
  46. package/sandbox/driver.mjs.map +1 -0
  47. package/sandbox/error.d.mts +7 -0
  48. package/sandbox/error.mjs +15 -0
  49. package/sandbox/error.mjs.map +1 -0
  50. package/sandbox/errors.d.mts +2 -0
  51. package/sandbox/errors.mjs +160 -0
  52. package/sandbox/errors.mjs.map +1 -0
  53. package/sandbox/filesystem.d.mts +2 -0
  54. package/sandbox/filesystem.mjs +142 -0
  55. package/sandbox/filesystem.mjs.map +1 -0
  56. package/sandbox/instance.d.mts +2 -0
  57. package/sandbox/instance.mjs +144 -0
  58. package/sandbox/instance.mjs.map +1 -0
  59. package/sandbox/io.d.mts +2 -0
  60. package/sandbox/io.mjs +127 -0
  61. package/sandbox/io.mjs.map +1 -0
  62. package/sandbox/resource.d.mts +28 -0
  63. package/sandbox/resource.mjs +29 -0
  64. package/sandbox/resource.mjs.map +1 -0
  65. package/sandbox/shell.d.mts +2 -0
  66. package/sandbox/shell.mjs +93 -0
  67. package/sandbox/shell.mjs.map +1 -0
  68. package/sandbox.d.mts +17 -0
  69. package/sandbox.mjs +39 -0
  70. package/sandbox.mjs.map +1 -0
  71. package/schema.d.mts +91 -0
  72. package/schema.mjs +105 -0
  73. package/schema.mjs.map +1 -0
  74. package/settings-CYL6yyDD.d.mts +193 -0
  75. package/settings.d.mts +2 -0
  76. package/settings.mjs +102 -0
  77. package/settings.mjs.map +1 -0
  78. package/shell-CZ6Y4lNU.d.mts +109 -0
  79. package/space-CR-9UxdT.d.mts +25 -0
  80. package/space.d.mts +2 -0
  81. package/space.mjs +33 -0
  82. package/space.mjs.map +1 -0
  83. package/tool/error.d.mts +2 -0
  84. package/tool/error.mjs +11 -0
  85. package/tool/error.mjs.map +1 -0
  86. package/tool/progress.d.mts +2 -0
  87. package/tool/progress.mjs +11 -0
  88. package/tool/progress.mjs.map +1 -0
  89. package/tool-BoVqkYvL.d.mts +287 -0
  90. package/tool-DuYBgiJf.d.mts +142 -0
  91. package/tool.d.mts +2 -0
  92. package/tool.mjs +71 -0
  93. package/tool.mjs.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sanchit Kudari <0xsanchit@gmail.com> & Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # @codeworksh/plugin
2
+
3
+ The SDK for building [CodeWork](https://www.codework.sh) plugins.
4
+
5
+ A plugin is a module that default-exports one plugin object. It registers tools, composes the
6
+ system prompt, and reads the session's sandbox, location, model and settings off a context the
7
+ harness hands it. This package is exactly that contract — and `@codeworksh/harness` depends on it
8
+ too, so a plugin compiled against these types is the same plugin the harness loads, not a
9
+ structurally similar copy.
10
+
11
+ ```bash
12
+ pnpm add @codeworksh/plugin effect
13
+ ```
14
+
15
+ `effect` is a peer dependency: the harness and every plugin share one copy of it.
16
+
17
+ ## A tool plugin
18
+
19
+ ```ts
20
+ import { Plugin, Tool } from "@codeworksh/plugin";
21
+ import { SandboxIO } from "@codeworksh/plugin/sandbox";
22
+ import { Effect, Schema } from "effect";
23
+
24
+ export default Plugin.define({
25
+ id: "acme.tool.wc",
26
+ kind: "tool",
27
+ setup: Effect.fn("WcPlugin.setup")(function* (ctx, options) {
28
+ // The session's shell, wherever it runs — this machine, a container, a remote sandbox.
29
+ const shell = yield* SandboxIO.Shell;
30
+ ctx.plugin.tools.add(
31
+ Tool.register(
32
+ Tool.make({
33
+ name: "count_lines",
34
+ description: "Count the lines in a file.",
35
+ parameters: Schema.Struct({ path: Schema.String }),
36
+ success: Schema.Struct({ lines: Schema.Finite }),
37
+ encodeContent: (success) => [{ type: "text", text: String(success.lines) }],
38
+ handler: ({ path }) =>
39
+ shell
40
+ .exec(`wc -l < ${JSON.stringify(path)}`)
41
+ .pipe(Effect.map((result) => ({ lines: Number(result.stdout.trim()) }))),
42
+ }),
43
+ ),
44
+ );
45
+ }),
46
+ });
47
+ ```
48
+
49
+ `setup` may be synchronous, return a promise, or be an `Effect` — only the `Effect` form can ask
50
+ for a capability such as `SandboxIO.Shell`.
51
+
52
+ ## A prompt plugin
53
+
54
+ ```ts
55
+ import { Plugin } from "@codeworksh/plugin";
56
+
57
+ export default Plugin.define({
58
+ id: "acme.prompt.house-style",
59
+ kind: "prompt",
60
+ setup(ctx) {
61
+ // `set` replaces the whole prompt, so compose on what earlier plugins rendered.
62
+ const existing = ctx.plugin.prompt.get();
63
+ const section = "## House style\n\n- No `any`.";
64
+ ctx.plugin.prompt.set(existing === undefined ? section : `${existing}\n\n${section}`);
65
+ },
66
+ });
67
+ ```
68
+
69
+ ## `kind` decides when a plugin runs
70
+
71
+ Every `tool` plugin runs before any `prompt` plugin, whichever settings layer each came from, so a
72
+ prompt plugin always sees the complete tool set. Plugins within one domain keep the order their
73
+ entries were written in — which is where composition actually happens, a plugin patching another's
74
+ tool or appending to the prompt it rendered.
75
+
76
+ ## Being installed
77
+
78
+ A user selects a plugin from a settings file. A string entry loads a module; an object entry
79
+ configures one something else already selected:
80
+
81
+ ```jsonc
82
+ {
83
+ "plugins": ["@acme/codework-plugin-wc", { "package": "@acme/codework-plugin-wc", "options": { "limit": 40 } }],
84
+ }
85
+ ```
86
+
87
+ The `options` block is handed to `setup` untouched — the harness never looks inside it, so a
88
+ plugin validates its own shape and falls back rather than failing the boot.
89
+
90
+ Publish built JavaScript. Node will not strip types under `node_modules`, so a package that ships
91
+ TypeScript can only be loaded by path.
92
+
93
+ ## What is in here
94
+
95
+ | Import | What it gives you |
96
+ | ---------------------------- | ----------------------------------------------------- |
97
+ | `@codeworksh/plugin` | `Plugin` and `Tool` — defining a plugin and its tools |
98
+ | `@codeworksh/plugin/sandbox` | the mount (`SandboxIO`) and the sandbox driver SDK |
99
+
100
+ That is the whole authoring surface. The package publishes further subpaths — `./event`,
101
+ `./ids`, `./location`, `./settings` and others — because `@codeworksh/harness` imports them across
102
+ the package boundary; they are reachable if you genuinely need one, but they are not re-exported
103
+ from the root entry and are not covered by the stability that `Plugin` and `Tool` carry.
104
+
105
+ Sandbox driver packages use `@codeworksh/plugin/sandbox` the same way: `SandboxDriver.module`
106
+ defines the default export the harness loads.
107
+
108
+ ## Versioning
109
+
110
+ `0.x` — the contract still moves. Pin the version you build against, and keep it in step with the
111
+ `@codeworksh/harness` you target.
@@ -0,0 +1,11 @@
1
+ import { Schema } from "effect";
2
+ //#region src/tool/error.d.ts
3
+ declare const ToolExecutionError_base: Schema.Class<ToolExecutionError, Schema.TaggedStruct<"ToolExecutionError", {
4
+ readonly toolName: Schema.String;
5
+ readonly cause: Schema.Defect;
6
+ }>, import("effect/Cause").YieldableError>;
7
+ /** A typed wrapper for a tool failure crossing the heterogeneous registry boundary. */
8
+ declare class ToolExecutionError extends ToolExecutionError_base {}
9
+ //#endregion
10
+ export { ToolExecutionError as t };
11
+ //# sourceMappingURL=error-ClDISWlT.d.mts.map