@brunosouzas/stackledger 0.0.0-stage → 0.4.1
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/LICENSE +202 -0
- package/README.md +260 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +97 -0
- package/dist/cli.js.map +1 -0
- package/dist/control.d.ts +2 -0
- package/dist/control.js +22 -0
- package/dist/control.js.map +1 -0
- package/dist/discover-command.d.ts +7 -0
- package/dist/discover-command.js +60 -0
- package/dist/discover-command.js.map +1 -0
- package/dist/discovery/annotations.d.ts +24 -0
- package/dist/discovery/annotations.js +37 -0
- package/dist/discovery/annotations.js.map +1 -0
- package/dist/discovery/host.d.ts +47 -0
- package/dist/discovery/host.js +56 -0
- package/dist/discovery/host.js.map +1 -0
- package/dist/discovery/index.d.ts +15 -0
- package/dist/discovery/index.js +30 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/discovery/machine.d.ts +14 -0
- package/dist/discovery/machine.js +17 -0
- package/dist/discovery/machine.js.map +1 -0
- package/dist/discovery/run.d.ts +39 -0
- package/dist/discovery/run.js +130 -0
- package/dist/discovery/run.js.map +1 -0
- package/dist/discovery/snapshot.d.ts +60 -0
- package/dist/discovery/snapshot.js +161 -0
- package/dist/discovery/snapshot.js.map +1 -0
- package/dist/discovery/sources/apps.d.ts +3 -0
- package/dist/discovery/sources/apps.js +136 -0
- package/dist/discovery/sources/apps.js.map +1 -0
- package/dist/discovery/sources/brew.d.ts +15 -0
- package/dist/discovery/sources/brew.js +69 -0
- package/dist/discovery/sources/brew.js.map +1 -0
- package/dist/discovery/sources/common.d.ts +39 -0
- package/dist/discovery/sources/common.js +70 -0
- package/dist/discovery/sources/common.js.map +1 -0
- package/dist/discovery/sources/index.d.ts +8 -0
- package/dist/discovery/sources/index.js +12 -0
- package/dist/discovery/sources/index.js.map +1 -0
- package/dist/discovery/sources/launchd.d.ts +3 -0
- package/dist/discovery/sources/launchd.js +65 -0
- package/dist/discovery/sources/launchd.js.map +1 -0
- package/dist/discovery/sources/mas.d.ts +9 -0
- package/dist/discovery/sources/mas.js +25 -0
- package/dist/discovery/sources/mas.js.map +1 -0
- package/dist/discovery/sources/mise.d.ts +5 -0
- package/dist/discovery/sources/mise.js +64 -0
- package/dist/discovery/sources/mise.js.map +1 -0
- package/dist/discovery/sources/npm.d.ts +12 -0
- package/dist/discovery/sources/npm.js +34 -0
- package/dist/discovery/sources/npm.js.map +1 -0
- package/dist/discovery/sources/pipx.d.ts +4 -0
- package/dist/discovery/sources/pipx.js +82 -0
- package/dist/discovery/sources/pipx.js.map +1 -0
- package/dist/discovery/types.d.ts +73 -0
- package/dist/discovery/types.js +10 -0
- package/dist/discovery/types.js.map +1 -0
- package/dist/discovery/write.d.ts +50 -0
- package/dist/discovery/write.js +196 -0
- package/dist/discovery/write.js.map +1 -0
- package/dist/drift-command.d.ts +62 -0
- package/dist/drift-command.js +375 -0
- package/dist/drift-command.js.map +1 -0
- package/dist/drift-formats.d.ts +3 -0
- package/dist/drift-formats.js +54 -0
- package/dist/drift-formats.js.map +1 -0
- package/dist/drift.d.ts +95 -0
- package/dist/drift.js +206 -0
- package/dist/drift.js.map +1 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.js +26 -0
- package/dist/errors.js.map +1 -0
- package/dist/graph.d.ts +103 -0
- package/dist/graph.js +181 -0
- package/dist/graph.js.map +1 -0
- package/dist/ics.d.ts +18 -0
- package/dist/ics.js +103 -0
- package/dist/ics.js.map +1 -0
- package/dist/identity.d.ts +18 -0
- package/dist/identity.js +36 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/map/badges.d.ts +20 -0
- package/dist/map/badges.js +95 -0
- package/dist/map/badges.js.map +1 -0
- package/dist/map/command.d.ts +8 -0
- package/dist/map/command.js +86 -0
- package/dist/map/command.js.map +1 -0
- package/dist/map/heap.d.ts +15 -0
- package/dist/map/heap.js +57 -0
- package/dist/map/heap.js.map +1 -0
- package/dist/map/ink.d.ts +11 -0
- package/dist/map/ink.js +10 -0
- package/dist/map/ink.js.map +1 -0
- package/dist/map/labels.d.ts +43 -0
- package/dist/map/labels.js +172 -0
- package/dist/map/labels.js.map +1 -0
- package/dist/map/layout.d.ts +59 -0
- package/dist/map/layout.js +197 -0
- package/dist/map/layout.js.map +1 -0
- package/dist/map/model.d.ts +46 -0
- package/dist/map/model.js +84 -0
- package/dist/map/model.js.map +1 -0
- package/dist/map/neighbourhood.d.ts +18 -0
- package/dist/map/neighbourhood.js +138 -0
- package/dist/map/neighbourhood.js.map +1 -0
- package/dist/map/parallel.d.ts +21 -0
- package/dist/map/parallel.js +174 -0
- package/dist/map/parallel.js.map +1 -0
- package/dist/map/relations.d.ts +39 -0
- package/dist/map/relations.js +127 -0
- package/dist/map/relations.js.map +1 -0
- package/dist/map/route.d.ts +25 -0
- package/dist/map/route.js +165 -0
- package/dist/map/route.js.map +1 -0
- package/dist/map/strip.d.ts +29 -0
- package/dist/map/strip.js +122 -0
- package/dist/map/strip.js.map +1 -0
- package/dist/map/suggest.d.ts +21 -0
- package/dist/map/suggest.js +97 -0
- package/dist/map/suggest.js.map +1 -0
- package/dist/map/svg.d.ts +22 -0
- package/dist/map/svg.js +232 -0
- package/dist/map/svg.js.map +1 -0
- package/dist/map/themes.d.ts +61 -0
- package/dist/map/themes.js +78 -0
- package/dist/map/themes.js.map +1 -0
- package/dist/map/xml.d.ts +8 -0
- package/dist/map/xml.js +68 -0
- package/dist/map/xml.js.map +1 -0
- package/dist/map/zones.d.ts +19 -0
- package/dist/map/zones.js +46 -0
- package/dist/map/zones.js.map +1 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +145 -0
- package/dist/mcp.js.map +1 -0
- package/dist/money.d.ts +32 -0
- package/dist/money.js +91 -0
- package/dist/money.js.map +1 -0
- package/dist/report-command.d.ts +3 -0
- package/dist/report-command.js +85 -0
- package/dist/report-command.js.map +1 -0
- package/dist/report-formats.d.ts +11 -0
- package/dist/report-formats.js +157 -0
- package/dist/report-formats.js.map +1 -0
- package/dist/reports.d.ts +105 -0
- package/dist/reports.js +247 -0
- package/dist/reports.js.map +1 -0
- package/dist/scaffold.d.ts +30 -0
- package/dist/scaffold.js +140 -0
- package/dist/scaffold.js.map +1 -0
- package/dist/schema.d.ts +330 -0
- package/dist/schema.js +116 -0
- package/dist/schema.js.map +1 -0
- package/dist/secrets.d.ts +7 -0
- package/dist/secrets.js +68 -0
- package/dist/secrets.js.map +1 -0
- package/dist/site/build.d.ts +22 -0
- package/dist/site/build.js +196 -0
- package/dist/site/build.js.map +1 -0
- package/dist/site/command.d.ts +2 -0
- package/dist/site/command.js +221 -0
- package/dist/site/command.js.map +1 -0
- package/dist/site/data.d.ts +205 -0
- package/dist/site/data.js +241 -0
- package/dist/site/data.js.map +1 -0
- package/dist/site/fs-ops.d.ts +35 -0
- package/dist/site/fs-ops.js +26 -0
- package/dist/site/fs-ops.js.map +1 -0
- package/dist/site/owners.d.ts +5 -0
- package/dist/site/owners.js +50 -0
- package/dist/site/owners.js.map +1 -0
- package/dist/site/paths.d.ts +34 -0
- package/dist/site/paths.js +48 -0
- package/dist/site/paths.js.map +1 -0
- package/dist/site/policy.d.ts +17 -0
- package/dist/site/policy.js +26 -0
- package/dist/site/policy.js.map +1 -0
- package/dist/site/publish.d.ts +14 -0
- package/dist/site/publish.js +90 -0
- package/dist/site/publish.js.map +1 -0
- package/dist/site/relative.d.ts +14 -0
- package/dist/site/relative.js +265 -0
- package/dist/site/relative.js.map +1 -0
- package/dist/site/skills-build.d.ts +22 -0
- package/dist/site/skills-build.js +126 -0
- package/dist/site/skills-build.js.map +1 -0
- package/dist/site/skills-data.d.ts +89 -0
- package/dist/site/skills-data.js +94 -0
- package/dist/site/skills-data.js.map +1 -0
- package/dist/site/staging.d.ts +19 -0
- package/dist/site/staging.js +76 -0
- package/dist/site/staging.js.map +1 -0
- package/dist/skills/command.d.ts +8 -0
- package/dist/skills/command.js +64 -0
- package/dist/skills/command.js.map +1 -0
- package/dist/skills/frontmatter.d.ts +37 -0
- package/dist/skills/frontmatter.js +219 -0
- package/dist/skills/frontmatter.js.map +1 -0
- package/dist/skills/graph.d.ts +39 -0
- package/dist/skills/graph.js +100 -0
- package/dist/skills/graph.js.map +1 -0
- package/dist/skills/ignore.d.ts +34 -0
- package/dist/skills/ignore.js +138 -0
- package/dist/skills/ignore.js.map +1 -0
- package/dist/skills/lines.d.ts +53 -0
- package/dist/skills/lines.js +221 -0
- package/dist/skills/lines.js.map +1 -0
- package/dist/skills/map-command.d.ts +28 -0
- package/dist/skills/map-command.js +533 -0
- package/dist/skills/map-command.js.map +1 -0
- package/dist/skills/mermaid.d.ts +29 -0
- package/dist/skills/mermaid.js +261 -0
- package/dist/skills/mermaid.js.map +1 -0
- package/dist/skills/metro.d.ts +8 -0
- package/dist/skills/metro.js +93 -0
- package/dist/skills/metro.js.map +1 -0
- package/dist/skills/read.d.ts +17 -0
- package/dist/skills/read.js +54 -0
- package/dist/skills/read.js.map +1 -0
- package/dist/skills/rules.d.ts +28 -0
- package/dist/skills/rules.js +57 -0
- package/dist/skills/rules.js.map +1 -0
- package/dist/skills/source.d.ts +66 -0
- package/dist/skills/source.js +281 -0
- package/dist/skills/source.js.map +1 -0
- package/dist/skills/walk.d.ts +64 -0
- package/dist/skills/walk.js +281 -0
- package/dist/skills/walk.js.map +1 -0
- package/dist/source.d.ts +40 -0
- package/dist/source.js +199 -0
- package/dist/source.js.map +1 -0
- package/dist/stdout.d.ts +2 -0
- package/dist/stdout.js +24 -0
- package/dist/stdout.js.map +1 -0
- package/dist/validate.d.ts +45 -0
- package/dist/validate.js +321 -0
- package/dist/validate.js.map +1 -0
- package/dist/views.d.ts +25 -0
- package/dist/views.js +58 -0
- package/dist/views.js.map +1 -0
- package/examples/catalogue-repository/.github/workflows/stackledger.yml +122 -0
- package/examples/catalogue-repository/README.md +96 -0
- package/examples/catalogue-repository/catalog/catalog-info.yaml +12 -0
- package/examples/hosting/Caddyfile +69 -0
- package/examples/northwind/catalog-info.yaml +680 -0
- package/examples/northwind/stackledger.yaml +16 -0
- package/examples/northwind-machine/snapshot.json +309 -0
- package/examples/northwind-skills/agents/builder.md +10 -0
- package/examples/northwind-skills/agents/reviewer.md +10 -0
- package/examples/northwind-skills/designer/SKILL.md +8 -0
- package/examples/northwind-skills/editor/SKILL.md +8 -0
- package/examples/northwind-skills/engineering/SKILL.md +12 -0
- package/examples/northwind-skills/linter/SKILL.md +8 -0
- package/examples/northwind-skills/linter/rules.md +5 -0
- package/examples/northwind-skills/publishing/SKILL.md +12 -0
- package/examples/northwind-skills/publishing/rules.md +5 -0
- package/examples/northwind-skills/spec-writer/SKILL.md +8 -0
- package/examples/northwind-skills/stackledger-skills.yaml +51 -0
- package/examples/northwind-skills/tester/SKILL.md +10 -0
- package/examples/northwind-skills/writer/SKILL.md +8 -0
- package/examples/northwind-skills/writer/rules.md +6 -0
- package/npm-shrinkwrap.json +4995 -0
- package/package.json +51 -4
- package/site/LICENSE-astroplate +21 -0
- package/site/README.md +18 -0
- package/site/package.json +6 -0
- package/site/public/favicon.svg +1 -0
- package/site/src/components/Footer.astro +25 -0
- package/site/src/components/Header.astro +35 -0
- package/site/src/components/Impact.astro +55 -0
- package/site/src/components/LinkOrText.astro +12 -0
- package/site/src/components/SkillItem.astro +141 -0
- package/site/src/components/SubNav.astro +40 -0
- package/site/src/components/ThemeSwitch.astro +16 -0
- package/site/src/components/Themed.astro +14 -0
- package/site/src/layouts/Base.astro +52 -0
- package/site/src/lib/site.ts +25 -0
- package/site/src/pages/[reports].astro +222 -0
- package/site/src/pages/agents/[file].astro +14 -0
- package/site/src/pages/index.astro +71 -0
- package/site/src/pages/journeys/[name].astro +50 -0
- package/site/src/pages/journeys/index.astro +37 -0
- package/site/src/pages/licences/[name].astro +56 -0
- package/site/src/pages/map/index.astro +78 -0
- package/site/src/pages/playbooks/[file].astro +14 -0
- package/site/src/pages/rules/[...rules].astro +61 -0
- package/site/src/pages/skill-map/[...map].astro +101 -0
- package/site/src/pages/skills/[...list].astro +75 -0
- package/site/src/pages/skills/[file].astro +14 -0
- package/site/src/pages/software/[name].astro +155 -0
- package/site/src/pages/software/index.astro +71 -0
- package/site/src/scripts/diagram.ts +8 -0
- package/site/src/scripts/links.ts +31 -0
- package/site/src/scripts/map.ts +133 -0
- package/site/src/scripts/software.ts +32 -0
- package/site/src/scripts/theme.ts +52 -0
- package/site/src/styles/base.css +470 -0
- package/site/src/styles/fonts.css +60 -0
- package/site/src/styles/override.css +1 -0
- package/site/src/styles/pages.css +299 -0
- package/site/src/styles/tokens.css +71 -0
- package/skills/stackledger/SKILL.md +155 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../src/skills/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAA4B,MAAM,MAAM,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAA6C,MAAM,cAAc,CAAC;AAE1H,MAAM,eAAe,GAAG,QAAQ,CAAC;AACjC,MAAM,UAAU,GAAG,KAAK,CAAC;AACzB,8DAA8D;AAC9D,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;AACvH,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AACzC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAC1C,MAAM,eAAe,GAAG,cAAc,CAAC;AACvC,MAAM,CAAC,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AAC3C,MAAM,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AAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;QAC9E,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,sCAAsC,EAAE,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IACtH,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAkB,EAAE,CAAC;AACxD,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { SkillSet, SourceFile } from './source.js';
|
|
2
|
+
export type NodeKind = 'skill' | 'playbook' | 'agent';
|
|
3
|
+
export type RelationKind = 'loads' | 'uses' | 'preloads';
|
|
4
|
+
export interface MapNode {
|
|
5
|
+
/** Unique within the graph: kind and name. */
|
|
6
|
+
key: string;
|
|
7
|
+
kind: NodeKind;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
/** Rule IDs in file order (skills and playbooks; none for agents). */
|
|
11
|
+
rules: string[];
|
|
12
|
+
files: SourceFile[];
|
|
13
|
+
}
|
|
14
|
+
export interface MapEdge {
|
|
15
|
+
from: MapNode;
|
|
16
|
+
kind: RelationKind;
|
|
17
|
+
to: MapNode;
|
|
18
|
+
}
|
|
19
|
+
export interface SkillGraph {
|
|
20
|
+
/** By kind, then name. */
|
|
21
|
+
nodes: MapNode[];
|
|
22
|
+
/** By source node, relation kind, then target node. */
|
|
23
|
+
edges: MapEdge[];
|
|
24
|
+
}
|
|
25
|
+
/** Diagram order: kind (skill, playbook, agent), then name by code point. */
|
|
26
|
+
export declare function compareNodes(left: MapNode, right: MapNode): number;
|
|
27
|
+
/** List and table order: name by code point, then kind. */
|
|
28
|
+
export declare function compareListed(left: MapNode, right: MapNode): number;
|
|
29
|
+
export declare function compareEdges(left: MapEdge, right: MapEdge): number;
|
|
30
|
+
/** The graph of a skill set's declared relations. */
|
|
31
|
+
export declare function buildGraph(set: Pick<SkillSet, 'skills' | 'agents'>): SkillGraph;
|
|
32
|
+
/** The relations that bring `node` in, in list order (name of the other item, then kind). */
|
|
33
|
+
export declare function incoming(graph: SkillGraph, node: MapNode): MapEdge[];
|
|
34
|
+
/** The relations `node` brings in, in list order. */
|
|
35
|
+
export declare function outgoing(graph: SkillGraph, node: MapNode): MapEdge[];
|
|
36
|
+
/** "Reached through": the items that bring `node` in only through two or more relations, in list order.
|
|
37
|
+
* A breadth-first walk over incoming edges visits each item once at its shortest distance, so cycles
|
|
38
|
+
* end; the item itself and what brings it in directly are not listed. */
|
|
39
|
+
export declare function reachedThrough(graph: SkillGraph, node: MapNode): MapNode[];
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/** The declared relations of a skill set as a graph (skills-map-command spec: Declared relations only,
|
|
2
|
+
* Order of relations, Item page's "Reached through"). Used by src/skills/mermaid.ts; `skills-site` is
|
|
3
|
+
* meant to draw the same graph, so the Markdown map and the site cannot disagree. Pure: no I/O.
|
|
4
|
+
*
|
|
5
|
+
* Nodes are keyed by kind and name: skills and playbooks share one namespace (a skill set's skill
|
|
6
|
+
* names are unique across both), agents have their own, so a skill and an agent may share a name.
|
|
7
|
+
* Edges, each drawn once:
|
|
8
|
+
* - `loads`: a skill or playbook to each skill or playbook in its `stackledger-skills`;
|
|
9
|
+
* - `uses`: a skill or playbook to each agent in its `stackledger-agents`;
|
|
10
|
+
* - `preloads`: an agent to each skill or playbook in its `skills`.
|
|
11
|
+
* An edge to a name not in the set is dropped (`skills validate` reports it); a self-relation and
|
|
12
|
+
* cycles are kept. Nothing is ever guessed from the text of a file (ADR 10).
|
|
13
|
+
*/
|
|
14
|
+
import { compareText } from '../identity.js';
|
|
15
|
+
/** The fixed order of kinds (lists, tables and diagram nodes) and of relation kinds (diagram edges). */
|
|
16
|
+
const KIND_ORDER = { skill: 0, playbook: 1, agent: 2 };
|
|
17
|
+
const RELATION_ORDER = { loads: 0, uses: 1, preloads: 2 };
|
|
18
|
+
/** Diagram order: kind (skill, playbook, agent), then name by code point. */
|
|
19
|
+
export function compareNodes(left, right) {
|
|
20
|
+
return KIND_ORDER[left.kind] - KIND_ORDER[right.kind] || compareText(left.name, right.name);
|
|
21
|
+
}
|
|
22
|
+
/** List and table order: name by code point, then kind. */
|
|
23
|
+
export function compareListed(left, right) {
|
|
24
|
+
return compareText(left.name, right.name) || KIND_ORDER[left.kind] - KIND_ORDER[right.kind];
|
|
25
|
+
}
|
|
26
|
+
export function compareEdges(left, right) {
|
|
27
|
+
return compareNodes(left.from, right.from) || RELATION_ORDER[left.kind] - RELATION_ORDER[right.kind] || compareNodes(left.to, right.to);
|
|
28
|
+
}
|
|
29
|
+
// Keys are JSON arrays, never joined text: a YAML name can hold any character, a NUL or a quote
|
|
30
|
+
// included, and JSON escapes them, so two different tuples never give one key.
|
|
31
|
+
const keyOf = (kind, name) => JSON.stringify([kind, name]);
|
|
32
|
+
/** The graph of a skill set's declared relations. */
|
|
33
|
+
export function buildGraph(set) {
|
|
34
|
+
const nodes = [];
|
|
35
|
+
const skillsByName = new Map(), agentsByName = new Map();
|
|
36
|
+
for (const skill of set.skills) {
|
|
37
|
+
const node = { key: keyOf(skill.kind, skill.name), kind: skill.kind, name: skill.name, description: skill.description,
|
|
38
|
+
rules: skill.rules.map(rule => rule.id), files: skill.files };
|
|
39
|
+
nodes.push(node);
|
|
40
|
+
skillsByName.set(skill.name, node);
|
|
41
|
+
}
|
|
42
|
+
for (const agent of set.agents) {
|
|
43
|
+
const node = { key: keyOf('agent', agent.name), kind: 'agent', name: agent.name, description: agent.description, rules: [], files: agent.files };
|
|
44
|
+
nodes.push(node);
|
|
45
|
+
agentsByName.set(agent.name, node);
|
|
46
|
+
}
|
|
47
|
+
const edges = [];
|
|
48
|
+
const seen = new Set();
|
|
49
|
+
const add = (from, kind, to) => {
|
|
50
|
+
if (!to)
|
|
51
|
+
return;
|
|
52
|
+
const key = JSON.stringify([from.key, kind, to.key]);
|
|
53
|
+
if (seen.has(key))
|
|
54
|
+
return;
|
|
55
|
+
seen.add(key);
|
|
56
|
+
edges.push({ from, kind, to });
|
|
57
|
+
};
|
|
58
|
+
for (const skill of set.skills) {
|
|
59
|
+
const from = skillsByName.get(skill.name);
|
|
60
|
+
for (const name of skill.skills)
|
|
61
|
+
add(from, 'loads', skillsByName.get(name));
|
|
62
|
+
for (const name of skill.agents)
|
|
63
|
+
add(from, 'uses', agentsByName.get(name));
|
|
64
|
+
}
|
|
65
|
+
for (const agent of set.agents) {
|
|
66
|
+
const from = agentsByName.get(agent.name);
|
|
67
|
+
for (const name of agent.preloads)
|
|
68
|
+
add(from, 'preloads', skillsByName.get(name));
|
|
69
|
+
}
|
|
70
|
+
return { nodes: nodes.sort(compareNodes), edges: edges.sort(compareEdges) };
|
|
71
|
+
}
|
|
72
|
+
/** The relations that bring `node` in, in list order (name of the other item, then kind). */
|
|
73
|
+
export function incoming(graph, node) {
|
|
74
|
+
return graph.edges.filter(edge => edge.to === node).sort((left, right) => compareListed(left.from, right.from));
|
|
75
|
+
}
|
|
76
|
+
/** The relations `node` brings in, in list order. */
|
|
77
|
+
export function outgoing(graph, node) {
|
|
78
|
+
return graph.edges.filter(edge => edge.from === node).sort((left, right) => compareListed(left.to, right.to));
|
|
79
|
+
}
|
|
80
|
+
/** "Reached through": the items that bring `node` in only through two or more relations, in list order.
|
|
81
|
+
* A breadth-first walk over incoming edges visits each item once at its shortest distance, so cycles
|
|
82
|
+
* end; the item itself and what brings it in directly are not listed. */
|
|
83
|
+
export function reachedThrough(graph, node) {
|
|
84
|
+
const sources = new Map();
|
|
85
|
+
for (const edge of graph.edges)
|
|
86
|
+
sources.set(edge.to, [...(sources.get(edge.to) ?? []), edge.from]);
|
|
87
|
+
const distance = new Map([[node, 0]]);
|
|
88
|
+
const queue = [node];
|
|
89
|
+
while (queue.length) {
|
|
90
|
+
const current = queue.shift();
|
|
91
|
+
for (const source of sources.get(current) ?? []) {
|
|
92
|
+
if (distance.has(source))
|
|
93
|
+
continue;
|
|
94
|
+
distance.set(source, distance.get(current) + 1);
|
|
95
|
+
queue.push(source);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return [...distance].filter(([, steps]) => steps >= 2).map(([found]) => found).sort(compareListed);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/skills/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAK7C,wGAAwG;AACxG,MAAM,UAAU,GAA6B,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AACjF,MAAM,cAAc,GAAiC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;AAoBxF,6EAA6E;AAC7E,MAAM,UAAU,YAAY,CAAC,IAAa,EAAE,KAAc;IACxD,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;AAC9F,CAAC;AACD,2DAA2D;AAC3D,MAAM,UAAU,aAAa,CAAC,IAAa,EAAE,KAAc;IACzD,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,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|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Problem } from '../source.js';
|
|
2
|
+
export declare const IGNORE_FILE = ".stackledgerignore";
|
|
3
|
+
export declare const MAX_IGNORE_BYTES: number;
|
|
4
|
+
export declare const MAX_PATTERN_LINES = 100;
|
|
5
|
+
export declare const MAX_PATTERN_CHARACTERS = 200;
|
|
6
|
+
export declare const MAX_PATTERN_WILDCARDS = 16;
|
|
7
|
+
/** What the walk needs from a matcher: whether a path relative to the given folder is ignored. */
|
|
8
|
+
export interface Matcher {
|
|
9
|
+
ignores(path: string): boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Builds the matcher of one file's pattern lines; injectable so a test can make matching fail. */
|
|
12
|
+
export type CreateMatcher = (patterns: string[]) => Matcher;
|
|
13
|
+
export declare const createMatcher: CreateMatcher;
|
|
14
|
+
export type IgnoreFile = {
|
|
15
|
+
status: 'read';
|
|
16
|
+
matcher: Matcher;
|
|
17
|
+
}
|
|
18
|
+
/** `key` identifies the file (its target, or the entry itself when that cannot be resolved). */
|
|
19
|
+
| {
|
|
20
|
+
status: 'problem';
|
|
21
|
+
key: string;
|
|
22
|
+
problems: Problem[];
|
|
23
|
+
};
|
|
24
|
+
/** Read the ignore file of the given folder `folder` (absolute), known to hold an entry with that name;
|
|
25
|
+
* `path` is its display path. */
|
|
26
|
+
export declare function readIgnoreFile(folder: string, path: string, create?: CreateMatcher): Promise<IgnoreFile>;
|
|
27
|
+
/** The matcher failed after its file was read: a bug, so an internal failure. The message is fixed, because
|
|
28
|
+
* the matcher's own message can repeat a pattern or the tested path. */
|
|
29
|
+
export declare class IgnoreMatcherError extends Error {
|
|
30
|
+
name: string;
|
|
31
|
+
constructor();
|
|
32
|
+
}
|
|
33
|
+
/** Whether `matcher` ignores `path`, turning any exception into an IgnoreMatcherError. */
|
|
34
|
+
export declare function ignores(matcher: Matcher, path: string): boolean;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/** Read the `.stackledgerignore` file at the top of a given folder (skill-source spec: Ignore file,
|
|
2
|
+
* Ignore file syntax, Ignore file text, Ignore file limits, Ignore file problems). Used by
|
|
3
|
+
* src/skills/walk.ts, which tests entries against the matcher this returns. Only reads.
|
|
4
|
+
*
|
|
5
|
+
* Why it is shaped this way:
|
|
6
|
+
* - The patterns are `.gitignore` lines, matched by the `ignore` package (pinned at 7.0.13), which
|
|
7
|
+
* follows Git; writing our own matcher would get an edge case wrong and hide a skill silently.
|
|
8
|
+
* Matching is case-sensitive (`ignorecase: false`) so macOS and Linux give the same set.
|
|
9
|
+
* - The file is an input a fork's pull request can change, so its cost is bounded: 64 KiB, at most 100
|
|
10
|
+
* pattern lines, 200 characters and 16 wildcard characters per line. Each line is also compiled on
|
|
11
|
+
* its own when the file is read, so a line the matcher cannot handle is an error before any entry is
|
|
12
|
+
* tested. Measured worst case at these limits: about 1.3 s against 5,000 deep paths.
|
|
13
|
+
* - Any problem means no pattern of the file is used: reading too much is loud (the run shows the extra
|
|
14
|
+
* items' problems), hiding too much would be silent.
|
|
15
|
+
* - Messages are fixed texts naming at most a line number: the file's text never reaches the output.
|
|
16
|
+
*
|
|
17
|
+
* What can go wrong: a problem with the file is returned as problems on its display path, with the key
|
|
18
|
+
* (device and inode) that reports them once per run. Only a matcher that throws after the file was
|
|
19
|
+
* accepted throws, as IgnoreMatcherError, which the command reports as an internal failure.
|
|
20
|
+
*/
|
|
21
|
+
import { lstat, stat } from 'node:fs/promises';
|
|
22
|
+
import { join } from 'node:path';
|
|
23
|
+
import ignore from 'ignore';
|
|
24
|
+
import { fileProblem } from '../source.js';
|
|
25
|
+
import { readBounded, secretProblems } from './read.js';
|
|
26
|
+
export const IGNORE_FILE = '.stackledgerignore';
|
|
27
|
+
export const MAX_IGNORE_BYTES = 64 * 1024;
|
|
28
|
+
export const MAX_PATTERN_LINES = 100;
|
|
29
|
+
export const MAX_PATTERN_CHARACTERS = 200;
|
|
30
|
+
export const MAX_PATTERN_WILDCARDS = 16;
|
|
31
|
+
const NO_PATTERNS = 'no pattern of this file is used';
|
|
32
|
+
const BYTE_ORDER_MARK = '\uFEFF';
|
|
33
|
+
export const createMatcher = patterns => ignore({ ignorecase: false }).add(patterns);
|
|
34
|
+
function identity(info) {
|
|
35
|
+
return `${info.dev}:${info.ino}`;
|
|
36
|
+
}
|
|
37
|
+
/** A line that adds a rule, as Git reads it: not a `#` comment and not empty once trailing spaces are dropped.
|
|
38
|
+
* Only these count towards the limits, so comments and blank lines cost nothing. */
|
|
39
|
+
function isPatternLine(line) {
|
|
40
|
+
return !line.startsWith('#') && line.replace(/ +$/, '') !== '';
|
|
41
|
+
}
|
|
42
|
+
function wildcards(line) {
|
|
43
|
+
// Escaped wildcards count too: the limit is on the line as written, the simplest bound to explain.
|
|
44
|
+
return [...line].filter(character => character === '*' || character === '?' || character === '[').length;
|
|
45
|
+
}
|
|
46
|
+
/** Whether the `ignore` package can compile the line. Rules compile lazily, on their first test, so
|
|
47
|
+
* the probe tests one path; `test` (not `ignores`) also runs negative rules. */
|
|
48
|
+
function compiles(line) {
|
|
49
|
+
try {
|
|
50
|
+
ignore({ ignorecase: false }).add(line).test('x');
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** The patterns of a text read from an ignore file, or the problem with its lines. */
|
|
58
|
+
function patternsOf(path, text) {
|
|
59
|
+
const lines = (text.startsWith(BYTE_ORDER_MARK) ? text.slice(1) : text).split(/\r?\n/);
|
|
60
|
+
let patternLines = 0;
|
|
61
|
+
for (const [index, line] of lines.entries()) {
|
|
62
|
+
if (!isPatternLine(line))
|
|
63
|
+
continue;
|
|
64
|
+
const number = index + 1;
|
|
65
|
+
if (++patternLines > MAX_PATTERN_LINES) {
|
|
66
|
+
return { problem: fileProblem(path, `Ignore file has more than ${MAX_PATTERN_LINES} pattern lines (line ${number}); ${NO_PATTERNS}`) };
|
|
67
|
+
}
|
|
68
|
+
if ([...line].length > MAX_PATTERN_CHARACTERS) {
|
|
69
|
+
return { problem: fileProblem(path, `Pattern at line ${number} is longer than ${MAX_PATTERN_CHARACTERS} characters; ${NO_PATTERNS}`) };
|
|
70
|
+
}
|
|
71
|
+
if (wildcards(line) > MAX_PATTERN_WILDCARDS) {
|
|
72
|
+
return { problem: fileProblem(path, `Pattern at line ${number} has more than ${MAX_PATTERN_WILDCARDS} wildcard characters; ${NO_PATTERNS}`) };
|
|
73
|
+
}
|
|
74
|
+
if (!compiles(line))
|
|
75
|
+
return { problem: fileProblem(path, `Pattern at line ${number} cannot be compiled; ${NO_PATTERNS}`) };
|
|
76
|
+
}
|
|
77
|
+
return { patterns: lines };
|
|
78
|
+
}
|
|
79
|
+
/** Read the ignore file of the given folder `folder` (absolute), known to hold an entry with that name;
|
|
80
|
+
* `path` is its display path. */
|
|
81
|
+
export async function readIgnoreFile(folder, path, create = createMatcher) {
|
|
82
|
+
const absolute = join(folder, IGNORE_FILE);
|
|
83
|
+
const problem = (key, message) => ({ status: 'problem', key, problems: [fileProblem(path, `${message}; ${NO_PATTERNS}`)] });
|
|
84
|
+
let entry;
|
|
85
|
+
// Vanished since the listing, or not even stat-able: no device and inode, so the absolute path is the key.
|
|
86
|
+
try {
|
|
87
|
+
entry = await lstat(absolute, { bigint: true });
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return problem(`path:${absolute}`, 'Ignore file cannot be read');
|
|
91
|
+
}
|
|
92
|
+
let target = entry;
|
|
93
|
+
if (entry.isSymbolicLink()) {
|
|
94
|
+
try {
|
|
95
|
+
target = await stat(absolute, { bigint: true });
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return problem(identity(entry), 'Ignore file is a symbolic link that is broken or loops');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const key = identity(target);
|
|
102
|
+
if (!target.isFile())
|
|
103
|
+
return problem(key, 'Ignore file is not a regular file');
|
|
104
|
+
const read = await readBounded(absolute, path, { bytes: MAX_IGNORE_BYTES,
|
|
105
|
+
tooLarge: `Ignore file is larger than 64 KiB; ${NO_PATTERNS}`, unreadable: `Ignore file cannot be read; ${NO_PATTERNS}` });
|
|
106
|
+
if ('problem' in read)
|
|
107
|
+
return { status: 'problem', key, problems: [read.problem] };
|
|
108
|
+
const secrets = secretProblems(path, [read.text]);
|
|
109
|
+
if (secrets.length)
|
|
110
|
+
return { status: 'problem', key, problems: secrets };
|
|
111
|
+
const parsed = patternsOf(path, read.text);
|
|
112
|
+
if ('problem' in parsed)
|
|
113
|
+
return { status: 'problem', key, problems: [parsed.problem] };
|
|
114
|
+
let matcher;
|
|
115
|
+
try {
|
|
116
|
+
matcher = create(parsed.patterns);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
throw new IgnoreMatcherError();
|
|
120
|
+
}
|
|
121
|
+
return { status: 'read', matcher };
|
|
122
|
+
}
|
|
123
|
+
/** The matcher failed after its file was read: a bug, so an internal failure. The message is fixed, because
|
|
124
|
+
* the matcher's own message can repeat a pattern or the tested path. */
|
|
125
|
+
export class IgnoreMatcherError extends Error {
|
|
126
|
+
name = 'IgnoreMatcherError';
|
|
127
|
+
constructor() { super('the ignore file matcher failed'); }
|
|
128
|
+
}
|
|
129
|
+
/** Whether `matcher` ignores `path`, turning any exception into an IgnoreMatcherError. */
|
|
130
|
+
export function ignores(matcher, path) {
|
|
131
|
+
try {
|
|
132
|
+
return matcher.ignores(path);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
throw new IgnoreMatcherError();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=ignore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ignore.js","sourceRoot":"","sources":["../../src/skills/ignore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,IA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AO,kBAAmB,SAAQ,KAAK;IAClC,IAAI,GAAG,oBAAoB,CAAC;IACrC,gBAAgB,KAAK,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC;CAC3D;AACD,0FAA0F;AAC1F,MAAM,UAAU,OAAO,CAAC,OAAgB,EAAE,IAAY;IACpD,IAAI,CAAC;QAAC,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,MAAM,IAAI,kBAAkB,EAAE,CAAC;IAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Read and check the skills map files of a skill set (skill-source spec: Skills map file, One read per
|
|
2
|
+
* map file, Skills map file problems, Skills map documents, Skill references, Playbook zones, Several
|
|
3
|
+
* skills map files). Used by src/skills/source.ts after the set is fixed; only reads.
|
|
4
|
+
*
|
|
5
|
+
* Why this shape:
|
|
6
|
+
* - Each file is read with the skill set's bounded reader (size, not-a-file, unreadable) and parsed with
|
|
7
|
+
* the catalogue's `parseSource`, then each document gets the catalogue's checks for a `Line` or a
|
|
8
|
+
* `MapLayout`: the same schemas, messages and secret scan, so a map file behaves like a catalogue file.
|
|
9
|
+
* - References are not catalogue references: `skill:`, `playbook:` or `agent:` in lower case, then the
|
|
10
|
+
* exact item name (everything after the first `:`), because skill identity is the exact name.
|
|
11
|
+
* - Problems here never remove an item from the set; a stop or a zone in error is simply not drawn
|
|
12
|
+
* (src/skills/metro.ts resolves the served lines and zones against the set again).
|
|
13
|
+
* - The documents of every map file are one catalogue, in folder order: names and codes are unique
|
|
14
|
+
* across files and only the first MapLayout is used.
|
|
15
|
+
*/
|
|
16
|
+
import { type Problem, type Source } from '../source.js';
|
|
17
|
+
import { type Line, type MapLayout } from '../schema.js';
|
|
18
|
+
export type ItemKind = 'skill' | 'playbook' | 'agent';
|
|
19
|
+
export declare const ITEM_KINDS: readonly ItemKind[];
|
|
20
|
+
/** The served map documents: lines in folder and document order, and the first valid layout. */
|
|
21
|
+
export interface SkillsMap {
|
|
22
|
+
lines: Line[];
|
|
23
|
+
layout?: MapLayout;
|
|
24
|
+
}
|
|
25
|
+
/** What the checks need to know about the set: each item name and its kind. */
|
|
26
|
+
export type ItemKinds = Map<string, ItemKind[]>;
|
|
27
|
+
/** A map-file reference split as written: the kind before the first `:`, the name after it. */
|
|
28
|
+
export declare function splitReference(value: string): {
|
|
29
|
+
kind: ItemKind;
|
|
30
|
+
name: string;
|
|
31
|
+
} | undefined;
|
|
32
|
+
/** Read the map files in folder order and check them against the set's items. */
|
|
33
|
+
export declare function readSkillsMap(files: {
|
|
34
|
+
path: string;
|
|
35
|
+
absolute: string;
|
|
36
|
+
}[], items: ItemKinds, problems: Problem[]): Promise<SkillsMap>;
|
|
37
|
+
/** The catalogue's document checks for Line and MapLayout, then the cross-document checks. */
|
|
38
|
+
export declare function checkSkillsMap(sources: Source[], items: ItemKinds, problems: Problem[]): SkillsMap;
|
|
39
|
+
/** The members of a playbook zone (skill-source, Playbook zones), as `kind:name` references: the playbook,
|
|
40
|
+
* then what its `stackledger-skills` and `stackledger-agents` name in the set, as written. Only direct
|
|
41
|
+
* relations: a playbook that loads another would otherwise take that one's whole zone. Empty when the
|
|
42
|
+
* name is no playbook of the set. */
|
|
43
|
+
export declare function zoneMembers(set: {
|
|
44
|
+
skills: {
|
|
45
|
+
name: string;
|
|
46
|
+
kind: 'skill' | 'playbook';
|
|
47
|
+
skills: string[];
|
|
48
|
+
agents: string[];
|
|
49
|
+
}[];
|
|
50
|
+
agents: {
|
|
51
|
+
name: string;
|
|
52
|
+
}[];
|
|
53
|
+
}, zone: string): string[];
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/** Read and check the skills map files of a skill set (skill-source spec: Skills map file, One read per
|
|
2
|
+
* map file, Skills map file problems, Skills map documents, Skill references, Playbook zones, Several
|
|
3
|
+
* skills map files). Used by src/skills/source.ts after the set is fixed; only reads.
|
|
4
|
+
*
|
|
5
|
+
* Why this shape:
|
|
6
|
+
* - Each file is read with the skill set's bounded reader (size, not-a-file, unreadable) and parsed with
|
|
7
|
+
* the catalogue's `parseSource`, then each document gets the catalogue's checks for a `Line` or a
|
|
8
|
+
* `MapLayout`: the same schemas, messages and secret scan, so a map file behaves like a catalogue file.
|
|
9
|
+
* - References are not catalogue references: `skill:`, `playbook:` or `agent:` in lower case, then the
|
|
10
|
+
* exact item name (everything after the first `:`), because skill identity is the exact name.
|
|
11
|
+
* - Problems here never remove an item from the set; a stop or a zone in error is simply not drawn
|
|
12
|
+
* (src/skills/metro.ts resolves the served lines and zones against the set again).
|
|
13
|
+
* - The documents of every map file are one catalogue, in folder order: names and codes are unique
|
|
14
|
+
* across files and only the first MapLayout is used.
|
|
15
|
+
*/
|
|
16
|
+
import { MAX_FILE_BYTES, parseSource, problem } from '../source.js';
|
|
17
|
+
import { lineSchema, layoutSchema, name as nameSchema } from '../schema.js';
|
|
18
|
+
import { scanSecrets } from '../secrets.js';
|
|
19
|
+
import { schemaProblems } from '../validate.js';
|
|
20
|
+
import { readBounded } from './read.js';
|
|
21
|
+
export const ITEM_KINDS = ['skill', 'playbook', 'agent'];
|
|
22
|
+
const API_VERSION = 'stackledger/v1alpha1';
|
|
23
|
+
function object(value) {
|
|
24
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
25
|
+
}
|
|
26
|
+
const spec = (document) => object(document.source.value.spec);
|
|
27
|
+
/** A map-file reference split as written: the kind before the first `:`, the name after it. */
|
|
28
|
+
export function splitReference(value) {
|
|
29
|
+
const at = value.indexOf(':');
|
|
30
|
+
if (at < 0)
|
|
31
|
+
return;
|
|
32
|
+
const kind = value.slice(0, at), name = value.slice(at + 1);
|
|
33
|
+
return ITEM_KINDS.includes(kind) && name ? { kind: kind, name } : undefined;
|
|
34
|
+
}
|
|
35
|
+
/** Read the map files in folder order and check them against the set's items. */
|
|
36
|
+
export async function readSkillsMap(files, items, problems) {
|
|
37
|
+
const sources = [];
|
|
38
|
+
for (const file of files) {
|
|
39
|
+
const read = await readBounded(file.absolute, file.path, { bytes: MAX_FILE_BYTES, tooLarge: 'File exceeds 1 MiB', unreadable: 'File cannot be read' });
|
|
40
|
+
if ('problem' in read) {
|
|
41
|
+
problems.push(read.problem);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const parsed = parseSource(file.path, read.text);
|
|
45
|
+
problems.push(...parsed.problems);
|
|
46
|
+
sources.push(...parsed.sources);
|
|
47
|
+
}
|
|
48
|
+
return checkSkillsMap(sources, items, problems);
|
|
49
|
+
}
|
|
50
|
+
/** The catalogue's document checks for Line and MapLayout, then the cross-document checks. */
|
|
51
|
+
export function checkSkillsMap(sources, items, problems) {
|
|
52
|
+
const documents = [];
|
|
53
|
+
// A file with a secret gives no line and no layout, and its values never reach another message.
|
|
54
|
+
const secretFiles = new Set();
|
|
55
|
+
for (const source of sources) {
|
|
56
|
+
const value = source.value, kind = value.kind;
|
|
57
|
+
if (typeof kind !== 'string' || !kind) {
|
|
58
|
+
problems.push(problem(source, ['kind'], 'kind is required'));
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (kind !== 'Line' && kind !== 'MapLayout') {
|
|
62
|
+
problems.push(problem(source, ['kind'], 'Supported kinds in a skills map file: Line, MapLayout'));
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (value.apiVersion !== API_VERSION) {
|
|
66
|
+
problems.push(problem(source, ['apiVersion'], `Supported pair: ${API_VERSION} ${kind}`));
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const parsedName = nameSchema.safeParse(object(value.metadata).name);
|
|
70
|
+
if (!parsedName.success) {
|
|
71
|
+
problems.push(problem(source, ['metadata', 'name'], 'Name must be 1–63 ASCII letters, digits, dots, underscores or hyphens, with alphanumeric ends'));
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const document = { source, kind, name: parsedName.data };
|
|
75
|
+
documents.push(document);
|
|
76
|
+
const namespace = object(value.metadata).namespace;
|
|
77
|
+
if (namespace !== undefined && namespace !== 'default')
|
|
78
|
+
problems.push(problem(source, ['metadata', 'namespace'], 'Namespaces are not supported; treated as default', 'warning'));
|
|
79
|
+
const parsed = (kind === 'Line' ? lineSchema : layoutSchema).safeParse(value);
|
|
80
|
+
if (!parsed.success) {
|
|
81
|
+
problems.push(...schemaProblems(source, parsed.error.issues));
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const secrets = scanSecrets(source);
|
|
85
|
+
problems.push(...secrets);
|
|
86
|
+
if (secrets.some(found => found.severity === 'error'))
|
|
87
|
+
secretFiles.add(source.path);
|
|
88
|
+
else
|
|
89
|
+
document.served = parsed.data;
|
|
90
|
+
}
|
|
91
|
+
// Duplicate names first, as in the catalogue: a later document with a used name is not served.
|
|
92
|
+
const first = new Map();
|
|
93
|
+
const unique = [];
|
|
94
|
+
for (const document of documents.filter(item => !secretFiles.has(item.source.path))) {
|
|
95
|
+
const key = `${document.kind}:${document.name.toLowerCase()}`, earlier = first.get(key);
|
|
96
|
+
if (earlier)
|
|
97
|
+
problems.push(problem(document.source, ['metadata', 'name'], `Duplicate name; earlier document is in ${earlier.source.path}`));
|
|
98
|
+
else {
|
|
99
|
+
first.set(key, document);
|
|
100
|
+
unique.push(document);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
crossCheck(unique, items, problems);
|
|
104
|
+
const layouts = unique.filter(document => document.kind === 'MapLayout');
|
|
105
|
+
return {
|
|
106
|
+
lines: unique.filter(document => document.kind === 'Line' && document.served).map(document => document.served),
|
|
107
|
+
...(layouts[0]?.served ? { layout: layouts[0].served } : {}),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function crossCheck(unique, items, problems) {
|
|
111
|
+
const add = (document, path, message, severity = 'error', key = false) => {
|
|
112
|
+
problems.push(problem(document.source, path, message, severity, key));
|
|
113
|
+
};
|
|
114
|
+
/** The item a reference names, as `kind:name`, or undefined with an error at it. */
|
|
115
|
+
function target(document, value, path, key = false) {
|
|
116
|
+
const ref = splitReference(value);
|
|
117
|
+
if (!ref) {
|
|
118
|
+
add(document, path, 'Reference must be skill:<name>, playbook:<name> or agent:<name>', 'error', key);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const kinds = items.get(ref.name) ?? [];
|
|
122
|
+
if (kinds.includes(ref.kind))
|
|
123
|
+
return `${ref.kind}:${ref.name}`;
|
|
124
|
+
const other = kinds.find(kind => kind !== ref.kind);
|
|
125
|
+
add(document, path, other ? `No ${ref.kind} named ${ref.name}; ${ref.name} is ${other === 'agent' ? 'an' : 'a'} ${other}` : `No ${ref.kind} named ${ref.name} in the set`, 'error', key);
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
const lines = unique.filter(document => document.kind === 'Line');
|
|
129
|
+
const layouts = unique.filter(document => document.kind === 'MapLayout');
|
|
130
|
+
const layout = layouts[0];
|
|
131
|
+
for (const later of layouts.slice(1))
|
|
132
|
+
add(later, [], `Only one MapLayout is allowed; earlier document is in ${layout.source.path}`);
|
|
133
|
+
const codes = new Map(), colors = new Map();
|
|
134
|
+
const firstStops = new Map();
|
|
135
|
+
for (const line of lines) {
|
|
136
|
+
for (const [field, seen, severity] of [['code', codes, 'error'], ['color', colors, 'warning']]) {
|
|
137
|
+
const value = spec(line)[field];
|
|
138
|
+
if (typeof value !== 'string')
|
|
139
|
+
continue;
|
|
140
|
+
const previous = seen.get(value.toLowerCase());
|
|
141
|
+
if (previous)
|
|
142
|
+
add(line, ['spec', field], `Shared ${field}; earlier line ${previous.name} is in ${previous.source.path}`, severity);
|
|
143
|
+
else
|
|
144
|
+
seen.set(value.toLowerCase(), line);
|
|
145
|
+
}
|
|
146
|
+
const seenStops = new Set();
|
|
147
|
+
const lineStops = spec(line).stops;
|
|
148
|
+
if (Array.isArray(lineStops))
|
|
149
|
+
lineStops.forEach((value, index) => {
|
|
150
|
+
if (typeof value !== 'string')
|
|
151
|
+
return;
|
|
152
|
+
const path = ['spec', 'stops', index], ref = target(line, value, path);
|
|
153
|
+
if (!ref)
|
|
154
|
+
return;
|
|
155
|
+
if (seenStops.has(ref))
|
|
156
|
+
add(line, path, 'Item is visited more than once');
|
|
157
|
+
seenStops.add(ref);
|
|
158
|
+
if (!firstStops.has(ref))
|
|
159
|
+
firstStops.set(ref, { document: line, path });
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
const stations = new Map();
|
|
163
|
+
if (layout) {
|
|
164
|
+
const positions = new Map();
|
|
165
|
+
for (const [key, position] of Object.entries(object(spec(layout).stations))) {
|
|
166
|
+
const path = ['spec', 'stations', key], ref = target(layout, key, path, true);
|
|
167
|
+
if (!ref)
|
|
168
|
+
continue;
|
|
169
|
+
if (Array.isArray(position) && position.length === 2 && position.every(v => Number.isInteger(v) && v >= 0)) {
|
|
170
|
+
const cell = position.join(',');
|
|
171
|
+
const earlier = positions.get(cell);
|
|
172
|
+
if (earlier)
|
|
173
|
+
add(layout, path, `Position already used by ${earlier}`, 'error', true);
|
|
174
|
+
else
|
|
175
|
+
positions.set(cell, key);
|
|
176
|
+
stations.set(ref, { document: layout, path });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const zones = new Set();
|
|
180
|
+
if (Array.isArray(spec(layout).zones))
|
|
181
|
+
spec(layout).zones.forEach((zone, index) => {
|
|
182
|
+
const value = object(zone).name;
|
|
183
|
+
if (typeof value !== 'string')
|
|
184
|
+
return;
|
|
185
|
+
const path = ['spec', 'zones', index, 'name'];
|
|
186
|
+
if (zones.has(value)) {
|
|
187
|
+
add(layout, path, 'Duplicate zone name');
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
zones.add(value);
|
|
191
|
+
if (!(items.get(value) ?? []).includes('playbook'))
|
|
192
|
+
add(layout, path, `Zone must name a playbook of the set; ${value} is not one`);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
for (const [ref, stop] of firstStops)
|
|
196
|
+
if (!stations.has(ref))
|
|
197
|
+
add(stop.document, stop.path, 'No position; the map will place this item', 'warning');
|
|
198
|
+
for (const [ref, station] of stations)
|
|
199
|
+
if (!firstStops.has(ref))
|
|
200
|
+
add(station.document, station.path, 'No line stops here; the map will not show this item', 'warning', true);
|
|
201
|
+
}
|
|
202
|
+
/** The members of a playbook zone (skill-source, Playbook zones), as `kind:name` references: the playbook,
|
|
203
|
+
* then what its `stackledger-skills` and `stackledger-agents` name in the set, as written. Only direct
|
|
204
|
+
* relations: a playbook that loads another would otherwise take that one's whole zone. Empty when the
|
|
205
|
+
* name is no playbook of the set. */
|
|
206
|
+
export function zoneMembers(set, zone) {
|
|
207
|
+
const playbook = set.skills.find(item => item.kind === 'playbook' && item.name === zone);
|
|
208
|
+
if (!playbook)
|
|
209
|
+
return [];
|
|
210
|
+
const members = [`playbook:${playbook.name}`];
|
|
211
|
+
for (const name of playbook.skills) {
|
|
212
|
+
const item = set.skills.find(candidate => candidate.name === name);
|
|
213
|
+
if (item)
|
|
214
|
+
members.push(`${item.kind}:${item.name}`);
|
|
215
|
+
}
|
|
216
|
+
for (const name of playbook.agents)
|
|
217
|
+
if (set.agents.some(candidate => candidate.name === name))
|
|
218
|
+
members.push(`agent:${name}`);
|
|
219
|
+
return [...new Set(members)];
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=lines.js.map
|