@pragma-sh/opencode-plugin 0.1.0-alpha.0 → 1.0.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/dist/index.mjs +26 -1
- package/dist/pragma-plugin.mjs +8 -4
- package/package.json +9 -4
- package/pragma-plugin.json +5 -1
package/dist/index.mjs
CHANGED
|
@@ -507,6 +507,7 @@ function createPragmaOpencodeHooks(reporter) {
|
|
|
507
507
|
const childSessions = new Map;
|
|
508
508
|
const activeChildSessions = new Set;
|
|
509
509
|
let pendingLegacyQuestion = null;
|
|
510
|
+
let activeCanonicalQuestionId = null;
|
|
510
511
|
const EVENT_HANDLERS = {
|
|
511
512
|
"session.status": applySessionStatusEvent,
|
|
512
513
|
"session.idle": applySessionIdleEvent,
|
|
@@ -550,6 +551,7 @@ function createPragmaOpencodeHooks(reporter) {
|
|
|
550
551
|
return false;
|
|
551
552
|
}
|
|
552
553
|
cancelPendingLegacyQuestion();
|
|
554
|
+
activeCanonicalQuestionId = questionRequestId(event) ?? null;
|
|
553
555
|
await raiseQuestionAttention(isRecord(event.properties) ? event.properties : {}, questionRequestId(event));
|
|
554
556
|
return true;
|
|
555
557
|
}
|
|
@@ -696,6 +698,7 @@ function createPragmaOpencodeHooks(reporter) {
|
|
|
696
698
|
}
|
|
697
699
|
async function clear() {
|
|
698
700
|
cancelPendingLegacyQuestion();
|
|
701
|
+
activeCanonicalQuestionId = null;
|
|
699
702
|
busy = false;
|
|
700
703
|
attention = false;
|
|
701
704
|
childSessions.clear();
|
|
@@ -813,8 +816,13 @@ function createPragmaOpencodeHooks(reporter) {
|
|
|
813
816
|
busy = true;
|
|
814
817
|
return "sync";
|
|
815
818
|
}
|
|
816
|
-
function applyQuestionRepliedEvent() {
|
|
819
|
+
function applyQuestionRepliedEvent(event) {
|
|
820
|
+
const responseId = questionResponseId(event);
|
|
821
|
+
if (activeCanonicalQuestionId !== null && responseId !== activeCanonicalQuestionId) {
|
|
822
|
+
return "none";
|
|
823
|
+
}
|
|
817
824
|
cancelPendingLegacyQuestion();
|
|
825
|
+
activeCanonicalQuestionId = null;
|
|
818
826
|
attention = false;
|
|
819
827
|
busy = true;
|
|
820
828
|
return "sync";
|
|
@@ -918,6 +926,9 @@ function createPragmaOpencodeHooks(reporter) {
|
|
|
918
926
|
return isRecord(part) ? part : undefined;
|
|
919
927
|
}
|
|
920
928
|
function applyQuestionPartState(part) {
|
|
929
|
+
if (activeCanonicalQuestionId !== null) {
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
921
932
|
const state = isRecord(part.state) ? part.state : undefined;
|
|
922
933
|
if (questionPartFinished(state)) {
|
|
923
934
|
cancelPendingLegacyQuestion();
|
|
@@ -931,9 +942,15 @@ function createPragmaOpencodeHooks(reporter) {
|
|
|
931
942
|
}
|
|
932
943
|
}
|
|
933
944
|
function scheduleLegacyQuestionAttention(args, requestId) {
|
|
945
|
+
if (activeCanonicalQuestionId !== null) {
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
934
948
|
cancelPendingLegacyQuestion();
|
|
935
949
|
pendingLegacyQuestion = setTimeout(() => {
|
|
936
950
|
pendingLegacyQuestion = null;
|
|
951
|
+
if (activeCanonicalQuestionId !== null) {
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
937
954
|
raiseQuestionAttention(args, requestId).catch(() => {
|
|
938
955
|
return;
|
|
939
956
|
});
|
|
@@ -1011,6 +1028,14 @@ function questionRequestId(event) {
|
|
|
1011
1028
|
const properties = event.properties;
|
|
1012
1029
|
return isRecord(properties) && typeof properties.id === "string" ? properties.id : undefined;
|
|
1013
1030
|
}
|
|
1031
|
+
function questionResponseId(event) {
|
|
1032
|
+
const properties = event.properties;
|
|
1033
|
+
if (!isRecord(properties))
|
|
1034
|
+
return;
|
|
1035
|
+
if (typeof properties.requestID === "string")
|
|
1036
|
+
return properties.requestID;
|
|
1037
|
+
return typeof properties.id === "string" ? properties.id : undefined;
|
|
1038
|
+
}
|
|
1014
1039
|
function permissionRequestId() {
|
|
1015
1040
|
return `opencode-${globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`}`;
|
|
1016
1041
|
}
|
package/dist/pragma-plugin.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// ../plugin/dist/shared/chunk-
|
|
2
|
-
var PLUGIN_API_VERSION = "
|
|
1
|
+
// ../plugin/dist/shared/chunk-jypnsjrp.js
|
|
2
|
+
var PLUGIN_API_VERSION = "1.0.0";
|
|
3
3
|
|
|
4
|
-
// ../plugin/dist/shared/chunk-
|
|
4
|
+
// ../plugin/dist/shared/chunk-jx8c1n1n.js
|
|
5
5
|
function defineAgent(input) {
|
|
6
6
|
return input;
|
|
7
7
|
}
|
|
@@ -574,7 +574,11 @@ function splitWhitespaceModel(line) {
|
|
|
574
574
|
return id?.includes("/") ? [id, parts.slice(1).join(" ") || displayName(id)] : [undefined, undefined];
|
|
575
575
|
}
|
|
576
576
|
function displayName(id) {
|
|
577
|
-
|
|
577
|
+
const bare = id.split("/").at(-1);
|
|
578
|
+
if (!bare) {
|
|
579
|
+
return id;
|
|
580
|
+
}
|
|
581
|
+
return bare.replaceAll(/(?<=\d)-(?=\d)/g, ".").replaceAll(/[-_]/g, " ");
|
|
578
582
|
}
|
|
579
583
|
function withProvider(id, name, provider = id.includes("/") ? id.split("/", 1)[0] : "") {
|
|
580
584
|
return provider && !name.endsWith(`(${provider})`) ? `${name} (${provider})` : name;
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pragma-sh/opencode-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "opencode plugin that reports agent status to Pragma automatically.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/pragma-sh/pragma.git",
|
|
9
|
+
"directory": "packages/opencode-plugin"
|
|
10
|
+
},
|
|
6
11
|
"files": [
|
|
7
12
|
"assets",
|
|
8
13
|
"dist",
|
|
@@ -32,9 +37,9 @@
|
|
|
32
37
|
},
|
|
33
38
|
"devDependencies": {
|
|
34
39
|
"@opencode-ai/plugin": "^1.17.8",
|
|
35
|
-
"@pragma/plugin": "workspace:*",
|
|
36
|
-
"@pragma/sdk": "workspace:*",
|
|
37
|
-
"@pragma/watcher-kit": "workspace:*",
|
|
40
|
+
"@pragma-sh/plugin": "workspace:*",
|
|
41
|
+
"@pragma-sh/sdk": "workspace:*",
|
|
42
|
+
"@pragma-sh/watcher-kit": "workspace:*",
|
|
38
43
|
"@types/node": "^24.12.3",
|
|
39
44
|
"bunup": "^0.16.32",
|
|
40
45
|
"typescript": "^6.0.3",
|
package/pragma-plugin.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/pragma-sh/pragma/main/packages/plugin-registry/pragma-plugin.schema.json",
|
|
3
3
|
"name": "OpenCode",
|
|
4
4
|
"description": "Launch OpenCode in Pragma with streaming status, approvals, questions, and usage limits.",
|
|
5
|
+
"longDescription": "Launch OpenCode from the Pragma launcher with streaming status, approvals, questions, and usage limits. The plugin wires OpenCode's event stream into Pragma, so a session started here reports progress live and can be answered from the tab or the agent board.",
|
|
5
6
|
"categories": ["agent-plugin"],
|
|
6
7
|
"images": [
|
|
7
8
|
{
|
|
@@ -9,6 +10,9 @@
|
|
|
9
10
|
"alt": "OpenCode logo"
|
|
10
11
|
}
|
|
11
12
|
],
|
|
12
|
-
"install": {
|
|
13
|
+
"install": {
|
|
14
|
+
"command": "node",
|
|
15
|
+
"args": ["scripts/install.mjs"]
|
|
16
|
+
},
|
|
13
17
|
"agentBinary": "opencode"
|
|
14
18
|
}
|