oc-tweaks 0.6.0 → 0.7.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/README.md +2 -2
- package/dist/index.js +74 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -136,7 +136,7 @@ This plugin provides an intelligent memory workflow:
|
|
|
136
136
|
|
|
137
137
|
### `backgroundSubagent`
|
|
138
138
|
|
|
139
|
-
This plugin injects a policy into the system prompt, reminding the AI agent to use `run_in_background=true` by default when dispatching sub-agents. It
|
|
139
|
+
This plugin injects a policy into the system prompt, reminding the AI agent to use `run_in_background=true` by default when dispatching sub-agents. It also requires each `task()` description to expose a compact transparency summary: agent type, loaded skills, background/foreground mode, and resume session when present. If a foreground task is dispatched, or if required transparency tags are missing, a friendly reminder is shown.
|
|
140
140
|
|
|
141
141
|
**Configuration Options:**
|
|
142
142
|
|
|
@@ -357,7 +357,7 @@ bunx oc-tweaks init
|
|
|
357
357
|
|
|
358
358
|
### `backgroundSubagent`
|
|
359
359
|
|
|
360
|
-
此插件向系统提示中注入一项策略,提醒 AI 代理在派发子代理时默认使用 `run_in_background=true
|
|
360
|
+
此插件向系统提示中注入一项策略,提醒 AI 代理在派发子代理时默认使用 `run_in_background=true`。它也要求每次 `task()` 调用在 `description` 里写出紧凑的透明度摘要:agent 类型、已加载 skills、background/foreground 模式,以及存在时的 resume session。若派发了前台任务,或缺少必需透明度标签,插件都会追加友好提醒。
|
|
361
361
|
|
|
362
362
|
**配置选项:**
|
|
363
363
|
|
package/dist/index.js
CHANGED
|
@@ -289,12 +289,68 @@ Only use \`run_in_background=false\` when ALL of these conditions are met:
|
|
|
289
289
|
3. The user is explicitly waiting for that specific result
|
|
290
290
|
|
|
291
291
|
When in doubt → background. Use \`background_output()\` to collect results later.
|
|
292
|
+
|
|
293
|
+
## Description Transparency Rule
|
|
294
|
+
|
|
295
|
+
Every \`task()\` call MUST include a compact transparency summary in the \`description\` field so the user can see how the sub-agent was dispatched.
|
|
296
|
+
|
|
297
|
+
Required formats:
|
|
298
|
+
- \`[category:xxx]\` when using \`category\`
|
|
299
|
+
- \`[subagent:xxx]\` when using \`subagent_type\`
|
|
300
|
+
- \`[skills:skill-a,skill-b]\` or \`[skills:none]\`
|
|
301
|
+
- \`[background]\` or \`[foreground]\`
|
|
302
|
+
- \`[resume:session-id]\` when using \`session_id\`
|
|
303
|
+
|
|
304
|
+
Examples:
|
|
305
|
+
- \`description="[category:quick] [skills:none] [background] Fix typo in config"\`
|
|
306
|
+
- \`description="[subagent:explore] [skills:none] [background] Inspect auth flow"\`
|
|
307
|
+
- \`description="[category:deep] [skills:refactor,test-driven-development] [foreground] [resume:ses_123] Continue auth refactor"\`
|
|
308
|
+
|
|
309
|
+
Do NOT omit any required transparency tag.
|
|
292
310
|
`;
|
|
293
311
|
var VIOLATION_WARNING = `\uD83D\uDCA1 [Reminder] Consider using background mode for better responsiveness.
|
|
294
312
|
You used foreground mode (run_in_background=false). Check the three conditions in the system prompt.
|
|
295
313
|
If not all three are met, consider run_in_background=true + background_output() for next time.`;
|
|
314
|
+
function getMissingTransparencyTags(args) {
|
|
315
|
+
const description = args?.description ?? "";
|
|
316
|
+
const missingTags = [];
|
|
317
|
+
if (args?.category) {
|
|
318
|
+
const tag = `[category:${args.category}]`;
|
|
319
|
+
if (!description.includes(tag))
|
|
320
|
+
missingTags.push(tag);
|
|
321
|
+
}
|
|
322
|
+
if (args?.subagent_type) {
|
|
323
|
+
const tag = `[subagent:${args.subagent_type}]`;
|
|
324
|
+
if (!description.includes(tag))
|
|
325
|
+
missingTags.push(tag);
|
|
326
|
+
}
|
|
327
|
+
const skillsTag = args?.load_skills && args.load_skills.length > 0 ? `[skills:${args.load_skills.join(",")}]` : `[skills:none]`;
|
|
328
|
+
if (!description.includes(skillsTag))
|
|
329
|
+
missingTags.push(skillsTag);
|
|
330
|
+
const modeTag = args?.run_in_background === false ? `[foreground]` : `[background]`;
|
|
331
|
+
if (!description.includes(modeTag))
|
|
332
|
+
missingTags.push(modeTag);
|
|
333
|
+
if (args?.session_id) {
|
|
334
|
+
const tag = `[resume:${args.session_id}]`;
|
|
335
|
+
if (!description.includes(tag))
|
|
336
|
+
missingTags.push(tag);
|
|
337
|
+
}
|
|
338
|
+
return missingTags;
|
|
339
|
+
}
|
|
340
|
+
function buildTransparencyWarning(missingTags) {
|
|
341
|
+
const plural = missingTags.length > 1 ? "s" : "";
|
|
342
|
+
return `⚠️ [Transparency] Your task description is missing the required transparency tag${plural}: ${missingTags.join(", ")}
|
|
343
|
+
Add the tag directly to \`description\` so the user can see the dispatch mode, loaded skills, and resume status.
|
|
344
|
+
Required formats:
|
|
345
|
+
- \`[category:xxx]\`
|
|
346
|
+
- \`[subagent:xxx]\`
|
|
347
|
+
- \`[skills:skill-a,skill-b]\` or \`[skills:none]\`
|
|
348
|
+
- \`[background]\` or \`[foreground]\`
|
|
349
|
+
- \`[resume:session-id]\` when applicable`;
|
|
350
|
+
}
|
|
296
351
|
var backgroundSubagentPlugin = async () => {
|
|
297
352
|
const foregroundCalls = new Set;
|
|
353
|
+
const transparencyViolations = new Map;
|
|
298
354
|
return {
|
|
299
355
|
"experimental.chat.system.transform": safeHook("background-subagent:system.transform", async (_input, output) => {
|
|
300
356
|
const config = await loadOcTweaksConfig();
|
|
@@ -308,17 +364,32 @@ var backgroundSubagentPlugin = async () => {
|
|
|
308
364
|
return;
|
|
309
365
|
if (input.tool !== "task")
|
|
310
366
|
return;
|
|
367
|
+
const missingTags = getMissingTransparencyTags(output.args);
|
|
368
|
+
if (missingTags.length > 0) {
|
|
369
|
+
transparencyViolations.set(input.callID, missingTags);
|
|
370
|
+
}
|
|
311
371
|
if (!output.args?.run_in_background) {
|
|
312
372
|
foregroundCalls.add(input.callID);
|
|
313
373
|
}
|
|
314
374
|
}),
|
|
315
375
|
"tool.execute.after": safeHook("background-subagent:tool.execute.after", async (input, output) => {
|
|
316
|
-
|
|
376
|
+
const warnings = [];
|
|
377
|
+
if (foregroundCalls.has(input.callID)) {
|
|
378
|
+
foregroundCalls.delete(input.callID);
|
|
379
|
+
warnings.push(VIOLATION_WARNING);
|
|
380
|
+
}
|
|
381
|
+
const missingTags = transparencyViolations.get(input.callID);
|
|
382
|
+
if (missingTags) {
|
|
383
|
+
transparencyViolations.delete(input.callID);
|
|
384
|
+
warnings.push(buildTransparencyWarning(missingTags));
|
|
385
|
+
}
|
|
386
|
+
if (warnings.length === 0)
|
|
317
387
|
return;
|
|
318
|
-
foregroundCalls.delete(input.callID);
|
|
319
388
|
output.output += `
|
|
320
389
|
|
|
321
|
-
${
|
|
390
|
+
${warnings.join(`
|
|
391
|
+
|
|
392
|
+
`)}`;
|
|
322
393
|
})
|
|
323
394
|
};
|
|
324
395
|
};
|