@ossdeveloper/github-compliance 1.0.0 → 1.0.2
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/plugin.js +31 -25
- package/package.json +1 -1
- package/tools.ts +37 -25
package/dist/plugin.js
CHANGED
|
@@ -12796,52 +12796,58 @@ function tool(input) {
|
|
|
12796
12796
|
tool.schema = exports_external;
|
|
12797
12797
|
// tools.ts
|
|
12798
12798
|
var createComplianceRecordTool = tool({
|
|
12799
|
-
description: "Create
|
|
12799
|
+
description: "Create compliance record",
|
|
12800
12800
|
args: {
|
|
12801
|
-
tool_name:
|
|
12802
|
-
owner:
|
|
12803
|
-
repo:
|
|
12804
|
-
title:
|
|
12805
|
-
body:
|
|
12806
|
-
github_username:
|
|
12807
|
-
approved_at:
|
|
12808
|
-
checks:
|
|
12809
|
-
check_type: tool.schema.string({ description: "Type of check performed" }),
|
|
12810
|
-
passed: tool.schema.boolean({ description: "Whether check passed" }),
|
|
12811
|
-
details: tool.schema.record(tool.schema.string(), tool.schema.any()).optional({ description: "Additional details" })
|
|
12812
|
-
})).optional({ description: "List of compliance checks performed" })
|
|
12801
|
+
tool_name: exports_external.string(),
|
|
12802
|
+
owner: exports_external.string(),
|
|
12803
|
+
repo: exports_external.string(),
|
|
12804
|
+
title: exports_external.string().optional(),
|
|
12805
|
+
body: exports_external.string(),
|
|
12806
|
+
github_username: exports_external.string(),
|
|
12807
|
+
approved_at: exports_external.string(),
|
|
12808
|
+
checks: exports_external.string().optional()
|
|
12813
12809
|
},
|
|
12814
12810
|
async execute(args, _context) {
|
|
12811
|
+
let checks3 = [];
|
|
12812
|
+
if (args.checks) {
|
|
12813
|
+
try {
|
|
12814
|
+
checks3 = JSON.parse(args.checks);
|
|
12815
|
+
} catch {
|
|
12816
|
+
checks3 = [];
|
|
12817
|
+
}
|
|
12818
|
+
}
|
|
12819
|
+
const body = Buffer.from(args.body, "base64").toString("utf-8");
|
|
12820
|
+
const title = args.title ? Buffer.from(args.title, "base64").toString("utf-8") : null;
|
|
12815
12821
|
const input = {
|
|
12816
12822
|
tool_name: args.tool_name,
|
|
12817
12823
|
owner: args.owner,
|
|
12818
12824
|
repo: args.repo,
|
|
12819
|
-
title
|
|
12820
|
-
body
|
|
12825
|
+
title,
|
|
12826
|
+
body,
|
|
12821
12827
|
github_username: args.github_username,
|
|
12822
12828
|
approved_at: args.approved_at,
|
|
12823
|
-
checks:
|
|
12829
|
+
checks: checks3
|
|
12824
12830
|
};
|
|
12825
12831
|
const recordId = await createComplianceRecord(input);
|
|
12826
|
-
return {
|
|
12832
|
+
return JSON.stringify({
|
|
12827
12833
|
success: true,
|
|
12828
12834
|
record_id: recordId,
|
|
12829
|
-
message: "Compliance record created
|
|
12835
|
+
message: "Compliance record created",
|
|
12830
12836
|
expires_at: new Date(Date.now() + 30 * 60 * 1000).toISOString()
|
|
12831
|
-
};
|
|
12837
|
+
});
|
|
12832
12838
|
}
|
|
12833
12839
|
});
|
|
12834
12840
|
var getComplianceStatusTool = tool({
|
|
12835
|
-
description: "Check
|
|
12841
|
+
description: "Check compliance status",
|
|
12836
12842
|
args: {
|
|
12837
|
-
tool_name:
|
|
12838
|
-
owner:
|
|
12839
|
-
repo:
|
|
12840
|
-
content_hash:
|
|
12843
|
+
tool_name: exports_external.string(),
|
|
12844
|
+
owner: exports_external.string(),
|
|
12845
|
+
repo: exports_external.string(),
|
|
12846
|
+
content_hash: exports_external.string()
|
|
12841
12847
|
},
|
|
12842
12848
|
async execute(args, _context) {
|
|
12843
12849
|
const status = await getComplianceStatus(args.tool_name, args.owner, args.repo, args.content_hash);
|
|
12844
|
-
return status;
|
|
12850
|
+
return JSON.stringify(status);
|
|
12845
12851
|
}
|
|
12846
12852
|
});
|
|
12847
12853
|
var tools = {
|
package/package.json
CHANGED
package/tools.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { tool } from "@opencode-ai/plugin";
|
|
10
|
+
import { z } from "zod";
|
|
10
11
|
import type { Plugin } from "@opencode-ai/plugin";
|
|
11
12
|
import {
|
|
12
13
|
createComplianceRecord,
|
|
@@ -26,43 +27,54 @@ import {
|
|
|
26
27
|
*
|
|
27
28
|
* The tool records that human approval was obtained and creates
|
|
28
29
|
* a valid compliance record that will allow the GitHub write operation.
|
|
30
|
+
*
|
|
31
|
+
* Note: body and title are base64 encoded to work around BunShell serialization
|
|
32
|
+
* issues with multiline strings. Caller should encode these values.
|
|
29
33
|
*/
|
|
30
34
|
export const createComplianceRecordTool = tool({
|
|
31
|
-
description: "Create
|
|
35
|
+
description: "Create compliance record",
|
|
32
36
|
args: {
|
|
33
|
-
tool_name:
|
|
34
|
-
owner:
|
|
35
|
-
repo:
|
|
36
|
-
title:
|
|
37
|
-
body:
|
|
38
|
-
github_username:
|
|
39
|
-
approved_at:
|
|
40
|
-
checks:
|
|
41
|
-
check_type: tool.schema.string({ description: "Type of check performed" }),
|
|
42
|
-
passed: tool.schema.boolean({ description: "Whether check passed" }),
|
|
43
|
-
details: tool.schema.record(tool.schema.string(), tool.schema.any()).optional({ description: "Additional details" })
|
|
44
|
-
})).optional({ description: "List of compliance checks performed" })
|
|
37
|
+
tool_name: z.string(),
|
|
38
|
+
owner: z.string(),
|
|
39
|
+
repo: z.string(),
|
|
40
|
+
title: z.string().optional(),
|
|
41
|
+
body: z.string(),
|
|
42
|
+
github_username: z.string(),
|
|
43
|
+
approved_at: z.string(),
|
|
44
|
+
checks: z.string().optional()
|
|
45
45
|
},
|
|
46
46
|
async execute(args, _context) {
|
|
47
|
+
let checks: CreateRecordInput['checks'] = [];
|
|
48
|
+
if (args.checks) {
|
|
49
|
+
try {
|
|
50
|
+
checks = JSON.parse(args.checks);
|
|
51
|
+
} catch {
|
|
52
|
+
checks = [];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const body = Buffer.from(args.body, 'base64').toString('utf-8');
|
|
57
|
+
const title = args.title ? Buffer.from(args.title, 'base64').toString('utf-8') : null;
|
|
58
|
+
|
|
47
59
|
const input: CreateRecordInput = {
|
|
48
60
|
tool_name: args.tool_name,
|
|
49
61
|
owner: args.owner,
|
|
50
62
|
repo: args.repo,
|
|
51
|
-
title
|
|
52
|
-
body
|
|
63
|
+
title,
|
|
64
|
+
body,
|
|
53
65
|
github_username: args.github_username,
|
|
54
66
|
approved_at: args.approved_at,
|
|
55
|
-
checks
|
|
67
|
+
checks
|
|
56
68
|
};
|
|
57
69
|
|
|
58
70
|
const recordId = await createComplianceRecord(input);
|
|
59
71
|
|
|
60
|
-
return {
|
|
72
|
+
return JSON.stringify({
|
|
61
73
|
success: true,
|
|
62
74
|
record_id: recordId,
|
|
63
|
-
message: "Compliance record created
|
|
75
|
+
message: "Compliance record created",
|
|
64
76
|
expires_at: new Date(Date.now() + 30 * 60 * 1000).toISOString()
|
|
65
|
-
};
|
|
77
|
+
});
|
|
66
78
|
}
|
|
67
79
|
});
|
|
68
80
|
|
|
@@ -73,16 +85,16 @@ export const createComplianceRecordTool = tool({
|
|
|
73
85
|
* before attempting a GitHub write operation.
|
|
74
86
|
*/
|
|
75
87
|
export const getComplianceStatusTool = tool({
|
|
76
|
-
description: "Check
|
|
88
|
+
description: "Check compliance status",
|
|
77
89
|
args: {
|
|
78
|
-
tool_name:
|
|
79
|
-
owner:
|
|
80
|
-
repo:
|
|
81
|
-
content_hash:
|
|
90
|
+
tool_name: z.string(),
|
|
91
|
+
owner: z.string(),
|
|
92
|
+
repo: z.string(),
|
|
93
|
+
content_hash: z.string()
|
|
82
94
|
},
|
|
83
95
|
async execute(args, _context) {
|
|
84
96
|
const status = await getComplianceStatus(args.tool_name, args.owner, args.repo, args.content_hash);
|
|
85
|
-
return status;
|
|
97
|
+
return JSON.stringify(status);
|
|
86
98
|
}
|
|
87
99
|
});
|
|
88
100
|
|