@usesketchbook/opencode-plugin 0.0.0-stage → 0.1.0-rc.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 +123 -2
- package/dist/generated/baseline-manifest.d.ts +2 -0
- package/dist/generated/baseline-manifest.js +1590 -0
- package/dist/generated/catalog-baseline.d.ts +2 -0
- package/dist/generated/catalog-baseline.js +255 -0
- package/dist/gui-experimental.cjs +111 -0
- package/dist/gui.d.ts +22 -0
- package/dist/gui.js +34 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +20 -0
- package/dist/rpc.d.ts +1173 -0
- package/dist/rpc.js +212 -0
- package/dist/server/catalog.d.ts +9 -0
- package/dist/server/catalog.js +74 -0
- package/dist/server/decision-guard-hooks.d.ts +2 -0
- package/dist/server/decision-guard-hooks.js +57 -0
- package/dist/server/decision-guards.d.ts +11 -0
- package/dist/server/decision-guards.js +36 -0
- package/dist/server/engine.d.ts +6 -0
- package/dist/server/engine.js +38 -0
- package/dist/server/guard-hooks.d.ts +3 -0
- package/dist/server/guard-hooks.js +35 -0
- package/dist/server/guards.d.ts +13 -0
- package/dist/server/guards.js +42 -0
- package/dist/server/operations.d.ts +93 -0
- package/dist/server/operations.js +300 -0
- package/dist/server/permissions.d.ts +29 -0
- package/dist/server/permissions.js +97 -0
- package/dist/server/rpc.d.ts +126 -0
- package/dist/server/rpc.js +308 -0
- package/dist/server/runner.d.ts +27 -0
- package/dist/server/runner.js +136 -0
- package/dist/server/schema.d.ts +4 -0
- package/dist/server/schema.js +66 -0
- package/dist/server/tools.d.ts +2 -0
- package/dist/server/tools.js +176 -0
- package/dist/server/tui.d.ts +70 -0
- package/dist/server/tui.js +172 -0
- package/dist/shared/catalog.d.ts +52 -0
- package/dist/shared/catalog.js +84 -0
- package/dist/shared/envelope.d.ts +24 -0
- package/dist/shared/envelope.js +28 -0
- package/dist/shared/manifest.d.ts +53 -0
- package/dist/shared/manifest.js +135 -0
- package/dist/test/baseline.test.d.ts +1 -0
- package/dist/test/baseline.test.js +11 -0
- package/dist/test/catalog.test.d.ts +1 -0
- package/dist/test/catalog.test.js +232 -0
- package/dist/test/decision-guards.test.d.ts +1 -0
- package/dist/test/decision-guards.test.js +30 -0
- package/dist/test/engine.test.d.ts +1 -0
- package/dist/test/engine.test.js +23 -0
- package/dist/test/fixtures.d.ts +12 -0
- package/dist/test/fixtures.js +55 -0
- package/dist/test/guard-hooks.integration.test.d.ts +1 -0
- package/dist/test/guard-hooks.integration.test.js +321 -0
- package/dist/test/guard-hooks.test.d.ts +1 -0
- package/dist/test/guard-hooks.test.js +14 -0
- package/dist/test/guards.test.d.ts +1 -0
- package/dist/test/guards.test.js +24 -0
- package/dist/test/gui.test.d.ts +1 -0
- package/dist/test/gui.test.js +61 -0
- package/dist/test/manifest.test.d.ts +1 -0
- package/dist/test/manifest.test.js +86 -0
- package/dist/test/operations.test.d.ts +1 -0
- package/dist/test/operations.test.js +263 -0
- package/dist/test/parity.test.d.ts +1 -0
- package/dist/test/parity.test.js +56 -0
- package/dist/test/permissions.integration.test.d.ts +1 -0
- package/dist/test/permissions.integration.test.js +535 -0
- package/dist/test/permissions.test.d.ts +1 -0
- package/dist/test/permissions.test.js +42 -0
- package/dist/test/rpc.test.d.ts +1 -0
- package/dist/test/rpc.test.js +389 -0
- package/dist/test/runner.test.d.ts +1 -0
- package/dist/test/runner.test.js +47 -0
- package/dist/test/schema.test.d.ts +1 -0
- package/dist/test/schema.test.js +51 -0
- package/dist/test/tui.test.d.ts +1 -0
- package/dist/test/tui.test.js +226 -0
- package/dist/tprobe.d.ts +1 -0
- package/dist/tprobe.js +2 -0
- package/dist/tui.d.ts +10 -0
- package/dist/tui.js +21 -0
- package/dist/views/operations.d.ts +50 -0
- package/dist/views/operations.js +80 -0
- package/package.json +71 -4
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/gui.tsx
|
|
21
|
+
var gui_exports = {};
|
|
22
|
+
__export(gui_exports, {
|
|
23
|
+
GUI_EXPERIMENTAL_MARKER: () => GUI_EXPERIMENTAL_MARKER,
|
|
24
|
+
SKETCHBOOK_DESKTOP_VIEWS: () => SKETCHBOOK_DESKTOP_VIEWS,
|
|
25
|
+
default: () => gui_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(gui_exports);
|
|
28
|
+
var import_gui = require("@opencode/plugin/gui");
|
|
29
|
+
|
|
30
|
+
// src/views/operations.ts
|
|
31
|
+
function formatStatusOverview(input) {
|
|
32
|
+
const lines = [];
|
|
33
|
+
const engine = input.engine;
|
|
34
|
+
if (engine?.name) {
|
|
35
|
+
lines.push(`Engine: ${engine.name}${engine.version ? `@${engine.version}` : ""}`);
|
|
36
|
+
} else {
|
|
37
|
+
lines.push("Engine: not detected");
|
|
38
|
+
}
|
|
39
|
+
if (input.protocolVersion) lines.push(`Protocol: v${input.protocolVersion}`);
|
|
40
|
+
if (input.envelopeVersion !== void 0) lines.push(`Envelope: v${input.envelopeVersion}`);
|
|
41
|
+
if (input.commandCount !== void 0) lines.push(`Commands: ${input.commandCount}`);
|
|
42
|
+
const operations = input.operations ?? [];
|
|
43
|
+
if (operations.length === 0) {
|
|
44
|
+
lines.push("Operations: none in this session");
|
|
45
|
+
} else {
|
|
46
|
+
lines.push(`Operations (${operations.length}):`);
|
|
47
|
+
for (const operation of operations.slice(-8)) {
|
|
48
|
+
lines.push(...formatOperationProgress(operation).map((line) => ` ${line}`));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return lines;
|
|
52
|
+
}
|
|
53
|
+
var PROGRESS_BAR_WIDTH = 12;
|
|
54
|
+
function formatOperationProgress(operation) {
|
|
55
|
+
const lines = [`${operation.command} \xB7 ${operation.operationID}`];
|
|
56
|
+
lines.push(`Status: ${operation.status}`);
|
|
57
|
+
const count = operation.progressCount ?? 0;
|
|
58
|
+
if (operation.status === "running") {
|
|
59
|
+
const filled = Math.min(PROGRESS_BAR_WIDTH, count);
|
|
60
|
+
const meter = `${"\u2588".repeat(filled)}${"\xB7".repeat(PROGRESS_BAR_WIDTH - filled)}`;
|
|
61
|
+
lines.push(`Progress: ${meter} (${count} line${count === 1 ? "" : "s"})`);
|
|
62
|
+
} else if (count > 0) {
|
|
63
|
+
lines.push(`Progress: ${count} line${count === 1 ? "" : "s"} of output`);
|
|
64
|
+
}
|
|
65
|
+
if (operation.finishedAt) lines.push(`Finished: ${operation.finishedAt}`);
|
|
66
|
+
return lines;
|
|
67
|
+
}
|
|
68
|
+
function formatPreviewPlan(plan, preview) {
|
|
69
|
+
const lines = [];
|
|
70
|
+
lines.push(`Preview of ${plan.command ?? "operation"}: ${plan.ok === false ? "FAILED" : "no errors"}`);
|
|
71
|
+
if (preview?.fingerprint) lines.push(`Fingerprint: ${preview.fingerprint}`);
|
|
72
|
+
lines.push(`Changed paths: ${(plan.changed ?? []).length}`);
|
|
73
|
+
const warnings = plan.warnings ?? [];
|
|
74
|
+
if (warnings.length > 0) lines.push(`Warnings (${warnings.length}):`);
|
|
75
|
+
for (const warning of warnings.slice(0, 5)) lines.push(` ! ${String(warning)}`);
|
|
76
|
+
const errors = plan.errors ?? [];
|
|
77
|
+
if (errors.length > 0) lines.push(`Errors (${errors.length}):`);
|
|
78
|
+
for (const error of errors.slice(0, 5)) lines.push(` x ${String(error)}`);
|
|
79
|
+
lines.push("Applying runs the same command for real; nothing was written yet.");
|
|
80
|
+
return lines;
|
|
81
|
+
}
|
|
82
|
+
function formatApplyResult(result) {
|
|
83
|
+
return [
|
|
84
|
+
`Applied ${result.command ?? "operation"} (${result.operationID ?? "unknown"}).`,
|
|
85
|
+
`Changed paths: ${(result.envelope?.changed ?? []).length}`
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/gui.tsx
|
|
90
|
+
var GUI_EXPERIMENTAL_MARKER = "sketchbook-desktop-experimental";
|
|
91
|
+
var SKETCHBOOK_DESKTOP_VIEWS = {
|
|
92
|
+
status: formatStatusOverview,
|
|
93
|
+
operation: formatOperationProgress,
|
|
94
|
+
preview: formatPreviewPlan,
|
|
95
|
+
applyResult: formatApplyResult
|
|
96
|
+
};
|
|
97
|
+
var gui_default = import_gui.Plugin.define({
|
|
98
|
+
i18n: {
|
|
99
|
+
en: {
|
|
100
|
+
title: "Sketchbook (experimental)",
|
|
101
|
+
statusTitle: "Sketchbook status (experimental)"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
setup() {
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
+
0 && (module.exports = {
|
|
109
|
+
GUI_EXPERIMENTAL_MARKER,
|
|
110
|
+
SKETCHBOOK_DESKTOP_VIEWS
|
|
111
|
+
});
|
package/dist/gui.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Plugin } from "@opencode/plugin/gui";
|
|
2
|
+
import { formatApplyResult, formatOperationProgress, formatPreviewPlan, formatStatusOverview } from "./views/operations.js";
|
|
3
|
+
/**
|
|
4
|
+
* EXPERIMENTAL Desktop interface for Sketchbook (`./gui-experimental`).
|
|
5
|
+
*
|
|
6
|
+
* This surface is explicitly experimental, per the plugin decision record:
|
|
7
|
+
* it must never destabilize the server or TUI parts. The Desktop panel is a
|
|
8
|
+
* read-only rendering of the same shared view sources the TUI uses
|
|
9
|
+
* (`src/views/operations.ts`); any apply flow goes through the same
|
|
10
|
+
* preview-then-apply-after-confirmation RPC path as the TUI, so no writes
|
|
11
|
+
* happen outside apply-after-validation. Setup performs no engine work.
|
|
12
|
+
*/
|
|
13
|
+
/** Stable marker used by hosts and tests to identify the experimental bundle. */
|
|
14
|
+
export declare const GUI_EXPERIMENTAL_MARKER = "sketchbook-desktop-experimental";
|
|
15
|
+
export declare const SKETCHBOOK_DESKTOP_VIEWS: {
|
|
16
|
+
readonly status: typeof formatStatusOverview;
|
|
17
|
+
readonly operation: typeof formatOperationProgress;
|
|
18
|
+
readonly preview: typeof formatPreviewPlan;
|
|
19
|
+
readonly applyResult: typeof formatApplyResult;
|
|
20
|
+
};
|
|
21
|
+
declare const _default: Plugin.Definition<{}, {}>;
|
|
22
|
+
export default _default;
|
package/dist/gui.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Plugin } from "@opencode/plugin/gui";
|
|
2
|
+
import { formatApplyResult, formatOperationProgress, formatPreviewPlan, formatStatusOverview, } from "./views/operations.js";
|
|
3
|
+
/**
|
|
4
|
+
* EXPERIMENTAL Desktop interface for Sketchbook (`./gui-experimental`).
|
|
5
|
+
*
|
|
6
|
+
* This surface is explicitly experimental, per the plugin decision record:
|
|
7
|
+
* it must never destabilize the server or TUI parts. The Desktop panel is a
|
|
8
|
+
* read-only rendering of the same shared view sources the TUI uses
|
|
9
|
+
* (`src/views/operations.ts`); any apply flow goes through the same
|
|
10
|
+
* preview-then-apply-after-confirmation RPC path as the TUI, so no writes
|
|
11
|
+
* happen outside apply-after-validation. Setup performs no engine work.
|
|
12
|
+
*/
|
|
13
|
+
/** Stable marker used by hosts and tests to identify the experimental bundle. */
|
|
14
|
+
export const GUI_EXPERIMENTAL_MARKER = "sketchbook-desktop-experimental";
|
|
15
|
+
export const SKETCHBOOK_DESKTOP_VIEWS = {
|
|
16
|
+
status: formatStatusOverview,
|
|
17
|
+
operation: formatOperationProgress,
|
|
18
|
+
preview: formatPreviewPlan,
|
|
19
|
+
applyResult: formatApplyResult,
|
|
20
|
+
};
|
|
21
|
+
export default Plugin.define({
|
|
22
|
+
i18n: {
|
|
23
|
+
en: {
|
|
24
|
+
title: "Sketchbook (experimental)",
|
|
25
|
+
statusTitle: "Sketchbook status (experimental)",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
setup() {
|
|
29
|
+
// The desktop panel renders SKETCHBOOK_DESKTOP_VIEWS (read-only) and
|
|
30
|
+
// routes any mutation through the SketchbookRpc preview → confirm →
|
|
31
|
+
// apply flow shared with the TUI. Nothing to register eagerly: setup
|
|
32
|
+
// must stay free of engine execution and project writes.
|
|
33
|
+
},
|
|
34
|
+
});
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Plugin } from "@opencode/plugin";
|
|
2
|
+
import { setupTools } from "./server/tools.js";
|
|
3
|
+
import { setupGuardHooks } from "./server/guard-hooks.js";
|
|
4
|
+
import { setupDecisionGuardHooks } from "./server/decision-guard-hooks.js";
|
|
5
|
+
import { setupCatalogSurfaces } from "./server/catalog.js";
|
|
6
|
+
import { setupRpc } from "./server/rpc.js";
|
|
7
|
+
export default Plugin.define({
|
|
8
|
+
id: "sketchbook",
|
|
9
|
+
async setup(ctx) {
|
|
10
|
+
await setupTools(ctx);
|
|
11
|
+
await setupRpc(ctx);
|
|
12
|
+
await setupCatalogSurfaces(ctx);
|
|
13
|
+
const disposeGuards = await setupGuardHooks(ctx);
|
|
14
|
+
const disposeDecisions = await setupDecisionGuardHooks(ctx);
|
|
15
|
+
return async () => {
|
|
16
|
+
await disposeDecisions();
|
|
17
|
+
await disposeGuards();
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
});
|