@specdest/devkit 0.2.2 → 0.3.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.
Files changed (138) hide show
  1. package/README.md +17 -18
  2. package/package.json +4 -4
  3. package/src/canonical-project-operations.js +164 -0
  4. package/src/canonical-project.js +78 -0
  5. package/src/canonical-source.js +114 -0
  6. package/src/cli.js +2 -2
  7. package/src/git-catalog.js +105 -0
  8. package/src/index.js +6 -2
  9. package/src/project-operations.js +65 -6
  10. package/src/remote-installer.js +478 -0
  11. package/src/sync-core.js +20 -7
  12. package/catalog/README.md +0 -11
  13. package/catalog/modules/backend-convex/manifest.json +0 -14
  14. package/catalog/modules/backend-convex-expo/manifest.json +0 -11
  15. package/catalog/modules/backend-supabase/manifest.json +0 -15
  16. package/catalog/modules/backend-supabase-expo/manifest.json +0 -11
  17. package/catalog/modules/checker-runtime/config.ts +0 -25
  18. package/catalog/modules/checker-runtime/fs.ts +0 -48
  19. package/catalog/modules/checker-runtime/manifest.json +0 -29
  20. package/catalog/modules/checker-runtime/runtime.ts +0 -79
  21. package/catalog/modules/devflow/.agents/skills/devflow/SKILL.md +0 -33
  22. package/catalog/modules/devflow/.devflow.json +0 -10
  23. package/catalog/modules/devflow/manifest.json +0 -35
  24. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/SKILL.md +0 -85
  25. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/activeScenario.mjs +0 -130
  26. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/checkLocalEnvironment.mjs +0 -7
  27. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/completeActiveScenario.mjs +0 -36
  28. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/createActiveScenario.mjs +0 -143
  29. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/localEnvironment.mjs +0 -43
  30. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/prompt.mjs +0 -25
  31. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runActiveScenario.mjs +0 -66
  32. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runAuthoringScenario.mjs +0 -146
  33. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seed.mjs +0 -56
  34. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seedActiveScenario.mjs +0 -6
  35. package/catalog/modules/e2e-playwright/docs/e2e-playwright/README.md +0 -103
  36. package/catalog/modules/e2e-playwright/manifest.json +0 -206
  37. package/catalog/modules/e2e-playwright/playwright.e2e.config.ts +0 -39
  38. package/catalog/modules/e2e-playwright/tests/e2e/support/e2ePlaywrightFlow.ts +0 -107
  39. package/catalog/modules/e2e-playwright/tests/e2e/support/fixtures.ts +0 -27
  40. package/catalog/modules/local-log/AGENTS.local-log.md +0 -13
  41. package/catalog/modules/local-log/docs/features/local-logging/README.md +0 -70
  42. package/catalog/modules/local-log/manifest.json +0 -39
  43. package/catalog/modules/local-log/tmp/logs/.gitignore +0 -2
  44. package/catalog/modules/local-log/tools/local-log/README.md +0 -47
  45. package/catalog/modules/local-log/tools/local-log/local-log.mjs +0 -241
  46. package/catalog/modules/stack-common-vite/manifest.json +0 -16
  47. package/catalog/modules/stack-expo-convex/manifest.json +0 -31
  48. package/catalog/modules/stack-expo-supabase/manifest.json +0 -44
  49. package/catalog/modules/stack-vite-convex/manifest.json +0 -32
  50. package/catalog/modules/stack-vite-supabase/manifest.json +0 -45
  51. package/catalog/rules/abac-permissions-convex/SKILL.md +0 -17
  52. package/catalog/rules/abac-permissions-convex/check.ts +0 -87
  53. package/catalog/rules/abac-permissions-convex/manifest.json +0 -33
  54. package/catalog/rules/abac-permissions-supabase/SKILL.md +0 -17
  55. package/catalog/rules/abac-permissions-supabase/check.ts +0 -87
  56. package/catalog/rules/abac-permissions-supabase/manifest.json +0 -33
  57. package/catalog/rules/convex-multi-presentation/SKILL.md +0 -47
  58. package/catalog/rules/convex-multi-presentation/check.ts +0 -205
  59. package/catalog/rules/convex-multi-presentation/manifest.json +0 -47
  60. package/catalog/rules/convex-multi-presentation/policy.ts +0 -261
  61. package/catalog/rules/design-rules/SKILL.md +0 -12
  62. package/catalog/rules/design-rules/check.ts +0 -84
  63. package/catalog/rules/design-rules/config.json +0 -5
  64. package/catalog/rules/design-rules/manifest.json +0 -38
  65. package/catalog/rules/e2e-test-rules/SKILL.md +0 -46
  66. package/catalog/rules/e2e-test-rules/check.ts +0 -145
  67. package/catalog/rules/e2e-test-rules/config.json +0 -32
  68. package/catalog/rules/e2e-test-rules/manifest.json +0 -38
  69. package/catalog/rules/error-handling-rules/SKILL.md +0 -21
  70. package/catalog/rules/error-handling-rules/check.ts +0 -73
  71. package/catalog/rules/error-handling-rules/manifest.json +0 -33
  72. package/catalog/rules/layers-and-contracts/SKILL.md +0 -36
  73. package/catalog/rules/layers-and-contracts/check.ts +0 -266
  74. package/catalog/rules/layers-and-contracts/manifest.json +0 -33
  75. package/catalog/rules/layers-and-contracts-convex/SKILL.md +0 -49
  76. package/catalog/rules/layers-and-contracts-convex/check.ts +0 -289
  77. package/catalog/rules/layers-and-contracts-convex/manifest.json +0 -38
  78. package/catalog/rules/layers-and-contracts-convex/policy.ts +0 -68
  79. package/catalog/rules/layers-and-contracts-supabase/SKILL.md +0 -52
  80. package/catalog/rules/layers-and-contracts-supabase/check.ts +0 -371
  81. package/catalog/rules/layers-and-contracts-supabase/manifest.json +0 -38
  82. package/catalog/rules/layers-and-contracts-supabase/policy.ts +0 -68
  83. package/catalog/rules/module-size-rules/SKILL.md +0 -5
  84. package/catalog/rules/module-size-rules/check.ts +0 -144
  85. package/catalog/rules/module-size-rules/config.json +0 -6
  86. package/catalog/rules/module-size-rules/manifest.json +0 -38
  87. package/catalog/rules/module-size-rules-convex/SKILL.md +0 -5
  88. package/catalog/rules/module-size-rules-convex/check.ts +0 -146
  89. package/catalog/rules/module-size-rules-convex/config.json +0 -6
  90. package/catalog/rules/module-size-rules-convex/manifest.json +0 -38
  91. package/catalog/rules/module-size-rules-supabase/SKILL.md +0 -5
  92. package/catalog/rules/module-size-rules-supabase/check.ts +0 -146
  93. package/catalog/rules/module-size-rules-supabase/config.json +0 -12
  94. package/catalog/rules/module-size-rules-supabase/manifest.json +0 -38
  95. package/catalog/rules/mutation-command-rules/SKILL.md +0 -15
  96. package/catalog/rules/mutation-command-rules/check.ts +0 -30
  97. package/catalog/rules/mutation-command-rules/config.json +0 -19
  98. package/catalog/rules/mutation-command-rules/manifest.json +0 -38
  99. package/catalog/rules/nearby-contracts/SKILL.md +0 -18
  100. package/catalog/rules/nearby-contracts/check.ts +0 -138
  101. package/catalog/rules/nearby-contracts/config.json +0 -10
  102. package/catalog/rules/nearby-contracts/manifest.json +0 -38
  103. package/catalog/rules/no-raw-click-buttons/SKILL.md +0 -5
  104. package/catalog/rules/no-raw-click-buttons/check.ts +0 -37
  105. package/catalog/rules/no-raw-click-buttons/manifest.json +0 -33
  106. package/catalog/rules/public-api-export-barrels/SKILL.md +0 -45
  107. package/catalog/rules/public-api-export-barrels/check.ts +0 -73
  108. package/catalog/rules/public-api-export-barrels/config.json +0 -4
  109. package/catalog/rules/public-api-export-barrels/manifest.json +0 -38
  110. package/catalog/rules/route-tree-fresh/SKILL.md +0 -16
  111. package/catalog/rules/route-tree-fresh/check.ts +0 -66
  112. package/catalog/rules/route-tree-fresh/manifest.json +0 -33
  113. package/catalog/rules/strict-typescript/SKILL.md +0 -3
  114. package/catalog/rules/strict-typescript/check.ts +0 -119
  115. package/catalog/rules/strict-typescript/manifest.json +0 -33
  116. package/catalog/rules/supabase-contracts/SKILL.md +0 -3
  117. package/catalog/rules/supabase-contracts/check.ts +0 -172
  118. package/catalog/rules/supabase-contracts/manifest.json +0 -33
  119. package/catalog/rules/supabase-declarative-schema/SKILL.md +0 -30
  120. package/catalog/rules/supabase-declarative-schema/check.ts +0 -262
  121. package/catalog/rules/supabase-declarative-schema/config.json +0 -8
  122. package/catalog/rules/supabase-declarative-schema/manifest.json +0 -38
  123. package/catalog/rules/tanstack-form-rules/SKILL.md +0 -11
  124. package/catalog/rules/tanstack-form-rules/check.ts +0 -58
  125. package/catalog/rules/tanstack-form-rules/manifest.json +0 -33
  126. package/catalog/rules/unit-test-rules/SKILL.md +0 -55
  127. package/catalog/rules/unit-test-rules/check.ts +0 -132
  128. package/catalog/rules/unit-test-rules/config.json +0 -22
  129. package/catalog/rules/unit-test-rules/manifest.json +0 -38
  130. package/catalog/rules/unit-test-rules-convex/SKILL.md +0 -41
  131. package/catalog/rules/unit-test-rules-convex/check.ts +0 -418
  132. package/catalog/rules/unit-test-rules-convex/manifest.json +0 -33
  133. package/catalog/rules/unit-test-rules-supabase/SKILL.md +0 -40
  134. package/catalog/rules/unit-test-rules-supabase/check.ts +0 -492
  135. package/catalog/rules/unit-test-rules-supabase/manifest.json +0 -33
  136. package/catalog/rules/workstation-controller-rules/SKILL.md +0 -22
  137. package/catalog/rules/workstation-controller-rules/check.ts +0 -108
  138. package/catalog/rules/workstation-controller-rules/manifest.json +0 -33
@@ -1,241 +0,0 @@
1
- #!/usr/bin/env node
2
- import { realpathSync } from "node:fs";
3
- import { appendFile, mkdir, readFile, readdir, rm, stat } from "node:fs/promises";
4
- import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
-
7
- const LOG_FILE_PATTERN = /^activity-\d{4}-\d{2}-\d{2}\.jsonl$/;
8
- const SENSITIVE_KEY_PATTERN =
9
- /token|password|secret|authorization|cookie|api[-_]?key|private[-_]?key/i;
10
- const MAX_STRING_LENGTH = 4000;
11
- const MAX_ARRAY_LENGTH = 50;
12
- const MAX_OBJECT_KEYS = 100;
13
- const MAX_DEPTH = 6;
14
-
15
- function truncate(value) {
16
- const text = String(value);
17
- if (text.length <= MAX_STRING_LENGTH) return text;
18
- return `${text.slice(0, MAX_STRING_LENGTH)}…[truncated ${text.length - MAX_STRING_LENGTH} chars]`;
19
- }
20
-
21
- export function sanitizeForLog(value, depth = 0, seen = new WeakSet()) {
22
- if (value === null || value === undefined) return value;
23
- if (typeof value === "string") return truncate(value);
24
- if (["number", "boolean"].includes(typeof value)) return value;
25
- if (typeof value === "bigint") return String(value);
26
- if (typeof value === "function") return `[Function ${value.name || "anonymous"}]`;
27
- if (value instanceof Error) {
28
- const error = /** @type {Error & { code?: unknown, details?: unknown }} */ (value);
29
- return {
30
- name: error.name,
31
- message: truncate(error.message || String(error)),
32
- stack: error.stack ? truncate(error.stack) : undefined,
33
- code: error.code,
34
- details: sanitizeForLog(error.details, depth + 1, seen),
35
- };
36
- }
37
- if (typeof value !== "object") return truncate(value);
38
- if (depth >= MAX_DEPTH) return "[Max depth reached]";
39
- if (seen.has(value)) return "[Circular]";
40
- seen.add(value);
41
-
42
- if (Array.isArray(value)) {
43
- const items = value
44
- .slice(0, MAX_ARRAY_LENGTH)
45
- .map((item) => sanitizeForLog(item, depth + 1, seen));
46
- if (value.length > MAX_ARRAY_LENGTH)
47
- items.push(`[${value.length - MAX_ARRAY_LENGTH} more items]`);
48
- return items;
49
- }
50
-
51
- const result = {};
52
- const entries = Object.entries(value).slice(0, MAX_OBJECT_KEYS);
53
- for (const [key, item] of entries) {
54
- result[key] = SENSITIVE_KEY_PATTERN.test(key)
55
- ? "[REDACTED]"
56
- : sanitizeForLog(item, depth + 1, seen);
57
- }
58
- if (Object.keys(value).length > MAX_OBJECT_KEYS) {
59
- result.__truncatedKeys = Object.keys(value).length - MAX_OBJECT_KEYS;
60
- }
61
- return result;
62
- }
63
-
64
- function positiveInteger(value, fallback, maximum) {
65
- const parsed = Number.parseInt(String(value), 10);
66
- if (!Number.isFinite(parsed) || parsed < 1) return fallback;
67
- return Math.min(parsed, maximum);
68
- }
69
-
70
- export class LocalLogger {
71
- /** @param {{ rootDir?: string, logRoot?: string, source?: string, now?: () => Date }} [options] */
72
- constructor({
73
- rootDir = process.cwd(),
74
- logRoot,
75
- source = "application",
76
- now = () => new Date(),
77
- } = {}) {
78
- this.rootDir = path.resolve(rootDir);
79
- this.logRoot = path.resolve(
80
- logRoot || process.env.LOCAL_LOG_ROOT || path.join(this.rootDir, "tmp", "logs"),
81
- );
82
- this.source = source;
83
- this.now = now;
84
- }
85
-
86
- currentLogPath(date = this.now()) {
87
- return path.join(this.logRoot, `activity-${date.toISOString().slice(0, 10)}.jsonl`);
88
- }
89
-
90
- async write(entry) {
91
- const date = this.now();
92
- const file = this.currentLogPath(date);
93
- const record = sanitizeForLog({
94
- timestamp: date.toISOString(),
95
- level: "info",
96
- source: this.source,
97
- ...entry,
98
- });
99
- await mkdir(this.logRoot, { recursive: true });
100
- await appendFile(file, `${JSON.stringify(record)}\n`, "utf8");
101
- return { path: this.logRoot, file, record };
102
- }
103
-
104
- async tail(lines = 200) {
105
- const limit = positiveInteger(lines, 200, 5000);
106
- const files = await this.listFiles();
107
- const output = [];
108
- for (let index = files.length - 1; index >= 0 && output.length < limit; index -= 1) {
109
- const source = await readFile(path.join(this.logRoot, files[index]), "utf8");
110
- const fileLines = source.split("\n").filter(Boolean);
111
- output.unshift(...fileLines.slice(-(limit - output.length)));
112
- }
113
- return { path: this.logRoot, lines: output.length, content: output.join("\n") };
114
- }
115
-
116
- async clearAll() {
117
- const files = await this.listFiles();
118
- await Promise.all(files.map((name) => rm(path.join(this.logRoot, name), { force: true })));
119
- return { path: this.logRoot, removed: files.length };
120
- }
121
-
122
- async clearOlderThan(days = 7) {
123
- const ageDays = positiveInteger(days, 7, 3650);
124
- const cutoff = this.now().getTime() - ageDays * 24 * 60 * 60 * 1000;
125
- const removed = [];
126
- for (const name of await this.listFiles()) {
127
- const file = path.join(this.logRoot, name);
128
- if ((await stat(file)).mtimeMs < cutoff) {
129
- await rm(file, { force: true });
130
- removed.push(name);
131
- }
132
- }
133
- return { path: this.logRoot, days: ageDays, removed: removed.length, files: removed };
134
- }
135
-
136
- async listFiles() {
137
- try {
138
- return (await readdir(this.logRoot, { withFileTypes: true }))
139
- .filter((entry) => entry.isFile() && LOG_FILE_PATTERN.test(entry.name))
140
- .map((entry) => entry.name)
141
- .sort();
142
- } catch (error) {
143
- const fsError = /** @type {NodeJS.ErrnoException} */ (error);
144
- if (fsError.code === "ENOENT") return [];
145
- throw error;
146
- }
147
- }
148
- }
149
-
150
- export function createLocalLogger(options = {}) {
151
- return new LocalLogger(options);
152
- }
153
-
154
- export async function traceOperation(
155
- logger,
156
- { event, requestId = crypto.randomUUID(), details = {} },
157
- operation,
158
- ) {
159
- const startedAt = Date.now();
160
- await logger.write({ level: "info", event: `${event}.start`, requestId, details });
161
- try {
162
- const result = await operation();
163
- await logger.write({
164
- level: "info",
165
- event: `${event}.success`,
166
- requestId,
167
- durationMs: Date.now() - startedAt,
168
- result,
169
- });
170
- return result;
171
- } catch (error) {
172
- await logger.write({
173
- level: "error",
174
- event: `${event}.error`,
175
- requestId,
176
- durationMs: Date.now() - startedAt,
177
- error,
178
- });
179
- throw error;
180
- }
181
- }
182
-
183
- function usage() {
184
- return [
185
- "Local diagnostic logger",
186
- "",
187
- "Commands:",
188
- " write <event> [details-json] Append one structured event",
189
- " tail [lines] Print the newest log lines",
190
- " clear-old [days] Delete daily files older than N days",
191
- " clear-all Delete all daily log files",
192
- " path Print the log directory",
193
- "",
194
- "Environment:",
195
- " LOCAL_LOG_ROOT Override tmp/logs",
196
- " LOCAL_LOG_SOURCE Set the default source name",
197
- ].join("\n");
198
- }
199
-
200
- async function runCli(argv) {
201
- const [command, ...args] = argv;
202
- const logger = createLocalLogger({ source: process.env.LOCAL_LOG_SOURCE || "cli" });
203
-
204
- if (command === "write") {
205
- const event = String(args[0] || "").trim();
206
- if (!event) throw new Error("write requires an event name");
207
- const details = args[1] ? JSON.parse(args[1]) : {};
208
- console.log(JSON.stringify(await logger.write({ event, details })));
209
- return;
210
- }
211
- if (command === "tail") {
212
- const result = await logger.tail(args[0]);
213
- if (result.content) process.stdout.write(`${result.content}\n`);
214
- return;
215
- }
216
- if (command === "clear-old") {
217
- console.log(JSON.stringify(await logger.clearOlderThan(args[0])));
218
- return;
219
- }
220
- if (command === "clear-all") {
221
- console.log(JSON.stringify(await logger.clearAll()));
222
- return;
223
- }
224
- if (command === "path") {
225
- console.log(logger.logRoot);
226
- return;
227
- }
228
- console.log(usage());
229
- if (command) process.exitCode = 1;
230
- }
231
-
232
- const isMain = Boolean(
233
- process.argv[1] &&
234
- realpathSync(fileURLToPath(import.meta.url)) === realpathSync(path.resolve(process.argv[1])),
235
- );
236
- if (isMain) {
237
- runCli(process.argv.slice(2)).catch((error) => {
238
- process.stderr.write(`${error?.stack || error?.message || String(error)}\n`);
239
- process.exitCode = 1;
240
- });
241
- }
@@ -1,16 +0,0 @@
1
- {
2
- "id": "stack-common-vite",
3
- "kind": "module",
4
- "version": "1.0.0",
5
- "requires": [
6
- "design-rules",
7
- "e2e-test-rules",
8
- "error-handling-rules",
9
- "nearby-contracts",
10
- "public-api-export-barrels",
11
- "route-tree-fresh",
12
- "strict-typescript"
13
- ],
14
- "artifacts": [],
15
- "obsolete": []
16
- }
@@ -1,31 +0,0 @@
1
- {
2
- "id": "stack-expo-convex",
3
- "kind": "module",
4
- "version": "1.1.0",
5
- "requires": [
6
- "backend-convex-expo"
7
- ],
8
- "setupRequirements": [
9
- {
10
- "kind": "env",
11
- "name": "EXPO_PUBLIC_CONVEX_URL",
12
- "required": true,
13
- "exampleFile": ".env.example",
14
- "description": "Required runtime configuration for stack-expo-convex."
15
- }
16
- ],
17
- "artifacts": [
18
- {
19
- "kind": "shared-key-value",
20
- "path": ".env.example",
21
- "key": "EXPO_PUBLIC_CONVEX_URL",
22
- "value": ""
23
- },
24
- {
25
- "kind": "shared-line",
26
- "path": ".gitignore",
27
- "line": "!.env.example"
28
- }
29
- ],
30
- "obsolete": []
31
- }
@@ -1,44 +0,0 @@
1
- {
2
- "id": "stack-expo-supabase",
3
- "kind": "module",
4
- "version": "1.1.0",
5
- "requires": [
6
- "backend-supabase-expo"
7
- ],
8
- "setupRequirements": [
9
- {
10
- "kind": "env",
11
- "name": "EXPO_PUBLIC_SUPABASE_URL",
12
- "required": true,
13
- "exampleFile": ".env.example",
14
- "description": "Required runtime configuration for stack-expo-supabase."
15
- },
16
- {
17
- "kind": "env",
18
- "name": "EXPO_PUBLIC_SUPABASE_ANON_KEY",
19
- "required": true,
20
- "exampleFile": ".env.example",
21
- "description": "Required runtime configuration for stack-expo-supabase."
22
- }
23
- ],
24
- "artifacts": [
25
- {
26
- "kind": "shared-key-value",
27
- "path": ".env.example",
28
- "key": "EXPO_PUBLIC_SUPABASE_URL",
29
- "value": ""
30
- },
31
- {
32
- "kind": "shared-key-value",
33
- "path": ".env.example",
34
- "key": "EXPO_PUBLIC_SUPABASE_ANON_KEY",
35
- "value": ""
36
- },
37
- {
38
- "kind": "shared-line",
39
- "path": ".gitignore",
40
- "line": "!.env.example"
41
- }
42
- ],
43
- "obsolete": []
44
- }
@@ -1,32 +0,0 @@
1
- {
2
- "id": "stack-vite-convex",
3
- "kind": "module",
4
- "version": "1.2.0",
5
- "requires": [
6
- "backend-convex",
7
- "stack-common-vite"
8
- ],
9
- "setupRequirements": [
10
- {
11
- "kind": "env",
12
- "name": "VITE_CONVEX_URL",
13
- "required": true,
14
- "exampleFile": ".env.example",
15
- "description": "Required runtime configuration for stack-vite-convex."
16
- }
17
- ],
18
- "artifacts": [
19
- {
20
- "kind": "shared-key-value",
21
- "path": ".env.example",
22
- "key": "VITE_CONVEX_URL",
23
- "value": ""
24
- },
25
- {
26
- "kind": "shared-line",
27
- "path": ".gitignore",
28
- "line": "!.env.example"
29
- }
30
- ],
31
- "obsolete": []
32
- }
@@ -1,45 +0,0 @@
1
- {
2
- "id": "stack-vite-supabase",
3
- "kind": "module",
4
- "version": "1.2.0",
5
- "requires": [
6
- "backend-supabase",
7
- "stack-common-vite"
8
- ],
9
- "setupRequirements": [
10
- {
11
- "kind": "env",
12
- "name": "VITE_SUPABASE_URL",
13
- "required": true,
14
- "exampleFile": ".env.example",
15
- "description": "Required runtime configuration for stack-vite-supabase."
16
- },
17
- {
18
- "kind": "env",
19
- "name": "VITE_SUPABASE_ANON_KEY",
20
- "required": true,
21
- "exampleFile": ".env.example",
22
- "description": "Required runtime configuration for stack-vite-supabase."
23
- }
24
- ],
25
- "artifacts": [
26
- {
27
- "kind": "shared-key-value",
28
- "path": ".env.example",
29
- "key": "VITE_SUPABASE_URL",
30
- "value": ""
31
- },
32
- {
33
- "kind": "shared-key-value",
34
- "path": ".env.example",
35
- "key": "VITE_SUPABASE_ANON_KEY",
36
- "value": ""
37
- },
38
- {
39
- "kind": "shared-line",
40
- "path": ".gitignore",
41
- "line": "!.env.example"
42
- }
43
- ],
44
- "obsolete": []
45
- }
@@ -1,17 +0,0 @@
1
- # ABAC permissions
2
-
3
- Authorization data lives in Convex auth session and permission state only. Do not copy authorization metadata into `profile documents` or any other public table.
4
-
5
- Use permission attributes, not roles, for authorization. Do not add a `role` column to `profile documents`, and do not add RBAC helpers such as `current_app_role()`.
6
-
7
- Standard shape:
8
-
9
- ```json
10
- {
11
- "permissions": {
12
- "profiles": ["self", "manager", "full"]
13
- }
14
- }
15
- ```
16
-
17
- A resource-level `full` permission is a wildcard for that resource. Add project-specific resources only inside the target project, not in this boilerplate template.
@@ -1,87 +0,0 @@
1
- import { runtime } from "../shared/runtime.ts";
2
- // oxlint-disable no-console no-await-in-loop no-useless-concat no-useless-escape
3
- const violations: string[] = [];
4
- const authorityColumn = "ro" + "le";
5
- const metadataKey = "app_" + "metadata";
6
- const rawMetadataKey = "raw_app_" + "meta_data";
7
- const targetMetadataKey = "target_app_" + "metadata";
8
-
9
- async function* walk(dir: string): AsyncGenerator<string> {
10
- try {
11
- for await (const entry of runtime.readDir(dir)) {
12
- const path = `${dir}/${entry.name}`;
13
- if (entry.isDirectory) yield* walk(path);
14
- if (entry.isFile && /\.(ts|tsx|sql|mjs|js)$/.test(entry.name)) yield path;
15
- }
16
- } catch {
17
- return;
18
- }
19
- }
20
-
21
- function isIgnored(file: string): boolean {
22
- return (
23
- file.includes("node_modules") ||
24
- file.includes(".git/") ||
25
- file.includes(".agents/skills/abac-permissions/") ||
26
- file.includes("/tests/") ||
27
- file.endsWith(".test.ts") ||
28
- file.endsWith(".test.tsx") ||
29
- file.endsWith(".test.sql") ||
30
- file.endsWith("routeTree.gen.ts")
31
- );
32
- }
33
-
34
- function statements(text: string): string[] {
35
- return text.toLowerCase().split(";");
36
- }
37
-
38
- function writesRoleMetadata(text: string): boolean {
39
- const pattern = new RegExp(
40
- `(${metadataKey}|${rawMetadataKey}|${targetMetadataKey})[\\s\\S]{0,160}['\"]${authorityColumn}['\"]`,
41
- );
42
- return pattern.test(text);
43
- }
44
-
45
- function readsRoleMetadata(text: string): boolean {
46
- const pattern = new RegExp(
47
- `auth\\.jwt\\(\\)\\s*->\\s*'${metadataKey}'\\s*->>?\\s*'${authorityColumn}'`,
48
- );
49
- return pattern.test(text);
50
- }
51
-
52
- for await (const file of walk(".")) {
53
- if (isIgnored(file)) continue;
54
- const text = await runtime.readTextFile(file);
55
- const lower = text.toLowerCase();
56
-
57
- const profileTableStatement = statements(text).find((statement) =>
58
- /create\s+table[\s\S]*public\.profiles/.test(statement),
59
- );
60
- if (profileTableStatement?.includes(metadataKey)) {
61
- violations.push(`${file}: profiles persistence must not store app metadata`);
62
- }
63
- if (profileTableStatement?.includes("permissions")) {
64
- violations.push(`${file}: profiles persistence must not store permissions`);
65
- }
66
- if (new RegExp(`\\b${authorityColumn}\\s+text\\b`).test(profileTableStatement ?? "")) {
67
- violations.push(
68
- `${file}: profiles persistence must not store authorization role; use ABAC permissions`,
69
- );
70
- }
71
-
72
- if (/\bcurrent_app_role\b/.test(lower)) {
73
- violations.push(`${file}: RBAC helper current_app_role is forbidden; use ABAC permissions`);
74
- }
75
- if (readsRoleMetadata(lower)) {
76
- violations.push(`${file}: role metadata must not be read for authorization`);
77
- }
78
- if (writesRoleMetadata(lower)) {
79
- violations.push(`${file}: role metadata must not be written to app metadata`);
80
- }
81
- }
82
-
83
- if (violations.length) {
84
- console.error(violations.join("\n"));
85
- runtime.exit(1);
86
- }
87
- console.log("abac-permissions ok");
@@ -1,33 +0,0 @@
1
- {
2
- "id": "abac-permissions-convex",
3
- "kind": "rule",
4
- "version": "1.0.1",
5
- "requires": [
6
- "checker-runtime"
7
- ],
8
- "artifacts": [
9
- {
10
- "kind": "managed-file",
11
- "path": ".agents/skills/abac-permissions/SKILL.md",
12
- "source": "SKILL.md"
13
- },
14
- {
15
- "kind": "managed-file",
16
- "path": ".agents/skills/abac-permissions/check.ts",
17
- "source": "check.ts"
18
- },
19
- {
20
- "kind": "shared-markdown-section",
21
- "path": "AGENTS.md",
22
- "heading": "## Specdest backend rule: abac-permissions",
23
- "body": "Use `.agents/skills/abac-permissions/SKILL.md` for this backend-specific rule. Run `node .agents/skills/abac-permissions/check.ts` before handoff."
24
- }
25
- ],
26
- "obsolete": [],
27
- "check": {
28
- "command": [
29
- "node",
30
- ".agents/skills/abac-permissions/check.ts"
31
- ]
32
- }
33
- }
@@ -1,17 +0,0 @@
1
- # ABAC permissions
2
-
3
- Authorization data lives in Supabase Auth app metadata / JWT only. Do not copy authorization metadata into `public.profiles` or any other public table.
4
-
5
- Use permission attributes, not roles, for authorization. Do not add a `role` column to `public.profiles`, and do not add RBAC helpers such as `current_app_role()`.
6
-
7
- Standard shape:
8
-
9
- ```json
10
- {
11
- "permissions": {
12
- "profiles": ["self", "manager", "full"]
13
- }
14
- }
15
- ```
16
-
17
- A resource-level `full` permission is a wildcard for that resource. Add project-specific resources only inside the target project, not in this boilerplate template.
@@ -1,87 +0,0 @@
1
- import { runtime } from "../shared/runtime.ts";
2
- // oxlint-disable no-console no-await-in-loop no-useless-concat no-useless-escape
3
- const violations: string[] = [];
4
- const authorityColumn = "ro" + "le";
5
- const metadataKey = "app_" + "metadata";
6
- const rawMetadataKey = "raw_app_" + "meta_data";
7
- const targetMetadataKey = "target_app_" + "metadata";
8
-
9
- async function* walk(dir: string): AsyncGenerator<string> {
10
- try {
11
- for await (const entry of runtime.readDir(dir)) {
12
- const path = `${dir}/${entry.name}`;
13
- if (entry.isDirectory) yield* walk(path);
14
- if (entry.isFile && /\.(ts|tsx|sql|mjs|js)$/.test(entry.name)) yield path;
15
- }
16
- } catch {
17
- return;
18
- }
19
- }
20
-
21
- function isIgnored(file: string): boolean {
22
- return (
23
- file.includes("node_modules") ||
24
- file.includes(".git/") ||
25
- file.includes(".agents/skills/abac-permissions/") ||
26
- file.includes("/tests/") ||
27
- file.endsWith(".test.ts") ||
28
- file.endsWith(".test.tsx") ||
29
- file.endsWith(".test.sql") ||
30
- file.endsWith("routeTree.gen.ts")
31
- );
32
- }
33
-
34
- function statements(text: string): string[] {
35
- return text.toLowerCase().split(";");
36
- }
37
-
38
- function writesRoleMetadata(text: string): boolean {
39
- const pattern = new RegExp(
40
- `(${metadataKey}|${rawMetadataKey}|${targetMetadataKey})[\\s\\S]{0,160}['\"]${authorityColumn}['\"]`,
41
- );
42
- return pattern.test(text);
43
- }
44
-
45
- function readsRoleMetadata(text: string): boolean {
46
- const pattern = new RegExp(
47
- `auth\\.jwt\\(\\)\\s*->\\s*'${metadataKey}'\\s*->>?\\s*'${authorityColumn}'`,
48
- );
49
- return pattern.test(text);
50
- }
51
-
52
- for await (const file of walk(".")) {
53
- if (isIgnored(file)) continue;
54
- const text = await runtime.readTextFile(file);
55
- const lower = text.toLowerCase();
56
-
57
- const profileTableStatement = statements(text).find((statement) =>
58
- /create\s+table[\s\S]*public\.profiles/.test(statement),
59
- );
60
- if (profileTableStatement?.includes(metadataKey)) {
61
- violations.push(`${file}: profiles persistence must not store app metadata`);
62
- }
63
- if (profileTableStatement?.includes("permissions")) {
64
- violations.push(`${file}: profiles persistence must not store permissions`);
65
- }
66
- if (new RegExp(`\\b${authorityColumn}\\s+text\\b`).test(profileTableStatement ?? "")) {
67
- violations.push(
68
- `${file}: profiles persistence must not store authorization role; use ABAC permissions`,
69
- );
70
- }
71
-
72
- if (/\bcurrent_app_role\b/.test(lower)) {
73
- violations.push(`${file}: RBAC helper current_app_role is forbidden; use ABAC permissions`);
74
- }
75
- if (readsRoleMetadata(lower)) {
76
- violations.push(`${file}: role metadata must not be read for authorization`);
77
- }
78
- if (writesRoleMetadata(lower)) {
79
- violations.push(`${file}: role metadata must not be written to app metadata`);
80
- }
81
- }
82
-
83
- if (violations.length) {
84
- console.error(violations.join("\n"));
85
- runtime.exit(1);
86
- }
87
- console.log("abac-permissions ok");
@@ -1,33 +0,0 @@
1
- {
2
- "id": "abac-permissions-supabase",
3
- "kind": "rule",
4
- "version": "1.0.1",
5
- "requires": [
6
- "checker-runtime"
7
- ],
8
- "artifacts": [
9
- {
10
- "kind": "managed-file",
11
- "path": ".agents/skills/abac-permissions/SKILL.md",
12
- "source": "SKILL.md"
13
- },
14
- {
15
- "kind": "managed-file",
16
- "path": ".agents/skills/abac-permissions/check.ts",
17
- "source": "check.ts"
18
- },
19
- {
20
- "kind": "shared-markdown-section",
21
- "path": "AGENTS.md",
22
- "heading": "## Specdest backend rule: abac-permissions",
23
- "body": "Use `.agents/skills/abac-permissions/SKILL.md` for this backend-specific rule. Run `node .agents/skills/abac-permissions/check.ts` before handoff."
24
- }
25
- ],
26
- "obsolete": [],
27
- "check": {
28
- "command": [
29
- "node",
30
- ".agents/skills/abac-permissions/check.ts"
31
- ]
32
- }
33
- }