@bevel-software/platform-shared 0.15.1 → 0.19.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/dist/auth/types.d.ts +12 -0
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/git/pr.types.d.ts +75 -11
- package/dist/git/pr.types.d.ts.map +1 -1
- package/dist/git/types.d.ts +28 -1
- package/dist/git/types.d.ts.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/workflow/events.d.ts +32 -4
- package/dist/workflow/events.d.ts.map +1 -1
- package/dist/workflow/events.js.map +1 -1
- package/dist/workflow/interface.d.ts +103 -4
- package/dist/workflow/interface.d.ts.map +1 -1
- package/dist/workflow/types.d.ts +49 -0
- package/dist/workflow/types.d.ts.map +1 -1
- package/dist/workspace/access-verbs.d.ts +83 -0
- package/dist/workspace/access-verbs.d.ts.map +1 -0
- package/dist/workspace/access-verbs.js +110 -0
- package/dist/workspace/access-verbs.js.map +1 -0
- package/dist/workspace/agent-preamble.d.ts +33 -0
- package/dist/workspace/agent-preamble.d.ts.map +1 -0
- package/dist/workspace/agent-preamble.js +45 -0
- package/dist/workspace/agent-preamble.js.map +1 -0
- package/dist/workspace/entry-exists.d.ts +27 -0
- package/dist/workspace/entry-exists.d.ts.map +1 -0
- package/dist/workspace/entry-exists.js +33 -0
- package/dist/workspace/entry-exists.js.map +1 -0
- package/dist/workspace/filename.d.ts +15 -0
- package/dist/workspace/filename.d.ts.map +1 -1
- package/dist/workspace/filename.js +30 -0
- package/dist/workspace/filename.js.map +1 -1
- package/dist/workspace/frontmatter-carriers.d.ts +44 -0
- package/dist/workspace/frontmatter-carriers.d.ts.map +1 -0
- package/dist/workspace/frontmatter-carriers.js +52 -0
- package/dist/workspace/frontmatter-carriers.js.map +1 -0
- package/dist/workspace/frontmatter.d.ts +23 -4
- package/dist/workspace/frontmatter.d.ts.map +1 -1
- package/dist/workspace/frontmatter.js +59 -9
- package/dist/workspace/frontmatter.js.map +1 -1
- package/dist/workspace/kb-layout.d.ts +226 -19
- package/dist/workspace/kb-layout.d.ts.map +1 -1
- package/dist/workspace/kb-layout.js +353 -23
- package/dist/workspace/kb-layout.js.map +1 -1
- package/dist/workspace/placeholder.d.ts +21 -0
- package/dist/workspace/placeholder.d.ts.map +1 -0
- package/dist/workspace/placeholder.js +28 -0
- package/dist/workspace/placeholder.js.map +1 -0
- package/dist/workspace/platform-files.d.ts +105 -0
- package/dist/workspace/platform-files.d.ts.map +1 -0
- package/dist/workspace/platform-files.js +147 -0
- package/dist/workspace/platform-files.js.map +1 -0
- package/dist/workspace/types.d.ts +8 -0
- package/dist/workspace/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/auth/types.ts +12 -0
- package/src/git/pr.types.ts +77 -11
- package/src/git/types.ts +35 -1
- package/src/index.ts +6 -0
- package/src/workflow/events.ts +33 -3
- package/src/workflow/interface.ts +127 -4
- package/src/workflow/types.ts +43 -0
- package/src/workspace/access-verbs.ts +124 -0
- package/src/workspace/agent-preamble.ts +47 -0
- package/src/workspace/entry-exists.ts +36 -0
- package/src/workspace/filename.ts +31 -0
- package/src/workspace/frontmatter-carriers.ts +57 -0
- package/src/workspace/frontmatter.ts +57 -8
- package/src/workspace/kb-layout.ts +388 -25
- package/src/workspace/placeholder.ts +29 -0
- package/src/workspace/platform-files.ts +188 -0
- package/src/workspace/types.ts +8 -0
|
@@ -1,15 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE fence rule: a line is a frontmatter fence when, whitespace aside, it is
|
|
3
|
+
* exactly `---`. Forgiving on purpose — an opening fence with a trailing space
|
|
4
|
+
* or an indented fence is still a fence.
|
|
5
|
+
*
|
|
6
|
+
* Every reader in the platform asks this one function. The access model's
|
|
7
|
+
* line scan always judged fences this way while the splitter below demanded
|
|
8
|
+
* `---` at column 0, so a file written with a near-miss fence had access
|
|
9
|
+
* rules that applied while the catalog, the tool manuals and the frontmatter
|
|
10
|
+
* panel saw no frontmatter at all. One rule, asked everywhere, is what keeps
|
|
11
|
+
* a file from meaning two things.
|
|
12
|
+
*/
|
|
13
|
+
export function isFrontmatterFence(line) {
|
|
14
|
+
return line?.trim() === '---';
|
|
15
|
+
}
|
|
1
16
|
/**
|
|
2
17
|
* The ONE `---` frontmatter splitter, shared by backend and frontend so no file
|
|
3
|
-
* type grows its own
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
18
|
+
* type grows its own reader. Splits a leading fenced YAML block from the body;
|
|
19
|
+
* null when the first line is not a fence or no later line closes it. Fences
|
|
20
|
+
* are judged by {@link isFrontmatterFence}. Parsing the YAML inside is the
|
|
21
|
+
* caller's concern (the access model keeps its own line scan, on the same
|
|
22
|
+
* fence rule, because a splice must put bytes back exactly as it found them).
|
|
23
|
+
*
|
|
24
|
+
* `frontmatter` is the raw text between the fence lines and `body` the raw
|
|
25
|
+
* text after the closing fence's line break, both byte for byte — line
|
|
26
|
+
* endings included — so a caller that rebuilds the file changes nothing it
|
|
27
|
+
* did not mean to.
|
|
7
28
|
*/
|
|
8
29
|
export function extractFrontmatter(text) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
30
|
+
// Walk the lines by offset rather than splitting, so both halves can be
|
|
31
|
+
// sliced out of the original text with their own line endings intact.
|
|
32
|
+
let start = 0;
|
|
33
|
+
let lineIndex = 0;
|
|
34
|
+
let openEnd = -1; // offset just past the opening fence's line break
|
|
35
|
+
while (start <= text.length) {
|
|
36
|
+
const nl = text.indexOf('\n', start);
|
|
37
|
+
const end = nl === -1 ? text.length : nl;
|
|
38
|
+
const line = text.slice(start, end).replace(/\r$/, '');
|
|
39
|
+
const next = nl === -1 ? text.length + 1 : nl + 1;
|
|
40
|
+
if (lineIndex === 0) {
|
|
41
|
+
// A lone `---` with nothing after it opens nothing.
|
|
42
|
+
if (!isFrontmatterFence(line) || nl === -1)
|
|
43
|
+
return null;
|
|
44
|
+
openEnd = next;
|
|
45
|
+
}
|
|
46
|
+
else if (isFrontmatterFence(line)) {
|
|
47
|
+
// The frontmatter ends before the line break that precedes this fence.
|
|
48
|
+
const fmEnd = start - (start >= 2 && text[start - 2] === '\r' ? 2 : 1);
|
|
49
|
+
return {
|
|
50
|
+
frontmatter: fmEnd > openEnd ? text.slice(openEnd, fmEnd) : '',
|
|
51
|
+
body: next > text.length ? '' : text.slice(next),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (nl === -1)
|
|
55
|
+
return null; // never closed
|
|
56
|
+
start = next;
|
|
57
|
+
lineIndex += 1;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
13
60
|
}
|
|
14
61
|
/**
|
|
15
62
|
* Set a top-level scalar key in a file's `---` frontmatter, LINE-based: replace an
|
|
@@ -37,7 +84,10 @@ export function setFrontmatterField(text, key, value) {
|
|
|
37
84
|
// No frontmatter — prepend a fresh block, keeping the original body intact.
|
|
38
85
|
return `---${eol}${line}${eol}---${eol}${text}`;
|
|
39
86
|
}
|
|
40
|
-
|
|
87
|
+
// An empty block has no lines, not one empty line: splitting '' would give
|
|
88
|
+
// [''], and the inserted key would be followed by a blank line before the
|
|
89
|
+
// closing fence.
|
|
90
|
+
const fmLines = fm.frontmatter === '' ? [] : fm.frontmatter.split(/\r?\n/);
|
|
41
91
|
const idx = fmLines.findIndex((l) => keyRe.test(l));
|
|
42
92
|
if (idx >= 0)
|
|
43
93
|
fmLines[idx] = line;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../src/workspace/frontmatter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../src/workspace/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAwB;IACzD,OAAO,IAAI,EAAE,IAAI,EA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E;IAC1E,iBAAiB;IACjB,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3E,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,IAAI,GAAG,IAAI,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;;QAC7B,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -96,14 +96,133 @@ export declare let SKILLS_DIR: string;
|
|
|
96
96
|
* manifest's `name` field.
|
|
97
97
|
*/
|
|
98
98
|
export declare let PLUGINS_DIR: string;
|
|
99
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* The file name of the platform's MANAGED agent guide at the repository root —
|
|
101
|
+
* the document every connected agent is told to read first, written and
|
|
102
|
+
* refreshed from the packaged template on every start.
|
|
103
|
+
*
|
|
104
|
+
* Configurable for one reason: `AGENTS.md` is the name coding agents look for
|
|
105
|
+
* by convention, so a customer arriving with a repository of their own very
|
|
106
|
+
* often already HAS one, and under the default name the platform would
|
|
107
|
+
* overwrite it on the first boot and on every boot after. Renaming the managed
|
|
108
|
+
* guide (`HEXIS.md`, say) hands that name back: `AGENTS.md` becomes ordinary
|
|
109
|
+
* content the platform never writes, never refreshes and never hides, and the
|
|
110
|
+
* customer's file is the one that points at ours (see
|
|
111
|
+
* {@link agentsFilePointerSentence}).
|
|
112
|
+
*
|
|
113
|
+
* A live binding like the three roots above — read it inside a function body,
|
|
114
|
+
* never capture it at module scope.
|
|
115
|
+
*/
|
|
116
|
+
export declare let AGENTS_FILE: string;
|
|
117
|
+
/**
|
|
118
|
+
* The name the managed guide had when it was the only name it could have.
|
|
119
|
+
*
|
|
120
|
+
* Referenced ONLY by the code that has to tell OUR file from THEIRS — the
|
|
121
|
+
* boot-time removal of a platform-written `AGENTS.md`, the ignore rule that
|
|
122
|
+
* stops hiding it, the instruction telling an agent to read the customer's
|
|
123
|
+
* file too. In the spirit of {@link LEGACY_GROUPS_DIR}: a second live spelling
|
|
124
|
+
* of the CURRENT name is how two layouts start being supported by accident, so
|
|
125
|
+
* this one is a constant and means exactly one thing.
|
|
126
|
+
*/
|
|
127
|
+
export declare const LEGACY_AGENTS_FILE = "AGENTS.md";
|
|
128
|
+
/**
|
|
129
|
+
* The platform files whose names are FIXED — the ones no deployment renames.
|
|
130
|
+
* The guide is the fourth platform file and is deliberately absent here: its
|
|
131
|
+
* name is {@link AGENTS_FILE}, and `platform-files.ts` composes the two into
|
|
132
|
+
* the set every gate reads.
|
|
133
|
+
*
|
|
134
|
+
* It lives in this module rather than beside that composition because the
|
|
135
|
+
* LAYOUT has to validate against it (a guide may not be called `access.md`),
|
|
136
|
+
* and `platform-files.ts` already reads this module — the other direction
|
|
137
|
+
* would be a cycle.
|
|
138
|
+
*/
|
|
139
|
+
export declare const FIXED_PLATFORM_FILE_NAMES: readonly string[];
|
|
140
|
+
/**
|
|
141
|
+
* The three renameable roots and the guide's file name, as a deployment
|
|
142
|
+
* declares them and `/api/config` serves them.
|
|
143
|
+
*/
|
|
100
144
|
export interface KbLayout {
|
|
101
145
|
knowledgeBaseDir: string;
|
|
102
146
|
skillsDir: string;
|
|
103
147
|
pluginsDir: string;
|
|
148
|
+
/**
|
|
149
|
+
* The managed agent guide's file name. OPTIONAL, and deliberately: a layout
|
|
150
|
+
* that predates the setting — an older server's `/api/config` body, a saved
|
|
151
|
+
* deployment that never named one — carries three folders and no guide, and
|
|
152
|
+
* the right answer to that is the right answer to an unset field, which is
|
|
153
|
+
* `AGENTS.md`. Read it through {@link agentsFileOf} rather than directly, so
|
|
154
|
+
* "absent" and "the default" can never come to mean two different things.
|
|
155
|
+
*/
|
|
156
|
+
agentsFile?: string;
|
|
104
157
|
}
|
|
105
158
|
/** The layout a deployment gets when it names nothing. */
|
|
106
|
-
export declare const DEFAULT_KB_LAYOUT: Readonly<KbLayout
|
|
159
|
+
export declare const DEFAULT_KB_LAYOUT: Readonly<Required<KbLayout>>;
|
|
160
|
+
/** The guide's name in a layout, with the default standing in for an absent one. */
|
|
161
|
+
export declare function agentsFileOf(layout: KbLayout): string;
|
|
162
|
+
/**
|
|
163
|
+
* `name` as one literal gitignore pattern. The guide's name is the
|
|
164
|
+
* operator's, and the name rules admit characters gitignore reads as syntax:
|
|
165
|
+
* a leading `#` is a comment and a leading `!` a negation (the rule would
|
|
166
|
+
* silently hide nothing), `[`, `]`, `*` and `?` are globs, and a backslash is
|
|
167
|
+
* the escape itself. Each is escaped so the pattern names exactly the file.
|
|
168
|
+
*/
|
|
169
|
+
export declare function gitignoreLiteral(name: string): string;
|
|
170
|
+
/**
|
|
171
|
+
* The ONE sentence the platform offers to keep in a customer's own
|
|
172
|
+
* `AGENTS.md`, pointing at the managed guide beside it.
|
|
173
|
+
*
|
|
174
|
+
* Defined here, once, because two surfaces must produce the identical text:
|
|
175
|
+
* the deployment-settings field previews it before the admin consents, and the
|
|
176
|
+
* startup step appends it. A sentence written twice is a sentence that drifts,
|
|
177
|
+
* and a drifted one appends a SECOND copy to every customer file on the boot
|
|
178
|
+
* after the drift — which is the one thing this whole feature exists to stop.
|
|
179
|
+
*
|
|
180
|
+
* A guide name is a FILE NAME, not an identifier: everything `validateFilename`
|
|
181
|
+
* admits can appear in it — spaces, brackets, parentheses, `#`, `%` — and each
|
|
182
|
+
* of those means something in an inline link. So the link is BUILT rather than
|
|
183
|
+
* interpolated: the label backslash-escaped ({@link markdownLinkLabel}), the
|
|
184
|
+
* destination percent-encoded ({@link agentsFileLinkPath}). A name that only
|
|
185
|
+
* parenthesised would break the destination; `#` would turn the rest of the
|
|
186
|
+
* name into a URL fragment, and the link would point at the customer's own
|
|
187
|
+
* file.
|
|
188
|
+
*
|
|
189
|
+
* Neither spelling need match the name as it is on disk, so nothing may ask
|
|
190
|
+
* whether this sentence is present by searching for the RAW name — see
|
|
191
|
+
* {@link mentionsAgentsFile}, which is how the startup step asks.
|
|
192
|
+
*/
|
|
193
|
+
export declare function agentsFilePointerSentence(agentsFile?: string): string;
|
|
194
|
+
/**
|
|
195
|
+
* `text` with every pointer sentence THE PLATFORM WROTE aimed at `agentsFile`
|
|
196
|
+
* — or null when it holds none of ours.
|
|
197
|
+
*
|
|
198
|
+
* This is what a SECOND rename needs. The guide's name is a setting an admin
|
|
199
|
+
* may change again: a knowledge base whose `AGENTS.md` was given a sentence
|
|
200
|
+
* pointing at `HEXIS.md` and is then renamed to `GUIDE.md` must have that
|
|
201
|
+
* sentence aimed at the new file, not a second one appended beneath a first
|
|
202
|
+
* that now points at nothing. Asking only whether the NEW name is mentioned
|
|
203
|
+
* cannot see that — the old sentence does not mention it.
|
|
204
|
+
*
|
|
205
|
+
* Returning the text unchanged (rather than null) when the sentence is already
|
|
206
|
+
* right is deliberate: "ours and correct" and "not ours at all" are different
|
|
207
|
+
* answers, and only the caller knows that the second one means "consider
|
|
208
|
+
* appending".
|
|
209
|
+
*/
|
|
210
|
+
export declare function retargetAgentsFilePointer(text: string, agentsFile?: string): string | null;
|
|
211
|
+
/**
|
|
212
|
+
* Whether `text` already points at the guide — the ONE question the startup
|
|
213
|
+
* step asks before appending {@link agentsFilePointerSentence} to a customer's
|
|
214
|
+
* own `AGENTS.md`.
|
|
215
|
+
*
|
|
216
|
+
* The plain name is the answer that matters: a mention in the customer's own
|
|
217
|
+
* words, a heading, a link they wrote, all count, and the platform stays out
|
|
218
|
+
* of a file it does not own. The other two spellings are the platform's OWN,
|
|
219
|
+
* and they are here for idempotence: the sentence writes the name escaped in
|
|
220
|
+
* the label and encoded in the destination, so on a punctuated name the file
|
|
221
|
+
* the last boot wrote need not contain the raw name at all. Asking only for
|
|
222
|
+
* that one would append a second copy on the next boot, and a third on the
|
|
223
|
+
* one after — the exact failure this feature exists to prevent.
|
|
224
|
+
*/
|
|
225
|
+
export declare function mentionsAgentsFile(text: string, agentsFile?: string): boolean;
|
|
107
226
|
/**
|
|
108
227
|
* What is wrong with one root name, or null. A root is joined onto the repo
|
|
109
228
|
* root and onto `<dir>/.gitkeep`, so a separator or `..` would write outside
|
|
@@ -111,14 +230,60 @@ export declare const DEFAULT_KB_LAYOUT: Readonly<KbLayout>;
|
|
|
111
230
|
* treats dot-entries as bookkeeping; `.git` in any case would corrupt the clone.
|
|
112
231
|
*/
|
|
113
232
|
export declare function validateKbRootName(name: string): string | null;
|
|
233
|
+
/**
|
|
234
|
+
* What is wrong with the agent guide's file name, or null.
|
|
235
|
+
*
|
|
236
|
+
* The rules, and what each one is for:
|
|
237
|
+
*
|
|
238
|
+
* - ONE FILE NAME. The name is joined onto the repository root and read from
|
|
239
|
+
* there and nowhere else, so a separator would name a file the platform
|
|
240
|
+
* would write but never read back.
|
|
241
|
+
* - A MARKDOWN NAME. The guide is a markdown document that people open in the
|
|
242
|
+
* app and agents read as text; `.md` is also what the per-file access rules
|
|
243
|
+
* apply to, so a guide under any other extension would take its folder's
|
|
244
|
+
* rules and stop being readable by everyone.
|
|
245
|
+
* - NOT `CLAUDE.md`. That is the guide's own pre-rename name; knowledge bases
|
|
246
|
+
* seeded before the rename still carry one, and it stays legacy content
|
|
247
|
+
* rather than becoming a second managed file.
|
|
248
|
+
* - NOT ANOTHER PLATFORM FILE. Two platform roles on one path means whichever
|
|
249
|
+
* writer runs last wins, silently.
|
|
250
|
+
* - NOT A ROOT FOLDER'S NAME, compared case-insensitively like the roots are
|
|
251
|
+
* to each other: the workspaces live on case-insensitive filesystems, where
|
|
252
|
+
* a file `Docs.md` and a folder `docs.md` are one entry.
|
|
253
|
+
*
|
|
254
|
+
* `roots` is the layout the name is judged against — the names this save would
|
|
255
|
+
* put in effect, not necessarily the ones running now.
|
|
256
|
+
*/
|
|
257
|
+
export declare function validateAgentsFileName(name: string, roots?: Pick<KbLayout, 'knowledgeBaseDir' | 'skillsDir' | 'pluginsDir'>): string | null;
|
|
114
258
|
/**
|
|
115
259
|
* What is wrong with a layout, or null — the same rule {@link configureKbLayout}
|
|
116
260
|
* enforces, without applying anything. Separate so the setup screen can judge a
|
|
117
|
-
* proposed layout before it is saved. The three names must differ,
|
|
118
|
-
* case-insensitively: the workspaces live on case-insensitive
|
|
119
|
-
* where `Skills` and `skills` are one folder.
|
|
261
|
+
* proposed layout before it is saved. The three folder names must differ,
|
|
262
|
+
* compared case-insensitively: the workspaces live on case-insensitive
|
|
263
|
+
* filesystems too, where `Skills` and `skills` are one folder. The guide's
|
|
264
|
+
* file name is judged against all three by the same rule (see
|
|
265
|
+
* {@link validateAgentsFileName}), which makes the four names distinct.
|
|
120
266
|
*/
|
|
121
267
|
export declare function validateKbLayout(layout: KbLayout): string | null;
|
|
268
|
+
/**
|
|
269
|
+
* Be told when {@link configureKbLayout} runs — for the few things that cannot
|
|
270
|
+
* read a live binding at the moment they are used.
|
|
271
|
+
*
|
|
272
|
+
* Almost nothing needs this: the roots and the guide's name are `let` bindings
|
|
273
|
+
* read inside function bodies, so code that follows the rule follows the
|
|
274
|
+
* layout for free. The exception is a value BUILT ONCE and handed to something
|
|
275
|
+
* that keeps it — the tool catalog's descriptions, which are validated into
|
|
276
|
+
* frozen-ish defs at registration and then served to agents from a map. Boot
|
|
277
|
+
* applies the layout before they are built, but the save that completes
|
|
278
|
+
* FIRST-RUN SETUP applies it afterwards (see `setup.routes.ts`, which must, so
|
|
279
|
+
* the KB phase that runs in the same request scaffolds the names the admin
|
|
280
|
+
* just chose) — and without this the catalog would go on naming `AGENTS.md`
|
|
281
|
+
* until someone restarted the server.
|
|
282
|
+
*
|
|
283
|
+
* Listeners run in registration order, after the bindings are updated and only
|
|
284
|
+
* when the layout was accepted.
|
|
285
|
+
*/
|
|
286
|
+
export declare function onKbLayoutApplied(listener: () => void): void;
|
|
122
287
|
/**
|
|
123
288
|
* Apply the layout. Called once during boot on each side; throws on an invalid
|
|
124
289
|
* one so a bad deployment setting fails beside the rest of the wiring rather
|
|
@@ -126,14 +291,24 @@ export declare function validateKbLayout(layout: KbLayout): string | null;
|
|
|
126
291
|
*/
|
|
127
292
|
export declare function configureKbLayout(layout: KbLayout): void;
|
|
128
293
|
/** The layout currently in effect. */
|
|
129
|
-
export declare function currentKbLayout(): KbLayout
|
|
294
|
+
export declare function currentKbLayout(): Required<KbLayout>;
|
|
295
|
+
/**
|
|
296
|
+
* Whether a layout — the one in effect, unless one is given — is the default
|
|
297
|
+
* one. The setup-completing save applies the stored names while this holds,
|
|
298
|
+
* the same "only from none to some" rule the branch model follows — and also
|
|
299
|
+
* on a retry after its own failed initialization run, when the process holds
|
|
300
|
+
* names setup applied but the app never opened (see `setup.routes.ts`). A
|
|
301
|
+
* layout the process booted with is never replaced here.
|
|
302
|
+
*/
|
|
303
|
+
export declare function isDefaultKbLayout(layout?: KbLayout): boolean;
|
|
130
304
|
/**
|
|
131
305
|
* Render the layout placeholders a managed template carries —
|
|
132
|
-
* `{{knowledgeBaseDir}}`, `{{skillsDir}}`, `{{pluginsDir}}`
|
|
133
|
-
* names in effect. The packaged
|
|
134
|
-
* this way so a deployment that renamed its roots hands the agent a
|
|
135
|
-
* that names the folders it will actually find
|
|
136
|
-
*
|
|
306
|
+
* `{{knowledgeBaseDir}}`, `{{skillsDir}}`, `{{pluginsDir}}`, `{{agentsFile}}`
|
|
307
|
+
* — with the names in effect. The packaged guide and `.bevelignore` are
|
|
308
|
+
* written this way so a deployment that renamed its roots hands the agent a
|
|
309
|
+
* guide that names the folders it will actually find, and a deployment that
|
|
310
|
+
* renamed the guide gets a guide naming the file it lives in. Text without
|
|
311
|
+
* placeholders passes through unchanged.
|
|
137
312
|
*/
|
|
138
313
|
export declare function renderKbLayoutPlaceholders(text: string, layout?: KbLayout): string;
|
|
139
314
|
/**
|
|
@@ -232,17 +407,39 @@ export declare function pluginIdentityOf(manifest: Record<string, unknown> | nul
|
|
|
232
407
|
/**
|
|
233
408
|
* What a person sees the plugin called: the manifest's `displayName` (the
|
|
234
409
|
* vendor field Claude Code shows in its picker; any casing, spaces allowed),
|
|
235
|
-
* else the
|
|
236
|
-
*
|
|
410
|
+
* else the manifest's `name`.
|
|
411
|
+
*
|
|
412
|
+
* THE MANIFEST IS THE ONLY SOURCE — there is no folder argument, on purpose.
|
|
413
|
+
* The folder's spelling used to stand in here, which made where a plugin
|
|
414
|
+
* happens to live a hidden input to what everyone sees it called: the API
|
|
415
|
+
* always answered with a display name while the file sometimes omitted the
|
|
416
|
+
* field, and moving or re-casing a folder silently renamed the plugin. Every
|
|
417
|
+
* write path now persists the field (see {@link renderPluginManifest} and
|
|
418
|
+
* the rename service), and one startup step backfilled the folder's spelling
|
|
419
|
+
* into the manifests written before that, so nothing renames itself.
|
|
420
|
+
*
|
|
421
|
+
* Empty only for a manifest that names nothing at all — the shape discovery
|
|
422
|
+
* already warns about and stands the folder in as the IDENTITY for; its
|
|
423
|
+
* display name then follows that identity, never the folder directly.
|
|
237
424
|
*/
|
|
238
|
-
export declare function pluginDisplayNameOf(manifest: Record<string, unknown> | null
|
|
425
|
+
export declare function pluginDisplayNameOf(manifest: Record<string, unknown> | null): string;
|
|
239
426
|
/**
|
|
240
427
|
* A minimal, valid `plugin.json` for a plugin folder: the identifier the
|
|
241
|
-
* folder name folds into, and
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
428
|
+
* folder name folds into, and the name a person sees it by — `displayName`,
|
|
429
|
+
* ALWAYS written, so a client's picker shows "Sales Team" for `sales-team`
|
|
430
|
+
* and every reader has the one field to read.
|
|
431
|
+
*
|
|
432
|
+
* ONE argument, deliberately: `folderName` is the folder's own leaf, and on
|
|
433
|
+
* the creation path that leaf IS the name its creator typed, trimmed — the
|
|
434
|
+
* dialog's route and the `create_plugin` tool make the folder out of the
|
|
435
|
+
* typed name and hand the same string to both. A second `displayName`
|
|
436
|
+
* parameter would be a way for the two to disagree that no caller needs.
|
|
437
|
+
* The field is written even when it equals the identifier: a manifest that
|
|
438
|
+
* omits it when the two agree is a manifest whose readers need a second rule.
|
|
439
|
+
*
|
|
440
|
+
* Nothing else: `version`, `license` and the rest are metadata about a
|
|
441
|
+
* DISTRIBUTED package, and inventing values for a folder someone just made
|
|
442
|
+
* in the app would be asserting things nobody said.
|
|
246
443
|
*/
|
|
247
444
|
export declare function renderPluginManifest(folderName: string): string;
|
|
248
445
|
/**
|
|
@@ -312,6 +509,16 @@ export declare function ontologyRoots(): readonly string[];
|
|
|
312
509
|
* renders as its own sections rather than folding into Knowledge.
|
|
313
510
|
*/
|
|
314
511
|
export declare function reservedRootDirNames(): ReadonlySet<string>;
|
|
512
|
+
/**
|
|
513
|
+
* The roots anyone may start a new folder in — knowledge, skills and plugins
|
|
514
|
+
* — whatever the root's own `access.md` grants them. Everywhere else a change
|
|
515
|
+
* needs read access to where it lands (the "read before write" rule); a new
|
|
516
|
+
* folder directly under one of these three is the one place that rule does
|
|
517
|
+
* not apply, because the new folder carries its creator's own grant. A
|
|
518
|
+
* function, like {@link reservedRootDirNames}, because the names are
|
|
519
|
+
* configurable.
|
|
520
|
+
*/
|
|
521
|
+
export declare function creatableRootDirNames(): ReadonlySet<string>;
|
|
315
522
|
/** The `Knowledge/` marker subfolder of an ontology (holds the graph nodes). */
|
|
316
523
|
export declare const KNOWLEDGE_DIR = "Knowledge";
|
|
317
524
|
/** The `NodeTypes/` marker subfolder of an ontology (holds the type definitions). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kb-layout.d.ts","sourceRoot":"","sources":["../../src/workspace/kb-layout.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kb-layout.d.ts","sourceRoot":"","sources":["../../src/workspace/kb-layout.ts"],"names":[],"mappings":"A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