opencode-pair-autonomy 1.0.2 → 1.0.4
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.js +35 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16849,6 +16849,11 @@ function createPreCompactHook(runtime) {
|
|
|
16849
16849
|
};
|
|
16850
16850
|
}
|
|
16851
16851
|
|
|
16852
|
+
// src/hooks/pre-tool-use.ts
|
|
16853
|
+
import { appendFileSync as appendFileSync2 } from "fs";
|
|
16854
|
+
import { homedir as homedir4 } from "os";
|
|
16855
|
+
import { join as join5 } from "path";
|
|
16856
|
+
|
|
16852
16857
|
// src/hooks/sdk.ts
|
|
16853
16858
|
class BlockingHookError extends Error {
|
|
16854
16859
|
constructor(message) {
|
|
@@ -16893,6 +16898,14 @@ function safeHook(name, hook) {
|
|
|
16893
16898
|
}
|
|
16894
16899
|
|
|
16895
16900
|
// src/hooks/pre-tool-use.ts
|
|
16901
|
+
var PLAN_MODE_DEBUG_LOG = join5(homedir4(), ".config", "opencode", "plan-mode-debug.log");
|
|
16902
|
+
function debugPlanMode(data) {
|
|
16903
|
+
try {
|
|
16904
|
+
const line = `${new Date().toISOString()} ${JSON.stringify(data)}
|
|
16905
|
+
`;
|
|
16906
|
+
appendFileSync2(PLAN_MODE_DEBUG_LOG, line, "utf8");
|
|
16907
|
+
} catch {}
|
|
16908
|
+
}
|
|
16896
16909
|
var NODE_COMMAND_RE = /^(npm|pnpm|yarn|bun|npx|bunx|node|tsc|tsx|vite|next|nuxt|vitest|jest|eslint|prettier)\b/;
|
|
16897
16910
|
var NODE_MODULES_BIN_RE = /node_modules\/\.bin\//;
|
|
16898
16911
|
var PLAN_MODE_ALWAYS_BLOCKED = new Set(["edit", "write", "patch"]);
|
|
@@ -16902,23 +16915,29 @@ var PLAN_MODE_ALLOWED_AGENTS = new Set([
|
|
|
16902
16915
|
"odokawa",
|
|
16903
16916
|
"rajdhani"
|
|
16904
16917
|
]);
|
|
16905
|
-
function isWorkerSpawnTool(tool) {
|
|
16906
|
-
return tool === "task" || tool.startsWith("task_") || tool === "delegate" || tool.startsWith("delegate");
|
|
16907
|
-
}
|
|
16908
16918
|
function resolveTargetAgent(args) {
|
|
16909
16919
|
if (typeof args.subagent_type === "string")
|
|
16910
16920
|
return args.subagent_type;
|
|
16911
16921
|
if (typeof args.agent === "string")
|
|
16912
16922
|
return args.agent;
|
|
16923
|
+
if (typeof args.subagent === "string")
|
|
16924
|
+
return args.subagent;
|
|
16925
|
+
if (typeof args.type === "string")
|
|
16926
|
+
return args.type;
|
|
16913
16927
|
return;
|
|
16914
16928
|
}
|
|
16915
16929
|
function isBlockedInPlanMode(tool, args) {
|
|
16916
16930
|
if (PLAN_MODE_ALWAYS_BLOCKED.has(tool))
|
|
16917
16931
|
return true;
|
|
16918
|
-
if (
|
|
16932
|
+
if (tool === "delegate" || tool.startsWith("delegation"))
|
|
16919
16933
|
return false;
|
|
16920
16934
|
const target = resolveTargetAgent(args);
|
|
16921
|
-
|
|
16935
|
+
if (target) {
|
|
16936
|
+
return !PLAN_MODE_ALLOWED_AGENTS.has(target);
|
|
16937
|
+
}
|
|
16938
|
+
if (tool === "task" || tool.startsWith("task_"))
|
|
16939
|
+
return true;
|
|
16940
|
+
return false;
|
|
16922
16941
|
}
|
|
16923
16942
|
function isNodeCommand(command) {
|
|
16924
16943
|
return NODE_COMMAND_RE.test(command.trim()) || NODE_MODULES_BIN_RE.test(command);
|
|
@@ -16941,7 +16960,16 @@ function createPreToolUseHook(config2, runtime, profile) {
|
|
|
16941
16960
|
runtime.incrementToolCount(sessionID);
|
|
16942
16961
|
}
|
|
16943
16962
|
if (sessionID && agent && PRIMARY_AGENTS.has(agent) && tool && runtime.getPlanMode(sessionID) === "planning") {
|
|
16963
|
+
const target = resolveTargetAgent(args);
|
|
16944
16964
|
const blocked = isBlockedInPlanMode(tool, args);
|
|
16965
|
+
debugPlanMode({
|
|
16966
|
+
tool,
|
|
16967
|
+
args: Object.keys(args),
|
|
16968
|
+
argsSnapshot: JSON.parse(JSON.stringify(args, (_, v) => typeof v === "string" && v.length > 80 ? `${v.slice(0, 80)}...` : v)),
|
|
16969
|
+
target,
|
|
16970
|
+
blocked,
|
|
16971
|
+
rawInput: typeof input === "object" && input ? Object.keys(input) : "not-object"
|
|
16972
|
+
});
|
|
16945
16973
|
if (blocked) {
|
|
16946
16974
|
const count = runtime.incrementPlanModeBlock(sessionID);
|
|
16947
16975
|
const msg = count >= 3 ? "[PlanMode] STILL in planning mode. You have attempted execution tools multiple times. STOP trying. Complete your plan with TodoWrite. The user will /go to start execution." : "[PlanMode] You are in planning mode. Cannot use execution tools. Use Read/Glob/Grep/TodoWrite to continue planning. The user will /go to start execution.";
|
|
@@ -17470,7 +17498,7 @@ function createSessionEndHook(runtime) {
|
|
|
17470
17498
|
|
|
17471
17499
|
// src/hooks/session-start.ts
|
|
17472
17500
|
import { existsSync as existsSync6 } from "fs";
|
|
17473
|
-
import { join as
|
|
17501
|
+
import { join as join6 } from "path";
|
|
17474
17502
|
function detectProjectDocs(directory) {
|
|
17475
17503
|
const candidates = [
|
|
17476
17504
|
"AGENTS.md",
|
|
@@ -17478,7 +17506,7 @@ function detectProjectDocs(directory) {
|
|
|
17478
17506
|
"CONTRIBUTING.md",
|
|
17479
17507
|
"ARCHITECTURE.md"
|
|
17480
17508
|
];
|
|
17481
|
-
return candidates.filter((name) => existsSync6(
|
|
17509
|
+
return candidates.filter((name) => existsSync6(join6(directory, name)));
|
|
17482
17510
|
}
|
|
17483
17511
|
function buildResourceInjection(runtime, directory) {
|
|
17484
17512
|
const parts = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-pair-autonomy",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "OpenCode harness with opinionated agent orchestration. One coordinator, eight specialized workers, automatic verify+review pipeline.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|