@brybrophy/lindy 0.1.0-preview.2 → 0.1.0-preview.3

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/README.md CHANGED
@@ -6,11 +6,11 @@ Try an editable reading-list sample before connecting an agent. It runs locally
6
6
 
7
7
  ## Install the preview
8
8
 
9
- This guide describes the opt-in `0.1.0-preview.2` preview. Before first publication, the registry commands below are prospective: a local candidate or passing CI does not establish npm availability. If npm returns E404, stop and check the release status with the maintainer rather than installing an unrelated package.
9
+ This guide describes the opt-in `0.1.0-preview.3` preview. Before first publication of this version, use the candidate archive to try its pack commands. If npm returns E404, stop and check the release status with the maintainer rather than installing an unrelated package.
10
10
 
11
11
  Use Node.js **24 or later** on Linux or macOS. The tested runtime lines are Node 24 and Node 26 LTS; other operating systems and future major versions are not verified. Choose an already installed package manager. No global installation is needed.
12
12
 
13
- The preview uses the explicit **`next`** tag, not `latest`. Use `@brybrophy/lindy@0.1.0-preview.2` instead of `@brybrophy/lindy@next` if you want to pin this version after it is published.
13
+ The preview uses the explicit **`next`** tag, not `latest`. Use `@brybrophy/lindy@0.1.0-preview.3` instead of `@brybrophy/lindy@next` if you want to pin this version after it is published.
14
14
 
15
15
  In a new empty directory:
16
16
 
@@ -74,3 +74,14 @@ The runtime does not invoke npm, pnpm or Yarn during preview. Keep generated out
74
74
  This is an opt-in preview, not a production-readiness claim. Report the Lindy version, Node/platform, installer/layout and a sanitized reproduction. Never include bootstrap URLs, cookies, credentials or private project content. Broader application scaffolding, persistent storage guarantees and untested agent/package-manager compatibility are outside this preview.
75
75
 
76
76
  Lindy is MIT licensed. Bundled dependencies retain their licenses in `THIRD_PARTY_NOTICES.txt` and their applicable license files.
77
+
78
+
79
+ ## Discover convention packs
80
+
81
+ Run `lindy packs catalog` from the project to see the official pack names and
82
+ capabilities. Search for a capability with `lindy packs catalog storage`.
83
+ Install the specific pack you want, then run
84
+ `lindy packs inspect @brybrophy/lindy-pack-postgres` to inspect its standards
85
+ and host requirements. The CLI also accepts installed private team packages
86
+ that export a v1 manifest at `./lindy-pack.json`. Discovery and proposal work
87
+ offline. A catalog listing does not establish registry availability.
package/distribution.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "schemaVersion": "0.2",
3
3
  "packageName": "@brybrophy/lindy",
4
- "packageVersion": "0.1.0-preview.2",
5
- "releaseInputHash": "sha256:d2cb2d16bb7c86ab99b26c51d22b9d618bc137e1b5ee1dda27f17a8402cbe961",
6
- "sourceCommit": "ddf91db8ada3e3b0893a8a96c6b83292568e2b0b",
4
+ "packageVersion": "0.1.0-preview.3",
5
+ "releaseInputHash": "sha256:d135d1594ed0b0c48a455583dd6337dfe3188fcd2ed7b3714a7f3895c0a8e74e",
6
+ "sourceCommit": "4d0b38e6e9274dc164d7af79329316882d9d9c1e",
7
7
  "nodeVersion": "24.19.0",
8
8
  "pnpmVersion": "11.21.0",
9
9
  "buildLockHash": "sha256:f72b037ea3d78f8a3f3a47c4b29668e85d3961e34e25f2887b8e74db57c24ebe",
@@ -51,8 +51,8 @@
51
51
  },
52
52
  {
53
53
  "path": "README.md",
54
- "byteLength": 4681,
55
- "hash": "sha256:c1cb81b59ff92fc7b0821ea1da02a2b512413bc0fe6de695d6fda4e8a9093b3a"
54
+ "byteLength": 5165,
55
+ "hash": "sha256:55f7ac893f77e055d131bb77400c295d2f813cb10d07078ddf7e2b2d31edb22c"
56
56
  },
57
57
  {
58
58
  "path": "THIRD_PARTY_NOTICES.txt",
@@ -66,8 +66,8 @@
66
66
  },
67
67
  {
68
68
  "path": "lib/lindy.mjs",
69
- "byteLength": 1826303,
70
- "hash": "sha256:4819b7dd66e4064d18a0d2833dc9fd760782cc29f1c9ba4631883ebcb09c0063"
69
+ "byteLength": 1845580,
70
+ "hash": "sha256:98fbfca0d35a711b9d1546113a8015caa44d1f16bac2a7f272d80e30a3235c1f"
71
71
  },
72
72
  {
73
73
  "path": "lib/starter/assets.json",
@@ -7496,13 +7496,13 @@
7496
7496
  },
7497
7497
  {
7498
7498
  "path": "package.json",
7499
- "byteLength": 525,
7500
- "hash": "sha256:cfe94251bedf730899057d26a3a5b7393121e8639063a7a4d60e7f67fd4dbc6f"
7499
+ "byteLength": 623,
7500
+ "hash": "sha256:8695a755889e6d25479df31127dabf0806183bf9ec02968b5a703407fc61b51a"
7501
7501
  },
7502
7502
  {
7503
7503
  "path": "release.json",
7504
7504
  "byteLength": 94,
7505
- "hash": "sha256:e87ef27fb1a3a55292cc288cd58125f1232193d1e253b93b1c72e8f03c8bbc2f"
7505
+ "hash": "sha256:8e59d7d39d6e31f5b8d7802f28dd86b6963305bd6eee6dace236f446e6b73674"
7506
7506
  }
7507
7507
  ]
7508
7508
  }
package/lib/lindy.mjs CHANGED
@@ -1,16 +1,39 @@
1
+ import { createRequire } from "node:module";
1
2
  import { access, lstat, mkdir, mkdtemp, open, readFile, realpath, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
2
3
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
3
4
  import { fileURLToPath, pathToFileURL } from "node:url";
5
+ import { createHash, randomUUID } from "node:crypto";
4
6
  import { constants } from "node:fs";
5
7
  import { Agent, request } from "node:https";
6
8
  import { rootCertificates } from "node:tls";
7
- import { createHash, randomUUID } from "node:crypto";
8
9
  import { AsyncLocalStorage } from "node:async_hooks";
9
10
  import { PassThrough } from "node:stream";
10
11
  import process$1 from "node:process";
11
12
  import { tmpdir } from "node:os";
12
13
  import { STATUS_CODES, createServer } from "node:http";
13
14
  import { Socket } from "node:net";
15
+ //#region conventions/v1/catalog.json
16
+ var catalog_default = [
17
+ {
18
+ "package": "@brybrophy/lindy-pack-react-next",
19
+ "source": "react-next",
20
+ "id": "lindy.react-next",
21
+ "capability": "ui.record-table"
22
+ },
23
+ {
24
+ "package": "@brybrophy/lindy-pack-postgres",
25
+ "source": "postgres",
26
+ "id": "lindy.postgres",
27
+ "capability": "storage.conditional-update"
28
+ },
29
+ {
30
+ "package": "@brybrophy/lindy-pack-kafka",
31
+ "source": "kafka",
32
+ "id": "lindy.kafka",
33
+ "capability": "events.revision-stream"
34
+ }
35
+ ];
36
+ //#endregion
14
37
  //#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
15
38
  var _a$1;
16
39
  const NEVER = Object.freeze({ status: "aborted" });
@@ -4643,6 +4666,404 @@ ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
4643
4666
  function number(params) {
4644
4667
  return _coercedNumber(ZodNumber, params);
4645
4668
  }
4669
+ //#endregion
4670
+ //#region scripts/pack-presentation.mjs
4671
+ const color = string().regex(/^#[0-9a-f]{6}$/i);
4672
+ const font = array(string().regex(/^[A-Za-z][A-Za-z0-9 -]{0,39}$/)).min(1).max(5);
4673
+ const library = strictObject({
4674
+ package: string().regex(/^@[a-z0-9][a-z0-9-]*\/[a-z][a-z0-9-]*$/),
4675
+ version: string().regex(/^\d+\.\d+\.\d+$/),
4676
+ tableExport: string().regex(/^[A-Z][A-Za-z0-9]*$/),
4677
+ buttonExport: string().regex(/^[A-Z][A-Za-z0-9]*$/)
4678
+ });
4679
+ const presentationSchema = strictObject({
4680
+ colors: strictObject({
4681
+ surface: color,
4682
+ text: color,
4683
+ danger: color,
4684
+ focus: color
4685
+ }),
4686
+ typography: strictObject({
4687
+ body: font,
4688
+ heading: font
4689
+ }),
4690
+ spacingPx: number$1().int().min(2).max(32),
4691
+ emptyText: string().trim().min(1).max(160),
4692
+ components: union([literal("native"), library])
4693
+ });
4694
+ function luminance(value) {
4695
+ const linear = value.slice(1).match(/../g).map((hex) => {
4696
+ const n = parseInt(hex, 16) / 255;
4697
+ return n <= .04045 ? n / 12.92 : ((n + .055) / 1.055) ** 2.4;
4698
+ });
4699
+ return linear[0] * .2126 + linear[1] * .7152 + linear[2] * .0722;
4700
+ }
4701
+ function checkContrast(theme) {
4702
+ const surface = luminance(theme.colors.surface);
4703
+ for (const [role, minimum] of [
4704
+ ["text", 4.5],
4705
+ ["danger", 4.5],
4706
+ ["focus", 3]
4707
+ ]) {
4708
+ const other = luminance(theme.colors[role]);
4709
+ if ((Math.max(surface, other) + .05) / (Math.min(surface, other) + .05) < minimum) throw Error("Insufficient " + role + " contrast against surface");
4710
+ }
4711
+ }
4712
+ const stack = (names) => names.map((n) => n.includes(" ") ? "\"" + n + "\"" : n).join(", ");
4713
+ function styles(theme, scope) {
4714
+ const root = "." + scope;
4715
+ return `${root}, ${root} dialog {background:${theme.colors.surface};color:${theme.colors.text};font-family:${stack(theme.typography.body)}}
4716
+ ${root} caption, ${root} h2 {font-family:${stack(theme.typography.heading)}}
4717
+ ${root} th, ${root} td {padding:${theme.spacingPx}px;text-align:start}
4718
+ ${root} button {font:inherit;background:${theme.colors.surface};color:${theme.colors.text}}
4719
+ ${root} button[data-danger] {color:${theme.colors.danger}}
4720
+ ${root} :focus-visible {outline:3px solid ${theme.colors.focus};outline-offset:2px}`;
4721
+ }
4722
+ function presentationRules(pack) {
4723
+ const c = pack.presentation.components;
4724
+ return {
4725
+ collection: c === "native" ? "table" : c.package + "#" + c.tableExport,
4726
+ command: c === "native" ? "button" : c.package + "#" + c.buttonExport,
4727
+ confirmation: "native modal dialog; initial focus on cancel; return focus to trigger",
4728
+ library: c === "native" ? null : {
4729
+ package: c.package,
4730
+ version: c.version
4731
+ },
4732
+ tokens: pack.presentation
4733
+ };
4734
+ }
4735
+ function renderPresentation(pack, fields, action) {
4736
+ const theme = pack.presentation, c = theme.components;
4737
+ const scope = "pack-" + pack.digest.slice(7, 23), css = JSON.stringify(styles(theme, scope));
4738
+ const imports = c === "native" ? "const Table = \"table\"; const Button = \"button\";" : `import { ${c.tableExport} as Table, ${c.buttonExport} as Button } from ${JSON.stringify(c.package)};`;
4739
+ const table = `${imports}
4740
+ const fields = ${JSON.stringify(fields.map((f) => f.name))};
4741
+ export default function RecordTable({ rows }) {
4742
+ return <section className="${scope}"><style>{${css}}</style><Table><caption>{${JSON.stringify(pack.title)}}</caption><thead><tr>{fields.map(f => <th scope="col" key={f}>{f}</th>)}</tr></thead><tbody>{rows.length ? rows.map(row => <tr key={row.id}>{fields.map(f => <td key={f}>{row[f]}</td>)}</tr>) : <tr><td colSpan={fields.length}>{${JSON.stringify(theme.emptyText)}}</td></tr>}</tbody></Table></section>;
4743
+ }
4744
+ `;
4745
+ if (!action) return { table };
4746
+ return {
4747
+ table,
4748
+ command: `"use client";
4749
+ import {useId,useRef} from "react";
4750
+ ${imports}
4751
+ const action = ${JSON.stringify(action)};
4752
+ export default function ConfirmedCommand({record,onApproved}){
4753
+ const dialog=useRef(null), trigger=useRef(null), cancel=useRef(null), title=useId();
4754
+ function confirm(){
4755
+ if (!dialog.current.open) return;
4756
+ dialog.current.close();
4757
+ onApproved(action.operationId,Object.fromEntries(action.arguments.map(a=>[a.parameter,record[a.field]])));
4758
+ }
4759
+ return <div className="${scope}"><style>{${css}}</style>
4760
+ <Button type="button" data-danger="" ref={trigger} onClick={()=>{dialog.current.showModal();cancel.current.focus();}}>{action.label}</Button>
4761
+ <dialog ref={dialog} aria-labelledby={title} onClose={()=>trigger.current.focus()}>
4762
+ <h2 id={title}>{action.title}</h2><p>{action.body}</p><p>{record[action.subject]}</p>
4763
+ <Button type="button" ref={cancel} onClick={()=>dialog.current.close()}>{action.cancelLabel}</Button>
4764
+ <Button type="button" data-danger="" onClick={confirm}>{action.label}</Button>
4765
+ </dialog></div>;
4766
+ }
4767
+ `
4768
+ };
4769
+ }
4770
+ function reviewedCommand(graph, model, fields, selection) {
4771
+ const node = (id, kind) => {
4772
+ const matches = graph.nodes.filter((n) => n.id === id && n.kind === kind);
4773
+ if (matches.length !== 1) throw Error("Missing or ambiguous " + kind);
4774
+ return matches[0];
4775
+ };
4776
+ const view = node(selection.view, "View");
4777
+ const matches = view.actions.filter((a) => a.key === selection.action);
4778
+ if (matches.length !== 1 || matches[0].intent !== "destructive" || !matches[0].confirmation) throw Error("Select a confirmed destructive view action");
4779
+ const action = matches[0], lookup = node(view.dataOperation.operationId, "Operation");
4780
+ const ret = lookup.returns.find((r) => r.name === action.confirmation.subject.output);
4781
+ const step = lookup.steps.find((s) => s.name === ret?.value.step);
4782
+ const caps = graph.nodes.filter((n) => n.kind === "Datasource").flatMap((n) => n.capabilities).filter((c) => c.id === step?.capabilityId);
4783
+ const output = caps[0]?.output;
4784
+ if (lookup.steps.length !== 1 || ret?.value.kind !== "step-output" || caps.length !== 1 || caps[0].effect !== "read-one" || (output.kind === "optional" ? output.value : output).modelId !== model) throw Error("Action record does not match model");
4785
+ function source(ref) {
4786
+ if (ref?.output !== ret.name || ref.path.length !== 1 || !fields.some((f) => f.name === ref.path[0])) throw Error("Expected a direct record field");
4787
+ return ref.path[0];
4788
+ }
4789
+ const op = node(action.operationId, "Operation");
4790
+ const args = action.arguments.map((a) => {
4791
+ if (a.value.kind !== "data") throw Error("Unsupported command argument");
4792
+ const field = source(a.value.source);
4793
+ const input = op.inputs.find((i) => i.name === a.parameter);
4794
+ if (input?.type.kind !== "scalar" || input.type.name !== fields.find((f) => f.name === field).type.name) throw Error("Command input type mismatch");
4795
+ return {
4796
+ parameter: a.parameter,
4797
+ field
4798
+ };
4799
+ });
4800
+ if (args.length !== op.inputs.length || new Set(args.map((a) => a.parameter)).size !== args.length) throw Error("Incomplete command arguments");
4801
+ return {
4802
+ view: view.id,
4803
+ action: action.key,
4804
+ operationId: op.id,
4805
+ label: action.label,
4806
+ title: action.confirmation.title,
4807
+ body: action.confirmation.body,
4808
+ cancelLabel: action.confirmation.cancelLabel,
4809
+ subject: source(action.confirmation.subject),
4810
+ arguments: args
4811
+ };
4812
+ }
4813
+ //#endregion
4814
+ //#region scripts/convention-engine.mjs
4815
+ const identifier = string().regex(/^[A-Za-z][A-Za-z0-9_]{0,62}$/);
4816
+ const rules = {
4817
+ "kafka.revision-events.v1": {
4818
+ provides: "events.revision-stream",
4819
+ output: "revision-events.mjs",
4820
+ requires: [
4821
+ "Kafka broker",
4822
+ "KafkaJS 2.2.4",
4823
+ "topic configuration and consumer group access"
4824
+ ]
4825
+ },
4826
+ "react.server-table.v1": {
4827
+ requires: ["React server component host", "rows supplied by the application"],
4828
+ provides: "ui.record-table",
4829
+ output: "RecordTable.jsx"
4830
+ },
4831
+ "postgres.revision-table.v1": {
4832
+ requires: ["PostgreSQL database", "connection-scoped prepared statement"],
4833
+ provides: "storage.conditional-update",
4834
+ output: "records.sql"
4835
+ }
4836
+ };
4837
+ const recipe = _enum(Object.keys(rules));
4838
+ const manifest = strictObject({
4839
+ schemaVersion: literal(1),
4840
+ id: string().regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/),
4841
+ version: string().regex(/^\d+\.\d+\.\d+$/),
4842
+ recipe,
4843
+ presentation: presentationSchema.optional(),
4844
+ database: strictObject({
4845
+ tableNaming: _enum(["model-name", "snake-case"]),
4846
+ updateStatement: string().regex(/^[a-z][a-z0-9_]{0,62}$/)
4847
+ }).optional(),
4848
+ messaging: strictObject({
4849
+ partitionKey: _enum(["record-id", "model-and-record-id"]),
4850
+ acknowledgments: literal("all")
4851
+ }).optional(),
4852
+ title: string().trim().min(1).max(100)
4853
+ });
4854
+ const needs = {
4855
+ "display-records": "ui.record-table",
4856
+ "retain-revision-checked-edits": "storage.conditional-update",
4857
+ "replay-revisions-independently": "events.revision-stream"
4858
+ };
4859
+ const policy = strictObject({
4860
+ schemaVersion: literal(1),
4861
+ model: string().regex(/^model\.[A-Za-z][A-Za-z0-9_]{0,62}$/),
4862
+ requirements: array(_enum([
4863
+ "display-records",
4864
+ "retain-revision-checked-edits",
4865
+ "replay-revisions-independently"
4866
+ ])).min(1).max(3),
4867
+ stream: strictObject({
4868
+ topic: string().regex(/^[a-z][a-z0-9.-]{0,120}$/),
4869
+ groups: array(string().regex(/^[a-z][a-z0-9.-]{0,100}$/)).min(2).max(16),
4870
+ retentionMs: number$1().int().positive().max(Number.MAX_SAFE_INTEGER),
4871
+ partitions: number$1().int().positive().max(256),
4872
+ replicas: number$1().int().positive().max(16)
4873
+ }).optional(),
4874
+ command: strictObject({
4875
+ view: string().regex(/^view\.[A-Za-z][A-Za-z0-9_]*$/),
4876
+ action: identifier
4877
+ }).optional(),
4878
+ prefer: array(manifest.shape.id).max(16)
4879
+ });
4880
+ const field = strictObject({
4881
+ name: identifier,
4882
+ type: strictObject({
4883
+ kind: literal("scalar"),
4884
+ name: _enum([
4885
+ "id",
4886
+ "int",
4887
+ "text"
4888
+ ])
4889
+ })
4890
+ });
4891
+ const digest$9 = (value) => "sha256:" + createHash("sha256").update(JSON.stringify(value)).digest("hex");
4892
+ function inspectPack(input) {
4893
+ const pack = manifest.parse(input);
4894
+ if (Boolean(pack.presentation) !== (pack.recipe === "react.server-table.v1")) throw Error("Only UI packs must declare presentation standards");
4895
+ if (Boolean(pack.database) !== (pack.recipe === "postgres.revision-table.v1") || Boolean(pack.messaging) !== (pack.recipe === "kafka.revision-events.v1")) throw Error("Declare standards for the selected recipe");
4896
+ if (pack.presentation) checkContrast(pack.presentation);
4897
+ return {
4898
+ ...pack,
4899
+ ...rules[pack.recipe],
4900
+ digest: digest$9(pack)
4901
+ };
4902
+ }
4903
+ function render(pack, model, fields, stream) {
4904
+ const names = fields.map((f) => f.name);
4905
+ if (pack.recipe === "kafka.revision-events.v1") {
4906
+ if (!fields.some((f) => f.name === "revision" && f.type.name === "int")) throw Error("Revision events require an integer revision");
4907
+ const topic = {
4908
+ topic: stream.topic,
4909
+ numPartitions: stream.partitions,
4910
+ replicationFactor: stream.replicas,
4911
+ configEntries: [{
4912
+ name: "retention.ms",
4913
+ value: String(stream.retentionMs)
4914
+ }, {
4915
+ name: "cleanup.policy",
4916
+ value: "delete"
4917
+ }]
4918
+ };
4919
+ return [
4920
+ "export const topic = " + JSON.stringify(topic) + ";",
4921
+ "const groups = " + JSON.stringify(stream.groups) + ";",
4922
+ "export async function publishRevision(producer, id, revision) {",
4923
+ " if (typeof id !== \"string\" || !id || !Number.isSafeInteger(revision) || revision < 0) throw Error(\"Invalid revision event\");",
4924
+ " await producer.send({topic:topic.topic,acks:-1,messages:[{key:" + (pack.messaging.partitionKey === "record-id" ? "id" : "JSON.stringify([" + JSON.stringify(model) + ",id])") + ",value:JSON.stringify({model:" + JSON.stringify(model) + ",id,revision})}]});",
4925
+ "}",
4926
+ "export async function subscribe(kafka, groupId, handler) {",
4927
+ " if (!groups.includes(groupId)) throw Error(\"Unreviewed consumer group\");",
4928
+ " const consumer = kafka.consumer({groupId});",
4929
+ " try { await consumer.connect(); await consumer.subscribe({topic:topic.topic,fromBeginning:true}); await consumer.run({eachMessage:handler}); }",
4930
+ " catch (error) { await consumer.disconnect(); throw error; }",
4931
+ " return consumer;",
4932
+ "}",
4933
+ ""
4934
+ ].join("\n");
4935
+ }
4936
+ if (!fields.some((f) => f.name === "revision" && f.type.name === "int")) throw Error("PostgreSQL recipe requires an integer revision");
4937
+ const editable = names.filter((n) => n !== "id" && n !== "revision");
4938
+ if (!editable.length) throw Error("No editable fields");
4939
+ const name = model.slice(6);
4940
+ const table = "\"" + (pack.database.tableNaming === "snake-case" ? name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase() : name) + "\"";
4941
+ const columns = fields.map((f) => "\"" + f.name + "\" " + (f.type.name === "int" ? "integer" : "text") + (f.name === "id" ? " PRIMARY KEY" : f.name === "revision" ? " NOT NULL DEFAULT 0" : " NOT NULL"));
4942
+ return "CREATE TABLE " + table + " (\n " + columns.join(",\n ") + "\n);\n\nPREPARE \"" + pack.database.updateStatement + "\" AS\nUPDATE " + table + " SET " + editable.map((n, i) => "\"" + n + "\" = $" + (i + 3)).concat("\"revision\" = \"revision\" + 1").join(", ") + "\nWHERE \"id\" = $1 AND \"revision\" = $2\nRETURNING *;\n";
4943
+ }
4944
+ function propose(graph, request, manifests) {
4945
+ const p = policy.parse(request);
4946
+ if (p.requirements.includes("replay-revisions-independently") !== Boolean(p.stream) || p.stream && new Set(p.stream.groups).size !== p.stream.groups.length) throw Error("Revision streams require explicit topic policy and distinct consumer groups");
4947
+ const matched = graph.nodes.filter((n) => n.id === p.model);
4948
+ if (matched.length !== 1 || matched[0].kind !== "Model") throw Error("Expected one selected model");
4949
+ const fields = array(field).min(1).max(64).parse(matched[0].fields);
4950
+ if (new Set(fields.map((f) => f.name)).size !== fields.length || !fields.some((f) => f.name === "id" && f.type.name === "id")) throw Error("Expected distinct fields and a scalar id");
4951
+ if (p.command && !p.requirements.includes("display-records")) throw Error("Command requires a UI pack");
4952
+ const command = p.command ? reviewedCommand(graph, p.model, fields, p.command) : null;
4953
+ const packs = manifests.map(inspectPack);
4954
+ if (new Set(packs.map((x) => x.id)).size !== packs.length || new Set(p.requirements).size !== p.requirements.length || new Set(p.prefer).size !== p.prefer.length || p.prefer.some((id) => !packs.some((x) => x.id === id))) throw Error("Duplicate or unknown selection");
4955
+ const artifacts = {}, selected = [];
4956
+ for (const requirement of p.requirements.toSorted()) {
4957
+ const capability = needs[requirement];
4958
+ const candidates = packs.filter((x) => x.provides === capability);
4959
+ const preferred = candidates.filter((x) => p.prefer.includes(x.id));
4960
+ const choices = preferred.length ? preferred : candidates;
4961
+ if (choices.length !== 1) throw Error("Expected exactly one provider for " + capability);
4962
+ const pack = choices[0];
4963
+ const ui = pack.presentation ? renderPresentation(pack, fields, command) : null;
4964
+ const body = ui ? ui.table : render(pack, p.model, fields, p.stream);
4965
+ if (ui?.command) artifacts["ConfirmedCommand.jsx"] = ui.command;
4966
+ artifacts[pack.output] = body;
4967
+ selected.push({
4968
+ requirement,
4969
+ capability,
4970
+ id: pack.id,
4971
+ version: pack.version,
4972
+ recipe: pack.recipe,
4973
+ ...ui ? {
4974
+ rules: presentationRules(pack),
4975
+ command,
4976
+ ...ui.command ? {
4977
+ commandFile: "ConfirmedCommand.jsx",
4978
+ commandDigest: "sha256:" + createHash("sha256").update(ui.command).digest("hex")
4979
+ } : {}
4980
+ } : {},
4981
+ ...pack.database ? { rules: pack.database } : {},
4982
+ ...pack.messaging ? { rules: pack.messaging } : {},
4983
+ requires: pack.requires,
4984
+ selection: preferred.length ? "team preference" : "only supplied provider",
4985
+ manifestDigest: pack.digest,
4986
+ output: pack.output,
4987
+ outputDigest: "sha256:" + createHash("sha256").update(body).digest("hex")
4988
+ });
4989
+ }
4990
+ const plan = {
4991
+ model: p.model,
4992
+ ...p.stream ? { stream: p.stream } : {},
4993
+ graphDigest: digest$9(graph),
4994
+ policyDigest: digest$9(p),
4995
+ selected
4996
+ };
4997
+ return {
4998
+ plan,
4999
+ approvalHash: digest$9(plan),
5000
+ artifacts
5001
+ };
5002
+ }
5003
+ const load = async (path) => JSON.parse(await readFile(path, "utf8"));
5004
+ async function verifyHost(packInput, root) {
5005
+ const library = inspectPack(packInput).presentation?.components;
5006
+ if (!library || library === "native") return { libraries: [] };
5007
+ const entry = createRequire(resolve(root, "package.json")).resolve(library.package);
5008
+ let dir = dirname(entry);
5009
+ while (true) {
5010
+ let metadata;
5011
+ try {
5012
+ metadata = await load(join(dir, "package.json"));
5013
+ } catch (error) {
5014
+ if (error.code !== "ENOENT") throw error;
5015
+ }
5016
+ if (metadata?.name === library.package) {
5017
+ if (metadata.version !== library.version) throw Error("Installed component library differs from reviewed version");
5018
+ return { libraries: [{
5019
+ package: metadata.name,
5020
+ version: metadata.version
5021
+ }] };
5022
+ }
5023
+ const parent = dirname(dir);
5024
+ if (parent === dir) throw Error("Unable to identify component library package");
5025
+ dir = parent;
5026
+ }
5027
+ }
5028
+ async function runPackCommand(argv, readPack = load) {
5029
+ const [cmd, ...args] = argv;
5030
+ if (cmd === "inspect" && args.length === 1) console.log(JSON.stringify(inspectPack(await readPack(args[0])), null, 2));
5031
+ else if (cmd === "verify-host" && args.length === 2) console.log(JSON.stringify(await verifyHost(await readPack(args[0]), args[1]), null, 2));
5032
+ else {
5033
+ if (!["propose", "compile"].includes(cmd)) throw Error("Use inspect MANIFEST or propose/compile [APPROVAL for compile] GRAPH POLICY MANIFEST...");
5034
+ const approval = cmd === "compile" ? args.shift() : void 0;
5035
+ if (args.length < 3) throw Error("Graph, policy and at least one manifest required");
5036
+ const [graph, request, ...packs] = await Promise.all(args.map((value, index) => index < 2 ? load(value) : readPack(value)));
5037
+ const { plan, approvalHash, artifacts } = propose(graph, request, packs);
5038
+ if (cmd === "compile" && approval !== approvalHash) throw Error("Approval does not match current proposal");
5039
+ console.log(JSON.stringify(cmd === "compile" ? {
5040
+ plan,
5041
+ approvalHash,
5042
+ artifacts
5043
+ } : {
5044
+ plan,
5045
+ approvalHash
5046
+ }, null, 2));
5047
+ }
5048
+ }
5049
+ //#endregion
5050
+ //#region scripts/installed-packs.mjs
5051
+ async function installedPacks(args) {
5052
+ if (args[0] === "catalog" && args.length <= 2) {
5053
+ const query = (args[1] ?? "").toLowerCase();
5054
+ console.log(JSON.stringify(catalog_default.filter((entry) => [entry.package, entry.capability].some((value) => value.includes(query))).map(({ package: name, capability }) => ({
5055
+ package: name,
5056
+ capability
5057
+ })), null, 2));
5058
+ return;
5059
+ }
5060
+ const project = createRequire(resolve("package.json"));
5061
+ await runPackCommand(args, async (name) => {
5062
+ if (!/^(?:@[a-z0-9][a-z0-9.-]*\/)?[a-z0-9][a-z0-9.-]*$/.test(name)) throw Error("Expected an installed pack package name");
5063
+ const path = project.resolve(name + "/lindy-pack.json");
5064
+ return JSON.parse(await readFile(path, "utf8"));
5065
+ });
5066
+ }
4646
5067
  const SemanticIdSchema = string().min(1).refine((id) => id.trim().length > 0, "Semantic IDs cannot be blank");
4647
5068
  const SemanticNodeKindSchema = _enum([
4648
5069
  "Model",
@@ -33987,7 +34408,16 @@ async function main(args = process.argv.slice(2)) {
33987
34408
  if (args.length === 1 && (args[0] === "--version" || args[0] === "--help")) {
33988
34409
  const metadata = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
33989
34410
  if (args[0] === "--version") process.stdout.write(metadata.version + "\n");
33990
- else process.stdout.write(`Lindy ${metadata.version} — unpublished portable candidate\nUsage: lindy init DIRECTORY\n lindy preview --project FILE [--port PORT]\n lindy mcp --project FILE\n lindy OPERATION --project FILE --request FILE [--approve]\nOperations: search, inspect, propose, patch, validate, affected, compile, artifact.\nPatch and compile retain explicit approval/revision requirements.\nPreview is loopback-only. Private one-use URL; restart resets sample records, not graph edits.\n`);
34411
+ else process.stdout.write(`Lindy ${metadata.version} — unpublished portable candidate\nUsage: lindy packs catalog [QUERY]\n lindy packs inspect PACKAGE\n lindy packs propose GRAPH POLICY PACKAGE...\n lindy packs compile APPROVAL GRAPH POLICY PACKAGE...\n lindy init DIRECTORY\n lindy preview --project FILE [--port PORT]\n lindy mcp --project FILE\n lindy OPERATION --project FILE --request FILE [--approve]\nOperations: search, inspect, propose, patch, validate, affected, compile, artifact.\nPatch and compile retain explicit approval/revision requirements.\nPreview is loopback-only. Private one-use URL; restart resets sample records, not graph edits.\n`);
34412
+ return;
34413
+ }
34414
+ if (args[0] === "packs") {
34415
+ try {
34416
+ await installedPacks(args.slice(1));
34417
+ } catch (error) {
34418
+ process.stderr.write((error instanceof Error ? error.message : "Pack command failed") + "\n");
34419
+ process.exitCode = 2;
34420
+ }
33991
34421
  return;
33992
34422
  }
33993
34423
  if (args[0] !== "init" && args[0] !== "preview") return main$1(args);
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@brybrophy/lindy",
3
- "version": "0.1.0-preview.2",
3
+ "version": "0.1.0-preview.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Bryan Brophy",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/brybrophy/Lindy.git"
11
+ },
8
12
  "engines": {
9
13
  "node": ">=24.0.0"
10
14
  },
package/release.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.0-preview.2",
2
+ "version": "0.1.0-preview.3",
3
3
  "node": ">=24.0.0",
4
4
  "packageName": "@brybrophy/lindy"
5
5
  }