@simetrajs/designer 0.3.0-next.2 → 0.3.0-next.4

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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as toolByName, c as writeChanges, d as parseDataLaunch, f as databaseResource, i as structureOf, l as checkEnvName, o as formatDiagnostics, r as presentation, s as isMetadataFile, t as invoke, u as dataResource } from "./invoke-DLCOtVpB.js";
2
+ import { a as toolByName, c as writeChanges, d as parseDataLaunch, f as databaseResource, i as structureOf, l as checkEnvName, o as formatDiagnostics, r as presentation, s as isMetadataFile, t as invoke, u as dataResource } from "./invoke-Dkbpi4Fq.js";
3
3
  import { i as DEFAULT_DATABASE_URL_ENV, n as trimSlash, p as UsageError, t as DEFAULT_DIR } from "./default-dir-DerxTbci.js";
4
4
  import { defineCommand } from "citty";
5
5
  import { mkdtemp, readdir, rm, stat } from "node:fs/promises";
@@ -3,7 +3,7 @@ import { d as installedPackageDir, f as posixRelative, p as UsageError, t as DEF
3
3
  import { t as mcpArgs } from "./mcp-args-D63akJ97.js";
4
4
  import { defineCommand, parseArgs } from "citty";
5
5
  import { lstat, mkdir, readFile, readdir, readlink, realpath, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
6
- import { basename, dirname, join, posix, resolve, win32 } from "node:path";
6
+ import { basename, dirname, isAbsolute, join, posix, relative, resolve, win32 } from "node:path";
7
7
  import { parse } from "smol-toml";
8
8
  import { randomUUID } from "node:crypto";
9
9
  // src/init/fs-probe.ts
@@ -60,6 +60,7 @@ const DEFAULT_AGENTS = ["claude"];
60
60
  const MCP_SERVER_NAME = "simetra";
61
61
  const WORKSPACE = "${workspaceFolder}";
62
62
  const CURSOR_METADATA_DIR = `${WORKSPACE}/${DEFAULT_DIR.replace(/^\.\//, "")}`;
63
+ const argsOf = (l) => l.dir === void 0 ? l.args : [...l.args, l.dir];
63
64
  const CLIENTS = {
64
65
  claude: {
65
66
  file: ".mcp.json",
@@ -67,7 +68,7 @@ const CLIENTS = {
67
68
  container: "mcpServers",
68
69
  entry: (l) => ({
69
70
  command: l.command,
70
- args: l.args
71
+ args: argsOf(l)
71
72
  })
72
73
  },
73
74
  codex: {
@@ -76,20 +77,20 @@ const CLIENTS = {
76
77
  container: "mcp_servers",
77
78
  entry: (l) => ({
78
79
  command: l.command,
79
- args: l.args
80
+ args: argsOf(l)
80
81
  })
81
82
  },
82
83
  cursor: {
83
84
  file: ".cursor/mcp.json",
84
85
  format: "json",
85
86
  container: "mcpServers",
86
- entry: ({ command, args: [bin, ...rest] }) => ({
87
+ entry: ({ command, args: [bin, ...rest], dir }) => ({
87
88
  type: "stdio",
88
89
  command,
89
90
  args: [
90
91
  `${WORKSPACE}/${bin}`,
91
92
  ...rest,
92
- CURSOR_METADATA_DIR
93
+ dir === void 0 ? CURSOR_METADATA_DIR : `${WORKSPACE}/${dir}`
93
94
  ]
94
95
  })
95
96
  },
@@ -100,7 +101,7 @@ const CLIENTS = {
100
101
  entry: (l) => ({
101
102
  type: "stdio",
102
103
  command: l.command,
103
- args: l.args,
104
+ args: argsOf(l),
104
105
  cwd: WORKSPACE
105
106
  })
106
107
  }
@@ -616,14 +617,20 @@ async function classifyFile(path, expected) {
616
617
  }
617
618
  // src/init/plan.ts
618
619
  /**
619
- * Повний план `init`: лише читає диск. Пакет шукається вгору від кореня тим
620
- * самим механізмом, що й `$schema` (спека designer §4.2); його відсутність —
621
- * `UsageError` з назвою пакета.
620
+ * Повний план `init`: лише читає диск. Пакет шукається вгору від теки
621
+ * метаданих тим самим механізмом, що й `$schema` (спека designer §4.2): корінь
622
+ * агента може лежати над проєктом, чий `node_modules` до нього не видно. Його
623
+ * відсутність — `UsageError` з назвою пакета. Тека метаданих іде в запис MCP
624
+ * відносно кореня, коли вона не типова для нього.
622
625
  */
623
- async function planInit(root, agents, platform) {
624
- const pkgDir = installedPackageDir(root, DESIGNER_PACKAGE);
626
+ async function planInit(root, metadataDir, agents, platform) {
627
+ const pkgDir = installedPackageDir(metadataDir, DESIGNER_PACKAGE);
625
628
  const skills = await planSkillLinks(root, pkgDir, platform);
626
- const configs = await planMcpConfigs(root, agents, await mcpLaunch(root, pkgDir), platform);
629
+ const dir = posixRelative(root, metadataDir) || ".";
630
+ const configs = await planMcpConfigs(root, agents, {
631
+ ...await mcpLaunch(root, pkgDir),
632
+ ...dir === posixRelative(root, resolve(root, "./metadata")) ? {} : { dir }
633
+ }, platform);
627
634
  return {
628
635
  actions: [...skills.actions, ...configs.actions],
629
636
  notes: [...skills.notes, ...configs.notes],
@@ -705,6 +712,15 @@ async function writeAtomic(path, content) {
705
712
  }
706
713
  // src/commands/init.ts
707
714
  const initArgs = {
715
+ dir: {
716
+ type: "positional",
717
+ description: `Metadata directory (default: ${DEFAULT_DIR}); the package is looked up from it`,
718
+ required: false
719
+ },
720
+ root: {
721
+ type: "string",
722
+ description: "Directory the agent starts in, where the skill links and MCP configs are written (default: the current directory)"
723
+ },
708
724
  agents: {
709
725
  type: "string",
710
726
  description: `Comma-separated agents to write MCP configs for: ${AGENTS.join(", ")} (default: ${DEFAULT_AGENTS.join(",")})`
@@ -720,6 +736,8 @@ const initArgs = {
720
736
  };
721
737
  const KNOWN_KEYS = /* @__PURE__ */ new Set([
722
738
  "_",
739
+ "dir",
740
+ "root",
723
741
  "agents",
724
742
  "dry-run",
725
743
  "dryRun",
@@ -745,11 +763,15 @@ var init_default = defineCommand({
745
763
  * поганий аргумент, а не відсутній пакет.
746
764
  */
747
765
  async function runInit(args, cwd, platform = process.platform) {
748
- const root = resolve(cwd);
749
- const rel = (path) => posixRelative(root, path);
766
+ const rel = (path) => posixRelative(resolve(cwd), path);
750
767
  try {
751
- const { agents, mode } = parseInitArgs(args);
752
- const plan = await planInit(root, agents, platform);
768
+ const { agents, mode, dir, root: rootArg } = parseInitArgs(args);
769
+ const root = resolve(cwd, rootArg);
770
+ if (!await isDirectory(root)) throw new UsageError(`--root ${rootArg} is not a directory`);
771
+ if (dir !== void 0 && !await isDirectory(resolve(cwd, dir))) throw new UsageError(`metadata directory ${dir} is not a directory`);
772
+ const metadataDir = resolve(cwd, dir ?? "./metadata");
773
+ if (isAbsolute(relative(root, metadataDir))) throw new UsageError(`metadata directory ${dir ?? "./metadata"} is on another drive than the root ${rootArg}; keep them on one drive`);
774
+ const plan = await planInit(root, metadataDir, agents, platform);
753
775
  if (plan.refusals.length > 0) return refused(plan, rel);
754
776
  const lines = plan.actions.map(renderAction(rel));
755
777
  const notes = plan.notes.map(renderNote(rel));
@@ -775,16 +797,20 @@ async function runInit(args, cwd, platform = process.platform) {
775
797
  throw e;
776
798
  }
777
799
  }
800
+ const isDirectory = (path) => stat(path).then((s) => s.isDirectory(), () => false);
778
801
  function parseInitArgs(args) {
779
802
  for (const key of Object.keys(args)) if (!KNOWN_KEYS.has(key)) throw new UsageError(`unknown option --${key}`);
780
803
  const positional = Array.isArray(args._) ? args._ : [];
781
- if (positional.length > 0) throw new UsageError(`unexpected argument "${String(positional[0])}": init takes no positional arguments`);
804
+ if (positional.length > 1) throw new UsageError(`unexpected argument "${String(positional[1])}": init takes one metadata directory`);
805
+ if (args.root !== void 0 && typeof args.root !== "string") throw new UsageError("--root needs a directory");
782
806
  const check = args.check === true;
783
807
  const dryRun = args["dry-run"] === true;
784
808
  if (check && dryRun) throw new UsageError("--check and --dry-run cannot be combined");
785
809
  return {
786
810
  agents: args.agents === void 0 ? DEFAULT_AGENTS : agentList(args.agents),
787
- mode: check ? "check" : dryRun ? "dry-run" : "init"
811
+ mode: check ? "check" : dryRun ? "dry-run" : "init",
812
+ dir: positional.length === 0 ? void 0 : String(positional[0]),
813
+ root: args.root ?? "."
788
814
  };
789
815
  }
790
816
  function agentList(value) {
@@ -1617,7 +1617,75 @@ function summarizeData(name, data) {
1617
1617
  if ("error" in data) return `${name}: ${data.error.code}${data.error.reason === void 0 ? "" : `: ${data.error.reason}`}`;
1618
1618
  const count = (n, what) => `${n} ${what}${n === 1 ? "" : "s"}`;
1619
1619
  if ("count" in data) return `${name}: ${data.capped === true ? "over " : ""}${count(data.count, "row")} counted`;
1620
- return "rows" in data ? `${name}: ${count(data.rows.length, "row")}` : `${name}: ${count(data.result.changes.length, "change")}`;
1620
+ if ("rows" in data) return `${name}: ${count(data.rows.length, "row")}`;
1621
+ const created = data.result.changes.filter((c) => c.operation === "create").map((c) => `created ${c.object.kind} ${c.object.name} ${c.id}`);
1622
+ return [`${name}: ${count(data.result.changes.length, "change")}`, ...created].join("\n");
1623
+ }
1624
+ /**
1625
+ * `id` для `create` без нього (спека designer §3.2): ключ рядка — UUID, і викликач не
1626
+ * мусить його вигадувати. Корінь виду скоупу лишається без `id`: його генерує
1627
+ * T3 і відмовляє на переданий; невідомий об'єкт відхилить T3.
1628
+ */
1629
+ function withCreateIds(catalog, batch, newId = () => crypto.randomUUID()) {
1630
+ return batch.map((op) => {
1631
+ if (op.action !== "create" || op.id !== void 0) return op;
1632
+ const object = catalog.objects.find((o) => o.kind === op.object.kind && o.name === op.object.name);
1633
+ if (object === void 0 || object.operations?.create?.root !== void 0) return op;
1634
+ return {
1635
+ ...op,
1636
+ id: newId()
1637
+ };
1638
+ });
1639
+ }
1640
+ /**
1641
+ * Скоуп для `create` скоупленого об'єкта без нього (спека designer §3.2): єдиний скоуп
1642
+ * цього виду, де користувач — учасник; інакше вибір неоднозначний, і
1643
+ * designer відмовляє діагностикою, а не підставляє навмання. Скоупи
1644
+ * читаються лише тоді, коли хоч одній операції скоупу бракує.
1645
+ */
1646
+ async function withCreateScopes(model, catalog, batch, myScopes) {
1647
+ let scopes;
1648
+ const operations = [];
1649
+ for (const [index, op] of batch.entries()) {
1650
+ const object = op.action === "create" ? catalog.objects.find((o) => o.kind === op.object.kind && o.name === op.object.name) : void 0;
1651
+ const attribute = object?.attributes.find((a) => a.column === object.scopeColumn);
1652
+ if (op.action !== "create" || object?.scopeKindId === void 0 || attribute?.insert !== true || Object.hasOwn(op.values ?? {}, attribute.name)) {
1653
+ operations.push(op);
1654
+ continue;
1655
+ }
1656
+ scopes ??= await myScopes();
1657
+ const mine = [...new Set(scopes.filter((s) => s.scopeKind === object.scopeKindId).map((s) => s.scope))];
1658
+ if (mine.length !== 1) {
1659
+ const kind = model.scopeKinds.find((k) => k.id === object.scopeKindId);
1660
+ return { diagnostic: diagnostic("data.scope-unspecified", "", `/operations/${index}/values`, {
1661
+ object: `${op.object.kind} ${op.object.name}`,
1662
+ scopeKind: kind?.name ?? object.scopeKindId,
1663
+ attribute: attribute.name,
1664
+ scopes: mine.length
1665
+ }) };
1666
+ }
1667
+ operations.push({
1668
+ ...op,
1669
+ values: {
1670
+ ...op.values,
1671
+ [attribute.name]: mine[0]
1672
+ }
1673
+ });
1674
+ }
1675
+ return { operations };
1676
+ }
1677
+ /**
1678
+ * Скоупи користувача сесії зі знімка прав (`members`). Проєкт без функцій
1679
+ * прав знімка не має (`command.invalid`) — тоді скоупів немає, і рішення
1680
+ * лишається за діагностикою, а не за помилкою рантайму.
1681
+ */
1682
+ async function membersOf(runtime, session) {
1683
+ try {
1684
+ return (await runtime.rightsSnapshot(session)).snapshot.members;
1685
+ } catch (error) {
1686
+ if (error instanceof CommandFailure && error.error.code === "command.invalid") return [];
1687
+ throw error;
1688
+ }
1621
1689
  }
1622
1690
  const SQLSTATE = /^[0-9A-Z]{5}$/;
1623
1691
  /**
@@ -1727,7 +1795,7 @@ const dataReadTool = defineTool({
1727
1795
  });
1728
1796
  const dataCommandTool = defineTool({
1729
1797
  name: "data-command",
1730
- description: "Change application data of the development database as the user given by --as, with that user's rights: a batch of create, update, markDeletion and delete operations in one transaction (update, markDeletion and delete need expectedVersion). A tabular section array in update replaces the section: every existing row must be in the array or in deleteIds. Rights catalogs and create of a scope root whose creator gets a role need --allow-rights-write; objects with a module are refused, and for such a root also when its membership catalog has one. BigInt values may be passed as decimal strings. Each result row has the shape of a read card: the tabular sections the operation wrote come under tabularSections. A runtime error comes as data.error with a code.",
1798
+ description: "Change application data of the development database as the user given by --as, with that user's rights: a batch of create, update, markDeletion and delete operations in one transaction (update, markDeletion and delete need expectedVersion). A create without id gets a fresh one; without its scope it takes the user's only scope of that kind. A tabular section array in update replaces the section: every existing row must be in the array or in deleteIds. Rights catalogs and create of a scope root whose creator gets a role need --allow-rights-write; objects with a module are refused, and for such a root also when its membership catalog has one. BigInt values may be passed as decimal strings. Each result row has the shape of a read card: the tabular sections the operation wrote come under tabularSections. A runtime error comes as data.error with a code.",
1731
1799
  input: z.strictObject({ operations: batchSchema }),
1732
1800
  files: "read",
1733
1801
  database: "none",
@@ -1739,8 +1807,9 @@ const dataCommandTool = defineTool({
1739
1807
  const { model } = compiled;
1740
1808
  const warnings = warningsFor(model, compiled.diagnostics, input.operations.map((op) => op.object));
1741
1809
  const catalog = buildRuntimeCatalog(model);
1810
+ const operations = withCreateIds(catalog, input.operations);
1742
1811
  const rightsWrite = ctx.allowRightsWrite === true;
1743
- const refusal = dataPolicyRefusal(model, catalog, input.operations, { rightsWrite });
1812
+ const refusal = dataPolicyRefusal(model, catalog, operations, { rightsWrite });
1744
1813
  if (refusal?.kind === "command") return {
1745
1814
  ok: false,
1746
1815
  changes: [],
@@ -1753,12 +1822,20 @@ const dataCommandTool = defineTool({
1753
1822
  diagnostics: [],
1754
1823
  refusalReason: "rights-write-disabled"
1755
1824
  };
1756
- return onRuntime("data-command", ctx, model, warnings, async (rt, session) => {
1825
+ const ran = await onRuntime("data-command", ctx, model, warnings, async (rt, session) => {
1826
+ const scoped = await withCreateScopes(model, catalog, operations, () => membersOf(rt, session));
1827
+ if ("diagnostic" in scoped) return scoped;
1757
1828
  return { result: await createAgentCore({
1758
1829
  runtime: rt,
1759
1830
  permissions: { rightsWrite }
1760
- }).execute(session, input.operations) };
1831
+ }).execute(session, scoped.operations) };
1761
1832
  });
1833
+ if (ran.data !== void 0 && "diagnostic" in ran.data) return {
1834
+ ok: false,
1835
+ changes: [],
1836
+ diagnostics: [...warnings, ran.data.diagnostic]
1837
+ };
1838
+ return ran;
1762
1839
  },
1763
1840
  present: {
1764
1841
  structure: (data) => toJson(data),
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as version } from "./package-CN8Tgd0H.js";
2
+ import { t as version } from "./package-CES8dI-k.js";
3
3
  import { n as TOOL_NAMES } from "./types-CMcZhIci.js";
4
4
  import { defineCommand, runCommand, runMain, showUsage } from "citty";
5
5
  // src/main.ts
@@ -10,9 +10,9 @@ const main = defineCommand({
10
10
  description: "Simetra metadata tooling"
11
11
  },
12
12
  subCommands: {
13
- ...Object.fromEntries(TOOL_NAMES.map((name) => [name, () => import("./command-W8Mnvc9E.js").then((m) => m.commandByName(name))])),
14
- mcp: () => import("./mcp-DYYIww-s.js").then((m) => m.default),
15
- init: () => import("./init-jr0Xsrpp.js").then((m) => m.default)
13
+ ...Object.fromEntries(TOOL_NAMES.map((name) => [name, () => import("./command-BfioPN5J.js").then((m) => m.commandByName(name))])),
14
+ mcp: () => import("./mcp-CDT28dWI.js").then((m) => m.default),
15
+ init: () => import("./init-BS7fCOls.js").then((m) => m.default)
16
16
  }
17
17
  });
18
18
  const rawArgs = process.argv.slice(2);
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { d as parseDataLaunch, f as databaseResource, i as structureOf, l as checkEnvName, n as TOOLS, o as formatDiagnostics, r as presentation, t as invoke, u as dataResource } from "./invoke-DLCOtVpB.js";
2
+ import { d as parseDataLaunch, f as databaseResource, i as structureOf, l as checkEnvName, n as TOOLS, o as formatDiagnostics, r as presentation, t as invoke, u as dataResource } from "./invoke-Dkbpi4Fq.js";
3
3
  import { a as dataWriteHint, l as readOnlyHint, n as trimSlash, o as databaseWriteHint, p as UsageError, r as ALLOW_RIGHTS_WRITE_FLAG } from "./default-dir-DerxTbci.js";
4
- import { t as version } from "./package-CN8Tgd0H.js";
4
+ import { t as version } from "./package-CES8dI-k.js";
5
5
  import { t as mcpArgs } from "./mcp-args-D63akJ97.js";
6
6
  import { defineCommand } from "citty";
7
7
  import { z } from "zod";
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  // package.json
3
- var version = "0.3.0-next.2";
3
+ var version = "0.3.0-next.4";
4
4
  export { version as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simetrajs/designer",
3
- "version": "0.3.0-next.2",
3
+ "version": "0.3.0-next.4",
4
4
  "description": "Simetra developer tools: command line and MCP server over the metadata compiler",
5
5
  "keywords": [
6
6
  "simetra",
@@ -37,7 +37,7 @@
37
37
  "pg-connection-string": "2.14.1",
38
38
  "smol-toml": "1.9.1",
39
39
  "zod": "^4.6.7",
40
- "simetra": "0.3.0-next.2"
40
+ "simetra": "0.3.0-next.4"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@arethetypeswrong/cli": "0.18.5",
@@ -57,7 +57,7 @@
57
57
  "publishConfig": {
58
58
  "access": "public"
59
59
  },
60
- "gitHead": "bd2da08175642d706b7879ed34da1619e20c4951",
60
+ "gitHead": "ff6b3e68ad97ec97f9c9f6948bc678485a4142be",
61
61
  "scripts": {
62
62
  "build": "tsc --noEmit",
63
63
  "build:package": "tsdown",
@@ -323,6 +323,9 @@ system rights catalogs and tenant creation: a scope root whose creator gets a
323
323
  }
324
324
  ```
325
325
 
326
+ A new scope kind comes with its root and membership catalog in one `add`
327
+ (`objects`): `references/people-and-rights.md`.
328
+
326
329
  The PG schema `simetra` (identities, the current user, provisioning) belongs
327
330
  to the platform and is reserved (`schema.reserved`); in SQL the current user is
328
331
  `(select simetra.current_user_id())`. Both rules in full: the same reference.
@@ -156,8 +156,12 @@ Read a card with the rows its references point to:
156
156
  }
157
157
  ```
158
158
 
159
- Seed rows in one transaction (`id` is a new UUID you generate; `update`,
160
- `markDeletion` and `delete` also need `expectedVersion`):
159
+ Seed rows in one transaction (`update`, `markDeletion` and `delete` also
160
+ need `expectedVersion`). A `create` without `id` gets a fresh UUID, and the
161
+ CLI text output prints `created <kind> <name> <id>` for every new row. A
162
+ `create` of a scoped object without its scope value takes the only scope of
163
+ that kind the `--as` user is a member of; with none or several the batch is
164
+ refused with `data.scope-unspecified` — pass the scope in `values` then:
161
165
 
162
166
  ```json simetra:data-command
163
167
  {
@@ -165,7 +169,6 @@ Seed rows in one transaction (`id` is a new UUID you generate; `update`,
165
169
  {
166
170
  "action": "create",
167
171
  "object": { "kind": "Catalog", "name": "Currency" },
168
- "id": "0b9d4c5e-8f1a-4c3b-9e2d-6a7f8b9c0d1e",
169
172
  "values": { "description": "US dollar", "symbol": "$" }
170
173
  }
171
174
  ]
@@ -52,6 +52,38 @@ People are platform data, not tables you write yourself:
52
52
  its scope set function from that catalog. Use it instead of a hand-written
53
53
  member table and set function. One membership catalog per scope kind.
54
54
 
55
+ A scope kind needs its root (scoped by the kind itself) and, with
56
+ `"setFunction": "membership"`, a membership catalog; none of the three compiles
57
+ alone, so `add` creates them in one change with `objects`. Every existing
58
+ object that takes a scope must already declare one (`"scope": "none"` or a
59
+ kind), or the first kind fails with `scope.declaration-missing`:
60
+
61
+ ```json simetra:add
62
+ {
63
+ "target": { "kind": "Project" },
64
+ "collection": "scopeKinds",
65
+ "element": {
66
+ "name": "org",
67
+ "root": { "object": { "kind": "Catalog", "name": "Organization" } },
68
+ "setFunction": "membership"
69
+ },
70
+ "objects": [
71
+ { "kind": "Catalog", "name": "Organization", "data": { "scope": "org" } },
72
+ {
73
+ "kind": "Catalog",
74
+ "name": "OrgMember",
75
+ "data": {
76
+ "scope": "org",
77
+ "membership": { "user": "user" },
78
+ "attributes": [
79
+ { "name": "user", "type": "Ref", "ref": { "kind": "Catalog", "name": "Users" } }
80
+ ]
81
+ }
82
+ }
83
+ ]
84
+ }
85
+ ```
86
+
55
87
  The platform layer (identities, the current user, provisioning) lives in the
56
88
  PG schema `simetra`, generated when a users catalog exists, or when the
57
89
  project has a membership source and its provider's user id is the `sub` claim
@@ -633,6 +665,34 @@ the scope kind in `project.meta.json`) says that no role reads any object of
633
665
  that scope kind, so nobody will see their rows: grant `read` to a role or
634
666
  declare one with `fullAccess`.
635
667
 
668
+ **Open self sign-up.** `"selfSignUp": true` in `project.meta.json` declares
669
+ that anyone may register, so whatever every signed-in user sees is open to
670
+ anyone. The warning `project.self-sign-up` then lists the objects with
671
+ `publicRead` `authenticated` and the grants of `everyUser` roles. List what you
672
+ open on purpose in `selfSignUpAccepted`, and the warning names only the rest;
673
+ a new object, action or wider form warns again:
674
+
675
+ ```json
676
+ "selfSignUpAccepted": {
677
+ "objects": [{ "object": { "kind": "Catalog", "name": "Country" } }],
678
+ "grants": [
679
+ {
680
+ "role": { "kind": "Role", "name": "ClientOwner" },
681
+ "object": { "kind": "Catalog", "name": "Client" },
682
+ "actions": ["read", "update"],
683
+ "extent": "own"
684
+ }
685
+ ]
686
+ }
687
+ ```
688
+
689
+ `"published": true` on an object entry accepts only the published rows of the
690
+ conditional `publicRead`. The names are references: `rename` rewrites them, and
691
+ `delete` of an accepted object, role, custom action or dimension is refused
692
+ until the entry is removed. An entry that matches nothing open any more warns
693
+ with `project.self-sign-up-stale`: remove it, and accept the openness again
694
+ when it comes back.
695
+
636
696
  ## Who writes what
637
697
 
638
698
  Kind tables are written **only by commands**: the write policies grant the
@@ -5,8 +5,18 @@ package skills into `.agents/skills/` and `.claude/skills/` and writes the MCP
5
5
  server entry for the chosen agents. Run it from the project root — the
6
6
  directory the agent starts in, where `metadata/` lives.
7
7
 
8
+ When the agent starts in another directory (a monorepo root above the app),
9
+ name it with `--root`, or run `init` from there with the metadata directory as
10
+ the argument. The package is looked up from the metadata directory; the links
11
+ and configs go into the root, and the MCP entry names the metadata directory
12
+ relative to the root. A directory an own entry already names is kept. A
13
+ named metadata directory must exist, and on Windows it must be on the same
14
+ drive as the root.
15
+
8
16
  ```sh
9
17
  pnpm exec simetra init
18
+ pnpm exec simetra init --root ..
19
+ pnpm exec simetra init apps/app/metadata
10
20
  pnpm exec simetra init --agents claude,codex,cursor,vscode
11
21
  pnpm exec simetra init --dry-run
12
22
  pnpm exec simetra init --check --agents claude,codex
@@ -15,7 +25,7 @@ pnpm exec simetra init --check --agents claude,codex
15
25
  - Without `--agents` only Claude Code's `.mcp.json` is written. The skill
16
26
  links are made in both skill directories for every agent.
17
27
  - The links and configs belong in git. In CI run `init --check` with the same
18
- `--agents`: it exits 1 when a link or an MCP entry is missing or stale, and
28
+ `--agents`, `--root` and metadata directory: it exits 1 when a link or an MCP entry is missing or stale, and
19
29
  changes nothing.
20
30
  - `init` never overwrites what it does not own: a skill directory with the
21
31
  same name, or a `simetra` MCP entry with another command, is left alone and