pi-braid 0.43.6 → 0.43.7
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/CHANGELOG.md +44 -0
- package/build-info.json +4 -4
- package/dist/extensions/core/skills-tool/applicability.d.ts +134 -0
- package/dist/extensions/core/skills-tool/applicability.js +161 -0
- package/dist/extensions/core/skills-tool/auto-inject.d.ts +10 -0
- package/dist/extensions/core/skills-tool/auto-inject.js +216 -1
- package/dist/extensions/core/skills-tool/index.js +64 -3
- package/dist/extensions/core/skills-tool/loading-guidance.js +2 -1
- package/dist/extensions/core/skills-tool/session-records.d.ts +297 -8
- package/dist/extensions/core/skills-tool/session-records.js +509 -5
- package/dist/extensions/core/skills-tool/skill-families.d.ts +60 -0
- package/dist/extensions/core/skills-tool/skill-families.js +105 -0
- package/docs/LOCAL_DEV.md +1 -1
- package/package.json +1 -1
- package/src/extensions/core/AGENTS.md +1 -0
- package/src/extensions/core/skills-tool/applicability.ts +220 -0
- package/src/extensions/core/skills-tool/auto-inject.ts +274 -0
- package/src/extensions/core/skills-tool/index.ts +75 -2
- package/src/extensions/core/skills-tool/loading-guidance.ts +2 -1
- package/src/extensions/core/skills-tool/session-records.ts +740 -5
- package/src/extensions/core/skills-tool/skill-families.ts +112 -0
|
@@ -116,11 +116,18 @@ import { getSkillsUsageFilePath } from "../../../lib/config/braid-paths.js";
|
|
|
116
116
|
import { SESSION_COMPACT, AGENT_SETTLED } from "../../../lib/core/event-names.js";
|
|
117
117
|
import {
|
|
118
118
|
getSessionProfile,
|
|
119
|
+
recordApplicabilityCensus,
|
|
120
|
+
recordApplicabilityVerdict,
|
|
121
|
+
recordObligationLegs,
|
|
119
122
|
recordSessionSkillLoad,
|
|
120
123
|
recordSessionStart,
|
|
121
124
|
} from "./session-records.js";
|
|
125
|
+
import type { ObligationLegs } from "./session-records.js";
|
|
126
|
+
import { evaluateApplicability } from "./applicability.js";
|
|
127
|
+
import type { SkillApplicabilityVerdict } from "./applicability.js";
|
|
122
128
|
import { triggerMatches } from "./skill-triggers.js";
|
|
123
129
|
import type { TriggerSource } from "./skill-triggers.js";
|
|
130
|
+
import { toolFamilyToken } from "./skill-families.js";
|
|
124
131
|
import {
|
|
125
132
|
advanceDrift,
|
|
126
133
|
driftDirectoryFor,
|
|
@@ -285,6 +292,51 @@ interface AutoInjectState {
|
|
|
285
292
|
hintSent: boolean;
|
|
286
293
|
/** Where the work is going, for the drift trigger (loading-guidance.ts). */
|
|
287
294
|
drift: DriftTracker;
|
|
295
|
+
/** Which skills' own declared conditions held this session (applicability.ts). */
|
|
296
|
+
applicability: ApplicabilityState;
|
|
297
|
+
/** What the session did with each skill body it met (see ObligationState). */
|
|
298
|
+
obligations: ObligationState;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* The session's obligation bookkeeping: one row of legs per skill, appended
|
|
303
|
+
* only when a leg changes, so at most a handful of lines per session.
|
|
304
|
+
*
|
|
305
|
+
* `called` holds the skills whose first call in a declared family was already
|
|
306
|
+
* decided; the applied leg is fixed at that moment and never revisited.
|
|
307
|
+
* `written` is the last signature that reached disk, which makes a repeated
|
|
308
|
+
* read, a repeated list row or a second call cost nothing.
|
|
309
|
+
*/
|
|
310
|
+
interface ObligationState {
|
|
311
|
+
legs: Map<string, ObligationLegs>;
|
|
312
|
+
called: Set<string>;
|
|
313
|
+
written: Map<string, string>;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function initialObligations(): ObligationState {
|
|
317
|
+
return { legs: new Map(), called: new Set(), written: new Map() };
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* The session's applicability bookkeeping. Cumulative by design: once a task
|
|
322
|
+
* text met a skill's declared condition, the skill applied to that session, and
|
|
323
|
+
* a read that lands on a later turn is still a read of a skill that applied.
|
|
324
|
+
*/
|
|
325
|
+
interface ApplicabilityState {
|
|
326
|
+
/** True once the session's census row landed on disk. */
|
|
327
|
+
censusWritten: boolean;
|
|
328
|
+
/** Verdicts by skill name; only ever grows, and an entry only ever upgrades. */
|
|
329
|
+
verdicts: Map<string, SkillApplicabilityVerdict>;
|
|
330
|
+
/** Skills declaring a condition, from the latest evaluation. */
|
|
331
|
+
evaluated: number;
|
|
332
|
+
/** Skills declaring none, from the latest evaluation. */
|
|
333
|
+
undeclared: string[];
|
|
334
|
+
/** Task-text length the latest evaluation read. */
|
|
335
|
+
taskChars: number;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function initialApplicability(): ApplicabilityState {
|
|
339
|
+
return { censusWritten: false, verdicts: new Map(), evaluated: 0, undeclared: [], taskChars: 0 };
|
|
288
340
|
}
|
|
289
341
|
|
|
290
342
|
const STATE_KEY = "skills-auto-inject";
|
|
@@ -295,6 +347,8 @@ function getState(ctx: ExtensionContext): AutoInjectState {
|
|
|
295
347
|
currentTurn: 0,
|
|
296
348
|
hintSent: false,
|
|
297
349
|
drift: initialDrift(),
|
|
350
|
+
applicability: initialApplicability(),
|
|
351
|
+
obligations: initialObligations(),
|
|
298
352
|
}));
|
|
299
353
|
}
|
|
300
354
|
|
|
@@ -315,6 +369,8 @@ export interface CachedSkill {
|
|
|
315
369
|
triggers?: string[];
|
|
316
370
|
/** Which source authored each phrase (the row's evidence label). */
|
|
317
371
|
triggerSources?: Record<string, TriggerSource>;
|
|
372
|
+
/** Tool families the file's `governs:` declaration claims (skill-families.ts). */
|
|
373
|
+
families?: string[];
|
|
318
374
|
}
|
|
319
375
|
|
|
320
376
|
// Shared module-level variable rather than a per-module copy: the import
|
|
@@ -1151,6 +1207,168 @@ export function resolveDiscoveryMode(ctx: ExtensionContext): DiscoveryState {
|
|
|
1151
1207
|
return state;
|
|
1152
1208
|
}
|
|
1153
1209
|
|
|
1210
|
+
// Applicability verdict (recorded, never enforced)
|
|
1211
|
+
|
|
1212
|
+
/**
|
|
1213
|
+
* Classify the catalog against this turn's task text and record what changed.
|
|
1214
|
+
*
|
|
1215
|
+
* Two writes, both append-only:
|
|
1216
|
+
* - the session's census row, once, retried until it lands. It is what makes
|
|
1217
|
+
* "not-applicable" derivable (evaluated minus the verdict rows) and what
|
|
1218
|
+
* names the skills whose files state no condition at all.
|
|
1219
|
+
* - one verdict row per skill whose declared condition held, and never twice
|
|
1220
|
+
* for the same (session, skill): the set only grows because the verdict is
|
|
1221
|
+
* per-session — a skill whose condition held on any turn applied to the
|
|
1222
|
+
* session.
|
|
1223
|
+
*
|
|
1224
|
+
* The row shape is the joint the sibling compliance record expects: it joins on
|
|
1225
|
+
* (sessionId, skill) and adds its own `suggested`/`listed`/`read`/`applied`
|
|
1226
|
+
* beside this verdict, so `ignored / (read + ignored)` becomes computable. This
|
|
1227
|
+
* module writes no `applied` leg: a tool belong to a skill's family only once
|
|
1228
|
+
* the skill declares that family, and no skill does yet.
|
|
1229
|
+
*
|
|
1230
|
+
* Reads only — it never touches `injected`, a counter or a send. That is the
|
|
1231
|
+
* whole point of the ordering in before_agent_start: this step cannot move the
|
|
1232
|
+
* suggestion, and the suggestion cannot move the verdict.
|
|
1233
|
+
*/
|
|
1234
|
+
function stepApplicability(
|
|
1235
|
+
ctx: ExtensionContext,
|
|
1236
|
+
state: AutoInjectState,
|
|
1237
|
+
skills: CachedSkill[],
|
|
1238
|
+
prompt: string,
|
|
1239
|
+
): void {
|
|
1240
|
+
const evaluation = evaluateApplicability(skills, prompt);
|
|
1241
|
+
const app = state.applicability;
|
|
1242
|
+
const fresh = evaluation.applicable.filter((verdict) => !app.verdicts.has(verdict.name));
|
|
1243
|
+
for (const verdict of fresh) app.verdicts.set(verdict.name, verdict);
|
|
1244
|
+
app.evaluated = evaluation.evaluated;
|
|
1245
|
+
app.undeclared = evaluation.undeclared;
|
|
1246
|
+
app.taskChars = prompt.length;
|
|
1247
|
+
|
|
1248
|
+
if (!app.censusWritten) {
|
|
1249
|
+
const wrote = recordApplicabilityCensus(ctx, {
|
|
1250
|
+
taskChars: app.taskChars,
|
|
1251
|
+
evaluated: app.evaluated,
|
|
1252
|
+
undeclared: app.undeclared,
|
|
1253
|
+
});
|
|
1254
|
+
// A session without an id, or a refused store: retry on the next turn.
|
|
1255
|
+
if (wrote) app.censusWritten = true;
|
|
1256
|
+
}
|
|
1257
|
+
if (!fresh.length) return;
|
|
1258
|
+
log.debug(
|
|
1259
|
+
`[skills-auto-inject] applicability: ${fresh.length} newly applicable, ` +
|
|
1260
|
+
`${evaluation.evaluated} evaluated, ${evaluation.undeclared.length} undeclared`,
|
|
1261
|
+
);
|
|
1262
|
+
for (const verdict of fresh) {
|
|
1263
|
+
recordApplicabilityVerdict(ctx, {
|
|
1264
|
+
skill: verdict.name,
|
|
1265
|
+
applicability: verdict.verdict,
|
|
1266
|
+
evidence: verdict.evidence,
|
|
1267
|
+
});
|
|
1268
|
+
// The obligation row lands with the verdict, not with the first leg: a
|
|
1269
|
+
// session that is merely told which body it owes, and then does nothing,
|
|
1270
|
+
// is the population the rate exists to count. Without this row that
|
|
1271
|
+
// session would be mistaken for one the instrument never saw.
|
|
1272
|
+
legsFor(state, verdict.name);
|
|
1273
|
+
appendObligationRow(ctx, state, verdict.name);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Upgrade an applicable skill to `read` and append its verdict row. A read of a
|
|
1279
|
+
* skill whose declared condition never held gets no row: the three classes are
|
|
1280
|
+
* about skills that applied, and a read is not a fourth one.
|
|
1281
|
+
*/
|
|
1282
|
+
function markApplicabilityRead(ctx: ExtensionContext, state: AutoInjectState, name: string): void {
|
|
1283
|
+
const app = state.applicability;
|
|
1284
|
+
const held = app.verdicts.get(name);
|
|
1285
|
+
if (!held || held.verdict === "read") return;
|
|
1286
|
+
app.verdicts.set(name, { ...held, verdict: "read" });
|
|
1287
|
+
recordApplicabilityVerdict(ctx, {
|
|
1288
|
+
skill: name,
|
|
1289
|
+
applicability: "read",
|
|
1290
|
+
evidence: held.evidence,
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
// Obligation rows (the applied leg)
|
|
1295
|
+
|
|
1296
|
+
/**
|
|
1297
|
+
* The session's legs for one skill, created on first sight. The object is the
|
|
1298
|
+
* snapshot every row carries, so a row states all five legs as of the moment
|
|
1299
|
+
* the leg changed rather than the single delta that triggered the write.
|
|
1300
|
+
*/
|
|
1301
|
+
function legsFor(state: AutoInjectState, name: string): ObligationLegs {
|
|
1302
|
+
let legs = state.obligations.legs.get(name);
|
|
1303
|
+
if (!legs) {
|
|
1304
|
+
legs = {
|
|
1305
|
+
skill: name,
|
|
1306
|
+
suggested: false,
|
|
1307
|
+
listed: false,
|
|
1308
|
+
read: false,
|
|
1309
|
+
called: false,
|
|
1310
|
+
applied: false,
|
|
1311
|
+
};
|
|
1312
|
+
state.obligations.legs.set(name, legs);
|
|
1313
|
+
}
|
|
1314
|
+
return legs;
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* Append the skill's legs when they changed since the last row. One row per
|
|
1319
|
+
* distinct state rather than one per event: a session that reads the same body
|
|
1320
|
+
* three times, or lists it on every turn, writes one line. A refused write
|
|
1321
|
+
* leaves the signature unset, so the next leg change retries.
|
|
1322
|
+
*/
|
|
1323
|
+
function appendObligationRow(ctx: ExtensionContext, state: AutoInjectState, name: string): void {
|
|
1324
|
+
const legs = state.obligations.legs.get(name);
|
|
1325
|
+
if (!legs) return;
|
|
1326
|
+
const signature = [legs.suggested, legs.listed, legs.read, legs.called, legs.applied]
|
|
1327
|
+
.map((flag) => (flag ? "1" : "0"))
|
|
1328
|
+
.join("");
|
|
1329
|
+
if (state.obligations.written.get(name) === signature) return;
|
|
1330
|
+
if (!recordObligationLegs(ctx, legs)) return;
|
|
1331
|
+
state.obligations.written.set(name, signature);
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
/** Note one observed leg for a skill and record the row it changed. */
|
|
1335
|
+
function noteObligationLeg(
|
|
1336
|
+
ctx: ExtensionContext,
|
|
1337
|
+
state: AutoInjectState,
|
|
1338
|
+
name: string,
|
|
1339
|
+
leg: "suggested" | "listed" | "read",
|
|
1340
|
+
): void {
|
|
1341
|
+
if (!name) return;
|
|
1342
|
+
const legs = legsFor(state, name);
|
|
1343
|
+
if (legs[leg]) return;
|
|
1344
|
+
legs[leg] = true;
|
|
1345
|
+
appendObligationRow(ctx, state, name);
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* Record the skills a delivered suggestion offered this session. Called only
|
|
1350
|
+
* after the send was accepted, so the row counts arrivals like the `suggested`
|
|
1351
|
+
* counter does. Never throws: a record is not worth a broken turn.
|
|
1352
|
+
*/
|
|
1353
|
+
export function noteObligationSuggested(ctx: ExtensionContext, names: string[]): void {
|
|
1354
|
+
try {
|
|
1355
|
+
const state = getState(ctx);
|
|
1356
|
+
for (const name of names) noteObligationLeg(ctx, state, name, "suggested");
|
|
1357
|
+
} catch (err) {
|
|
1358
|
+
log.debug(`[skills-auto-inject] obligation suggested leg failed (best-effort): ${err}`);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
/** Record the skills a catalog page listed (called from the list_skills tool). */
|
|
1363
|
+
export function noteObligationListed(ctx: ExtensionContext, names: string[]): void {
|
|
1364
|
+
try {
|
|
1365
|
+
const state = getState(ctx);
|
|
1366
|
+
for (const name of names) noteObligationLeg(ctx, state, name, "listed");
|
|
1367
|
+
} catch (err) {
|
|
1368
|
+
log.debug(`[skills-auto-inject] obligation listed leg failed (best-effort): ${err}`);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1154
1372
|
// Main Handler
|
|
1155
1373
|
|
|
1156
1374
|
/** The tool_result fields this module reads. */
|
|
@@ -1183,10 +1401,46 @@ function detectSkillLoad(
|
|
|
1183
1401
|
const held = state.injected.find((i) => i.name === name && i.loadedTurn === undefined);
|
|
1184
1402
|
if (held) held.loadedTurn = state.currentTurn;
|
|
1185
1403
|
recordSkillLoad(ctx, name);
|
|
1404
|
+
// The load counters say a read happened; this says whether the session was
|
|
1405
|
+
// one where the skill applied. Independent writes, independent failures.
|
|
1406
|
+
markApplicabilityRead(ctx, state, name);
|
|
1407
|
+
noteObligationLeg(ctx, state, name, "read");
|
|
1186
1408
|
log.debug(`[skills-auto-inject] counted actual load of "${name}" via read`);
|
|
1187
1409
|
return name;
|
|
1188
1410
|
}
|
|
1189
1411
|
|
|
1412
|
+
/**
|
|
1413
|
+
* Record a call into a declared family (the applied leg).
|
|
1414
|
+
*
|
|
1415
|
+
* The FIRST call per (session, skill) decides it: a read already on record
|
|
1416
|
+
* means the body came first and the call applies what it says; no read means
|
|
1417
|
+
* the call came first, and no later read can turn that into satisfaction — the
|
|
1418
|
+
* ordering is a fact about what happened, not a state that improves.
|
|
1419
|
+
*
|
|
1420
|
+
* A failed call still counts: a refusal would fire before the tool ran and
|
|
1421
|
+
* could not know the outcome. Skills that declare no family are never reached
|
|
1422
|
+
* here, which is most of them.
|
|
1423
|
+
*/
|
|
1424
|
+
function stepFamilyCalls(
|
|
1425
|
+
ctx: ExtensionContext,
|
|
1426
|
+
state: AutoInjectState,
|
|
1427
|
+
event: ToolResultEvent,
|
|
1428
|
+
): void {
|
|
1429
|
+
const toolName = event?.toolName;
|
|
1430
|
+
if (!toolName) return;
|
|
1431
|
+
const family = toolFamilyToken(toolName);
|
|
1432
|
+
if (!family) return;
|
|
1433
|
+
for (const skill of _skillsCache) {
|
|
1434
|
+
if (!skill.families?.length || !skill.families.includes(family)) continue;
|
|
1435
|
+
if (state.obligations.called.has(skill.name)) continue;
|
|
1436
|
+
const legs = legsFor(state, skill.name);
|
|
1437
|
+
state.obligations.called.add(skill.name);
|
|
1438
|
+
legs.called = true;
|
|
1439
|
+
legs.applied = legs.read;
|
|
1440
|
+
appendObligationRow(ctx, state, skill.name);
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1190
1444
|
/**
|
|
1191
1445
|
* Fire the drift line when the work has moved into a new work area (the rule
|
|
1192
1446
|
* and its bounds live in loading-guidance.ts, beside the floor text the line
|
|
@@ -1259,6 +1513,10 @@ export function registerAutoInject(pi: ExtensionAPI): void {
|
|
|
1259
1513
|
const ev = event as ToolResultEvent;
|
|
1260
1514
|
const state = getState(ctx);
|
|
1261
1515
|
if (detectSkillLoad(ev, ctx, state)) noteDriftSurface(state.drift);
|
|
1516
|
+
// A call in a declared family is the applied leg. It runs after the load
|
|
1517
|
+
// detector so a SKILL.md read of the very tool call in flight is already
|
|
1518
|
+
// on record when the family is looked up.
|
|
1519
|
+
stepFamilyCalls(ctx, state, ev);
|
|
1262
1520
|
stepDrift(pi, ctx, state, ev);
|
|
1263
1521
|
} catch {
|
|
1264
1522
|
// best-effort — never break the tool loop over a counter or a whisper
|
|
@@ -1316,6 +1574,17 @@ export function registerAutoInject(pi: ExtensionAPI): void {
|
|
|
1316
1574
|
return; // No user input to match against
|
|
1317
1575
|
}
|
|
1318
1576
|
|
|
1577
|
+
// Applicability is recorded BEFORE every scoring early-return below.
|
|
1578
|
+
// Most sessions match no skill, and those are exactly the sessions the
|
|
1579
|
+
// adoption counters cannot explain: the returns would erase them. The
|
|
1580
|
+
// step reads the catalog and the prompt only, so the suggestion decision
|
|
1581
|
+
// below is untouched by it (and its failure cannot cost a suggestion).
|
|
1582
|
+
try {
|
|
1583
|
+
stepApplicability(ctx, state, skills, prompt);
|
|
1584
|
+
} catch (err) {
|
|
1585
|
+
log.debug(`[skills-auto-inject] applicability step failed (best-effort): ${err}`);
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1319
1588
|
// One-shot profile hint: the first non-empty prompt of a session whose
|
|
1320
1589
|
// configured profile carries a hint gets exactly one steer — the hint
|
|
1321
1590
|
// text itself, byte-for-byte. Profiles without a hint and sessions
|
|
@@ -1432,6 +1701,11 @@ export function registerAutoInject(pi: ExtensionAPI): void {
|
|
|
1432
1701
|
ctx,
|
|
1433
1702
|
skillsToInject.map((s) => s.name),
|
|
1434
1703
|
);
|
|
1704
|
+
// The same delivery is an obligation leg: the body was offered here.
|
|
1705
|
+
noteObligationSuggested(
|
|
1706
|
+
ctx,
|
|
1707
|
+
skillsToInject.map((s) => s.name),
|
|
1708
|
+
);
|
|
1435
1709
|
} catch (err) {
|
|
1436
1710
|
log.debug(`[skills-auto-inject] Error in before_agent_start: ${err}`);
|
|
1437
1711
|
}
|
|
@@ -43,19 +43,27 @@ import {
|
|
|
43
43
|
updateSkillCache,
|
|
44
44
|
getSkillStats,
|
|
45
45
|
getDurableSkillStats,
|
|
46
|
+
noteObligationListed,
|
|
46
47
|
resolveDiscoveryMode,
|
|
47
48
|
rankSkillsDeterministic,
|
|
48
49
|
} from "./auto-inject.js";
|
|
49
50
|
import type { DeterministicRanking, RankedSkill, RelevanceReason } from "./auto-inject.js";
|
|
50
51
|
import { readSkillTriggerEntries } from "./skill-triggers.js";
|
|
51
52
|
import type { TriggerSource } from "./skill-triggers.js";
|
|
53
|
+
import { readGovernedFamilies } from "./skill-families.js";
|
|
52
54
|
import {
|
|
53
55
|
clampSectionsMax,
|
|
54
56
|
DEFAULT_SECTIONS_MAX,
|
|
55
57
|
SECTIONS_MAX_LIMIT,
|
|
56
58
|
readSkillReach,
|
|
57
59
|
} from "./reach.js";
|
|
58
|
-
import {
|
|
60
|
+
import {
|
|
61
|
+
getMonthlyAdoptionRollup,
|
|
62
|
+
getObligationRate,
|
|
63
|
+
getSessionApplicability,
|
|
64
|
+
getSessionObligation,
|
|
65
|
+
judgeSessionObligations,
|
|
66
|
+
} from "./session-records.js";
|
|
59
67
|
import { checkArgumentValues } from "../../../lib/utils/argument-report.js";
|
|
60
68
|
|
|
61
69
|
const log = createLogger("skills-tool");
|
|
@@ -93,7 +101,15 @@ export function setCachedSkills(skills: CachedSkill[]): void {
|
|
|
93
101
|
const entries = readSkillTriggerEntries(s.filePath, s.description);
|
|
94
102
|
const triggerSources: Record<string, TriggerSource> = {};
|
|
95
103
|
for (const entry of entries) triggerSources[entry.phrase] = entry.source;
|
|
96
|
-
return {
|
|
104
|
+
return {
|
|
105
|
+
...s,
|
|
106
|
+
triggers: entries.map((entry) => entry.phrase),
|
|
107
|
+
triggerSources,
|
|
108
|
+
// The families the file says its advice directs, resolved from the same
|
|
109
|
+
// frontmatter read the phrases come from (one extra parse per file per
|
|
110
|
+
// process). An empty list is a declaration of no family, not a miss.
|
|
111
|
+
families: readGovernedFamilies(s.filePath),
|
|
112
|
+
};
|
|
97
113
|
});
|
|
98
114
|
// Sync with auto-inject subsystem (enriched cache — triggers ride along)
|
|
99
115
|
updateSkillCache(cachedSkills);
|
|
@@ -348,6 +364,14 @@ export default function skillsToolExtension(pi: ExtensionAPI): void {
|
|
|
348
364
|
...(answer.relevance.has(s.name) ? { relevance: answer.relevance.get(s.name) } : {}),
|
|
349
365
|
}));
|
|
350
366
|
|
|
367
|
+
// A listed row is one of the session's obligation legs: the catalog is
|
|
368
|
+
// where a body becomes findable without a whisper. Recorded before the
|
|
369
|
+
// response is built so the row and the page describe the same read.
|
|
370
|
+
noteObligationListed(
|
|
371
|
+
ctx,
|
|
372
|
+
skills.map((s) => s.name),
|
|
373
|
+
);
|
|
374
|
+
|
|
351
375
|
return {
|
|
352
376
|
content: [
|
|
353
377
|
{
|
|
@@ -417,6 +441,42 @@ export default function skillsToolExtension(pi: ExtensionAPI): void {
|
|
|
417
441
|
}
|
|
418
442
|
const monthly = getMonthlyAdoptionRollup();
|
|
419
443
|
const discovery = resolveDiscoveryMode(ctx);
|
|
444
|
+
// The session's skill verdicts (read | ignored, plus the not-applicable
|
|
445
|
+
// remainder of the census) from the durable record, never from memory:
|
|
446
|
+
// the point of the record is that it outlives the turn that saw it.
|
|
447
|
+
// Absent when the session wrote none — an older store, or a session that
|
|
448
|
+
// never reached a task text — so an exhausted reader of the old counters
|
|
449
|
+
// keeps byte-identical output. Only the verdict classes are summarized in
|
|
450
|
+
// details; the full evidence stays in the text payload.
|
|
451
|
+
const recorded = getSessionApplicability(ctx);
|
|
452
|
+
const applicability = recorded
|
|
453
|
+
? {
|
|
454
|
+
taskChars: recorded.taskChars,
|
|
455
|
+
evaluated: recorded.evaluated,
|
|
456
|
+
undeclared: recorded.undeclared,
|
|
457
|
+
classes: recorded.classes,
|
|
458
|
+
verdicts: recorded.verdicts,
|
|
459
|
+
updatedAt: recorded.updatedAt,
|
|
460
|
+
}
|
|
461
|
+
: undefined;
|
|
462
|
+
// The session's obligation legs and its boolean: what the session did
|
|
463
|
+
// with the bodies whose conditions held. Absent when the session has no
|
|
464
|
+
// leg row, so a store this build never wrote to reads byte for byte as
|
|
465
|
+
// it did before (the same rule the applicability block above follows).
|
|
466
|
+
const legRecord = getSessionObligation(ctx);
|
|
467
|
+
const judgement = judgeSessionObligations(recorded, legRecord);
|
|
468
|
+
const obligations =
|
|
469
|
+
judgement && legRecord && legRecord.skills.length
|
|
470
|
+
? {
|
|
471
|
+
allSatisfied: judgement.allSatisfied,
|
|
472
|
+
obligations: judgement.obligations,
|
|
473
|
+
skills: judgement.skills,
|
|
474
|
+
}
|
|
475
|
+
: undefined;
|
|
476
|
+
// Both rates over one population, or absent while the store carries no
|
|
477
|
+
// obligation row at all: a build that predates the leg reads the same
|
|
478
|
+
// sessions and must see the same payload.
|
|
479
|
+
const obligationRate = getObligationRate();
|
|
420
480
|
return {
|
|
421
481
|
content: [
|
|
422
482
|
{
|
|
@@ -437,6 +497,9 @@ export default function skillsToolExtension(pi: ExtensionAPI): void {
|
|
|
437
497
|
suggestedEpoch: suggestedMixed === 0 ? "delivered" : "mixed",
|
|
438
498
|
},
|
|
439
499
|
monthly,
|
|
500
|
+
...(applicability ? { applicability } : {}),
|
|
501
|
+
...(obligations ? { obligations } : {}),
|
|
502
|
+
...(obligationRate ? { obligationRate } : {}),
|
|
440
503
|
discovery: {
|
|
441
504
|
// Whether the stock skill catalog sits in the persisted
|
|
442
505
|
// transcript (it re-enters via pi's post-compaction
|
|
@@ -458,6 +521,16 @@ export default function skillsToolExtension(pi: ExtensionAPI): void {
|
|
|
458
521
|
allTimeSkills: Object.keys(allTime).length,
|
|
459
522
|
allTimeTotals: { ...totals, suggestedDelivered, suggestedMixed },
|
|
460
523
|
monthly,
|
|
524
|
+
...(applicability ? { applicability: applicability.classes } : {}),
|
|
525
|
+
...(obligations
|
|
526
|
+
? {
|
|
527
|
+
obligations: {
|
|
528
|
+
allSatisfied: obligations.allSatisfied,
|
|
529
|
+
count: obligations.obligations,
|
|
530
|
+
},
|
|
531
|
+
}
|
|
532
|
+
: {}),
|
|
533
|
+
...(obligationRate ? { obligationRate } : {}),
|
|
461
534
|
},
|
|
462
535
|
};
|
|
463
536
|
},
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
39
|
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
40
|
+
import { toolFamilyToken } from "./skill-families.js";
|
|
40
41
|
|
|
41
42
|
/** One visible skill as the floor renders it. */
|
|
42
43
|
export interface CatalogEntry {
|
|
@@ -158,7 +159,7 @@ export function mechanicalTriggerExamples(toolNames: string[], skillNames: strin
|
|
|
158
159
|
// Family token (lowercased) -> lexicographically smallest active tool name.
|
|
159
160
|
const familyTool = new Map<string, string>();
|
|
160
161
|
for (const tool of toolNames) {
|
|
161
|
-
const family = tool
|
|
162
|
+
const family = toolFamilyToken(tool);
|
|
162
163
|
const incumbent = familyTool.get(family);
|
|
163
164
|
if (incumbent === undefined || tool < incumbent) familyTool.set(family, tool);
|
|
164
165
|
}
|