pi-braid 0.43.11 → 0.43.12
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 +17 -0
- package/build-info.json +4 -4
- package/dist/extensions/core/skills-tool/index.d.ts +11 -3
- package/dist/extensions/core/skills-tool/index.js +27 -3
- package/dist/extensions/core/skills-tool/skill-triggers.d.ts +22 -0
- package/dist/extensions/core/skills-tool/skill-triggers.js +29 -4
- 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/index.ts +34 -6
- package/src/extensions/core/skills-tool/skill-triggers.ts +43 -4
package/CHANGELOG.md
CHANGED
|
@@ -53,6 +53,23 @@ record; the tag scheme above applies unchanged.
|
|
|
53
53
|
|
|
54
54
|
---
|
|
55
55
|
|
|
56
|
+
## Core — 0.43.12 (2026-11-01: a skill that says it is retired stops being advertised)
|
|
57
|
+
|
|
58
|
+
- **A retired skill no longer competes with its successor.** Four skills in the packs declare
|
|
59
|
+
`status: merged` and nothing read the declaration, so `code-search` was still listed beside
|
|
60
|
+
`code-refactoring` — two entries for one job, no sign which was current. A declared status of
|
|
61
|
+
`merged`, `archived` or `deprecated` now rides the exclusion the cache already had, so the catalog,
|
|
62
|
+
the suggestion whisper, the at-use line, both catalog accessors and `list_skills` agree without a
|
|
63
|
+
second concept. The file stays on disk and an explicit read of it still resolves: the skill stops
|
|
64
|
+
being advertised, it does not become unreadable. The status comes from the frontmatter parse the
|
|
65
|
+
trigger phrases already paid for, so no skill file is read a third time.
|
|
66
|
+
- **The budget gate it disturbed now tests the rule rather than its own reflection.** One existing
|
|
67
|
+
measurement asserted that every skill in the pack appears in one catalog page; with a retired skill
|
|
68
|
+
legitimately absent, the writer's first repair compared the page to the module's own accessor, which
|
|
69
|
+
is the same code on both sides and cannot catch a _wrong_ exclusion. The assertion instead derives the
|
|
70
|
+
expected population from the SKILL.md files themselves, so a skill retired for no reason in its
|
|
71
|
+
frontmatter reddens the gate. The seat verified that by planting one.
|
|
72
|
+
|
|
56
73
|
## Core — 0.43.11 (2026-11-01: an owner ruling becomes findable, and the pointer rule stops licensing the skip)
|
|
57
74
|
|
|
58
75
|
- **The pointer rule no longer licenses skipping the read.** The sentence it carried — `The prompt already
|
package/build-info.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-braid",
|
|
3
|
-
"version": "0.43.
|
|
4
|
-
"sha": "
|
|
5
|
-
"shaShort": "
|
|
3
|
+
"version": "0.43.12",
|
|
4
|
+
"sha": "f6a311a974d34f1d7cc70a491a8f5544e85dd233",
|
|
5
|
+
"shaShort": "f6a311a9",
|
|
6
6
|
"branch": "detached",
|
|
7
7
|
"dirty": false,
|
|
8
|
-
"packedAt": "2026-11-
|
|
8
|
+
"packedAt": "2026-11-01T08:52:31.302Z"
|
|
9
9
|
}
|
|
@@ -45,9 +45,10 @@ interface CachedSkill {
|
|
|
45
45
|
package?: string;
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
48
|
+
* Excluded from model selection: pi's own frontmatter flag, or a status this
|
|
49
|
+
* cache reads as retired (see RETIRED_STATUSES). Either way braid keeps the
|
|
50
|
+
* skill out of the surfaces that advertise skills to the model, while the
|
|
51
|
+
* file stays on disk and an explicit read of it still resolves.
|
|
51
52
|
*/
|
|
52
53
|
disableModelInvocation?: boolean;
|
|
53
54
|
/** Frontmatter trigger phrases, resolved from SKILL.md at cache time. */
|
|
@@ -60,6 +61,13 @@ interface CachedSkill {
|
|
|
60
61
|
* Resolves each skill's frontmatter trigger phrases here, once per turn:
|
|
61
62
|
* the matcher scores triggers, pi's skill objects never carry them (fixed
|
|
62
63
|
* shape), and the memoized read makes repeat turns stat-only.
|
|
64
|
+
*
|
|
65
|
+
* The same read answers the file's `status:`, and a retired status rides the
|
|
66
|
+
* `disableModelInvocation` exclusion rather than a second one: every surface
|
|
67
|
+
* that advertises skills already filters on that flag, so one derived field
|
|
68
|
+
* keeps the catalog, the whisper, the at-use line and the accessors in
|
|
69
|
+
* agreement. The row is still cached, so an explicit read of the file is still
|
|
70
|
+
* recognized — the skill stops being advertised, not becoming unreadable.
|
|
63
71
|
*/
|
|
64
72
|
export declare function setCachedSkills(skills: CachedSkill[]): void;
|
|
65
73
|
/**
|
|
@@ -35,25 +35,47 @@ import { Type } from "typebox";
|
|
|
35
35
|
import { createLogger } from "../../../lib/core/logger.js";
|
|
36
36
|
import { getSkillsInformMode, getSkillsRankingMode } from "../../../lib/config/braid-settings.js";
|
|
37
37
|
import { registerAutoInject, updateSkillCache, getSkillStats, getDurableSkillStats, noteObligationListed, resolveDiscoveryMode, rankSkillsDeterministic, } from "./auto-inject.js";
|
|
38
|
-
import {
|
|
38
|
+
import { readSkillFrontmatter } from "./skill-triggers.js";
|
|
39
39
|
import { readGovernedFamilies } from "./skill-families.js";
|
|
40
40
|
import { clampSectionsMax, DEFAULT_SECTIONS_MAX, SECTIONS_MAX_LIMIT, readSkillReach, } from "./reach.js";
|
|
41
41
|
import { getInformRate, getMonthlyAdoptionRollup, getObligationRate, getSessionApplicability, getSessionObligation, judgeSessionObligations, } from "./session-records.js";
|
|
42
42
|
import { checkArgumentValues } from "../../../lib/utils/argument-report.js";
|
|
43
43
|
const log = createLogger("skills-tool");
|
|
44
44
|
let cachedSkills = [];
|
|
45
|
+
/**
|
|
46
|
+
* Statuses that mean the skill is no longer the place to look: its content
|
|
47
|
+
* lives in a successor, or the file is kept as history. The vocabulary is the
|
|
48
|
+
* pack's (a `status:` frontmatter key), and the exclusion is this module's:
|
|
49
|
+
* no file is deleted, renamed or edited to make a skill stop being advertised.
|
|
50
|
+
*/
|
|
51
|
+
const RETIRED_STATUSES = new Set(["merged", "archived", "deprecated"]);
|
|
52
|
+
/** Whether a declared status retires the skill from model selection. */
|
|
53
|
+
function isRetiredStatus(status) {
|
|
54
|
+
return RETIRED_STATUSES.has(status);
|
|
55
|
+
}
|
|
45
56
|
/**
|
|
46
57
|
* Called from prompt-builder's before_agent_start to populate the cache.
|
|
47
58
|
* Resolves each skill's frontmatter trigger phrases here, once per turn:
|
|
48
59
|
* the matcher scores triggers, pi's skill objects never carry them (fixed
|
|
49
60
|
* shape), and the memoized read makes repeat turns stat-only.
|
|
61
|
+
*
|
|
62
|
+
* The same read answers the file's `status:`, and a retired status rides the
|
|
63
|
+
* `disableModelInvocation` exclusion rather than a second one: every surface
|
|
64
|
+
* that advertises skills already filters on that flag, so one derived field
|
|
65
|
+
* keeps the catalog, the whisper, the at-use line and the accessors in
|
|
66
|
+
* agreement. The row is still cached, so an explicit read of the file is still
|
|
67
|
+
* recognized — the skill stops being advertised, not becoming unreadable.
|
|
50
68
|
*/
|
|
51
69
|
export function setCachedSkills(skills) {
|
|
70
|
+
let retired = 0;
|
|
52
71
|
cachedSkills = skills.map((s) => {
|
|
53
|
-
const entries =
|
|
72
|
+
const { entries, status } = readSkillFrontmatter(s.filePath, s.description);
|
|
54
73
|
const triggerSources = {};
|
|
55
74
|
for (const entry of entries)
|
|
56
75
|
triggerSources[entry.phrase] = entry.source;
|
|
76
|
+
const isRetired = isRetiredStatus(status);
|
|
77
|
+
if (isRetired)
|
|
78
|
+
retired++;
|
|
57
79
|
return {
|
|
58
80
|
...s,
|
|
59
81
|
triggers: entries.map((entry) => entry.phrase),
|
|
@@ -62,11 +84,13 @@ export function setCachedSkills(skills) {
|
|
|
62
84
|
// frontmatter read the phrases come from (one extra parse per file per
|
|
63
85
|
// process). An empty list is a declaration of no family, not a miss.
|
|
64
86
|
families: readGovernedFamilies(s.filePath),
|
|
87
|
+
disableModelInvocation: s.disableModelInvocation === true || isRetired,
|
|
65
88
|
};
|
|
66
89
|
});
|
|
67
90
|
// Sync with auto-inject subsystem (enriched cache — triggers ride along)
|
|
68
91
|
updateSkillCache(cachedSkills);
|
|
69
|
-
log.debug(`Cached ${skills.length} skills for list_skills tool`
|
|
92
|
+
log.debug(`Cached ${skills.length} skills for list_skills tool` +
|
|
93
|
+
(retired ? ` (${retired} retired by status)` : ""));
|
|
70
94
|
}
|
|
71
95
|
/**
|
|
72
96
|
* The installed visible skill names — the same set the list_skills catalog
|
|
@@ -28,6 +28,12 @@
|
|
|
28
28
|
* capitalized ("MASTERSHIP TRANSFER: …"), and a phrase that only matched
|
|
29
29
|
* lowercase text would be dead in production while a lowercase-only unit
|
|
30
30
|
* fixture kept the suite green.
|
|
31
|
+
*
|
|
32
|
+
* The same parse also returns the file's declared lifecycle `status`, which is
|
|
33
|
+
* NOT matcher input: the skills-tool needs it once per file, at cache time, to
|
|
34
|
+
* decide whether the skill is still advertised. It rides this read because the
|
|
35
|
+
* file is already open here — a reader of its own would be a third read of the
|
|
36
|
+
* same bytes per process, and a status is not worth one.
|
|
31
37
|
*/
|
|
32
38
|
/**
|
|
33
39
|
* Max trigger phrases read per skill — a longer list is an authoring bug, not a
|
|
@@ -51,6 +57,15 @@ export interface TriggerEntry {
|
|
|
51
57
|
phrase: string;
|
|
52
58
|
source: TriggerSource;
|
|
53
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* One SKILL.md's trigger phrases plus the lifecycle status its frontmatter
|
|
62
|
+
* declares — everything one parse of the file answers.
|
|
63
|
+
*/
|
|
64
|
+
export interface SkillFrontmatterRead {
|
|
65
|
+
entries: TriggerEntry[];
|
|
66
|
+
/** Lowercased `status:` token, or "" when the file declares none. */
|
|
67
|
+
status: string;
|
|
68
|
+
}
|
|
54
69
|
/**
|
|
55
70
|
* Normalize a frontmatter `triggers` value into clean phrases. Accepts a YAML
|
|
56
71
|
* list or a comma-separated string; drops empty, overlong, and surplus
|
|
@@ -76,6 +91,13 @@ export declare function readSkillTriggers(filePath: string, description?: string
|
|
|
76
91
|
* a miss, because the merged list depends on it).
|
|
77
92
|
*/
|
|
78
93
|
export declare function readSkillTriggerEntries(filePath: string, description?: string): TriggerEntry[];
|
|
94
|
+
/**
|
|
95
|
+
* Read a skill's trigger phrases WITH their provenance plus its declared
|
|
96
|
+
* lifecycle status, from one memoized parse. Same sources, precedence and
|
|
97
|
+
* memoization as readSkillTriggerEntries; the status is the frontmatter key of
|
|
98
|
+
* that name, lowercased, "" when absent or unreadable.
|
|
99
|
+
*/
|
|
100
|
+
export declare function readSkillFrontmatter(filePath: string, description?: string): SkillFrontmatterRead;
|
|
79
101
|
/**
|
|
80
102
|
* Merge authored phrase sources into one bounded list, in priority order.
|
|
81
103
|
*
|
|
@@ -28,6 +28,12 @@
|
|
|
28
28
|
* capitalized ("MASTERSHIP TRANSFER: …"), and a phrase that only matched
|
|
29
29
|
* lowercase text would be dead in production while a lowercase-only unit
|
|
30
30
|
* fixture kept the suite green.
|
|
31
|
+
*
|
|
32
|
+
* The same parse also returns the file's declared lifecycle `status`, which is
|
|
33
|
+
* NOT matcher input: the skills-tool needs it once per file, at cache time, to
|
|
34
|
+
* decide whether the skill is still advertised. It rides this read because the
|
|
35
|
+
* file is already open here — a reader of its own would be a third read of the
|
|
36
|
+
* same bytes per process, and a status is not worth one.
|
|
31
37
|
*/
|
|
32
38
|
import { statSync, readFileSync } from "node:fs";
|
|
33
39
|
import { parseFrontmatter } from "@earendil-works/pi-coding-agent";
|
|
@@ -76,6 +82,14 @@ export function normalizeTriggers(value) {
|
|
|
76
82
|
export function readSkillTriggers(filePath, description) {
|
|
77
83
|
return readSkillTriggerEntries(filePath, description).map((entry) => entry.phrase);
|
|
78
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Normalize a frontmatter `status` value into the token a caller matches on.
|
|
87
|
+
* Only a string is a declaration: a missing key, a null, or a nested shape is
|
|
88
|
+
* the absence of one. Pure.
|
|
89
|
+
*/
|
|
90
|
+
function normalizeSkillStatus(value) {
|
|
91
|
+
return typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
92
|
+
}
|
|
79
93
|
/**
|
|
80
94
|
* Read a skill's authored phrases WITH their provenance, merged in priority
|
|
81
95
|
* order: frontmatter (`trigger` or `triggers`), then a `## trigger:` body
|
|
@@ -86,6 +100,15 @@ export function readSkillTriggers(filePath, description) {
|
|
|
86
100
|
* a miss, because the merged list depends on it).
|
|
87
101
|
*/
|
|
88
102
|
export function readSkillTriggerEntries(filePath, description) {
|
|
103
|
+
return readSkillFrontmatter(filePath, description).entries;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Read a skill's trigger phrases WITH their provenance plus its declared
|
|
107
|
+
* lifecycle status, from one memoized parse. Same sources, precedence and
|
|
108
|
+
* memoization as readSkillTriggerEntries; the status is the frontmatter key of
|
|
109
|
+
* that name, lowercased, "" when absent or unreadable.
|
|
110
|
+
*/
|
|
111
|
+
export function readSkillFrontmatter(filePath, description) {
|
|
89
112
|
const desc = description ?? "";
|
|
90
113
|
let st;
|
|
91
114
|
try {
|
|
@@ -93,20 +116,22 @@ export function readSkillTriggerEntries(filePath, description) {
|
|
|
93
116
|
}
|
|
94
117
|
catch {
|
|
95
118
|
cache.delete(filePath);
|
|
96
|
-
return [];
|
|
119
|
+
return { entries: [], status: "" };
|
|
97
120
|
}
|
|
98
121
|
const cached = cache.get(filePath);
|
|
99
122
|
if (cached &&
|
|
100
123
|
cached.mtimeMs === st.mtimeMs &&
|
|
101
124
|
cached.size === st.size &&
|
|
102
125
|
cached.description === desc) {
|
|
103
|
-
return cached.entries;
|
|
126
|
+
return { entries: cached.entries, status: cached.status };
|
|
104
127
|
}
|
|
105
128
|
const sources = [];
|
|
129
|
+
let status = "";
|
|
106
130
|
try {
|
|
107
131
|
const { frontmatter, body } = parseFrontmatter(readFileSync(filePath, "utf-8"));
|
|
108
132
|
const fm = frontmatter;
|
|
109
133
|
const label = (source) => (phrase) => ({ phrase, source });
|
|
134
|
+
status = normalizeSkillStatus(fm.status);
|
|
110
135
|
sources.push(normalizeTriggers(fm.trigger).map(label("frontmatter")), normalizeTriggers(fm.triggers).map(label("frontmatter")), parseBodyTriggers(body).map(label("heading")));
|
|
111
136
|
}
|
|
112
137
|
catch {
|
|
@@ -116,8 +141,8 @@ export function readSkillTriggerEntries(filePath, description) {
|
|
|
116
141
|
if (desc)
|
|
117
142
|
sources.push(parseDescriptionTriggers(desc).map((phrase) => ({ phrase, source: "description" })));
|
|
118
143
|
const entries = mergeTriggerEntries(sources);
|
|
119
|
-
cache.set(filePath, { mtimeMs: st.mtimeMs, size: st.size, description: desc, entries });
|
|
120
|
-
return entries;
|
|
144
|
+
cache.set(filePath, { mtimeMs: st.mtimeMs, size: st.size, description: desc, entries, status });
|
|
145
|
+
return { entries, status };
|
|
121
146
|
}
|
|
122
147
|
/**
|
|
123
148
|
* Merge authored phrase sources into one bounded list, in priority order.
|
package/docs/LOCAL_DEV.md
CHANGED
|
@@ -138,7 +138,7 @@ before and after a full run. A non-zero delta is the leak this rule prevents.
|
|
|
138
138
|
### New fixtures: use `node:test`
|
|
139
139
|
|
|
140
140
|
A new fixture is written on `node:test`. The runner does not care which style a
|
|
141
|
-
file uses -
|
|
141
|
+
file uses - 98 of the core suite's 333 fixtures already use `node:test` - so the
|
|
142
142
|
reason is the failure the other style produces. A hand-rolled helper that calls
|
|
143
143
|
`fn()` without awaiting it discards the case's promise, so an `async` case runs
|
|
144
144
|
detached and the file can print its green tally before that case settles, with
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-braid",
|
|
3
|
-
"version": "0.43.
|
|
3
|
+
"version": "0.43.12",
|
|
4
4
|
"description": "🥨 Braid - Metacognitive extension suite for pi coding agent: Adds memory, plan tracking, structured cognitive signals and completion checks on top of pi core loop, so long sessions keep their context and stop claiming unfinished work.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,6 +33,7 @@ Two surfaces in `skills-tool/` put a skill body in front of the agent: the auto-
|
|
|
33
33
|
- **Conversion is a detected read.** The whisper asks the agent to open the SKILL.md; the conversion signal is the `read` tool_result (`actual`), which is also what sets `hadSkillLoad` in the durable session record. The retired LOADED/SKIP reply is no longer solicited; `claimed` keeps its historical honor-system meaning and stays monotone.
|
|
34
34
|
- **The trigger has a mechanical form.** `skills-tool/loading-guidance.ts` carries both the judgment form (the task entered a listed skill's domain) and the mechanical form (about to call a tool family whose word appears in a skill's name). `prompt-builder` renders that text through the `skillsLoadingText` builder as the `skills-loading` section and holds no copy of the rules; the trigger's worked examples are derived at assembly from the live tool and skill names, so the text names no pair that the running session does not have. The identity's skills prose stays one sentence.
|
|
35
35
|
- **The catalog is in the prompt.** The same section renders every visible skill as one `- name: description` row, with the read path derived from the skills' own file paths (one root for a single pack, a directory heading per pack when a catalog is installed from several). A tool call is no longer the way the agent learns which skills exist: the floor exists because the prompt that opens a resumed session carries no domain vocabulary for a matcher to rank against. `list_skills` remains the price tool (reach, headings, ranking) rather than the catalog.
|
|
36
|
+
- **A retired skill is not advertised.** A SKILL.md whose frontmatter declares `status: merged`, `archived` or `deprecated` stops being advertised and matched, and the file stays on disk as history. The exclusion rides the flag `disable-model-invocation` already owns (derived at cache time in `index.ts`), so the catalog, the suggestion whisper, the at-use line, the accessor and `list_skills` agree without a second concept. The row stays in the unfiltered cache, so a read of the file still resolves.
|
|
36
37
|
- **Drift re-points at the floor.** When the session's own path-taking calls (`read`/`edit`/`write`) accumulate entries in a work area the floor was not rendered against, one steer line names that area and points back at the catalog. The rule and its bounds (two entries, one fire per twelve calls, three per session, quiet for the same window after any skill surface) live in `loading-guidance.ts` beside the floor text; the wiring is the `tool_result` handler in `auto-inject.ts`. Bounds are the whole design: the line is only worth its noise if it stays rare.
|
|
37
38
|
- **The at-use line is observed, never enforced.** With `braid.skills.inform` set to `inform` (default `off`), a `tool_result` whose call **succeeded**, whose tool name yields a family token some visible cached skill declares with `governs:`, and whose obligation row carries no `read` leg emits one steer line naming the file path and the family. It runs after the result exists, returns no replacement, and refuses, delays and rewrites nothing: any gating change can only make it quieter, which is the property that separates it from a refusal gate. The payload is derived from the declaration and the catalogue entry only (the skill's own `filePath`, the token the call's name yields), so no skill name is invented in code and no tool argument is echoed. Once per session per skill, suppressed by the same obligation record the legs write (its `informed` leg), silenced by a read at any point, and hidden skills are never named. `skill_stats` reports it as `inform` from the store: `undecided` below twenty informs, `beats` only when the lower Wilson bound clears the suggestion channel's 18.8% pair conversion, `noise` otherwise.
|
|
38
39
|
- **Applicability is recorded, never enforced.** The counters cannot tell a skill that applied and was ignored from one that never applied, and the sessions that read nothing are mostly sessions no phrase matches. `skills-tool/applicability.ts` decides that difference from the skill's own declaration (the trigger phrases its file carries: frontmatter `trigger:`/`triggers:`, a `## trigger:` body heading, a description `Triggers:` tail), never from the ranking heuristic, with the injector's occurrence boundary and a clause-scoped negation read, so a phrase inside "do not research this" is not a condition met. The verdict is `read` (condition held and a detected read followed), `ignored` (condition held and no read followed), or `not-applicable` (derived: the census's `evaluated` minus the verdict rows); a skill whose file declares no phrase is named `undeclared` rather than judged either way. It reaches disk as `kind: "applicability"` rows in the per-session store (one verdict row per applicable skill keyed on `sessionId` + `skill`, one census row per session) and out through `skill_stats`. It is an observer: it writes no delivery, slot, cooldown, counter or prompt, and it owns no compliance leg. `suggested`/`listed`/`informed`/`read`/`applied` belong to the record that owns each skill's declared tool family; the verdict row joins it on the skill name.
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
rankSkillsDeterministic,
|
|
49
49
|
} from "./auto-inject.js";
|
|
50
50
|
import type { DeterministicRanking, RankedSkill, RelevanceReason } from "./auto-inject.js";
|
|
51
|
-
import {
|
|
51
|
+
import { readSkillFrontmatter } from "./skill-triggers.js";
|
|
52
52
|
import type { TriggerSource } from "./skill-triggers.js";
|
|
53
53
|
import { readGovernedFamilies } from "./skill-families.js";
|
|
54
54
|
import {
|
|
@@ -78,9 +78,10 @@ interface CachedSkill {
|
|
|
78
78
|
baseDir: string;
|
|
79
79
|
sourceInfo?: { source?: string; package?: string };
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
81
|
+
* Excluded from model selection: pi's own frontmatter flag, or a status this
|
|
82
|
+
* cache reads as retired (see RETIRED_STATUSES). Either way braid keeps the
|
|
83
|
+
* skill out of the surfaces that advertise skills to the model, while the
|
|
84
|
+
* file stays on disk and an explicit read of it still resolves.
|
|
84
85
|
*/
|
|
85
86
|
disableModelInvocation?: boolean;
|
|
86
87
|
/** Frontmatter trigger phrases, resolved from SKILL.md at cache time. */
|
|
@@ -91,17 +92,40 @@ interface CachedSkill {
|
|
|
91
92
|
|
|
92
93
|
let cachedSkills: CachedSkill[] = [];
|
|
93
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Statuses that mean the skill is no longer the place to look: its content
|
|
97
|
+
* lives in a successor, or the file is kept as history. The vocabulary is the
|
|
98
|
+
* pack's (a `status:` frontmatter key), and the exclusion is this module's:
|
|
99
|
+
* no file is deleted, renamed or edited to make a skill stop being advertised.
|
|
100
|
+
*/
|
|
101
|
+
const RETIRED_STATUSES = new Set(["merged", "archived", "deprecated"]);
|
|
102
|
+
|
|
103
|
+
/** Whether a declared status retires the skill from model selection. */
|
|
104
|
+
function isRetiredStatus(status: string): boolean {
|
|
105
|
+
return RETIRED_STATUSES.has(status);
|
|
106
|
+
}
|
|
107
|
+
|
|
94
108
|
/**
|
|
95
109
|
* Called from prompt-builder's before_agent_start to populate the cache.
|
|
96
110
|
* Resolves each skill's frontmatter trigger phrases here, once per turn:
|
|
97
111
|
* the matcher scores triggers, pi's skill objects never carry them (fixed
|
|
98
112
|
* shape), and the memoized read makes repeat turns stat-only.
|
|
113
|
+
*
|
|
114
|
+
* The same read answers the file's `status:`, and a retired status rides the
|
|
115
|
+
* `disableModelInvocation` exclusion rather than a second one: every surface
|
|
116
|
+
* that advertises skills already filters on that flag, so one derived field
|
|
117
|
+
* keeps the catalog, the whisper, the at-use line and the accessors in
|
|
118
|
+
* agreement. The row is still cached, so an explicit read of the file is still
|
|
119
|
+
* recognized — the skill stops being advertised, not becoming unreadable.
|
|
99
120
|
*/
|
|
100
121
|
export function setCachedSkills(skills: CachedSkill[]): void {
|
|
122
|
+
let retired = 0;
|
|
101
123
|
cachedSkills = skills.map((s) => {
|
|
102
|
-
const entries =
|
|
124
|
+
const { entries, status } = readSkillFrontmatter(s.filePath, s.description);
|
|
103
125
|
const triggerSources: Record<string, TriggerSource> = {};
|
|
104
126
|
for (const entry of entries) triggerSources[entry.phrase] = entry.source;
|
|
127
|
+
const isRetired = isRetiredStatus(status);
|
|
128
|
+
if (isRetired) retired++;
|
|
105
129
|
return {
|
|
106
130
|
...s,
|
|
107
131
|
triggers: entries.map((entry) => entry.phrase),
|
|
@@ -110,11 +134,15 @@ export function setCachedSkills(skills: CachedSkill[]): void {
|
|
|
110
134
|
// frontmatter read the phrases come from (one extra parse per file per
|
|
111
135
|
// process). An empty list is a declaration of no family, not a miss.
|
|
112
136
|
families: readGovernedFamilies(s.filePath),
|
|
137
|
+
disableModelInvocation: s.disableModelInvocation === true || isRetired,
|
|
113
138
|
};
|
|
114
139
|
});
|
|
115
140
|
// Sync with auto-inject subsystem (enriched cache — triggers ride along)
|
|
116
141
|
updateSkillCache(cachedSkills);
|
|
117
|
-
log.debug(
|
|
142
|
+
log.debug(
|
|
143
|
+
`Cached ${skills.length} skills for list_skills tool` +
|
|
144
|
+
(retired ? ` (${retired} retired by status)` : ""),
|
|
145
|
+
);
|
|
118
146
|
}
|
|
119
147
|
|
|
120
148
|
/**
|
|
@@ -28,6 +28,12 @@
|
|
|
28
28
|
* capitalized ("MASTERSHIP TRANSFER: …"), and a phrase that only matched
|
|
29
29
|
* lowercase text would be dead in production while a lowercase-only unit
|
|
30
30
|
* fixture kept the suite green.
|
|
31
|
+
*
|
|
32
|
+
* The same parse also returns the file's declared lifecycle `status`, which is
|
|
33
|
+
* NOT matcher input: the skills-tool needs it once per file, at cache time, to
|
|
34
|
+
* decide whether the skill is still advertised. It rides this read because the
|
|
35
|
+
* file is already open here — a reader of its own would be a third read of the
|
|
36
|
+
* same bytes per process, and a status is not worth one.
|
|
31
37
|
*/
|
|
32
38
|
|
|
33
39
|
import { statSync, readFileSync } from "node:fs";
|
|
@@ -65,6 +71,18 @@ interface TriggerCacheEntry {
|
|
|
65
71
|
/** The description the entries were merged with: a different one is a miss. */
|
|
66
72
|
description: string;
|
|
67
73
|
entries: TriggerEntry[];
|
|
74
|
+
/** The declared lifecycle status, lowercased; "" when the file declares none. */
|
|
75
|
+
status: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* One SKILL.md's trigger phrases plus the lifecycle status its frontmatter
|
|
80
|
+
* declares — everything one parse of the file answers.
|
|
81
|
+
*/
|
|
82
|
+
export interface SkillFrontmatterRead {
|
|
83
|
+
entries: TriggerEntry[];
|
|
84
|
+
/** Lowercased `status:` token, or "" when the file declares none. */
|
|
85
|
+
status: string;
|
|
68
86
|
}
|
|
69
87
|
|
|
70
88
|
const cache = new Map<string, TriggerCacheEntry>();
|
|
@@ -102,6 +120,15 @@ export function readSkillTriggers(filePath: string, description?: string): strin
|
|
|
102
120
|
return readSkillTriggerEntries(filePath, description).map((entry) => entry.phrase);
|
|
103
121
|
}
|
|
104
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Normalize a frontmatter `status` value into the token a caller matches on.
|
|
125
|
+
* Only a string is a declaration: a missing key, a null, or a nested shape is
|
|
126
|
+
* the absence of one. Pure.
|
|
127
|
+
*/
|
|
128
|
+
function normalizeSkillStatus(value: unknown): string {
|
|
129
|
+
return typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
130
|
+
}
|
|
131
|
+
|
|
105
132
|
/**
|
|
106
133
|
* Read a skill's authored phrases WITH their provenance, merged in priority
|
|
107
134
|
* order: frontmatter (`trigger` or `triggers`), then a `## trigger:` body
|
|
@@ -112,13 +139,23 @@ export function readSkillTriggers(filePath: string, description?: string): strin
|
|
|
112
139
|
* a miss, because the merged list depends on it).
|
|
113
140
|
*/
|
|
114
141
|
export function readSkillTriggerEntries(filePath: string, description?: string): TriggerEntry[] {
|
|
142
|
+
return readSkillFrontmatter(filePath, description).entries;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Read a skill's trigger phrases WITH their provenance plus its declared
|
|
147
|
+
* lifecycle status, from one memoized parse. Same sources, precedence and
|
|
148
|
+
* memoization as readSkillTriggerEntries; the status is the frontmatter key of
|
|
149
|
+
* that name, lowercased, "" when absent or unreadable.
|
|
150
|
+
*/
|
|
151
|
+
export function readSkillFrontmatter(filePath: string, description?: string): SkillFrontmatterRead {
|
|
115
152
|
const desc = description ?? "";
|
|
116
153
|
let st;
|
|
117
154
|
try {
|
|
118
155
|
st = statSync(filePath);
|
|
119
156
|
} catch {
|
|
120
157
|
cache.delete(filePath);
|
|
121
|
-
return [];
|
|
158
|
+
return { entries: [], status: "" };
|
|
122
159
|
}
|
|
123
160
|
const cached = cache.get(filePath);
|
|
124
161
|
if (
|
|
@@ -127,13 +164,15 @@ export function readSkillTriggerEntries(filePath: string, description?: string):
|
|
|
127
164
|
cached.size === st.size &&
|
|
128
165
|
cached.description === desc
|
|
129
166
|
) {
|
|
130
|
-
return cached.entries;
|
|
167
|
+
return { entries: cached.entries, status: cached.status };
|
|
131
168
|
}
|
|
132
169
|
const sources: TriggerEntry[][] = [];
|
|
170
|
+
let status = "";
|
|
133
171
|
try {
|
|
134
172
|
const { frontmatter, body } = parseFrontmatter(readFileSync(filePath, "utf-8"));
|
|
135
173
|
const fm = frontmatter as Record<string, unknown>;
|
|
136
174
|
const label = (source: TriggerSource) => (phrase: string) => ({ phrase, source });
|
|
175
|
+
status = normalizeSkillStatus(fm.status);
|
|
137
176
|
sources.push(
|
|
138
177
|
normalizeTriggers(fm.trigger).map(label("frontmatter")),
|
|
139
178
|
normalizeTriggers(fm.triggers).map(label("frontmatter")),
|
|
@@ -148,8 +187,8 @@ export function readSkillTriggerEntries(filePath: string, description?: string):
|
|
|
148
187
|
parseDescriptionTriggers(desc).map((phrase) => ({ phrase, source: "description" })),
|
|
149
188
|
);
|
|
150
189
|
const entries = mergeTriggerEntries(sources);
|
|
151
|
-
cache.set(filePath, { mtimeMs: st.mtimeMs, size: st.size, description: desc, entries });
|
|
152
|
-
return entries;
|
|
190
|
+
cache.set(filePath, { mtimeMs: st.mtimeMs, size: st.size, description: desc, entries, status });
|
|
191
|
+
return { entries, status };
|
|
153
192
|
}
|
|
154
193
|
|
|
155
194
|
/**
|