@gempack/squad-mcp 0.3.1 → 0.6.0
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +4 -2
- package/CHANGELOG.md +395 -8
- package/INSTALL.md +554 -0
- package/README.md +311 -25
- package/agents/{Skill-Squad-Dev.md → _shared/Skill-Squad-Dev.md} +30 -3
- package/agents/{Skill-Squad-Review.md → _shared/Skill-Squad-Review.md} +70 -0
- package/agents/{PO.md → product-owner.md} +33 -1
- package/agents/{Senior-Architect.md → senior-architect.md} +33 -1
- package/agents/{Senior-DBA.md → senior-dba.md} +33 -1
- package/agents/senior-dev-reviewer.md +640 -0
- package/agents/{Senior-Dev-Security.md → senior-dev-security.md} +33 -1
- package/agents/{Senior-Developer.md → senior-developer.md} +33 -1
- package/agents/{Senior-QA.md → senior-qa.md} +33 -1
- package/agents/{TechLead-Consolidator.md → tech-lead-consolidator.md} +7 -1
- package/agents/{TechLead-Planner.md → tech-lead-planner.md} +7 -1
- package/commands/brainstorm.md +21 -0
- package/commands/commit-suggest.md +12 -0
- package/commands/squad-review.md +10 -58
- package/commands/squad.md +11 -70
- package/dist/config/ownership-matrix.d.ts +24 -2
- package/dist/config/ownership-matrix.js +466 -139
- package/dist/config/ownership-matrix.js.map +1 -1
- package/dist/config/squad-yaml.d.ts +242 -0
- package/dist/config/squad-yaml.js +403 -0
- package/dist/config/squad-yaml.js.map +1 -0
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/format/pr-review.d.ts +61 -0
- package/dist/format/pr-review.js +146 -0
- package/dist/format/pr-review.js.map +1 -0
- package/dist/index.js +19 -13
- package/dist/index.js.map +1 -1
- package/dist/learning/format.d.ts +29 -0
- package/dist/learning/format.js +55 -0
- package/dist/learning/format.js.map +1 -0
- package/dist/learning/store.d.ts +102 -0
- package/dist/learning/store.js +169 -0
- package/dist/learning/store.js.map +1 -0
- package/dist/resources/agent-loader.d.ts +14 -2
- package/dist/resources/agent-loader.js +235 -53
- package/dist/resources/agent-loader.js.map +1 -1
- package/dist/tasks/select.d.ts +64 -0
- package/dist/tasks/select.js +84 -0
- package/dist/tasks/select.js.map +1 -0
- package/dist/tasks/store.d.ts +338 -0
- package/dist/tasks/store.js +321 -0
- package/dist/tasks/store.js.map +1 -0
- package/dist/tools/agents.js +4 -1
- package/dist/tools/agents.js.map +1 -1
- package/dist/tools/compose-advisory-bundle.d.ts +5 -5
- package/dist/tools/compose-advisory-bundle.js +24 -12
- package/dist/tools/compose-advisory-bundle.js.map +1 -1
- package/dist/tools/compose-prd-parse.d.ts +53 -0
- package/dist/tools/compose-prd-parse.js +167 -0
- package/dist/tools/compose-prd-parse.js.map +1 -0
- package/dist/tools/compose-squad-workflow.d.ts +28 -10
- package/dist/tools/compose-squad-workflow.js +0 -0
- package/dist/tools/compose-squad-workflow.js.map +1 -1
- package/dist/tools/consolidate.d.ts +55 -4
- package/dist/tools/consolidate.js +87 -15
- package/dist/tools/consolidate.js.map +1 -1
- package/dist/tools/expand-task.d.ts +51 -0
- package/dist/tools/expand-task.js +35 -0
- package/dist/tools/expand-task.js.map +1 -0
- package/dist/tools/list-tasks.d.ts +31 -0
- package/dist/tools/list-tasks.js +50 -0
- package/dist/tools/list-tasks.js.map +1 -0
- package/dist/tools/next-task.d.ts +37 -0
- package/dist/tools/next-task.js +60 -0
- package/dist/tools/next-task.js.map +1 -0
- package/dist/tools/read-learnings.d.ts +53 -0
- package/dist/tools/read-learnings.js +72 -0
- package/dist/tools/read-learnings.js.map +1 -0
- package/dist/tools/read-squad-config.d.ts +23 -0
- package/dist/tools/read-squad-config.js +34 -0
- package/dist/tools/read-squad-config.js.map +1 -0
- package/dist/tools/record-learning.d.ts +62 -0
- package/dist/tools/record-learning.js +80 -0
- package/dist/tools/record-learning.js.map +1 -0
- package/dist/tools/record-tasks.d.ts +71 -0
- package/dist/tools/record-tasks.js +45 -0
- package/dist/tools/record-tasks.js.map +1 -0
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/registry.js +71 -39
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/score-rubric.d.ts +74 -0
- package/dist/tools/score-rubric.js +140 -0
- package/dist/tools/score-rubric.js.map +1 -0
- package/dist/tools/slice-files-for-task.d.ts +31 -0
- package/dist/tools/slice-files-for-task.js +52 -0
- package/dist/tools/slice-files-for-task.js.map +1 -0
- package/dist/tools/update-task-status.d.ts +29 -0
- package/dist/tools/update-task-status.js +35 -0
- package/dist/tools/update-task-status.js.map +1 -0
- package/dist/util/override-allowlist.d.ts +63 -0
- package/dist/util/override-allowlist.js +191 -0
- package/dist/util/override-allowlist.js.map +1 -0
- package/dist/util/path-internal.d.ts +6 -0
- package/dist/util/path-internal.js +27 -0
- package/dist/util/path-internal.js.map +1 -0
- package/dist/util/path-safety.js +0 -0
- package/dist/util/path-safety.js.map +1 -1
- package/package.json +5 -1
- package/skills/brainstorm/SKILL.md +284 -0
- package/skills/commit-suggest/SKILL.md +255 -0
- package/skills/squad/SKILL.md +454 -0
- package/tools/post-review.mjs +212 -0
- package/agents/Senior-Dev-Reviewer.md +0 -104
- /package/agents/{_Severity-and-Ownership.md → _shared/_Severity-and-Ownership.md} +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { readSquadYaml, } from "../config/squad-yaml.js";
|
|
3
|
+
import { resolveSafePath, createSafePathContext } from "../util/path-safety.js";
|
|
4
|
+
const schema = z.object({
|
|
5
|
+
workspace_root: z.string().min(1).max(4096),
|
|
6
|
+
});
|
|
7
|
+
/**
|
|
8
|
+
* MCP tool wrapper around the YAML reader. Lets non-Claude-Code clients (or
|
|
9
|
+
* non-composer callers) inspect the resolved config explicitly. Pure tools
|
|
10
|
+
* (apply_consolidation_rules, score_rubric, select_squad) do NOT call this —
|
|
11
|
+
* the composers (compose_squad_workflow, compose_advisory_bundle) read
|
|
12
|
+
* .squad.yaml automatically when they receive workspace_root, then pass the
|
|
13
|
+
* concrete values down. This tool is for direct introspection and for clients
|
|
14
|
+
* that want to construct a tailored bundle themselves.
|
|
15
|
+
*/
|
|
16
|
+
export async function readSquadConfig(input) {
|
|
17
|
+
// Containment check — canonicalise the workspace root via the same machinery
|
|
18
|
+
// every other path-receiving tool uses. resolveSafePath returns the realpath
|
|
19
|
+
// of `<root>/.` which is the root itself.
|
|
20
|
+
const ctx = createSafePathContext();
|
|
21
|
+
const safe = await resolveSafePath(input.workspace_root, ".", ctx);
|
|
22
|
+
return await readSquadYaml(safe);
|
|
23
|
+
}
|
|
24
|
+
export const readSquadConfigTool = {
|
|
25
|
+
name: "read_squad_config",
|
|
26
|
+
description: "Read and resolve `.squad.yaml` (or `.squad.yml`) at the given workspace_root. " +
|
|
27
|
+
"Returns effective weights (defaults merged), threshold, min_score, skip_paths, disable_agents, " +
|
|
28
|
+
"and the source path (or null if no file present). Composers (compose_squad_workflow, " +
|
|
29
|
+
"compose_advisory_bundle) read this automatically when they receive workspace_root; this tool " +
|
|
30
|
+
"is for explicit introspection and for clients that build their own bundle.",
|
|
31
|
+
schema,
|
|
32
|
+
handler: readSquadConfig,
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=read-squad-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-squad-config.js","sourceRoot":"","sources":["../../src/tools/read-squad-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,aAAa,GAEd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEhF,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;CAC5C,CAAC,CAAC;AAIH;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAY;IAEZ,6EAA6E;IAC7E,6EAA6E;IAC7E,0CAA0C;IAC1C,MAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;IACpC,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACnE,OAAO,MAAM,aAAa,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAA2B;IACzD,IAAI,EAAE,mBAAmB;IACzB,WAAW,EACT,gFAAgF;QAChF,iGAAiG;QACjG,uFAAuF;QACvF,+FAA+F;QAC/F,4EAA4E;IAC9E,MAAM;IACN,OAAO,EAAE,eAAe;CACzB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolDef } from "./registry.js";
|
|
3
|
+
declare const schema: z.ZodObject<{
|
|
4
|
+
workspace_root: z.ZodString;
|
|
5
|
+
/** Which agent's finding this decision concerns. */
|
|
6
|
+
agent: z.ZodEnum<[import("../config/ownership-matrix.js").AgentName, ...import("../config/ownership-matrix.js").AgentName[]]>;
|
|
7
|
+
/** Short title of the finding (matches finding.title from consolidate). */
|
|
8
|
+
finding: z.ZodString;
|
|
9
|
+
/** Whether the team accepted or rejected this finding. */
|
|
10
|
+
decision: z.ZodEnum<["accept", "reject"]>;
|
|
11
|
+
/** Severity at the time of the decision. */
|
|
12
|
+
severity: z.ZodOptional<z.ZodEnum<["Blocker", "Major", "Minor", "Suggestion"]>>;
|
|
13
|
+
/** Free-form rationale. Surfaces in the consolidator prompt. */
|
|
14
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
15
|
+
/** PR number when recorded from `/squad-review #N`. */
|
|
16
|
+
pr: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
/** Branch name when recorded from a local review. */
|
|
18
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
19
|
+
/** Glob-ish path scope (e.g. "src/auth/**"). When absent, repo-wide. */
|
|
20
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
workspace_root: string;
|
|
23
|
+
agent: import("../config/ownership-matrix.js").AgentName;
|
|
24
|
+
finding: string;
|
|
25
|
+
decision: "accept" | "reject";
|
|
26
|
+
reason?: string | undefined;
|
|
27
|
+
severity?: "Blocker" | "Major" | "Minor" | "Suggestion" | undefined;
|
|
28
|
+
pr?: number | undefined;
|
|
29
|
+
branch?: string | undefined;
|
|
30
|
+
scope?: string | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
workspace_root: string;
|
|
33
|
+
agent: import("../config/ownership-matrix.js").AgentName;
|
|
34
|
+
finding: string;
|
|
35
|
+
decision: "accept" | "reject";
|
|
36
|
+
reason?: string | undefined;
|
|
37
|
+
severity?: "Blocker" | "Major" | "Minor" | "Suggestion" | undefined;
|
|
38
|
+
pr?: number | undefined;
|
|
39
|
+
branch?: string | undefined;
|
|
40
|
+
scope?: string | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
type Input = z.infer<typeof schema>;
|
|
43
|
+
/**
|
|
44
|
+
* Append a new entry to `.squad/learnings.jsonl`. Atomic per-line. Skill calls
|
|
45
|
+
* this in Phase 14 (post-PR record). The CLI helper `tools/record-learning.mjs`
|
|
46
|
+
* is the equivalent for non-MCP clients.
|
|
47
|
+
*
|
|
48
|
+
* Side-effecting (writes to disk). The skill or CLI is responsible for
|
|
49
|
+
* confirming with the user before invoking — this tool itself never asks
|
|
50
|
+
* (MCP tools don't have user prompts).
|
|
51
|
+
*/
|
|
52
|
+
export declare function recordLearningTool(input: Input): Promise<{
|
|
53
|
+
recorded: true;
|
|
54
|
+
file: string;
|
|
55
|
+
entry: {
|
|
56
|
+
ts: string;
|
|
57
|
+
agent: string;
|
|
58
|
+
decision: string;
|
|
59
|
+
};
|
|
60
|
+
}>;
|
|
61
|
+
export declare const recordLearningToolDef: ToolDef<typeof schema>;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { appendLearning } from "../learning/store.js";
|
|
3
|
+
import { readSquadYaml } from "../config/squad-yaml.js";
|
|
4
|
+
import { resolveSafePath, createSafePathContext } from "../util/path-safety.js";
|
|
5
|
+
import { AGENT_NAMES_TUPLE } from "../config/ownership-matrix.js";
|
|
6
|
+
const schema = z.object({
|
|
7
|
+
workspace_root: z.string().min(1).max(4096),
|
|
8
|
+
/** Which agent's finding this decision concerns. */
|
|
9
|
+
agent: z.enum(AGENT_NAMES_TUPLE),
|
|
10
|
+
/** Short title of the finding (matches finding.title from consolidate). */
|
|
11
|
+
finding: z.string().min(1).max(2048),
|
|
12
|
+
/** Whether the team accepted or rejected this finding. */
|
|
13
|
+
decision: z.enum(["accept", "reject"]),
|
|
14
|
+
/** Severity at the time of the decision. */
|
|
15
|
+
severity: z.enum(["Blocker", "Major", "Minor", "Suggestion"]).optional(),
|
|
16
|
+
/** Free-form rationale. Surfaces in the consolidator prompt. */
|
|
17
|
+
reason: z.string().max(4096).optional(),
|
|
18
|
+
/** PR number when recorded from `/squad-review #N`. */
|
|
19
|
+
pr: z.number().int().positive().optional(),
|
|
20
|
+
/** Branch name when recorded from a local review. */
|
|
21
|
+
branch: z.string().min(1).max(255).optional(),
|
|
22
|
+
/** Glob-ish path scope (e.g. "src/auth/**"). When absent, repo-wide. */
|
|
23
|
+
scope: z.string().min(1).max(512).optional(),
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Append a new entry to `.squad/learnings.jsonl`. Atomic per-line. Skill calls
|
|
27
|
+
* this in Phase 14 (post-PR record). The CLI helper `tools/record-learning.mjs`
|
|
28
|
+
* is the equivalent for non-MCP clients.
|
|
29
|
+
*
|
|
30
|
+
* Side-effecting (writes to disk). The skill or CLI is responsible for
|
|
31
|
+
* confirming with the user before invoking — this tool itself never asks
|
|
32
|
+
* (MCP tools don't have user prompts).
|
|
33
|
+
*/
|
|
34
|
+
export async function recordLearningTool(input) {
|
|
35
|
+
const ctx = createSafePathContext();
|
|
36
|
+
const safeRoot = await resolveSafePath(input.workspace_root, ".", ctx);
|
|
37
|
+
const config = await readSquadYaml(safeRoot);
|
|
38
|
+
// Recording IS allowed even when reads are disabled — turning off injection
|
|
39
|
+
// (e.g. for a quiet release window) shouldn't throw away the journal. The
|
|
40
|
+
// skill is responsible for not calling record_learning when the user did
|
|
41
|
+
// not authorise the decision.
|
|
42
|
+
const configuredPath = config.learnings.path;
|
|
43
|
+
const entry = {
|
|
44
|
+
agent: input.agent,
|
|
45
|
+
finding: input.finding,
|
|
46
|
+
decision: input.decision,
|
|
47
|
+
};
|
|
48
|
+
if (input.severity !== undefined)
|
|
49
|
+
entry.severity = input.severity;
|
|
50
|
+
if (input.reason !== undefined)
|
|
51
|
+
entry.reason = input.reason;
|
|
52
|
+
if (input.pr !== undefined)
|
|
53
|
+
entry.pr = input.pr;
|
|
54
|
+
if (input.branch !== undefined)
|
|
55
|
+
entry.branch = input.branch;
|
|
56
|
+
if (input.scope !== undefined)
|
|
57
|
+
entry.scope = input.scope;
|
|
58
|
+
const result = await appendLearning(safeRoot, entry, {
|
|
59
|
+
...(configuredPath !== undefined ? { configuredPath } : {}),
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
recorded: true,
|
|
63
|
+
file: result.filePath,
|
|
64
|
+
entry: {
|
|
65
|
+
ts: result.entry.ts,
|
|
66
|
+
agent: result.entry.agent,
|
|
67
|
+
decision: result.entry.decision,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export const recordLearningToolDef = {
|
|
72
|
+
name: "record_learning",
|
|
73
|
+
description: "Append a team decision (accept | reject) on a finding to `.squad/learnings.jsonl`. " +
|
|
74
|
+
"Future runs of the squad will inject the most recent entries into agent / consolidator prompts so " +
|
|
75
|
+
"the squad stops re-suggesting things the team has already declined (with reason). " +
|
|
76
|
+
"Side-effecting — writes to disk. Caller (skill or CLI) is responsible for user confirmation.",
|
|
77
|
+
schema,
|
|
78
|
+
handler: recordLearningTool,
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=record-learning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-learning.js","sourceRoot":"","sources":["../../src/tools/record-learning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;IAC3C,oDAAoD;IACpD,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC;IAChC,2EAA2E;IAC3E,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;IACpC,0DAA0D;IAC1D,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACtC,4CAA4C;IAC5C,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,QAAQ,EAAE;IACxE,gEAAgE;IAChE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ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AK,CAAC,EAAE,CAAC;IAChD,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;QAAE,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5D,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;QAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAEzD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE;QACnD,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5D,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,KAAK,EAAE;YACL,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE;YACnB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK;YACzB,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ;SAChC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAA2B;IAC3D,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,qFAAqF;QACrF,oGAAoG;QACpG,oFAAoF;QACpF,8FAA8F;IAChG,MAAM;IACN,OAAO,EAAE,kBAAkB;CAC5B,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolDef } from "./registry.js";
|
|
3
|
+
declare const schema: z.ZodObject<{
|
|
4
|
+
workspace_root: z.ZodString;
|
|
5
|
+
tasks: z.ZodArray<z.ZodObject<{
|
|
6
|
+
id: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
title: z.ZodString;
|
|
8
|
+
description: z.ZodOptional<z.ZodString>;
|
|
9
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
10
|
+
priority: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
11
|
+
details: z.ZodOptional<z.ZodString>;
|
|
12
|
+
test_strategy: z.ZodOptional<z.ZodString>;
|
|
13
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
14
|
+
agent_hints: z.ZodOptional<z.ZodArray<z.ZodEnum<[import("../config/ownership-matrix.js").AgentName, ...import("../config/ownership-matrix.js").AgentName[]]>, "many">>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
title: string;
|
|
17
|
+
details?: string | undefined;
|
|
18
|
+
scope?: string | undefined;
|
|
19
|
+
id?: number | undefined;
|
|
20
|
+
description?: string | undefined;
|
|
21
|
+
dependencies?: number[] | undefined;
|
|
22
|
+
priority?: "high" | "medium" | "low" | undefined;
|
|
23
|
+
test_strategy?: string | undefined;
|
|
24
|
+
agent_hints?: import("../config/ownership-matrix.js").AgentName[] | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
title: string;
|
|
27
|
+
details?: string | undefined;
|
|
28
|
+
scope?: string | undefined;
|
|
29
|
+
id?: number | undefined;
|
|
30
|
+
description?: string | undefined;
|
|
31
|
+
dependencies?: number[] | undefined;
|
|
32
|
+
priority?: "high" | "medium" | "low" | undefined;
|
|
33
|
+
test_strategy?: string | undefined;
|
|
34
|
+
agent_hints?: import("../config/ownership-matrix.js").AgentName[] | undefined;
|
|
35
|
+
}>, "many">;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
workspace_root: string;
|
|
38
|
+
tasks: {
|
|
39
|
+
title: string;
|
|
40
|
+
details?: string | undefined;
|
|
41
|
+
scope?: string | undefined;
|
|
42
|
+
id?: number | undefined;
|
|
43
|
+
description?: string | undefined;
|
|
44
|
+
dependencies?: number[] | undefined;
|
|
45
|
+
priority?: "high" | "medium" | "low" | undefined;
|
|
46
|
+
test_strategy?: string | undefined;
|
|
47
|
+
agent_hints?: import("../config/ownership-matrix.js").AgentName[] | undefined;
|
|
48
|
+
}[];
|
|
49
|
+
}, {
|
|
50
|
+
workspace_root: string;
|
|
51
|
+
tasks: {
|
|
52
|
+
title: string;
|
|
53
|
+
details?: string | undefined;
|
|
54
|
+
scope?: string | undefined;
|
|
55
|
+
id?: number | undefined;
|
|
56
|
+
description?: string | undefined;
|
|
57
|
+
dependencies?: number[] | undefined;
|
|
58
|
+
priority?: "high" | "medium" | "low" | undefined;
|
|
59
|
+
test_strategy?: string | undefined;
|
|
60
|
+
agent_hints?: import("../config/ownership-matrix.js").AgentName[] | undefined;
|
|
61
|
+
}[];
|
|
62
|
+
}>;
|
|
63
|
+
type Input = z.infer<typeof schema>;
|
|
64
|
+
export interface RecordTasksOutput {
|
|
65
|
+
recorded: true;
|
|
66
|
+
file: string;
|
|
67
|
+
ids: number[];
|
|
68
|
+
}
|
|
69
|
+
export declare function recordTasksTool(input: Input): Promise<RecordTasksOutput>;
|
|
70
|
+
export declare const recordTasksToolDef: ToolDef<typeof schema>;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { recordTasks } from "../tasks/store.js";
|
|
3
|
+
import { readSquadYaml } from "../config/squad-yaml.js";
|
|
4
|
+
import { resolveSafePath, createSafePathContext } from "../util/path-safety.js";
|
|
5
|
+
import { AGENT_NAMES_TUPLE } from "../config/ownership-matrix.js";
|
|
6
|
+
const taskInputSchema = z.object({
|
|
7
|
+
id: z.number().int().positive().optional(),
|
|
8
|
+
title: z.string().min(1).max(512),
|
|
9
|
+
description: z.string().max(4096).optional(),
|
|
10
|
+
dependencies: z.array(z.number().int().positive()).max(50).optional(),
|
|
11
|
+
priority: z.enum(["low", "medium", "high"]).optional(),
|
|
12
|
+
details: z.string().max(16384).optional(),
|
|
13
|
+
test_strategy: z.string().max(4096).optional(),
|
|
14
|
+
scope: z.string().min(1).max(512).optional(),
|
|
15
|
+
agent_hints: z.array(z.enum(AGENT_NAMES_TUPLE)).optional(),
|
|
16
|
+
});
|
|
17
|
+
const schema = z.object({
|
|
18
|
+
workspace_root: z.string().min(1).max(4096),
|
|
19
|
+
tasks: z.array(taskInputSchema).min(1).max(500),
|
|
20
|
+
});
|
|
21
|
+
export async function recordTasksTool(input) {
|
|
22
|
+
const ctx = createSafePathContext();
|
|
23
|
+
const safeRoot = await resolveSafePath(input.workspace_root, ".", ctx);
|
|
24
|
+
const config = await readSquadYaml(safeRoot);
|
|
25
|
+
// Writes stay open even when reads disabled — same policy as learnings.
|
|
26
|
+
const result = await recordTasks(safeRoot, input.tasks.map((t) => ({
|
|
27
|
+
...(t.id !== undefined && { id: t.id }),
|
|
28
|
+
title: t.title,
|
|
29
|
+
...(t.description !== undefined && { description: t.description }),
|
|
30
|
+
...(t.dependencies !== undefined && { dependencies: t.dependencies }),
|
|
31
|
+
...(t.priority !== undefined && { priority: t.priority }),
|
|
32
|
+
...(t.details !== undefined && { details: t.details }),
|
|
33
|
+
...(t.test_strategy !== undefined && { test_strategy: t.test_strategy }),
|
|
34
|
+
...(t.scope !== undefined && { scope: t.scope }),
|
|
35
|
+
...(t.agent_hints !== undefined && { agent_hints: t.agent_hints }),
|
|
36
|
+
})), { configuredPath: config.tasks.path });
|
|
37
|
+
return { recorded: true, file: result.filePath, ids: result.ids };
|
|
38
|
+
}
|
|
39
|
+
export const recordTasksToolDef = {
|
|
40
|
+
name: "record_tasks",
|
|
41
|
+
description: "Bulk-create tasks in `.squad/tasks.json`. Each task: id (optional, auto-allocated), title, description, dependencies, priority, details, test_strategy, scope (glob), agent_hints. Side-effecting — atomic write (tmp + rename). Validates: unique ids, all dependencies resolve, no self-deps. The host LLM is responsible for confirming with the user before bulk-recording from a parsed PRD.",
|
|
42
|
+
schema,
|
|
43
|
+
handler: recordTasksTool,
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=record-tasks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-tasks.js","sourceRoot":"","sources":["../../src/tools/record-tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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,SAAS,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QACtD,GAAG,CAAC,CAAC,CAAC,aAAa,KAAK,SAAS,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC;QACxE,GAAG,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QAChD,GAAG,CAAC,CAAC,CAAC,WAAW,KAAK,SAAS,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;KACnE,CAAC,CAAC,EACH,EAAE,cAAc,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CACtC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;AACpE,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAA2B;IACxD,IAAI,EAAE,cAAc;IACpB,WAAW,EACT,mYAAmY;IACrY,MAAM;IACN,OAAO,EAAE,eAAe;CACzB,CAAC"}
|
package/dist/tools/registry.d.ts
CHANGED
package/dist/tools/registry.js
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { scoreRiskTool } from
|
|
3
|
-
import { selectSquadTool } from
|
|
4
|
-
import { sliceFilesForAgentTool } from
|
|
5
|
-
import { listAgentsTool, getAgentDefinitionTool, initLocalConfigTool } from
|
|
6
|
-
import { applyConsolidationRulesTool } from
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { scoreRiskTool } from "./score-risk.js";
|
|
3
|
+
import { selectSquadTool } from "./select-squad.js";
|
|
4
|
+
import { sliceFilesForAgentTool } from "./slice-files.js";
|
|
5
|
+
import { listAgentsTool, getAgentDefinitionTool, initLocalConfigTool, } from "./agents.js";
|
|
6
|
+
import { applyConsolidationRulesTool } from "./consolidate.js";
|
|
7
|
+
import { scoreRubricTool } from "./score-rubric.js";
|
|
8
|
+
import { readSquadConfigTool } from "./read-squad-config.js";
|
|
9
|
+
import { readLearningsToolDef } from "./read-learnings.js";
|
|
10
|
+
import { recordLearningToolDef } from "./record-learning.js";
|
|
11
|
+
import { listTasksToolDef } from "./list-tasks.js";
|
|
12
|
+
import { nextTaskToolDef } from "./next-task.js";
|
|
13
|
+
import { recordTasksToolDef } from "./record-tasks.js";
|
|
14
|
+
import { updateTaskStatusToolDef } from "./update-task-status.js";
|
|
15
|
+
import { expandTaskToolDef } from "./expand-task.js";
|
|
16
|
+
import { sliceFilesForTaskToolDef } from "./slice-files-for-task.js";
|
|
17
|
+
import { composePrdParseToolDef } from "./compose-prd-parse.js";
|
|
18
|
+
import { classifyWorkTypeTool } from "./classify-work-type.js";
|
|
19
|
+
import { detectChangedFilesTool } from "./detect-changed-files.js";
|
|
20
|
+
import { validatePlanTextTool } from "./validate-plan-text.js";
|
|
21
|
+
import { composeSquadWorkflowTool } from "./compose-squad-workflow.js";
|
|
22
|
+
import { composeAdvisoryBundleTool } from "./compose-advisory-bundle.js";
|
|
23
|
+
import { isSquadError } from "../errors.js";
|
|
24
|
+
import { logger, newRequestId } from "../observability/logger.js";
|
|
14
25
|
const tools = new Map();
|
|
15
26
|
export function register(def) {
|
|
16
27
|
tools.set(def.name, def);
|
|
@@ -23,6 +34,17 @@ export function registerTools() {
|
|
|
23
34
|
register(getAgentDefinitionTool);
|
|
24
35
|
register(initLocalConfigTool);
|
|
25
36
|
register(applyConsolidationRulesTool);
|
|
37
|
+
register(scoreRubricTool);
|
|
38
|
+
register(readSquadConfigTool);
|
|
39
|
+
register(readLearningsToolDef);
|
|
40
|
+
register(recordLearningToolDef);
|
|
41
|
+
register(listTasksToolDef);
|
|
42
|
+
register(nextTaskToolDef);
|
|
43
|
+
register(recordTasksToolDef);
|
|
44
|
+
register(updateTaskStatusToolDef);
|
|
45
|
+
register(expandTaskToolDef);
|
|
46
|
+
register(sliceFilesForTaskToolDef);
|
|
47
|
+
register(composePrdParseToolDef);
|
|
26
48
|
register(classifyWorkTypeTool);
|
|
27
49
|
register(detectChangedFilesTool);
|
|
28
50
|
register(validatePlanTextTool);
|
|
@@ -38,12 +60,12 @@ export function listTools() {
|
|
|
38
60
|
}
|
|
39
61
|
function asToolErrorResponse(body) {
|
|
40
62
|
return {
|
|
41
|
-
content: [{ type:
|
|
63
|
+
content: [{ type: "text", text: JSON.stringify(body, null, 2) }],
|
|
42
64
|
isError: true,
|
|
43
65
|
};
|
|
44
66
|
}
|
|
45
67
|
function shapeOf(args) {
|
|
46
|
-
if (args === null || typeof args !==
|
|
68
|
+
if (args === null || typeof args !== "object")
|
|
47
69
|
return undefined;
|
|
48
70
|
const out = {};
|
|
49
71
|
for (const [k, v] of Object.entries(args)) {
|
|
@@ -53,10 +75,10 @@ function shapeOf(args) {
|
|
|
53
75
|
else if (Array.isArray(v)) {
|
|
54
76
|
out[k] = `[Array(${v.length})]`;
|
|
55
77
|
}
|
|
56
|
-
else if (typeof v ===
|
|
57
|
-
out[k] =
|
|
78
|
+
else if (typeof v === "object") {
|
|
79
|
+
out[k] = "[object]";
|
|
58
80
|
}
|
|
59
|
-
else if (typeof v ===
|
|
81
|
+
else if (typeof v === "string") {
|
|
60
82
|
out[k] = `[string(${v.length})]`;
|
|
61
83
|
}
|
|
62
84
|
else {
|
|
@@ -70,28 +92,32 @@ export async function dispatchTool(name, args) {
|
|
|
70
92
|
const started = Date.now();
|
|
71
93
|
const tool = tools.get(name);
|
|
72
94
|
if (!tool) {
|
|
73
|
-
logger.warn(
|
|
95
|
+
logger.warn("unknown tool", {
|
|
74
96
|
tool: name,
|
|
75
97
|
request_id: requestId,
|
|
76
|
-
outcome:
|
|
98
|
+
outcome: "unknown_tool",
|
|
77
99
|
duration_ms: Date.now() - started,
|
|
78
100
|
});
|
|
79
101
|
return asToolErrorResponse({
|
|
80
|
-
error: { code:
|
|
102
|
+
error: { code: "UNKNOWN_TOOL", message: `unknown tool: ${name}` },
|
|
81
103
|
});
|
|
82
104
|
}
|
|
83
|
-
logger.debug(
|
|
105
|
+
logger.debug("tool call", {
|
|
106
|
+
tool: name,
|
|
107
|
+
request_id: requestId,
|
|
108
|
+
input_shape: shapeOf(args),
|
|
109
|
+
});
|
|
84
110
|
const parsed = tool.schema.safeParse(args);
|
|
85
111
|
if (!parsed.success) {
|
|
86
|
-
logger.warn(
|
|
112
|
+
logger.warn("invalid input", {
|
|
87
113
|
tool: name,
|
|
88
114
|
request_id: requestId,
|
|
89
|
-
outcome:
|
|
115
|
+
outcome: "invalid_input",
|
|
90
116
|
duration_ms: Date.now() - started,
|
|
91
117
|
});
|
|
92
118
|
return asToolErrorResponse({
|
|
93
119
|
error: {
|
|
94
|
-
code:
|
|
120
|
+
code: "INVALID_INPUT",
|
|
95
121
|
message: parsed.error.message,
|
|
96
122
|
details: { issues: parsed.error.issues.length },
|
|
97
123
|
},
|
|
@@ -99,23 +125,25 @@ export async function dispatchTool(name, args) {
|
|
|
99
125
|
}
|
|
100
126
|
try {
|
|
101
127
|
const result = await tool.handler(parsed.data);
|
|
102
|
-
logger.info(
|
|
128
|
+
logger.info("tool ok", {
|
|
103
129
|
tool: name,
|
|
104
130
|
request_id: requestId,
|
|
105
|
-
outcome:
|
|
131
|
+
outcome: "success",
|
|
106
132
|
duration_ms: Date.now() - started,
|
|
107
133
|
});
|
|
108
134
|
return {
|
|
109
|
-
content: [
|
|
135
|
+
content: [
|
|
136
|
+
{ type: "text", text: JSON.stringify(result, null, 2) },
|
|
137
|
+
],
|
|
110
138
|
};
|
|
111
139
|
}
|
|
112
140
|
catch (err) {
|
|
113
141
|
const duration_ms = Date.now() - started;
|
|
114
142
|
if (isSquadError(err)) {
|
|
115
|
-
logger.warn(
|
|
143
|
+
logger.warn("tool error", {
|
|
116
144
|
tool: name,
|
|
117
145
|
request_id: requestId,
|
|
118
|
-
outcome:
|
|
146
|
+
outcome: "tool_error",
|
|
119
147
|
duration_ms,
|
|
120
148
|
error_code: err.code,
|
|
121
149
|
});
|
|
@@ -124,15 +152,15 @@ export async function dispatchTool(name, args) {
|
|
|
124
152
|
});
|
|
125
153
|
}
|
|
126
154
|
const message = err instanceof Error ? err.message : String(err);
|
|
127
|
-
logger.error(
|
|
155
|
+
logger.error("internal error", {
|
|
128
156
|
tool: name,
|
|
129
157
|
request_id: requestId,
|
|
130
|
-
outcome:
|
|
158
|
+
outcome: "internal_error",
|
|
131
159
|
duration_ms,
|
|
132
160
|
details: { message },
|
|
133
161
|
});
|
|
134
162
|
return asToolErrorResponse({
|
|
135
|
-
error: { code:
|
|
163
|
+
error: { code: "INTERNAL_ERROR", message: "internal tool error" },
|
|
136
164
|
});
|
|
137
165
|
}
|
|
138
166
|
}
|
|
@@ -146,18 +174,22 @@ function zodToJsonSchema(schema) {
|
|
|
146
174
|
if (!value.isOptional())
|
|
147
175
|
required.push(key);
|
|
148
176
|
}
|
|
149
|
-
return {
|
|
177
|
+
return {
|
|
178
|
+
type: "object",
|
|
179
|
+
properties,
|
|
180
|
+
...(required.length ? { required } : {}),
|
|
181
|
+
};
|
|
150
182
|
}
|
|
151
183
|
if (schema instanceof z.ZodString)
|
|
152
|
-
return { type:
|
|
184
|
+
return { type: "string" };
|
|
153
185
|
if (schema instanceof z.ZodNumber)
|
|
154
|
-
return { type:
|
|
186
|
+
return { type: "number" };
|
|
155
187
|
if (schema instanceof z.ZodBoolean)
|
|
156
|
-
return { type:
|
|
188
|
+
return { type: "boolean" };
|
|
157
189
|
if (schema instanceof z.ZodArray)
|
|
158
|
-
return { type:
|
|
190
|
+
return { type: "array", items: zodToJsonSchema(schema.element) };
|
|
159
191
|
if (schema instanceof z.ZodEnum)
|
|
160
|
-
return { type:
|
|
192
|
+
return { type: "string", enum: schema.options };
|
|
161
193
|
if (schema instanceof z.ZodOptional)
|
|
162
194
|
return zodToJsonSchema(schema.unwrap());
|
|
163
195
|
if (schema instanceof z.ZodDefault)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAc,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAc,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,C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|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolDef } from "./registry.js";
|
|
3
|
+
import { type AgentName } from "../config/ownership-matrix.js";
|
|
4
|
+
declare const schema: z.ZodObject<{
|
|
5
|
+
scores: z.ZodArray<z.ZodObject<{
|
|
6
|
+
agent: z.ZodEnum<[AgentName, ...AgentName[]]>;
|
|
7
|
+
score: z.ZodNumber;
|
|
8
|
+
rationale: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
agent: AgentName;
|
|
11
|
+
score: number;
|
|
12
|
+
rationale?: string | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
agent: AgentName;
|
|
15
|
+
score: number;
|
|
16
|
+
rationale?: string | undefined;
|
|
17
|
+
}>, "many">;
|
|
18
|
+
weights: z.ZodOptional<z.ZodRecord<z.ZodEnum<[AgentName, ...AgentName[]]>, z.ZodNumber>>;
|
|
19
|
+
threshold: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
scores: {
|
|
22
|
+
agent: AgentName;
|
|
23
|
+
score: number;
|
|
24
|
+
rationale?: string | undefined;
|
|
25
|
+
}[];
|
|
26
|
+
threshold: number;
|
|
27
|
+
weights?: Partial<Record<AgentName, number>> | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
scores: {
|
|
30
|
+
agent: AgentName;
|
|
31
|
+
score: number;
|
|
32
|
+
rationale?: string | undefined;
|
|
33
|
+
}[];
|
|
34
|
+
weights?: Partial<Record<AgentName, number>> | undefined;
|
|
35
|
+
threshold?: number | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
type Input = z.infer<typeof schema>;
|
|
38
|
+
export interface DimensionEntry {
|
|
39
|
+
agent: AgentName;
|
|
40
|
+
dimension: string;
|
|
41
|
+
score: number;
|
|
42
|
+
weight: number;
|
|
43
|
+
contribution: number;
|
|
44
|
+
rationale?: string;
|
|
45
|
+
below_threshold: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface RubricOutput {
|
|
48
|
+
weighted_score: number;
|
|
49
|
+
threshold: number;
|
|
50
|
+
passes_threshold: boolean;
|
|
51
|
+
dimensions: DimensionEntry[];
|
|
52
|
+
ignored_agents: string[];
|
|
53
|
+
weights_source: "default" | "override";
|
|
54
|
+
scorecard_text: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Compute the weighted-rubric scorecard from per-agent dimension scores.
|
|
58
|
+
*
|
|
59
|
+
* Math:
|
|
60
|
+
* - Reduce supplied scores to the subset of agents present.
|
|
61
|
+
* - Resolve weights: override (if provided AND keys sum to 100) > default.
|
|
62
|
+
* - For each scored agent, contribution = score * weight / 100.
|
|
63
|
+
* - weighted_score = sum of contributions normalised so weights sum to 100
|
|
64
|
+
* across the agents that ACTUALLY scored. (If only 6 of 9 agents scored,
|
|
65
|
+
* the rubric renormalises across those 6 instead of leaving 3 dimensions
|
|
66
|
+
* contributing 0 to the weighted average.)
|
|
67
|
+
* - Dimensions below `threshold` are flagged.
|
|
68
|
+
*
|
|
69
|
+
* Returns a RubricOutput; meta-agents (weight 0) and unscored agents are listed
|
|
70
|
+
* in `ignored_agents`.
|
|
71
|
+
*/
|
|
72
|
+
export declare function scoreRubric(input: Input): RubricOutput;
|
|
73
|
+
export declare const scoreRubricTool: ToolDef<typeof schema>;
|
|
74
|
+
export {};
|