@astrosheep/keiyaku 0.1.17 → 0.1.18
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/build/config/term-presets.js +27 -24
- package/build/handlers/close.js +45 -14
- package/build/index.js +3 -1
- package/build/types/tooling.js +50 -18
- package/package.json +1 -1
|
@@ -99,17 +99,20 @@ export const DEFAULT_PRESET = {
|
|
|
99
99
|
'If there is a bug, **YOU** put it there.\n' +
|
|
100
100
|
'If it is messy, **YOU** left it there.\n\n' +
|
|
101
101
|
'Stand by your work. If uncertain, return to ${drive}. Premature claims are not forgiven.\n\n' +
|
|
102
|
+
'Input rules:\n' +
|
|
103
|
+
'- CLAIM: fill criteriaChecks, constraintsChecks, all five scores, and oath.\n' +
|
|
104
|
+
'- FORFEIT: only petition is required; the other fields can be left empty.\n\n' +
|
|
102
105
|
'Flow: ${start} → [${drive} x N] → ${close}',
|
|
103
106
|
args: {
|
|
104
107
|
petition: 'REQUIRED. CLAIM declares fulfillment; FORFEIT concedes failure.\nREQUIRES AN ACTIVE KEIYAKU (started via ${start}).\nIf any score wavers, do not claim—return to ${drive}.',
|
|
105
|
-
criteriaChecks: '
|
|
106
|
-
constraintsChecks: '
|
|
107
|
-
score_precise: '
|
|
108
|
-
score_minimal: '
|
|
109
|
-
score_isolated: '
|
|
110
|
-
score_idiomatic: '
|
|
111
|
-
score_cohesive: '
|
|
112
|
-
oath: 'Required for CLAIM. Your binding word. The Contract holds you to it.\nVerbatim: ${oath_text}',
|
|
108
|
+
criteriaChecks: 'Required for CLAIM. Evidence that each criterion is met. For FORFEIT, optional (can be left empty).',
|
|
109
|
+
constraintsChecks: 'Required for CLAIM. Evidence that each constraint stayed compliant. For FORFEIT, optional (can be left empty).',
|
|
110
|
+
score_precise: 'Required for CLAIM (0-10). Architectural placement. 10 = exact layer, exact boundary, zero misplacement. For FORFEIT, optional.',
|
|
111
|
+
score_minimal: 'Required for CLAIM (0-10). Economy of change. 10 = no avoidable lines, no speculative edits, no hidden bloat. For FORFEIT, optional.',
|
|
112
|
+
score_isolated: 'Required for CLAIM (0-10). Surgical containment. 10 = zero unrelated files, zero opportunistic cleanup, zero collateral. For FORFEIT, optional.',
|
|
113
|
+
score_idiomatic: 'Required for CLAIM (0-10). Native fluency. 10 = naming, structure, style indistinguishable from the codebase. For FORFEIT, optional.',
|
|
114
|
+
score_cohesive: 'Required for CLAIM (0-10). Single responsibility. 10 = each unit does one thing, boundaries intact. For FORFEIT, optional.',
|
|
115
|
+
oath: 'Required for CLAIM. Your binding word. The Contract holds you to it. For FORFEIT, optional.\nVerbatim: ${oath_text}',
|
|
113
116
|
cwd: "Optional repository path. Defaults to the server's current working directory.",
|
|
114
117
|
},
|
|
115
118
|
},
|
|
@@ -198,14 +201,14 @@ export const POCKET_PRESET = {
|
|
|
198
201
|
description: 'Attempt Capture. Present the weakened target for League Inspection.\nWARNING: The League (System) checks every Badge. If you attempt to `CLAIM` with fainted code, Disqualification (FORFEIT) is immediate.\nOnly throw the Ball when the target is 100% ready.\n\nFlow: ${start} → [${drive} x N] → ${close}',
|
|
199
202
|
args: {
|
|
200
203
|
petition: 'REQUIRED. CLAIM seeks Badge; FORFEIT forfeits the match.\nREQUIRES AN ACTIVE BATTLE (started via ${start}).\nIf stats are low, continue with ${drive}.',
|
|
201
|
-
criteriaChecks: '
|
|
202
|
-
constraintsChecks: '
|
|
203
|
-
score_precise: '
|
|
204
|
-
score_minimal: '
|
|
205
|
-
score_isolated: '
|
|
206
|
-
score_idiomatic: "
|
|
207
|
-
score_cohesive: '
|
|
208
|
-
oath: "Trainer's Honor Code. Required for CLAIM. Verbatim: ${oath_text}",
|
|
204
|
+
criteriaChecks: 'Required for CLAIM. Badge-by-badge proof. For FORFEIT, optional (can be left empty).',
|
|
205
|
+
constraintsChecks: 'Required for CLAIM. Rule-by-rule proof that constraints were respected. For FORFEIT, optional (can be left empty).',
|
|
206
|
+
score_precise: 'Required for CLAIM score (0-10). 10 means a Critical Hit: exact layer, exact target, zero meaningful misplacement. For FORFEIT, optional.',
|
|
207
|
+
score_minimal: 'Required for CLAIM score (0-10). 10 means Max Efficiency: no wasted PP, no extra motion. For FORFEIT, optional.',
|
|
208
|
+
score_isolated: 'Required for CLAIM score (0-10). 10 means 1v1 Focus: zero side-quests, zero unrelated damage. For FORFEIT, optional.',
|
|
209
|
+
score_idiomatic: "Required for CLAIM score (0-10). 10 means STAB (Same Type Attack Bonus): perfectly matches the codebase style. For FORFEIT, optional.",
|
|
210
|
+
score_cohesive: 'Required for CLAIM score (0-10). 10 means Team Synergy: action serves one purpose with clean boundaries. For FORFEIT, optional.',
|
|
211
|
+
oath: "Trainer's Honor Code. Required for CLAIM. For FORFEIT, optional. Verbatim: ${oath_text}",
|
|
209
212
|
cwd: 'Optional battlefield path (repository root). Defaults to current arena.',
|
|
210
213
|
},
|
|
211
214
|
},
|
|
@@ -294,14 +297,14 @@ export const MISCHIEF_PRESET = {
|
|
|
294
297
|
description: 'The Final Reveal. Present your Masterpiece to the Dark Council (System).\nWARNING: The Council destroys failure. If you `CLAIM` with weak plans, you will be eaten (FORFEIT).\nOnly throw the switch when the Doomsday Device is 100% operational.\n\nFlow: ${start} → [${drive} x N] → ${close}',
|
|
295
298
|
args: {
|
|
296
299
|
petition: 'REQUIRED. CLAIM demands rule; FORFEIT admits defeat.\nREQUIRES AN ACTIVE SCHEME (started via ${start}).\nIf the plan is weak, improve it with ${drive}.',
|
|
297
|
-
criteriaChecks: '
|
|
298
|
-
constraintsChecks: '
|
|
299
|
-
score_precise: '
|
|
300
|
-
score_minimal: '
|
|
301
|
-
score_isolated: '
|
|
302
|
-
score_idiomatic: '
|
|
303
|
-
score_cohesive: '
|
|
304
|
-
oath: "Mastermind's Vow. Required for CLAIM. Verbatim: ${oath_text}",
|
|
300
|
+
criteriaChecks: 'Required for CLAIM. Proof of conquest. For FORFEIT, optional (can be left empty).',
|
|
301
|
+
constraintsChecks: 'Required for CLAIM. Constraint-by-constraint compliance proof. For FORFEIT, optional (can be left empty).',
|
|
302
|
+
score_precise: 'Required for CLAIM (0-10). Architectural placement. 10 = exact layer, exact boundary, zero misplacement. For FORFEIT, optional.',
|
|
303
|
+
score_minimal: 'Required for CLAIM (0-10). Economy of change. 10 = no avoidable lines, no speculative edits, no hidden bloat. For FORFEIT, optional.',
|
|
304
|
+
score_isolated: 'Required for CLAIM (0-10). Surgical containment. 10 = zero unrelated files, zero opportunistic cleanup, zero collateral. For FORFEIT, optional.',
|
|
305
|
+
score_idiomatic: 'Required for CLAIM (0-10). Native fluency. 10 = naming, structure, style indistinguishable from the codebase. For FORFEIT, optional.',
|
|
306
|
+
score_cohesive: 'Required for CLAIM (0-10). Single responsibility. 10 = each unit does one thing, boundaries intact. For FORFEIT, optional.',
|
|
307
|
+
oath: "Mastermind's Vow. Required for CLAIM. For FORFEIT, optional. Verbatim: ${oath_text}",
|
|
305
308
|
cwd: 'Optional lair path (repository root). Defaults to current command chamber.',
|
|
306
309
|
},
|
|
307
310
|
},
|
package/build/handlers/close.js
CHANGED
|
@@ -2,8 +2,15 @@ import { appendDebugLog } from "../utils/debug-log.js";
|
|
|
2
2
|
import { presentWork } from "../workflow/present.js";
|
|
3
3
|
import { buildCloseDoneResponse, buildCloseDropResponse, } from "../workflow/response-builders.js";
|
|
4
4
|
import { resolveTermPreset } from "../config/term-presets.js";
|
|
5
|
+
import { FlowError } from "../common/errors.js";
|
|
5
6
|
import { closeToolSchema } from "../types/tooling.js";
|
|
6
7
|
import { handleToolError } from "./shared.js";
|
|
8
|
+
function requireClaimField(value, name) {
|
|
9
|
+
if (value === undefined) {
|
|
10
|
+
throw new FlowError("EMPTY_PARAM", `parameter '${name}' is required when petition=CLAIM`);
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
7
14
|
export function createCloseHandler() {
|
|
8
15
|
return async (args, extra) => {
|
|
9
16
|
let petition = "UNKNOWN";
|
|
@@ -17,21 +24,45 @@ export function createCloseHandler() {
|
|
|
17
24
|
petition = input.petition;
|
|
18
25
|
workingDir = input.cwd || process.cwd();
|
|
19
26
|
if (input.petition === "CLAIM") {
|
|
20
|
-
criteriaCheckParts = input.criteriaChecks;
|
|
21
|
-
constraintsCheckParts = input.constraintsChecks;
|
|
27
|
+
criteriaCheckParts = input.criteriaChecks ?? [];
|
|
28
|
+
constraintsCheckParts = input.constraintsChecks ?? [];
|
|
22
29
|
oath = input.oath;
|
|
23
|
-
scoreLine = `Scores: precise=${input.score_precise} minimal=${input.score_minimal} isolated=${input.score_isolated} idiomatic=${input.score_idiomatic} cohesive=${input.score_cohesive}`;
|
|
30
|
+
scoreLine = `Scores: precise=${input.score_precise ?? "MISSING"} minimal=${input.score_minimal ?? "MISSING"} isolated=${input.score_isolated ?? "MISSING"} idiomatic=${input.score_idiomatic ?? "MISSING"} cohesive=${input.score_cohesive ?? "MISSING"}`;
|
|
24
31
|
}
|
|
25
32
|
appendDebugLog(`tool close start petition=${petition} cwd=${workingDir} criteriaChecks=${criteriaCheckParts.length} constraintsChecks=${constraintsCheckParts.length}`, {
|
|
26
33
|
cwd: workingDir,
|
|
27
34
|
section: "script",
|
|
28
35
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
cwd: workingDir,
|
|
32
|
-
signal: extra.signal,
|
|
33
|
-
});
|
|
36
|
+
let closeInput;
|
|
37
|
+
let claimInput;
|
|
34
38
|
if (input.petition === "CLAIM") {
|
|
39
|
+
claimInput = {
|
|
40
|
+
petition: "CLAIM",
|
|
41
|
+
criteriaChecks: requireClaimField(input.criteriaChecks, "criteriaChecks"),
|
|
42
|
+
constraintsChecks: requireClaimField(input.constraintsChecks, "constraintsChecks"),
|
|
43
|
+
score_precise: requireClaimField(input.score_precise, "score_precise"),
|
|
44
|
+
score_minimal: requireClaimField(input.score_minimal, "score_minimal"),
|
|
45
|
+
score_isolated: requireClaimField(input.score_isolated, "score_isolated"),
|
|
46
|
+
score_idiomatic: requireClaimField(input.score_idiomatic, "score_idiomatic"),
|
|
47
|
+
score_cohesive: requireClaimField(input.score_cohesive, "score_cohesive"),
|
|
48
|
+
oath: requireClaimField(input.oath, "oath"),
|
|
49
|
+
cwd: workingDir,
|
|
50
|
+
signal: extra.signal,
|
|
51
|
+
};
|
|
52
|
+
closeInput = claimInput;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
closeInput = {
|
|
56
|
+
petition: "FORFEIT",
|
|
57
|
+
cwd: workingDir,
|
|
58
|
+
signal: extra.signal,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const outcome = await presentWork(closeInput);
|
|
62
|
+
if (input.petition === "CLAIM") {
|
|
63
|
+
if (!claimInput) {
|
|
64
|
+
throw new Error("Unexpected CLAIM input shape");
|
|
65
|
+
}
|
|
35
66
|
if (!("result" in outcome) || outcome.result !== "merged") {
|
|
36
67
|
throw new Error("Unexpected CLAIM outcome shape");
|
|
37
68
|
}
|
|
@@ -43,12 +74,12 @@ export function createCloseHandler() {
|
|
|
43
74
|
return buildCloseDoneResponse(finalOutcome, {
|
|
44
75
|
criteriaChecks: criteriaCheckParts,
|
|
45
76
|
constraintsChecks: constraintsCheckParts,
|
|
46
|
-
score_precise:
|
|
47
|
-
score_minimal:
|
|
48
|
-
score_isolated:
|
|
49
|
-
score_idiomatic:
|
|
50
|
-
score_cohesive:
|
|
51
|
-
oath:
|
|
77
|
+
score_precise: claimInput.score_precise,
|
|
78
|
+
score_minimal: claimInput.score_minimal,
|
|
79
|
+
score_isolated: claimInput.score_isolated,
|
|
80
|
+
score_idiomatic: claimInput.score_idiomatic,
|
|
81
|
+
score_cohesive: claimInput.score_cohesive,
|
|
82
|
+
oath: claimInput.oath,
|
|
52
83
|
cwd: workingDir,
|
|
53
84
|
});
|
|
54
85
|
}
|
package/build/index.js
CHANGED
|
@@ -41,7 +41,9 @@ function registerTools(server) {
|
|
|
41
41
|
const askPreset = renderedPreset.tools.ask;
|
|
42
42
|
const closePreset = renderedPreset.tools.close;
|
|
43
43
|
const helpPreset = renderedPreset.tools.help;
|
|
44
|
-
const dynamicCloseSchema = closeToolSchema
|
|
44
|
+
const dynamicCloseSchema = applyArgumentDescriptions(closeToolSchema, {
|
|
45
|
+
...closePreset.args,
|
|
46
|
+
});
|
|
45
47
|
const dynamicStartSchema = applyArgumentDescriptions(startToolSchema, {
|
|
46
48
|
...startPreset.args,
|
|
47
49
|
});
|
package/build/types/tooling.js
CHANGED
|
@@ -22,22 +22,54 @@ export const askToolSchema = z.object({
|
|
|
22
22
|
name: z.string().optional(),
|
|
23
23
|
cwd: z.string().optional(),
|
|
24
24
|
});
|
|
25
|
-
export const closeToolSchema = z.
|
|
26
|
-
z.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
25
|
+
export const closeToolSchema = z.object({
|
|
26
|
+
petition: z.enum(["CLAIM", "FORFEIT"]).describe("REQUIRED. CLAIM to finalize, FORFEIT to abandon."),
|
|
27
|
+
criteriaChecks: z
|
|
28
|
+
.array(z.string().trim().min(1))
|
|
29
|
+
.min(1)
|
|
30
|
+
.optional()
|
|
31
|
+
.describe("Required when petition=CLAIM. For FORFEIT, this field is optional and can be omitted."),
|
|
32
|
+
constraintsChecks: z
|
|
33
|
+
.array(z.string().trim().min(1))
|
|
34
|
+
.min(1)
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Required when petition=CLAIM. For FORFEIT, this field is optional and can be omitted."),
|
|
37
|
+
score_precise: z
|
|
38
|
+
.number()
|
|
39
|
+
.min(0)
|
|
40
|
+
.max(10)
|
|
41
|
+
.optional()
|
|
42
|
+
.describe("Required when petition=CLAIM. For FORFEIT, this field is optional and can be omitted."),
|
|
43
|
+
score_minimal: z
|
|
44
|
+
.number()
|
|
45
|
+
.min(0)
|
|
46
|
+
.max(10)
|
|
47
|
+
.optional()
|
|
48
|
+
.describe("Required when petition=CLAIM. For FORFEIT, this field is optional and can be omitted."),
|
|
49
|
+
score_isolated: z
|
|
50
|
+
.number()
|
|
51
|
+
.min(0)
|
|
52
|
+
.max(10)
|
|
53
|
+
.optional()
|
|
54
|
+
.describe("Required when petition=CLAIM. For FORFEIT, this field is optional and can be omitted."),
|
|
55
|
+
score_idiomatic: z
|
|
56
|
+
.number()
|
|
57
|
+
.min(0)
|
|
58
|
+
.max(10)
|
|
59
|
+
.optional()
|
|
60
|
+
.describe("Required when petition=CLAIM. For FORFEIT, this field is optional and can be omitted."),
|
|
61
|
+
score_cohesive: z
|
|
62
|
+
.number()
|
|
63
|
+
.min(0)
|
|
64
|
+
.max(10)
|
|
65
|
+
.optional()
|
|
66
|
+
.describe("Required when petition=CLAIM. For FORFEIT, this field is optional and can be omitted."),
|
|
67
|
+
oath: z
|
|
68
|
+
.string()
|
|
69
|
+
.trim()
|
|
70
|
+
.min(1)
|
|
71
|
+
.optional()
|
|
72
|
+
.describe("Required when petition=CLAIM. For FORFEIT, this field is optional and can be omitted."),
|
|
73
|
+
cwd: z.string().optional(),
|
|
74
|
+
});
|
|
43
75
|
export const helpToolSchema = z.object({});
|