@astrosheep/keiyaku 0.1.4 → 0.1.6
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 +1 -1
- package/build/common/errors.js +76 -83
- package/build/config/term-presets.js +121 -126
- package/build/handlers/ask.js +9 -16
- package/build/handlers/close.js +10 -15
- package/build/handlers/drive.js +9 -16
- package/build/handlers/help.js +1 -21
- package/build/handlers/shared.js +17 -1
- package/build/handlers/start.js +12 -23
- package/build/index.js +39 -41
- package/build/types/tool-schemas.js +5 -5
- package/build/utils/git.js +12 -2
- package/build/utils/schema-utils.js +16 -0
- package/build/utils/text-utils.js +30 -0
- package/build/workflow/oath.js +1 -1
- package/build/workflow/orchestrator.js +67 -18
- package/build/workflow/prompts.js +2 -2
- package/build/workflow/response-builders.js +2 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ Set `KEIYAKU_TERM_PRESET` in the MCP server env (recommended), or in your shell
|
|
|
56
56
|
|
|
57
57
|
Each run/round can pick a profile via tool input `name`, or globally via `KEIYAKU_SUBAGENT_NAME_OVERRIDE`.
|
|
58
58
|
|
|
59
|
-
- `default`: `
|
|
59
|
+
- `default`: `B-tier`, `A-tier`, `S-tier` (also accepts internal names `agent-a|agent-b|agent-c`)
|
|
60
60
|
- `pokemon`: `caterpie`, `pikachu`, `mewtwo`
|
|
61
61
|
- `mischief`: `imp`, `minion`, `mastermind`
|
|
62
62
|
|
package/build/common/errors.js
CHANGED
|
@@ -28,92 +28,85 @@ export function wrapFlowError(action, err) {
|
|
|
28
28
|
}
|
|
29
29
|
return new Error(`${action} failed: ${asMessage(err)}`);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return unknownSubagentHint();
|
|
64
|
-
default:
|
|
65
|
-
return "Review the error details, fix the issue, and retry.";
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// Fallback for untyped runtime errors.
|
|
69
|
-
if (message.includes("is not a git repository")) {
|
|
70
|
-
return "The provided `cwd` is not a git repository.";
|
|
71
|
-
}
|
|
72
|
-
if (message.includes("active keiyaku already exists")) {
|
|
73
|
-
return "An active keiyaku branch already exists in this repository.";
|
|
74
|
-
}
|
|
75
|
-
if (message.includes("existing keiyaku branch found")) {
|
|
76
|
-
return "At least one local `keiyaku/*` branch already exists in this repository.";
|
|
77
|
-
}
|
|
78
|
-
if (message.includes("parameter") && message.includes("cannot be empty")) {
|
|
79
|
-
return "One or more required parameters are empty.";
|
|
80
|
-
}
|
|
81
|
-
if (message.includes("working tree has uncommitted changes")) {
|
|
82
|
-
return "The working tree has uncommitted changes.";
|
|
83
|
-
}
|
|
84
|
-
if (message.includes("current branch is not an active keiyaku branch")) {
|
|
85
|
-
return "No active keiyaku branch (`keiyaku/*`). If this task is not using keiyaku workflow, skip this tool call.";
|
|
86
|
-
}
|
|
87
|
-
if (message.includes("is missing base metadata")) {
|
|
88
|
-
return "Current keiyaku branch is missing `keiyakuBase` metadata.";
|
|
31
|
+
function hintForFlowCode(code, message) {
|
|
32
|
+
switch (code) {
|
|
33
|
+
case "NOT_GIT_REPO":
|
|
34
|
+
return "The provided `cwd` is not a git repository.";
|
|
35
|
+
case "ACTIVE_KEIYAKU_EXISTS":
|
|
36
|
+
return "An active keiyaku branch already exists in this repository. Continue with `drive`, or use `close` + `ABANDON` to drop it.";
|
|
37
|
+
case "EXISTING_KEIYAKU_BRANCH_FOUND":
|
|
38
|
+
return "At least one local `keiyaku/*` branch already exists in this repository.";
|
|
39
|
+
case "EMPTY_PARAM":
|
|
40
|
+
return "One or more required parameters are empty.";
|
|
41
|
+
case "DIRTY_WORKTREE":
|
|
42
|
+
return "The working tree has uncommitted changes.";
|
|
43
|
+
case "NOT_ACTIVE_KEIYAKU_BRANCH":
|
|
44
|
+
return message;
|
|
45
|
+
case "MISSING_KEIYAKU_BASE":
|
|
46
|
+
return "Current keiyaku branch is missing `keiyakuBase` metadata.";
|
|
47
|
+
case "MISSING_PROTOCOL_FILES":
|
|
48
|
+
return "Required protocol files are missing (`KEIYAKU.md` or `KEIYAKU_TRACE.md`).";
|
|
49
|
+
case "DONE_MERGE_CONFLICT":
|
|
50
|
+
return "DONE encountered a git merge conflict.";
|
|
51
|
+
case "CLOSE_QUALITY_GATE_FAILED":
|
|
52
|
+
return "INVOKE was denied by Divine Judgment because one or more commandment thresholds or the minimum total score were not met.";
|
|
53
|
+
case "OATH_MISMATCH":
|
|
54
|
+
return message;
|
|
55
|
+
case "SUBAGENT_DID_NOT_ADVANCE_ROUND":
|
|
56
|
+
return "Subagent run did not append the expected new round in `KEIYAKU_TRACE.md`.";
|
|
57
|
+
case "ROUND_SUBAGENT_FAILED":
|
|
58
|
+
return "Subagent execution failed. Review KEIYAKU_TRACE.md for details, then continue with a narrower directive.";
|
|
59
|
+
case "INVALID_BRANCH_TITLE":
|
|
60
|
+
return "Title cannot be converted to a valid branch token for `keiyaku/<title>`.";
|
|
61
|
+
case "UNKNOWN_SUBAGENT":
|
|
62
|
+
return unknownSubagentHint();
|
|
89
63
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
64
|
+
}
|
|
65
|
+
const MESSAGE_HINT_PATTERNS = [
|
|
66
|
+
{ code: "NOT_GIT_REPO", patterns: ["is not a git repository"] },
|
|
67
|
+
{ code: "ACTIVE_KEIYAKU_EXISTS", patterns: ["active keiyaku already exists"] },
|
|
68
|
+
{ code: "EXISTING_KEIYAKU_BRANCH_FOUND", patterns: ["existing keiyaku branch found"] },
|
|
69
|
+
{ code: "EMPTY_PARAM", patterns: ["cannot be empty"] },
|
|
70
|
+
{ code: "DIRTY_WORKTREE", patterns: ["working tree has uncommitted changes"] },
|
|
71
|
+
{ code: "NOT_ACTIVE_KEIYAKU_BRANCH", patterns: ["current branch is not an active keiyaku branch"] },
|
|
72
|
+
{ code: "MISSING_KEIYAKU_BASE", patterns: ["is missing base metadata"] },
|
|
73
|
+
{ code: "MISSING_PROTOCOL_FILES", patterns: ["missing protocol files"] },
|
|
74
|
+
{ code: "DONE_MERGE_CONFLICT", patterns: ["DONE merge conflict"] },
|
|
75
|
+
{ code: "CLOSE_QUALITY_GATE_FAILED", patterns: ["God's Wrath: INVOKE denied"] },
|
|
76
|
+
{
|
|
77
|
+
code: "OATH_MISMATCH",
|
|
78
|
+
patterns: [
|
|
79
|
+
"requires the sacred oath to exactly equal",
|
|
80
|
+
"requires oath to exactly match configured value",
|
|
81
|
+
"requires oath to match configured value. If template contains",
|
|
82
|
+
"To declare DONE, you must solemnly swear the sacred oath.",
|
|
83
|
+
"To declare DONE, oath mismatch.",
|
|
84
|
+
"Oath mismatch.",
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
code: "SUBAGENT_DID_NOT_ADVANCE_ROUND",
|
|
89
|
+
patterns: ["subagent did not advance round", "did not append KEIYAKU_TRACE"],
|
|
90
|
+
},
|
|
91
|
+
{ code: "ROUND_SUBAGENT_FAILED", patterns: ["failed during subagent execution"] },
|
|
92
|
+
{ code: "INVALID_BRANCH_TITLE", patterns: ["cannot be converted to a valid branch name"] },
|
|
93
|
+
{ code: "UNKNOWN_SUBAGENT", patterns: ["Unknown subagent"] },
|
|
94
|
+
];
|
|
95
|
+
function inferFlowCodeFromMessage(message) {
|
|
96
|
+
for (const entry of MESSAGE_HINT_PATTERNS) {
|
|
97
|
+
if (entry.patterns.some((pattern) => message.includes(pattern))) {
|
|
98
|
+
return entry.code;
|
|
99
|
+
}
|
|
111
100
|
}
|
|
112
|
-
|
|
113
|
-
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
export function pickHintFromError(err, message) {
|
|
104
|
+
if (isFlowError(err)) {
|
|
105
|
+
return hintForFlowCode(err.code, err.message);
|
|
114
106
|
}
|
|
115
|
-
|
|
116
|
-
|
|
107
|
+
const inferredCode = inferFlowCodeFromMessage(message);
|
|
108
|
+
if (inferredCode) {
|
|
109
|
+
return hintForFlowCode(inferredCode, message);
|
|
117
110
|
}
|
|
118
111
|
return "Review the error details, fix the issue, and retry.";
|
|
119
112
|
}
|