@brainervirus/workit-cursor 8.27.0 → 8.28.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/.cursor-plugin/plugin.json +1 -1
- package/dist/cursor-session-start.js +167 -3
- package/dist/mcp-server.js +26 -0
- package/dist/workit-hook.js +169 -2
- package/package.json +3 -3
|
@@ -8122,7 +8122,33 @@ var nonBlank, branchPreset, commitPreset, workspaceBranchPolicySchema, workspace
|
|
|
8122
8122
|
workspace: found?.workspace ?? null,
|
|
8123
8123
|
from: found?.source?.name ?? null
|
|
8124
8124
|
};
|
|
8125
|
-
}, workspaceLiveSessionGuard = (cwd, dir) => inheritedSetting(cwd, dir, (entry) => typeof entry.liveSessionGuard === "boolean")?.source?.liveSessionGuard !== false,
|
|
8125
|
+
}, workspaceLiveSessionGuard = (cwd, dir) => inheritedSetting(cwd, dir, (entry) => typeof entry.liveSessionGuard === "boolean")?.source?.liveSessionGuard !== false, modelSources = (cwd, dir) => {
|
|
8126
|
+
const out = [];
|
|
8127
|
+
try {
|
|
8128
|
+
const matched = matchRuntimeWorkspace(cwd, dir);
|
|
8129
|
+
if (matched) {
|
|
8130
|
+
const enclosing = matched.matches.filter((entry) => entry !== matched.selected).toSorted((a, b) => globSpecificity(b.glob) - globSpecificity(a.glob));
|
|
8131
|
+
for (const entry of [matched.selected, ...enclosing])
|
|
8132
|
+
out.push({
|
|
8133
|
+
name: entry.name,
|
|
8134
|
+
global: false,
|
|
8135
|
+
models: entry.models,
|
|
8136
|
+
tierModels: entry.fanout?.tierModels
|
|
8137
|
+
});
|
|
8138
|
+
}
|
|
8139
|
+
} catch {}
|
|
8140
|
+
try {
|
|
8141
|
+
const document = JSON.parse(readFileSync2(path4.join(dir ?? configDir(), "workspaces.json"), "utf8"));
|
|
8142
|
+
if (document && typeof document === "object" && !Array.isArray(document))
|
|
8143
|
+
out.push({
|
|
8144
|
+
name: "global",
|
|
8145
|
+
global: true,
|
|
8146
|
+
models: document.models,
|
|
8147
|
+
tierModels: undefined
|
|
8148
|
+
});
|
|
8149
|
+
} catch {}
|
|
8150
|
+
return out;
|
|
8151
|
+
}, hostFamily = (host) => host.replace(/_(?:cli|desktop)$/u, ""), TIER_KEYS, TIER_HOSTS, resolveRuntimeWorkspaceCandidate = (cwd, kind) => {
|
|
8126
8152
|
const matched = matchRuntimeWorkspace(cwd);
|
|
8127
8153
|
if (!matched)
|
|
8128
8154
|
return null;
|
|
@@ -22037,6 +22063,131 @@ var init_standing = __esm(() => {
|
|
|
22037
22063
|
sinceStart = new Map;
|
|
22038
22064
|
});
|
|
22039
22065
|
|
|
22066
|
+
// packages/workit-core/src/core/role-models.ts
|
|
22067
|
+
var MODEL_ROLES, MODEL_TIERS, HOST_KEYS, BUILT_IN_CLAUDE_CODE, isObject7 = (value) => !!value && typeof value === "object" && !Array.isArray(value), name = (value) => typeof value === "string" && value.trim() ? value.trim() : null, leaf = (value) => {
|
|
22068
|
+
const text = name(value);
|
|
22069
|
+
if (text)
|
|
22070
|
+
return { model: text, effort: null };
|
|
22071
|
+
if (!isObject7(value))
|
|
22072
|
+
return null;
|
|
22073
|
+
const model = name(value.model);
|
|
22074
|
+
return model ? { model, effort: name(value.effort) } : null;
|
|
22075
|
+
}, isFlat = (value) => typeof value === "string" || isObject7(value) && Object.hasOwn(value, "model"), forHost = (value, host) => {
|
|
22076
|
+
if (isFlat(value))
|
|
22077
|
+
return leaf(value);
|
|
22078
|
+
if (!isObject7(value))
|
|
22079
|
+
return null;
|
|
22080
|
+
const family = host ? hostFamily(host) : null;
|
|
22081
|
+
for (const key of [family, host, "default"])
|
|
22082
|
+
if (key && Object.hasOwn(value, key)) {
|
|
22083
|
+
const found = leaf(value[key]);
|
|
22084
|
+
if (found)
|
|
22085
|
+
return found;
|
|
22086
|
+
}
|
|
22087
|
+
return null;
|
|
22088
|
+
}, rolesOf = (models) => isObject7(models) && isObject7(models.roles) ? models.roles : null, resolveRoleModel = (cwd, selector, host, dir) => {
|
|
22089
|
+
const { role, tier } = selector;
|
|
22090
|
+
for (const source of modelSources(cwd, dir)) {
|
|
22091
|
+
const where = source.global ? "the global default" : `workspace ${source.name}`;
|
|
22092
|
+
const roles = rolesOf(source.models);
|
|
22093
|
+
const configured = roles && Object.hasOwn(roles, role) ? roles[role] : undefined;
|
|
22094
|
+
const fromRoles = role === "implementer" ? tier && isObject7(configured) && Object.hasOwn(configured, tier) ? forHost(configured[tier], host) : null : forHost(configured, host);
|
|
22095
|
+
if (fromRoles)
|
|
22096
|
+
return { ...fromRoles, source: `models.roles in ${where}` };
|
|
22097
|
+
if (role === "implementer" && tier && isObject7(source.tierModels)) {
|
|
22098
|
+
const fromTiers = Object.hasOwn(source.tierModels, tier) ? forHost(source.tierModels[tier], host) : null;
|
|
22099
|
+
if (fromTiers)
|
|
22100
|
+
return { model: fromTiers.model, effort: null, source: `fanout.tierModels in ${where}` };
|
|
22101
|
+
}
|
|
22102
|
+
}
|
|
22103
|
+
if (host && hostFamily(host) === "claude_code") {
|
|
22104
|
+
const builtIn = BUILT_IN_CLAUDE_CODE[tier ? `${role}.${tier}` : role];
|
|
22105
|
+
if (builtIn)
|
|
22106
|
+
return { model: builtIn.model, effort: builtIn.effort ?? null, source: "built-in" };
|
|
22107
|
+
}
|
|
22108
|
+
return null;
|
|
22109
|
+
}, ROLE_SELECTORS, roleForAgentType = (agentType, prompt) => {
|
|
22110
|
+
switch (agentType) {
|
|
22111
|
+
case "workit:implementer": {
|
|
22112
|
+
const tier = typeof prompt === "string" ? /^[ \t]*TIER:[ \t]*(mundane|standard|hard)\b/im.exec(prompt)?.[1] : undefined;
|
|
22113
|
+
return { role: "implementer", tier: tier?.toLowerCase() ?? "standard" };
|
|
22114
|
+
}
|
|
22115
|
+
case "workit:verifier":
|
|
22116
|
+
return { role: "verifier" };
|
|
22117
|
+
case "workit:reviewer":
|
|
22118
|
+
return { role: "reviewer" };
|
|
22119
|
+
case "Explore":
|
|
22120
|
+
return { role: "explore" };
|
|
22121
|
+
default:
|
|
22122
|
+
return null;
|
|
22123
|
+
}
|
|
22124
|
+
};
|
|
22125
|
+
var init_role_models = __esm(() => {
|
|
22126
|
+
init_workspaces();
|
|
22127
|
+
MODEL_ROLES = [
|
|
22128
|
+
"decider",
|
|
22129
|
+
"implementer",
|
|
22130
|
+
"verifier",
|
|
22131
|
+
"reviewer",
|
|
22132
|
+
"explore",
|
|
22133
|
+
"babysit"
|
|
22134
|
+
];
|
|
22135
|
+
MODEL_TIERS = ["mundane", "standard", "hard"];
|
|
22136
|
+
HOST_KEYS = new Set([
|
|
22137
|
+
"claude_code",
|
|
22138
|
+
"opencode",
|
|
22139
|
+
"codex",
|
|
22140
|
+
"codex_cli",
|
|
22141
|
+
"codex_desktop",
|
|
22142
|
+
"cursor",
|
|
22143
|
+
"pi",
|
|
22144
|
+
"default"
|
|
22145
|
+
]);
|
|
22146
|
+
BUILT_IN_CLAUDE_CODE = {
|
|
22147
|
+
decider: { model: "fable", effort: "high" },
|
|
22148
|
+
"implementer.hard": { model: "opus" },
|
|
22149
|
+
"implementer.standard": { model: "sonnet" },
|
|
22150
|
+
"implementer.mundane": { model: "haiku" },
|
|
22151
|
+
verifier: { model: "sonnet" },
|
|
22152
|
+
reviewer: { model: "opus" },
|
|
22153
|
+
explore: { model: "haiku" },
|
|
22154
|
+
babysit: { model: "haiku" }
|
|
22155
|
+
};
|
|
22156
|
+
ROLE_SELECTORS = MODEL_ROLES.flatMap((role) => role === "implementer" ? MODEL_TIERS.map((tier) => ({ role, tier })) : [{ role }]);
|
|
22157
|
+
});
|
|
22158
|
+
|
|
22159
|
+
// packages/workit-core/src/hooks/agent-model.ts
|
|
22160
|
+
var MODELS, EFFORTS, given = (value) => typeof value === "string" && value.trim() !== "", agentModelDecision = (cwd, tool, env = process.env) => {
|
|
22161
|
+
if (given(tool.model) || env.CLAUDE_CODE_SUBAGENT_MODEL_FORCE)
|
|
22162
|
+
return { kind: "none" };
|
|
22163
|
+
const selector = roleForAgentType(tool.subagent_type, tool.prompt);
|
|
22164
|
+
if (!selector)
|
|
22165
|
+
return { kind: "none" };
|
|
22166
|
+
const resolved = resolveRoleModel(cwd, selector, "claude_code");
|
|
22167
|
+
if (!resolved)
|
|
22168
|
+
return { kind: "none" };
|
|
22169
|
+
const model = resolved.model.toLowerCase();
|
|
22170
|
+
const effort = resolved.effort?.toLowerCase() ?? null;
|
|
22171
|
+
const input = { ...tool };
|
|
22172
|
+
if (MODELS.has(model))
|
|
22173
|
+
input.model = model;
|
|
22174
|
+
if (effort && EFFORTS.has(effort) && !given(tool.effort))
|
|
22175
|
+
input.effort = effort;
|
|
22176
|
+
if (input.model === undefined && input.effort === tool.effort)
|
|
22177
|
+
return { kind: "none" };
|
|
22178
|
+
const label = selector.tier ? `${selector.role} ${selector.tier}` : selector.role;
|
|
22179
|
+
return {
|
|
22180
|
+
kind: "update-input",
|
|
22181
|
+
input,
|
|
22182
|
+
text: `Workit set ${String(input.model ?? "no model")}${input.effort !== tool.effort ? ` (effort ${String(input.effort)})` : ""} on this ${String(tool.subagent_type)} spawn: role ${label}, ${resolved.source}. Name a model to choose another.`
|
|
22183
|
+
};
|
|
22184
|
+
};
|
|
22185
|
+
var init_agent_model = __esm(() => {
|
|
22186
|
+
init_role_models();
|
|
22187
|
+
MODELS = new Set(["sonnet", "opus", "haiku", "fable"]);
|
|
22188
|
+
EFFORTS = new Set(["low", "medium", "high", "xhigh", "max"]);
|
|
22189
|
+
});
|
|
22190
|
+
|
|
22040
22191
|
// packages/workit-core/src/hooks/cwd-normalize.ts
|
|
22041
22192
|
var DIR, COMPOUND, GLOBALS_FIRST, VERB_FIRST, VERBS, FILTERS, clean = (s) => !s.unanalyzable && !s.group && !s.subs?.length && !s.stdin?.length && !s.redirects.length, stdinOnly = (words) => {
|
|
22042
22193
|
const [name, ...args] = words;
|
|
@@ -22345,7 +22496,7 @@ function handleHook(input, deps) {
|
|
|
22345
22496
|
const delta = standingDelta(input);
|
|
22346
22497
|
if (!delta)
|
|
22347
22498
|
return decision;
|
|
22348
|
-
return decision.kind === "rewrite" ? { ...decision, text: [decision.text, delta].filter(Boolean).join(`
|
|
22499
|
+
return decision.kind === "rewrite" || decision.kind === "update-input" ? { ...decision, text: [decision.text, delta].filter(Boolean).join(`
|
|
22349
22500
|
`) } : withContextLine(decision, delta);
|
|
22350
22501
|
}
|
|
22351
22502
|
function decide(input, deps) {
|
|
@@ -22458,6 +22609,8 @@ function decide(input, deps) {
|
|
|
22458
22609
|
case "tool.pre":
|
|
22459
22610
|
if (event.skill)
|
|
22460
22611
|
recordSkillLoad(input, event.skill, "tool");
|
|
22612
|
+
if (event.agentInput && input.host === "claude_code")
|
|
22613
|
+
return agentModelDecision(input.cwd, event.agentInput);
|
|
22461
22614
|
return NONE6;
|
|
22462
22615
|
case "stop":
|
|
22463
22616
|
return usable2(descriptor.events.stop.support) ? stopDecision(input, descriptor) : NONE6;
|
|
@@ -22530,6 +22683,7 @@ var init_handle = __esm(() => {
|
|
|
22530
22683
|
init_branch();
|
|
22531
22684
|
init_workspaces();
|
|
22532
22685
|
init_host_session();
|
|
22686
|
+
init_agent_model();
|
|
22533
22687
|
init_cwd_normalize();
|
|
22534
22688
|
init_delivery_verbs();
|
|
22535
22689
|
init_heavy_gate();
|
|
@@ -22680,6 +22834,16 @@ var CLAUDE_CODE_DESCRIPTOR, EVENTS, SOURCES, SHELL_TOOLS, dialectOf2 = (value) =
|
|
|
22680
22834
|
skill: isRecord6(value.tool_input) ? optionalText(value.tool_input.skill) : null
|
|
22681
22835
|
}
|
|
22682
22836
|
};
|
|
22837
|
+
if (value.tool_name === "Agent" || value.tool_name === "Task")
|
|
22838
|
+
return {
|
|
22839
|
+
ok: true,
|
|
22840
|
+
event: {
|
|
22841
|
+
kind: "tool.pre",
|
|
22842
|
+
tool: value.tool_name,
|
|
22843
|
+
toolUseId,
|
|
22844
|
+
...isRecord6(value.tool_input) ? { agentInput: value.tool_input } : {}
|
|
22845
|
+
}
|
|
22846
|
+
};
|
|
22683
22847
|
if (!SHELL_TOOLS.has(value.tool_name))
|
|
22684
22848
|
return { ok: true, event: { kind: "tool.pre", tool: value.tool_name, toolUseId } };
|
|
22685
22849
|
const command = toolCommand(value);
|
|
@@ -22748,7 +22912,7 @@ var CLAUDE_CODE_DESCRIPTOR, EVENTS, SOURCES, SHELL_TOOLS, dialectOf2 = (value) =
|
|
|
22748
22912
|
};
|
|
22749
22913
|
}
|
|
22750
22914
|
}, CONTEXT_EVENTS, render = (decision, native) => {
|
|
22751
|
-
if (decision.kind === "rewrite" && native === "PreToolUse" && decision.input)
|
|
22915
|
+
if ((decision.kind === "rewrite" || decision.kind === "update-input") && native === "PreToolUse" && decision.input)
|
|
22752
22916
|
return {
|
|
22753
22917
|
json: {
|
|
22754
22918
|
hookSpecificOutput: {
|
package/dist/mcp-server.js
CHANGED
|
@@ -28185,6 +28185,32 @@ var WRITE_TOOLS = new Set([
|
|
|
28185
28185
|
]);
|
|
28186
28186
|
// packages/workit-core/src/hooks/standing.ts
|
|
28187
28187
|
var sinceStart = new Map;
|
|
28188
|
+
// packages/workit-core/src/core/role-models.ts
|
|
28189
|
+
var MODEL_ROLES = [
|
|
28190
|
+
"decider",
|
|
28191
|
+
"implementer",
|
|
28192
|
+
"verifier",
|
|
28193
|
+
"reviewer",
|
|
28194
|
+
"explore",
|
|
28195
|
+
"babysit"
|
|
28196
|
+
];
|
|
28197
|
+
var MODEL_TIERS = ["mundane", "standard", "hard"];
|
|
28198
|
+
var HOST_KEYS = new Set([
|
|
28199
|
+
"claude_code",
|
|
28200
|
+
"opencode",
|
|
28201
|
+
"codex",
|
|
28202
|
+
"codex_cli",
|
|
28203
|
+
"codex_desktop",
|
|
28204
|
+
"cursor",
|
|
28205
|
+
"pi",
|
|
28206
|
+
"default"
|
|
28207
|
+
]);
|
|
28208
|
+
var ROLE_SELECTORS = MODEL_ROLES.flatMap((role) => role === "implementer" ? MODEL_TIERS.map((tier) => ({ role, tier })) : [{ role }]);
|
|
28209
|
+
|
|
28210
|
+
// packages/workit-core/src/hooks/agent-model.ts
|
|
28211
|
+
var MODELS = new Set(["sonnet", "opus", "haiku", "fable"]);
|
|
28212
|
+
var EFFORTS = new Set(["low", "medium", "high", "xhigh", "max"]);
|
|
28213
|
+
|
|
28188
28214
|
// packages/workit-core/src/hooks/cwd-normalize.ts
|
|
28189
28215
|
var DIR = String.raw`[A-Za-z0-9_./@%+:,=-]+|'[^'$${"`"}\\\n]*'|"[^"$${"`"}\\!\n]*"`;
|
|
28190
28216
|
var COMPOUND = new RegExp(String.raw`^\s*cd\s+(${DIR})\s*&&\s*(workit(?:\s[\s\S]*)?)$`, "u");
|
package/dist/workit-hook.js
CHANGED
|
@@ -8205,6 +8205,34 @@ var workspaceTrailers = (cwd, dir) => {
|
|
|
8205
8205
|
};
|
|
8206
8206
|
};
|
|
8207
8207
|
var workspaceLiveSessionGuard = (cwd, dir) => inheritedSetting(cwd, dir, (entry) => typeof entry.liveSessionGuard === "boolean")?.source?.liveSessionGuard !== false;
|
|
8208
|
+
var modelSources = (cwd, dir) => {
|
|
8209
|
+
const out = [];
|
|
8210
|
+
try {
|
|
8211
|
+
const matched = matchRuntimeWorkspace(cwd, dir);
|
|
8212
|
+
if (matched) {
|
|
8213
|
+
const enclosing = matched.matches.filter((entry) => entry !== matched.selected).toSorted((a, b) => globSpecificity(b.glob) - globSpecificity(a.glob));
|
|
8214
|
+
for (const entry of [matched.selected, ...enclosing])
|
|
8215
|
+
out.push({
|
|
8216
|
+
name: entry.name,
|
|
8217
|
+
global: false,
|
|
8218
|
+
models: entry.models,
|
|
8219
|
+
tierModels: entry.fanout?.tierModels
|
|
8220
|
+
});
|
|
8221
|
+
}
|
|
8222
|
+
} catch {}
|
|
8223
|
+
try {
|
|
8224
|
+
const document = JSON.parse(readFileSync2(path4.join(dir ?? configDir(), "workspaces.json"), "utf8"));
|
|
8225
|
+
if (document && typeof document === "object" && !Array.isArray(document))
|
|
8226
|
+
out.push({
|
|
8227
|
+
name: "global",
|
|
8228
|
+
global: true,
|
|
8229
|
+
models: document.models,
|
|
8230
|
+
tierModels: undefined
|
|
8231
|
+
});
|
|
8232
|
+
} catch {}
|
|
8233
|
+
return out;
|
|
8234
|
+
};
|
|
8235
|
+
var hostFamily = (host) => host.replace(/_(?:cli|desktop)$/u, "");
|
|
8208
8236
|
var TIER_KEYS = new Set(["mundane", "standard", "hard"]);
|
|
8209
8237
|
var TIER_HOSTS = new Set([
|
|
8210
8238
|
"claude_code",
|
|
@@ -22250,6 +22278,133 @@ var standingDelta = (input) => {
|
|
|
22250
22278
|
}
|
|
22251
22279
|
};
|
|
22252
22280
|
var sinceStart = new Map;
|
|
22281
|
+
// packages/workit-core/src/core/role-models.ts
|
|
22282
|
+
var MODEL_ROLES = [
|
|
22283
|
+
"decider",
|
|
22284
|
+
"implementer",
|
|
22285
|
+
"verifier",
|
|
22286
|
+
"reviewer",
|
|
22287
|
+
"explore",
|
|
22288
|
+
"babysit"
|
|
22289
|
+
];
|
|
22290
|
+
var MODEL_TIERS = ["mundane", "standard", "hard"];
|
|
22291
|
+
var HOST_KEYS = new Set([
|
|
22292
|
+
"claude_code",
|
|
22293
|
+
"opencode",
|
|
22294
|
+
"codex",
|
|
22295
|
+
"codex_cli",
|
|
22296
|
+
"codex_desktop",
|
|
22297
|
+
"cursor",
|
|
22298
|
+
"pi",
|
|
22299
|
+
"default"
|
|
22300
|
+
]);
|
|
22301
|
+
var BUILT_IN_CLAUDE_CODE = {
|
|
22302
|
+
decider: { model: "fable", effort: "high" },
|
|
22303
|
+
"implementer.hard": { model: "opus" },
|
|
22304
|
+
"implementer.standard": { model: "sonnet" },
|
|
22305
|
+
"implementer.mundane": { model: "haiku" },
|
|
22306
|
+
verifier: { model: "sonnet" },
|
|
22307
|
+
reviewer: { model: "opus" },
|
|
22308
|
+
explore: { model: "haiku" },
|
|
22309
|
+
babysit: { model: "haiku" }
|
|
22310
|
+
};
|
|
22311
|
+
var isObject7 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
22312
|
+
var name = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
22313
|
+
var leaf = (value) => {
|
|
22314
|
+
const text = name(value);
|
|
22315
|
+
if (text)
|
|
22316
|
+
return { model: text, effort: null };
|
|
22317
|
+
if (!isObject7(value))
|
|
22318
|
+
return null;
|
|
22319
|
+
const model = name(value.model);
|
|
22320
|
+
return model ? { model, effort: name(value.effort) } : null;
|
|
22321
|
+
};
|
|
22322
|
+
var isFlat = (value) => typeof value === "string" || isObject7(value) && Object.hasOwn(value, "model");
|
|
22323
|
+
var forHost = (value, host) => {
|
|
22324
|
+
if (isFlat(value))
|
|
22325
|
+
return leaf(value);
|
|
22326
|
+
if (!isObject7(value))
|
|
22327
|
+
return null;
|
|
22328
|
+
const family = host ? hostFamily(host) : null;
|
|
22329
|
+
for (const key of [family, host, "default"])
|
|
22330
|
+
if (key && Object.hasOwn(value, key)) {
|
|
22331
|
+
const found = leaf(value[key]);
|
|
22332
|
+
if (found)
|
|
22333
|
+
return found;
|
|
22334
|
+
}
|
|
22335
|
+
return null;
|
|
22336
|
+
};
|
|
22337
|
+
var rolesOf = (models) => isObject7(models) && isObject7(models.roles) ? models.roles : null;
|
|
22338
|
+
var resolveRoleModel = (cwd, selector, host, dir) => {
|
|
22339
|
+
const { role, tier } = selector;
|
|
22340
|
+
for (const source of modelSources(cwd, dir)) {
|
|
22341
|
+
const where = source.global ? "the global default" : `workspace ${source.name}`;
|
|
22342
|
+
const roles = rolesOf(source.models);
|
|
22343
|
+
const configured = roles && Object.hasOwn(roles, role) ? roles[role] : undefined;
|
|
22344
|
+
const fromRoles = role === "implementer" ? tier && isObject7(configured) && Object.hasOwn(configured, tier) ? forHost(configured[tier], host) : null : forHost(configured, host);
|
|
22345
|
+
if (fromRoles)
|
|
22346
|
+
return { ...fromRoles, source: `models.roles in ${where}` };
|
|
22347
|
+
if (role === "implementer" && tier && isObject7(source.tierModels)) {
|
|
22348
|
+
const fromTiers = Object.hasOwn(source.tierModels, tier) ? forHost(source.tierModels[tier], host) : null;
|
|
22349
|
+
if (fromTiers)
|
|
22350
|
+
return { model: fromTiers.model, effort: null, source: `fanout.tierModels in ${where}` };
|
|
22351
|
+
}
|
|
22352
|
+
}
|
|
22353
|
+
if (host && hostFamily(host) === "claude_code") {
|
|
22354
|
+
const builtIn = BUILT_IN_CLAUDE_CODE[tier ? `${role}.${tier}` : role];
|
|
22355
|
+
if (builtIn)
|
|
22356
|
+
return { model: builtIn.model, effort: builtIn.effort ?? null, source: "built-in" };
|
|
22357
|
+
}
|
|
22358
|
+
return null;
|
|
22359
|
+
};
|
|
22360
|
+
var ROLE_SELECTORS = MODEL_ROLES.flatMap((role) => role === "implementer" ? MODEL_TIERS.map((tier) => ({ role, tier })) : [{ role }]);
|
|
22361
|
+
var roleForAgentType = (agentType, prompt) => {
|
|
22362
|
+
switch (agentType) {
|
|
22363
|
+
case "workit:implementer": {
|
|
22364
|
+
const tier = typeof prompt === "string" ? /^[ \t]*TIER:[ \t]*(mundane|standard|hard)\b/im.exec(prompt)?.[1] : undefined;
|
|
22365
|
+
return { role: "implementer", tier: tier?.toLowerCase() ?? "standard" };
|
|
22366
|
+
}
|
|
22367
|
+
case "workit:verifier":
|
|
22368
|
+
return { role: "verifier" };
|
|
22369
|
+
case "workit:reviewer":
|
|
22370
|
+
return { role: "reviewer" };
|
|
22371
|
+
case "Explore":
|
|
22372
|
+
return { role: "explore" };
|
|
22373
|
+
default:
|
|
22374
|
+
return null;
|
|
22375
|
+
}
|
|
22376
|
+
};
|
|
22377
|
+
|
|
22378
|
+
// packages/workit-core/src/hooks/agent-model.ts
|
|
22379
|
+
var MODELS = new Set(["sonnet", "opus", "haiku", "fable"]);
|
|
22380
|
+
var EFFORTS = new Set(["low", "medium", "high", "xhigh", "max"]);
|
|
22381
|
+
var given = (value) => typeof value === "string" && value.trim() !== "";
|
|
22382
|
+
var agentModelDecision = (cwd, tool, env = process.env) => {
|
|
22383
|
+
if (given(tool.model) || env.CLAUDE_CODE_SUBAGENT_MODEL_FORCE)
|
|
22384
|
+
return { kind: "none" };
|
|
22385
|
+
const selector = roleForAgentType(tool.subagent_type, tool.prompt);
|
|
22386
|
+
if (!selector)
|
|
22387
|
+
return { kind: "none" };
|
|
22388
|
+
const resolved = resolveRoleModel(cwd, selector, "claude_code");
|
|
22389
|
+
if (!resolved)
|
|
22390
|
+
return { kind: "none" };
|
|
22391
|
+
const model = resolved.model.toLowerCase();
|
|
22392
|
+
const effort = resolved.effort?.toLowerCase() ?? null;
|
|
22393
|
+
const input = { ...tool };
|
|
22394
|
+
if (MODELS.has(model))
|
|
22395
|
+
input.model = model;
|
|
22396
|
+
if (effort && EFFORTS.has(effort) && !given(tool.effort))
|
|
22397
|
+
input.effort = effort;
|
|
22398
|
+
if (input.model === undefined && input.effort === tool.effort)
|
|
22399
|
+
return { kind: "none" };
|
|
22400
|
+
const label = selector.tier ? `${selector.role} ${selector.tier}` : selector.role;
|
|
22401
|
+
return {
|
|
22402
|
+
kind: "update-input",
|
|
22403
|
+
input,
|
|
22404
|
+
text: `Workit set ${String(input.model ?? "no model")}${input.effort !== tool.effort ? ` (effort ${String(input.effort)})` : ""} on this ${String(tool.subagent_type)} spawn: role ${label}, ${resolved.source}. Name a model to choose another.`
|
|
22405
|
+
};
|
|
22406
|
+
};
|
|
22407
|
+
|
|
22253
22408
|
// packages/workit-core/src/hooks/cwd-normalize.ts
|
|
22254
22409
|
var DIR = String.raw`[A-Za-z0-9_./@%+:,=-]+|'[^'$${"`"}\\\n]*'|"[^"$${"`"}\\!\n]*"`;
|
|
22255
22410
|
var COMPOUND = new RegExp(String.raw`^\s*cd\s+(${DIR})\s*&&\s*(workit(?:\s[\s\S]*)?)$`, "u");
|
|
@@ -22613,7 +22768,7 @@ function handleHook(input, deps) {
|
|
|
22613
22768
|
const delta = standingDelta(input);
|
|
22614
22769
|
if (!delta)
|
|
22615
22770
|
return decision;
|
|
22616
|
-
return decision.kind === "rewrite" ? { ...decision, text: [decision.text, delta].filter(Boolean).join(`
|
|
22771
|
+
return decision.kind === "rewrite" || decision.kind === "update-input" ? { ...decision, text: [decision.text, delta].filter(Boolean).join(`
|
|
22617
22772
|
`) } : withContextLine(decision, delta);
|
|
22618
22773
|
}
|
|
22619
22774
|
function decide(input, deps) {
|
|
@@ -22726,6 +22881,8 @@ function decide(input, deps) {
|
|
|
22726
22881
|
case "tool.pre":
|
|
22727
22882
|
if (event.skill)
|
|
22728
22883
|
recordSkillLoad(input, event.skill, "tool");
|
|
22884
|
+
if (event.agentInput && input.host === "claude_code")
|
|
22885
|
+
return agentModelDecision(input.cwd, event.agentInput);
|
|
22729
22886
|
return NONE6;
|
|
22730
22887
|
case "stop":
|
|
22731
22888
|
return usable2(descriptor.events.stop.support) ? stopDecision(input, descriptor) : NONE6;
|
|
@@ -23009,6 +23166,16 @@ var eventOf = (name, value) => {
|
|
|
23009
23166
|
skill: isRecord6(value.tool_input) ? optionalText(value.tool_input.skill) : null
|
|
23010
23167
|
}
|
|
23011
23168
|
};
|
|
23169
|
+
if (value.tool_name === "Agent" || value.tool_name === "Task")
|
|
23170
|
+
return {
|
|
23171
|
+
ok: true,
|
|
23172
|
+
event: {
|
|
23173
|
+
kind: "tool.pre",
|
|
23174
|
+
tool: value.tool_name,
|
|
23175
|
+
toolUseId,
|
|
23176
|
+
...isRecord6(value.tool_input) ? { agentInput: value.tool_input } : {}
|
|
23177
|
+
}
|
|
23178
|
+
};
|
|
23012
23179
|
if (!SHELL_TOOLS.has(value.tool_name))
|
|
23013
23180
|
return { ok: true, event: { kind: "tool.pre", tool: value.tool_name, toolUseId } };
|
|
23014
23181
|
const command = toolCommand(value);
|
|
@@ -23085,7 +23252,7 @@ var CONTEXT_EVENTS = new Set([
|
|
|
23085
23252
|
"PostToolUse"
|
|
23086
23253
|
]);
|
|
23087
23254
|
var render = (decision, native) => {
|
|
23088
|
-
if (decision.kind === "rewrite" && native === "PreToolUse" && decision.input)
|
|
23255
|
+
if ((decision.kind === "rewrite" || decision.kind === "update-input") && native === "PreToolUse" && decision.input)
|
|
23089
23256
|
return {
|
|
23090
23257
|
json: {
|
|
23091
23258
|
hookSpecificOutput: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brainervirus/workit-cursor",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.28.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Workit Cursor plugin — shared MCP transport, native hooks, and sixteen method skills",
|
|
6
6
|
"keywords": [
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"build": "bun scripts/build.ts"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@brainervirus/workit-core": "^8.
|
|
50
|
-
"@brainervirus/workit-mcp": "^8.
|
|
49
|
+
"@brainervirus/workit-core": "^8.28.0",
|
|
50
|
+
"@brainervirus/workit-mcp": "^8.28.0"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">=24"
|