@aryaminus/controlkeel-opencode 0.3.2 → 0.3.5
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/.opencode/plugins/controlkeel-governance.ts +27 -7
- package/index.js +27 -7
- package/package.json +1 -1
|
@@ -180,25 +180,45 @@ export const ControlKeelGovernance: Plugin = async ({ project, client, $, direct
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
const normalizeReviewId = (value: string | number | null | undefined, label: string) => {
|
|
184
|
+
if (value == null || value === "") return null
|
|
185
|
+
|
|
186
|
+
if (typeof value === "number") {
|
|
187
|
+
if (!Number.isFinite(value) || !Number.isInteger(value) || value <= 0) {
|
|
188
|
+
throw new Error(`${label} must be a positive finite integer. Omit it to let ControlKeel infer scope from the bound project.`)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return String(value)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const trimmed = String(value).trim()
|
|
195
|
+
if (/^[1-9]\d*$/.test(trimmed)) return trimmed
|
|
196
|
+
|
|
197
|
+
throw new Error(`${label} must be a positive integer string. Omit it to let ControlKeel infer scope from the bound project.`)
|
|
198
|
+
}
|
|
199
|
+
|
|
183
200
|
const resolveReviewScope = async (
|
|
184
201
|
explicitTaskId?: string | number | null,
|
|
185
202
|
explicitSessionId?: string | number | null
|
|
186
203
|
) => {
|
|
187
|
-
|
|
204
|
+
const normalizedExplicitTaskId = normalizeReviewId(explicitTaskId, "task_id")
|
|
205
|
+
const normalizedExplicitSessionId = normalizeReviewId(explicitSessionId, "session_id")
|
|
206
|
+
|
|
207
|
+
if (normalizedExplicitTaskId || normalizedExplicitSessionId) {
|
|
188
208
|
return {
|
|
189
|
-
taskId:
|
|
190
|
-
sessionId:
|
|
209
|
+
taskId: normalizedExplicitTaskId,
|
|
210
|
+
sessionId: normalizedExplicitSessionId,
|
|
191
211
|
source: "explicit",
|
|
192
212
|
}
|
|
193
213
|
}
|
|
194
214
|
|
|
195
|
-
const envTaskId = process.env.CONTROLKEEL_TASK_ID
|
|
196
|
-
const envSessionId = process.env.CONTROLKEEL_SESSION_ID
|
|
215
|
+
const envTaskId = normalizeReviewId(process.env.CONTROLKEEL_TASK_ID, "CONTROLKEEL_TASK_ID")
|
|
216
|
+
const envSessionId = normalizeReviewId(process.env.CONTROLKEEL_SESSION_ID, "CONTROLKEEL_SESSION_ID")
|
|
197
217
|
|
|
198
218
|
if (envTaskId || envSessionId) {
|
|
199
219
|
return {
|
|
200
|
-
taskId: envTaskId
|
|
201
|
-
sessionId: envSessionId
|
|
220
|
+
taskId: envTaskId,
|
|
221
|
+
sessionId: envSessionId,
|
|
202
222
|
source: "env",
|
|
203
223
|
}
|
|
204
224
|
}
|
package/index.js
CHANGED
|
@@ -173,22 +173,42 @@ export const ControlKeelGovernance = async ({ $, directory }) => {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
const normalizeReviewId = (value, label) => {
|
|
177
|
+
if (value == null || value === "") return null
|
|
178
|
+
|
|
179
|
+
if (typeof value === "number") {
|
|
180
|
+
if (!Number.isFinite(value) || !Number.isInteger(value) || value <= 0) {
|
|
181
|
+
throw new Error(`${label} must be a positive finite integer. Omit it to let ControlKeel infer scope from the bound project.`)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return String(value)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const trimmed = String(value).trim()
|
|
188
|
+
if (/^[1-9]\d*$/.test(trimmed)) return trimmed
|
|
189
|
+
|
|
190
|
+
throw new Error(`${label} must be a positive integer string. Omit it to let ControlKeel infer scope from the bound project.`)
|
|
191
|
+
}
|
|
192
|
+
|
|
176
193
|
const resolveReviewScope = async (explicitTaskId, explicitSessionId) => {
|
|
177
|
-
|
|
194
|
+
const normalizedExplicitTaskId = normalizeReviewId(explicitTaskId, "task_id")
|
|
195
|
+
const normalizedExplicitSessionId = normalizeReviewId(explicitSessionId, "session_id")
|
|
196
|
+
|
|
197
|
+
if (normalizedExplicitTaskId || normalizedExplicitSessionId) {
|
|
178
198
|
return {
|
|
179
|
-
taskId:
|
|
180
|
-
sessionId:
|
|
199
|
+
taskId: normalizedExplicitTaskId,
|
|
200
|
+
sessionId: normalizedExplicitSessionId,
|
|
181
201
|
source: "explicit",
|
|
182
202
|
}
|
|
183
203
|
}
|
|
184
204
|
|
|
185
|
-
const envTaskId = process.env.CONTROLKEEL_TASK_ID
|
|
186
|
-
const envSessionId = process.env.CONTROLKEEL_SESSION_ID
|
|
205
|
+
const envTaskId = normalizeReviewId(process.env.CONTROLKEEL_TASK_ID, "CONTROLKEEL_TASK_ID")
|
|
206
|
+
const envSessionId = normalizeReviewId(process.env.CONTROLKEEL_SESSION_ID, "CONTROLKEEL_SESSION_ID")
|
|
187
207
|
|
|
188
208
|
if (envTaskId || envSessionId) {
|
|
189
209
|
return {
|
|
190
|
-
taskId: envTaskId
|
|
191
|
-
sessionId: envSessionId
|
|
210
|
+
taskId: envTaskId,
|
|
211
|
+
sessionId: envSessionId,
|
|
192
212
|
source: "env",
|
|
193
213
|
}
|
|
194
214
|
}
|
package/package.json
CHANGED