swallowkit 1.0.0-beta.9 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/README.ja.md +87 -181
  2. package/README.md +87 -238
  3. package/dist/__tests__/fixtures.d.ts +12 -0
  4. package/dist/__tests__/fixtures.d.ts.map +1 -1
  5. package/dist/__tests__/fixtures.js +101 -0
  6. package/dist/__tests__/fixtures.js.map +1 -1
  7. package/dist/cli/commands/add-auth.d.ts +15 -0
  8. package/dist/cli/commands/add-auth.d.ts.map +1 -0
  9. package/dist/cli/commands/add-auth.js +790 -0
  10. package/dist/cli/commands/add-auth.js.map +1 -0
  11. package/dist/cli/commands/add-connector.d.ts +20 -0
  12. package/dist/cli/commands/add-connector.d.ts.map +1 -0
  13. package/dist/cli/commands/add-connector.js +164 -0
  14. package/dist/cli/commands/add-connector.js.map +1 -0
  15. package/dist/cli/commands/cosmos-worktree-isolation.d.ts +25 -0
  16. package/dist/cli/commands/cosmos-worktree-isolation.d.ts.map +1 -0
  17. package/dist/cli/commands/cosmos-worktree-isolation.js +124 -0
  18. package/dist/cli/commands/cosmos-worktree-isolation.js.map +1 -0
  19. package/dist/cli/commands/create-model.d.ts +1 -4
  20. package/dist/cli/commands/create-model.d.ts.map +1 -1
  21. package/dist/cli/commands/create-model.js +20 -82
  22. package/dist/cli/commands/create-model.js.map +1 -1
  23. package/dist/cli/commands/dev-seeds.d.ts +27 -0
  24. package/dist/cli/commands/dev-seeds.d.ts.map +1 -1
  25. package/dist/cli/commands/dev-seeds.js +188 -6
  26. package/dist/cli/commands/dev-seeds.js.map +1 -1
  27. package/dist/cli/commands/dev.d.ts +30 -0
  28. package/dist/cli/commands/dev.d.ts.map +1 -1
  29. package/dist/cli/commands/dev.js +495 -129
  30. package/dist/cli/commands/dev.js.map +1 -1
  31. package/dist/cli/commands/init.d.ts +69 -1
  32. package/dist/cli/commands/init.d.ts.map +1 -1
  33. package/dist/cli/commands/init.js +788 -766
  34. package/dist/cli/commands/init.js.map +1 -1
  35. package/dist/cli/commands/scaffold.d.ts +24 -3
  36. package/dist/cli/commands/scaffold.d.ts.map +1 -1
  37. package/dist/cli/commands/scaffold.js +408 -189
  38. package/dist/cli/commands/scaffold.js.map +1 -1
  39. package/dist/cli/index.d.ts +5 -1
  40. package/dist/cli/index.d.ts.map +1 -1
  41. package/dist/cli/index.js +335 -58
  42. package/dist/cli/index.js.map +1 -1
  43. package/dist/core/config.d.ts +13 -3
  44. package/dist/core/config.d.ts.map +1 -1
  45. package/dist/core/config.js +151 -8
  46. package/dist/core/config.js.map +1 -1
  47. package/dist/core/mock/connector-mock-server.d.ts +101 -0
  48. package/dist/core/mock/connector-mock-server.d.ts.map +1 -0
  49. package/dist/core/mock/connector-mock-server.js +480 -0
  50. package/dist/core/mock/connector-mock-server.js.map +1 -0
  51. package/dist/core/mock/zod-mock-generator.d.ts +14 -0
  52. package/dist/core/mock/zod-mock-generator.d.ts.map +1 -0
  53. package/dist/core/mock/zod-mock-generator.js +163 -0
  54. package/dist/core/mock/zod-mock-generator.js.map +1 -0
  55. package/dist/core/operations/auth-operations.d.ts +61 -0
  56. package/dist/core/operations/auth-operations.d.ts.map +1 -0
  57. package/dist/core/operations/auth-operations.js +272 -0
  58. package/dist/core/operations/auth-operations.js.map +1 -0
  59. package/dist/core/operations/create-model.d.ts +15 -0
  60. package/dist/core/operations/create-model.d.ts.map +1 -0
  61. package/dist/core/operations/create-model.js +185 -0
  62. package/dist/core/operations/create-model.js.map +1 -0
  63. package/dist/core/operations/file-session.d.ts +56 -0
  64. package/dist/core/operations/file-session.d.ts.map +1 -0
  65. package/dist/core/operations/file-session.js +203 -0
  66. package/dist/core/operations/file-session.js.map +1 -0
  67. package/dist/core/operations/provision-operations.d.ts +52 -0
  68. package/dist/core/operations/provision-operations.d.ts.map +1 -0
  69. package/dist/core/operations/provision-operations.js +211 -0
  70. package/dist/core/operations/provision-operations.js.map +1 -0
  71. package/dist/core/operations/runtime.d.ts +37 -0
  72. package/dist/core/operations/runtime.d.ts.map +1 -0
  73. package/dist/core/operations/runtime.js +248 -0
  74. package/dist/core/operations/runtime.js.map +1 -0
  75. package/dist/core/operations/scaffold-apply.d.ts +21 -0
  76. package/dist/core/operations/scaffold-apply.d.ts.map +1 -0
  77. package/dist/core/operations/scaffold-apply.js +57 -0
  78. package/dist/core/operations/scaffold-apply.js.map +1 -0
  79. package/dist/core/operations/scaffold-machine.d.ts +16 -0
  80. package/dist/core/operations/scaffold-machine.d.ts.map +1 -0
  81. package/dist/core/operations/scaffold-machine.js +51 -0
  82. package/dist/core/operations/scaffold-machine.js.map +1 -0
  83. package/dist/core/operations/scaffold-plan.d.ts +43 -0
  84. package/dist/core/operations/scaffold-plan.d.ts.map +1 -0
  85. package/dist/core/operations/scaffold-plan.js +187 -0
  86. package/dist/core/operations/scaffold-plan.js.map +1 -0
  87. package/dist/core/project/agent-instructions.d.ts +29 -0
  88. package/dist/core/project/agent-instructions.d.ts.map +1 -0
  89. package/dist/core/project/agent-instructions.js +160 -0
  90. package/dist/core/project/agent-instructions.js.map +1 -0
  91. package/dist/core/project/artifacts.d.ts +58 -0
  92. package/dist/core/project/artifacts.d.ts.map +1 -0
  93. package/dist/core/project/artifacts.js +179 -0
  94. package/dist/core/project/artifacts.js.map +1 -0
  95. package/dist/core/project/boundaries.d.ts +50 -0
  96. package/dist/core/project/boundaries.d.ts.map +1 -0
  97. package/dist/core/project/boundaries.js +117 -0
  98. package/dist/core/project/boundaries.js.map +1 -0
  99. package/dist/core/project/capabilities.d.ts +58 -0
  100. package/dist/core/project/capabilities.d.ts.map +1 -0
  101. package/dist/core/project/capabilities.js +135 -0
  102. package/dist/core/project/capabilities.js.map +1 -0
  103. package/dist/core/project/drift.d.ts +29 -0
  104. package/dist/core/project/drift.d.ts.map +1 -0
  105. package/dist/core/project/drift.js +188 -0
  106. package/dist/core/project/drift.js.map +1 -0
  107. package/dist/core/project/infra.d.ts +49 -0
  108. package/dist/core/project/infra.d.ts.map +1 -0
  109. package/dist/core/project/infra.js +167 -0
  110. package/dist/core/project/infra.js.map +1 -0
  111. package/dist/core/project/manifest.d.ts +92 -0
  112. package/dist/core/project/manifest.d.ts.map +1 -0
  113. package/dist/core/project/manifest.js +321 -0
  114. package/dist/core/project/manifest.js.map +1 -0
  115. package/dist/core/project/state.d.ts +15 -0
  116. package/dist/core/project/state.d.ts.map +1 -0
  117. package/dist/core/project/state.js +106 -0
  118. package/dist/core/project/state.js.map +1 -0
  119. package/dist/core/project/validation.d.ts +20 -0
  120. package/dist/core/project/validation.d.ts.map +1 -0
  121. package/dist/core/project/validation.js +274 -0
  122. package/dist/core/project/validation.js.map +1 -0
  123. package/dist/core/project/workflows.d.ts +43 -0
  124. package/dist/core/project/workflows.d.ts.map +1 -0
  125. package/dist/core/project/workflows.js +299 -0
  126. package/dist/core/project/workflows.js.map +1 -0
  127. package/dist/core/scaffold/auth-generator.d.ts +63 -0
  128. package/dist/core/scaffold/auth-generator.d.ts.map +1 -0
  129. package/dist/core/scaffold/auth-generator.js +1774 -0
  130. package/dist/core/scaffold/auth-generator.js.map +1 -0
  131. package/dist/core/scaffold/connector-functions-generator.d.ts +41 -0
  132. package/dist/core/scaffold/connector-functions-generator.d.ts.map +1 -0
  133. package/dist/core/scaffold/connector-functions-generator.js +1029 -0
  134. package/dist/core/scaffold/connector-functions-generator.js.map +1 -0
  135. package/dist/core/scaffold/functions-generator.d.ts +4 -3
  136. package/dist/core/scaffold/functions-generator.d.ts.map +1 -1
  137. package/dist/core/scaffold/functions-generator.js +405 -134
  138. package/dist/core/scaffold/functions-generator.js.map +1 -1
  139. package/dist/core/scaffold/model-parser.d.ts +20 -0
  140. package/dist/core/scaffold/model-parser.d.ts.map +1 -1
  141. package/dist/core/scaffold/model-parser.js +229 -78
  142. package/dist/core/scaffold/model-parser.js.map +1 -1
  143. package/dist/core/scaffold/native-schema-generator.d.ts +19 -0
  144. package/dist/core/scaffold/native-schema-generator.d.ts.map +1 -0
  145. package/dist/core/scaffold/native-schema-generator.js +753 -0
  146. package/dist/core/scaffold/native-schema-generator.js.map +1 -0
  147. package/dist/core/scaffold/nextjs-generator.d.ts +8 -0
  148. package/dist/core/scaffold/nextjs-generator.d.ts.map +1 -1
  149. package/dist/core/scaffold/nextjs-generator.js +152 -8
  150. package/dist/core/scaffold/nextjs-generator.js.map +1 -1
  151. package/dist/core/scaffold/ui-generator.d.ts +17 -4
  152. package/dist/core/scaffold/ui-generator.d.ts.map +1 -1
  153. package/dist/core/scaffold/ui-generator.js +174 -34
  154. package/dist/core/scaffold/ui-generator.js.map +1 -1
  155. package/dist/core/verify/index.d.ts +69 -0
  156. package/dist/core/verify/index.d.ts.map +1 -0
  157. package/dist/core/verify/index.js +412 -0
  158. package/dist/core/verify/index.js.map +1 -0
  159. package/dist/machine/contracts.d.ts +24 -0
  160. package/dist/machine/contracts.d.ts.map +1 -0
  161. package/dist/machine/contracts.js +3 -0
  162. package/dist/machine/contracts.js.map +1 -0
  163. package/dist/machine/errors.d.ts +14 -0
  164. package/dist/machine/errors.d.ts.map +1 -0
  165. package/dist/machine/errors.js +42 -0
  166. package/dist/machine/errors.js.map +1 -0
  167. package/dist/machine/index.d.ts +3 -0
  168. package/dist/machine/index.d.ts.map +1 -0
  169. package/dist/machine/index.js +566 -0
  170. package/dist/machine/index.js.map +1 -0
  171. package/dist/mcp/index.d.ts +25 -0
  172. package/dist/mcp/index.d.ts.map +1 -0
  173. package/dist/mcp/index.js +425 -0
  174. package/dist/mcp/index.js.map +1 -0
  175. package/dist/types/index.d.ts +105 -0
  176. package/dist/types/index.d.ts.map +1 -1
  177. package/dist/utils/package-manager.d.ts +7 -11
  178. package/dist/utils/package-manager.d.ts.map +1 -1
  179. package/dist/utils/package-manager.js +42 -17
  180. package/dist/utils/package-manager.js.map +1 -1
  181. package/dist/utils/python-uv.d.ts +21 -0
  182. package/dist/utils/python-uv.d.ts.map +1 -0
  183. package/dist/utils/python-uv.js +111 -0
  184. package/dist/utils/python-uv.js.map +1 -0
  185. package/dist/version.d.ts +2 -0
  186. package/dist/version.d.ts.map +1 -0
  187. package/dist/version.js +49 -0
  188. package/dist/version.js.map +1 -0
  189. package/package.json +15 -17
  190. package/src/__tests__/__snapshots__/functions-generator.test.ts.snap +716 -22
  191. package/src/__tests__/__snapshots__/nextjs-generator.test.ts.snap +19 -7
  192. package/src/__tests__/__snapshots__/ui-generator.test.ts.snap +20 -12
  193. package/src/__tests__/agent-instructions.test.ts +237 -0
  194. package/src/__tests__/agent-loop-phase34.test.ts +513 -0
  195. package/src/__tests__/auth.test.ts +770 -0
  196. package/src/__tests__/bff-swa-auth.test.ts +275 -0
  197. package/src/__tests__/config.test.ts +176 -3
  198. package/src/__tests__/connector-functions-generator.test.ts +288 -0
  199. package/src/__tests__/connector-mock-server.test.ts +459 -0
  200. package/src/__tests__/connector-model-bff.test.ts +162 -0
  201. package/src/__tests__/cosmos-worktree-isolation.test.ts +149 -0
  202. package/src/__tests__/dev-seeds.test.ts +124 -0
  203. package/src/__tests__/dev.test.ts +254 -0
  204. package/src/__tests__/file-session.test.ts +98 -0
  205. package/src/__tests__/fixtures.ts +101 -0
  206. package/src/__tests__/functions-generator.test.ts +137 -1
  207. package/src/__tests__/init.test.ts +366 -2
  208. package/src/__tests__/jest-globals.d.ts +8 -0
  209. package/src/__tests__/machine.test.ts +371 -0
  210. package/src/__tests__/mcp.test.ts +253 -0
  211. package/src/__tests__/model-parser.test.ts +142 -0
  212. package/src/__tests__/multi-auth.test.ts +160 -0
  213. package/src/__tests__/nextjs-generator.test.ts +8 -0
  214. package/src/__tests__/package-manager.test.ts +59 -4
  215. package/src/__tests__/plan-apply.test.ts +499 -0
  216. package/src/__tests__/python-uv.test.ts +48 -0
  217. package/src/__tests__/scaffold.test.ts +287 -24
  218. package/src/__tests__/tsconfig.json +15 -0
  219. package/src/__tests__/ui-generator.test.ts +104 -0
  220. package/src/__tests__/zod-mock-generator.test.ts +132 -0
  221. package/src/cli/commands/add-auth.ts +853 -0
  222. package/src/cli/commands/add-connector.ts +159 -0
  223. package/src/cli/commands/cosmos-worktree-isolation.ts +130 -0
  224. package/src/cli/commands/create-model.ts +21 -100
  225. package/src/cli/commands/dev-seeds.ts +278 -7
  226. package/src/cli/commands/dev.ts +607 -160
  227. package/src/cli/commands/init.ts +851 -786
  228. package/src/cli/commands/scaffold.ts +531 -236
  229. package/src/cli/index.ts +338 -60
  230. package/src/core/config.ts +145 -9
  231. package/src/core/mock/connector-mock-server.ts +555 -0
  232. package/src/core/mock/zod-mock-generator.ts +205 -0
  233. package/src/core/operations/auth-operations.ts +360 -0
  234. package/src/core/operations/create-model.ts +191 -0
  235. package/src/core/operations/file-session.ts +222 -0
  236. package/src/core/operations/provision-operations.ts +297 -0
  237. package/src/core/operations/runtime.ts +258 -0
  238. package/src/core/operations/scaffold-apply.ts +106 -0
  239. package/src/core/operations/scaffold-machine.ts +77 -0
  240. package/src/core/operations/scaffold-plan.ts +215 -0
  241. package/src/core/project/agent-instructions.ts +167 -0
  242. package/src/core/project/agent-templates/AGENTS.md +504 -0
  243. package/src/core/project/agent-templates/CLAUDE.md +31 -0
  244. package/src/core/project/agent-templates/azure-functions.instructions.md +22 -0
  245. package/src/core/project/agent-templates/bff-routes.instructions.md +18 -0
  246. package/src/core/project/agent-templates/copilot-instructions.md +27 -0
  247. package/src/core/project/agent-templates/shared-models.instructions.md +72 -0
  248. package/src/core/project/artifacts.ts +205 -0
  249. package/src/core/project/boundaries.ts +170 -0
  250. package/src/core/project/capabilities.ts +193 -0
  251. package/src/core/project/drift.ts +202 -0
  252. package/src/core/project/infra.ts +196 -0
  253. package/src/core/project/manifest.ts +402 -0
  254. package/src/core/project/state.ts +77 -0
  255. package/src/core/project/validation.ts +295 -0
  256. package/src/core/project/workflows.ts +295 -0
  257. package/src/core/scaffold/auth-generator.ts +1824 -0
  258. package/src/core/scaffold/connector-functions-generator.ts +1133 -0
  259. package/src/core/scaffold/functions-generator.ts +432 -134
  260. package/src/core/scaffold/model-parser.ts +244 -90
  261. package/src/core/scaffold/native-schema-generator.ts +904 -0
  262. package/src/core/scaffold/nextjs-generator.ts +174 -9
  263. package/src/core/scaffold/ui-generator.ts +191 -36
  264. package/src/core/verify/index.ts +468 -0
  265. package/src/machine/contracts.ts +33 -0
  266. package/src/machine/errors.ts +45 -0
  267. package/src/machine/index.ts +690 -0
  268. package/src/mcp/index.ts +423 -0
  269. package/src/types/index.ts +137 -0
  270. package/src/utils/package-manager.ts +41 -19
  271. package/src/utils/python-uv.ts +96 -0
  272. package/src/version.ts +13 -0
@@ -0,0 +1,274 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.validateProject = validateProject;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const manifest_1 = require("./manifest");
40
+ const model_parser_1 = require("../scaffold/model-parser");
41
+ function pushViolation(violations, violation) {
42
+ violations.push(violation);
43
+ }
44
+ function hasScaffoldedEntities(manifest) {
45
+ return manifest.entities.length > 0;
46
+ }
47
+ function validateRequiredPaths(manifest, violations) {
48
+ const requiredModules = manifest.modules.filter((module) => ["shared-models", "bff", "functions"].includes(module.kind));
49
+ for (const module of requiredModules) {
50
+ if (!module.exists) {
51
+ pushViolation(violations, {
52
+ code: "missing-required-module",
53
+ severity: "error",
54
+ message: `Required module path is missing: ${module.rootPath}`,
55
+ location: { path: module.rootPath },
56
+ suggestedFix: "Initialize or restore the standard SwallowKit project directories before generating code.",
57
+ });
58
+ }
59
+ }
60
+ if (hasScaffoldedEntities(manifest) && !manifest.artifacts.callFunctionHelperExists) {
61
+ pushViolation(violations, {
62
+ code: "missing-call-function-helper",
63
+ severity: "warning",
64
+ message: "BFF helper lib/api/call-function.ts is missing.",
65
+ location: { path: manifest.artifacts.callFunctionHelperPath },
66
+ suggestedFix: "Run scaffold to regenerate the BFF helper.",
67
+ });
68
+ }
69
+ }
70
+ function validateSchemaNaming(entity, violations) {
71
+ const expectedFileName = `${(0, model_parser_1.toKebabCase)(entity.name)}.ts`;
72
+ if (!entity.filePath.endsWith(expectedFileName)) {
73
+ pushViolation(violations, {
74
+ code: "naming-model-file",
75
+ severity: "warning",
76
+ message: `Model file should match the entity name in kebab-case: expected ${expectedFileName}.`,
77
+ location: { path: entity.filePath, entity: entity.name },
78
+ suggestedFix: `Rename the model file to ${expectedFileName} to keep generator conventions deterministic.`,
79
+ });
80
+ }
81
+ const camelSchema = `${(0, model_parser_1.toCamelCase)(entity.name)}Schema`;
82
+ if (entity.schemaName !== entity.name && entity.schemaName !== camelSchema) {
83
+ pushViolation(violations, {
84
+ code: "naming-schema-export",
85
+ severity: "warning",
86
+ message: `Schema export should be ${entity.name} or ${camelSchema}. Found ${entity.schemaName}.`,
87
+ location: { path: entity.filePath, entity: entity.name },
88
+ suggestedFix: "Use either the PascalCase Zod export or the camelCase Schema suffix pattern supported by SwallowKit.",
89
+ });
90
+ }
91
+ }
92
+ function validateGeneratedArtifacts(manifest, violations) {
93
+ for (const route of manifest.routes.filter((candidate) => candidate.kind === "entity")) {
94
+ if (!route.exists) {
95
+ pushViolation(violations, {
96
+ code: route.surface === "bff" ? "missing-bff-route" : "missing-functions-artifact",
97
+ severity: "warning",
98
+ message: `${route.surface === "bff" ? "BFF route" : "Functions artifact"} is missing for ${route.entityName}.`,
99
+ location: {
100
+ path: route.filePath,
101
+ entity: route.entityName,
102
+ },
103
+ suggestedFix: `Run scaffold for ${route.entityName} to regenerate ${route.surface === "bff" ? "API routes" : "Functions code"}.`,
104
+ });
105
+ }
106
+ }
107
+ if (hasScaffoldedEntities(manifest) &&
108
+ manifest.backendLanguage !== "typescript" &&
109
+ manifest.artifacts.openApiSpecs.length === 0) {
110
+ pushViolation(violations, {
111
+ code: "missing-openapi-artifacts",
112
+ severity: "warning",
113
+ message: `No OpenAPI export or native schema artifacts were found for ${manifest.backendLanguage} backend generation.`,
114
+ location: { path: "functions/openapi" },
115
+ suggestedFix: "Run scaffold to regenerate the OpenAPI export and native backend schema artifacts.",
116
+ });
117
+ }
118
+ }
119
+ function validateLayeringViolations(projectRoot, violations) {
120
+ const apiDir = path.join(projectRoot, "app", "api");
121
+ const modelsDir = path.join(projectRoot, "shared", "models");
122
+ if (fs.existsSync(apiDir)) {
123
+ for (const filePath of walkFiles(apiDir, [".ts", ".tsx"])) {
124
+ const content = fs.readFileSync(filePath, "utf-8");
125
+ if (content.includes("@azure/cosmos") || content.match(/from\s+['"].*functions\//)) {
126
+ pushViolation(violations, {
127
+ code: "forbidden-bff-dependency",
128
+ severity: "error",
129
+ message: "BFF files must not depend directly on Azure Cosmos or Functions implementation paths.",
130
+ location: { path: path.relative(projectRoot, filePath).replace(/\\/g, "/") },
131
+ suggestedFix: "Keep app/api as a pure BFF layer and call the backend through generated helpers instead.",
132
+ });
133
+ }
134
+ }
135
+ }
136
+ if (fs.existsSync(modelsDir)) {
137
+ for (const filePath of walkFiles(modelsDir, [".ts", ".tsx"])) {
138
+ const content = fs.readFileSync(filePath, "utf-8");
139
+ if (content.match(/from\s+['"].*(app\/|functions\/|lib\/api\/)/)) {
140
+ pushViolation(violations, {
141
+ code: "forbidden-model-layer-import",
142
+ severity: "error",
143
+ message: "Shared models must not import from app/, functions/, or lib/api/ layers.",
144
+ location: { path: path.relative(projectRoot, filePath).replace(/\\/g, "/") },
145
+ suggestedFix: "Keep shared/models framework-agnostic so generators can reuse them across all layers.",
146
+ });
147
+ }
148
+ }
149
+ }
150
+ }
151
+ function validateManifestDrift(projectRoot, loadedManifest, rebuiltManifest, violations) {
152
+ const sameEntitySet = JSON.stringify(loadedManifest.entities.map((entity) => entity.name).sort()) ===
153
+ JSON.stringify(rebuiltManifest.entities.map((entity) => entity.name).sort());
154
+ const sameRouteSet = JSON.stringify(loadedManifest.routes.map((route) => route.name).sort()) ===
155
+ JSON.stringify(rebuiltManifest.routes.map((route) => route.name).sort());
156
+ if (!sameEntitySet || !sameRouteSet) {
157
+ pushViolation(violations, {
158
+ code: "manifest-out-of-date",
159
+ severity: "warning",
160
+ message: `${manifest_1.SWALLOWKIT_MANIFEST_PATH} is out of date with the current project structure.`,
161
+ location: { path: manifest_1.SWALLOWKIT_MANIFEST_PATH },
162
+ suggestedFix: "Run a SwallowKit generator command or refresh the manifest so inspection and validation use current metadata.",
163
+ });
164
+ }
165
+ }
166
+ function walkFiles(directory, extensions) {
167
+ const collected = [];
168
+ for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
169
+ const entryPath = path.join(directory, entry.name);
170
+ if (entry.isDirectory()) {
171
+ collected.push(...walkFiles(entryPath, extensions));
172
+ continue;
173
+ }
174
+ if (extensions.some((extension) => entry.name.endsWith(extension))) {
175
+ collected.push(entryPath);
176
+ }
177
+ }
178
+ return collected;
179
+ }
180
+ const VERIFIER_STUB_MARKER = /External token verifier(?: for \S+)? is not configured/;
181
+ /**
182
+ * external-token スキームの verifier が生成スタブのまま (fail-closed throw のみ) だと
183
+ * typecheck / verify は通るのに実行時は必ず 401/503 になる。
184
+ * 「認証は生成されたが動かない」状態を warning として可視化する。
185
+ */
186
+ function validateExternalTokenVerifierStubs(projectRoot, manifest, violations) {
187
+ const auth = manifest.auth;
188
+ const hasExternalToken = auth?.provider === "external-token" ||
189
+ Object.values(auth?.schemes ?? {}).some((scheme) => scheme.provider === "external-token");
190
+ if (!hasExternalToken)
191
+ return;
192
+ const candidates = [
193
+ path.join("functions", "src", "auth", "external-token-verifier.ts"),
194
+ path.join("functions", "Auth", "ExternalTokenVerifier.cs"),
195
+ path.join("functions", "auth", "external_token_verifier.py"),
196
+ ];
197
+ const schemeDirs = [
198
+ { root: path.join("functions", "src", "auth", "schemes"), file: "verifier.ts" },
199
+ { root: path.join("functions", "Auth", "Schemes"), file: "ExternalTokenVerifier.cs" },
200
+ { root: path.join("functions", "auth", "schemes"), file: "verifier.py" },
201
+ ];
202
+ for (const { root, file } of schemeDirs) {
203
+ const absoluteRoot = path.join(projectRoot, root);
204
+ if (!fs.existsSync(absoluteRoot))
205
+ continue;
206
+ for (const entry of fs.readdirSync(absoluteRoot, { withFileTypes: true })) {
207
+ if (entry.isDirectory())
208
+ candidates.push(path.join(root, entry.name, file));
209
+ }
210
+ }
211
+ for (const relativePath of candidates) {
212
+ const absolutePath = path.join(projectRoot, relativePath);
213
+ if (!fs.existsSync(absolutePath))
214
+ continue;
215
+ const content = fs.readFileSync(absolutePath, "utf-8");
216
+ if (VERIFIER_STUB_MARKER.test(content)) {
217
+ pushViolation(violations, {
218
+ code: "auth-verifier-stub",
219
+ severity: "warning",
220
+ message: "External token verifier is still the generated stub; it fails closed, so external-token authentication cannot succeed at runtime.",
221
+ location: { path: relativePath.replace(/\\/g, "/") },
222
+ suggestedFix: "Implement the verifier against your identity provider. The file is yours to edit (generated-once).",
223
+ });
224
+ }
225
+ }
226
+ }
227
+ async function validateProject(projectRoot = process.cwd()) {
228
+ const loaded = await (0, manifest_1.loadProjectManifest)(projectRoot);
229
+ const rebuilt = await (0, manifest_1.buildProjectManifest)(projectRoot);
230
+ const violations = [];
231
+ validateRequiredPaths(loaded.manifest, violations);
232
+ for (const error of loaded.manifest.configValidation.errors) {
233
+ pushViolation(violations, {
234
+ code: "config-validation",
235
+ severity: "error",
236
+ message: error,
237
+ location: loaded.manifest.configPath ? { path: loaded.manifest.configPath } : undefined,
238
+ suggestedFix: "Fix the SwallowKit config so generators and validators have a stable project definition.",
239
+ });
240
+ }
241
+ const namedPolicies = loaded.manifest.auth?.authorization?.policies ?? {};
242
+ for (const entity of loaded.manifest.entities) {
243
+ const policy = entity.authPolicy;
244
+ if (!policy)
245
+ continue;
246
+ const references = [policy.policy, typeof policy.read === "string" ? policy.read : undefined, typeof policy.write === "string" ? policy.write : undefined].filter((value) => Boolean(value));
247
+ for (const name of references) {
248
+ if (!namedPolicies[name])
249
+ pushViolation(violations, {
250
+ code: "undefined-auth-policy",
251
+ severity: "error",
252
+ message: `Model '${entity.name}' references undefined authorization policy '${name}'.`,
253
+ location: { path: entity.filePath, entity: entity.name },
254
+ suggestedFix: `Define auth.authorization.policies.${name} or update the model authPolicy reference.`,
255
+ });
256
+ }
257
+ }
258
+ for (const entity of loaded.manifest.entities) {
259
+ validateSchemaNaming(entity, violations);
260
+ }
261
+ validateGeneratedArtifacts(loaded.manifest, violations);
262
+ validateLayeringViolations(projectRoot, violations);
263
+ validateExternalTokenVerifierStubs(projectRoot, loaded.manifest, violations);
264
+ if (loaded.source === "file") {
265
+ validateManifestDrift(projectRoot, loaded.manifest, rebuilt.manifest, violations);
266
+ }
267
+ return {
268
+ manifest: loaded.manifest,
269
+ manifestSource: loaded.source,
270
+ diagnostics: [...loaded.diagnostics, ...rebuilt.diagnostics],
271
+ violations: violations.sort((left, right) => left.code.localeCompare(right.code)),
272
+ };
273
+ }
274
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/core/project/validation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmPA,0CAmDC;AAtSD,uCAAyB;AACzB,2CAA6B;AAC7B,yCAAyI;AACzI,2DAAoE;AAsBpE,SAAS,aAAa,CACpB,UAA8B,EAC9B,SAA2B;IAE3B,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,qBAAqB,CAAC,QAAyB;IACtD,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,qBAAqB,CAAC,QAAyB,EAAE,UAA8B;IACtF,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CACzD,CAAC,eAAe,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAC5D,CAAC;IAEF,KAAK,MAAM,MAAM,IAAI,eAAe,EAAE,CAAC;QACrC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,aAAa,CAAC,UAAU,EAAE;gBACxB,IAAI,EAAE,yBAAyB;gBAC/B,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,oCAAoC,MAAM,CAAC,QAAQ,EAAE;gBAC9D,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,QAAQ,EAAE;gBACnC,YAAY,EAAE,2FAA2F;aAC1G,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,IAAI,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,wBAAwB,EAAE,CAAC;QACpF,aAAa,CAAC,UAAU,EAAE;YACxB,IAAI,EAAE,8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BAA0B,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACpD,kCAAkC,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAE7E,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC7B,qBAAqB,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACpF,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,cAAc,EAAE,MAAM,CAAC,MAAM;QAC7B,WAAW,EAAE,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;QAC5D,UAAU,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KAClF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Workflow Docs & Agent Skills
3
+ *
4
+ * 同一のランブック コンテンツから 2 つの表面を生成する:
5
+ * - `.swallowkit/workflows/*.md` — Coding Agent 非依存の Markdown ランブック
6
+ * (AGENTS.md / CLAUDE.md / copilot-instructions.md から参照される)
7
+ * - `.github/skills/<name>/SKILL.md` — Agent Skills (agentskills.io open standard)。
8
+ * GitHub Copilot (VS Code / CLI / cloud agent) 等が name/description で自動発見し、
9
+ * タスクに関連するときだけ本文をロードする (progressive disclosure)。
10
+ */
11
+ export interface WorkflowDoc {
12
+ /** `.swallowkit/workflows/` 配下のファイル名 */
13
+ fileName: string;
14
+ title: string;
15
+ content: string;
16
+ /**
17
+ * Agent Skills のスキル名 (ディレクトリ名と一致必須)。
18
+ * agentskills.io 仕様: 小文字英数字とハイフンのみ・64 文字以内。
19
+ * undefined の場合はスキルとして出力しない (README など)。
20
+ */
21
+ skillName?: string;
22
+ /**
23
+ * Agent Skills の description (最大 1024 文字)。
24
+ * 「何をするか」と「いつ使うか」の両方を書く。
25
+ */
26
+ skillDescription?: string;
27
+ }
28
+ export declare function buildWorkflowDocs(runCmd: string): WorkflowDoc[];
29
+ export declare const WORKFLOWS_DIR: string;
30
+ export declare const SKILLS_DIR: string;
31
+ /** `.swallowkit/workflows/*.md` を書き出し、書き込んだ相対パスを返す。 */
32
+ export declare function writeWorkflowDocs(projectDir: string, runCmd: string): string[];
33
+ /** Agent Skills (agentskills.io) の SKILL.md コンテンツを組み立てる。 */
34
+ export declare function buildAgentSkills(runCmd: string): Array<{
35
+ skillName: string;
36
+ content: string;
37
+ }>;
38
+ /**
39
+ * `.github/skills/<name>/SKILL.md` を書き出し、書き込んだ相対パスを返す。
40
+ * agentskills.io 仕様: ディレクトリ名は frontmatter の name と一致必須。
41
+ */
42
+ export declare function writeAgentSkills(projectDir: string, runCmd: string): string[];
43
+ //# sourceMappingURL=workflows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../../src/core/project/workflows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CA4N/D;AAED,eAAO,MAAM,aAAa,QAAwC,CAAC;AACnE,eAAO,MAAM,UAAU,QAAiC,CAAC;AAEzD,uDAAuD;AACvD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAS9E;AAED,4DAA4D;AAC5D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAS9F;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAS7E"}
@@ -0,0 +1,299 @@
1
+ "use strict";
2
+ /**
3
+ * Workflow Docs & Agent Skills
4
+ *
5
+ * 同一のランブック コンテンツから 2 つの表面を生成する:
6
+ * - `.swallowkit/workflows/*.md` — Coding Agent 非依存の Markdown ランブック
7
+ * (AGENTS.md / CLAUDE.md / copilot-instructions.md から参照される)
8
+ * - `.github/skills/<name>/SKILL.md` — Agent Skills (agentskills.io open standard)。
9
+ * GitHub Copilot (VS Code / CLI / cloud agent) 等が name/description で自動発見し、
10
+ * タスクに関連するときだけ本文をロードする (progressive disclosure)。
11
+ */
12
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
+ desc = { enumerable: true, get: function() { return m[k]; } };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ }) : (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ }));
23
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
25
+ }) : function(o, v) {
26
+ o["default"] = v;
27
+ });
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.SKILLS_DIR = exports.WORKFLOWS_DIR = void 0;
47
+ exports.buildWorkflowDocs = buildWorkflowDocs;
48
+ exports.writeWorkflowDocs = writeWorkflowDocs;
49
+ exports.buildAgentSkills = buildAgentSkills;
50
+ exports.writeAgentSkills = writeAgentSkills;
51
+ const fs = __importStar(require("fs"));
52
+ const path = __importStar(require("path"));
53
+ function buildWorkflowDocs(runCmd) {
54
+ const addModel = {
55
+ fileName: "add-model.md",
56
+ title: "Add a new model (autonomous loop)",
57
+ skillName: "swallowkit-add-model",
58
+ skillDescription: "Add a new data model to a SwallowKit project and deterministically derive CRUD Functions, BFF routes, UI pages, and Cosmos DB infra from it using the plan/apply/verify loop. Use when asked to add a model, entity, resource, table, or a new CRUD feature.",
59
+ content: `# Workflow: Add a new model
60
+
61
+ Goal: add a data model and derive CRUD/BFF/UI/infra deterministically.
62
+
63
+ ## Responsibility boundary
64
+
65
+ - **You author freely**: the model schema (\`shared/models/<name>.ts\`) and any business logic.
66
+ - **SwallowKit generates deterministically**: Functions CRUD, BFF routes, UI pages, OpenAPI, Bicep containers.
67
+ - Query the full contract: \`${runCmd} swallowkit machine inspect boundaries\`
68
+
69
+ ## Steps
70
+
71
+ 1. Create the model file (deterministic template):
72
+ \`${runCmd} swallowkit machine generate model <name> --overwrite never\`
73
+ 2. Edit \`shared/models/<name>.ts\` — add domain fields (free-form authoring).
74
+ 3. Compute the change plan (writes nothing):
75
+ \`${runCmd} swallowkit machine plan scaffold <name>\`
76
+ - \`status: "requires-human"\` → review \`data.conflicts\`; only proceed with \`--approve\` if overwriting is intended.
77
+ 4. Apply:
78
+ \`${runCmd} swallowkit machine apply scaffold --plan <planId>\`
79
+ 5. Verify:
80
+ \`${runCmd} swallowkit machine verify project\`
81
+ - \`summary.done: false\` → \`${runCmd} swallowkit machine explain failure\` and repair, then re-verify.
82
+ 6. If \`dev-seeds/\` exists, update seed JSON for the new model. Seeds are only
83
+ applied by \`${runCmd} swallowkit dev --seed-env <environment>\` — editing the
84
+ JSON alone does nothing.
85
+
86
+ ## Terminal states
87
+
88
+ | status | meaning | next |
89
+ |--------|---------|------|
90
+ | complete | operation finished | continue |
91
+ | in-progress | more work remains (e.g. failing checks) | follow nextActions |
92
+ | blocked | prerequisite missing (e.g. stale plan) | re-plan |
93
+ | requires-human | approval needed | ask the human, or pass --approve when instructed |
94
+ | failed | operation failed | inspect error.details |
95
+ `,
96
+ };
97
+ const modifyModel = {
98
+ fileName: "modify-model.md",
99
+ title: "Modify an existing model schema",
100
+ skillName: "swallowkit-modify-model",
101
+ skillDescription: "Change an existing Zod model schema in a SwallowKit project and re-align every generated artifact (Functions, BFF, UI, infra) via drift inspection and plan/apply regeneration. Use when asked to add/remove/rename model fields, change validation rules, or when inspect drift reports schema-drift.",
102
+ content: `# Workflow: Modify an existing model
103
+
104
+ Goal: change a schema and re-align every generated artifact.
105
+
106
+ ## Steps
107
+
108
+ 1. Edit \`shared/models/<name>.ts\` (free-form authoring).
109
+ 2. Check what drifted:
110
+ \`${runCmd} swallowkit machine inspect drift\`
111
+ - \`schema-drift\` findings list the models whose artifacts are stale.
112
+ 3. Plan the regeneration:
113
+ \`${runCmd} swallowkit machine plan scaffold <name>\`
114
+ - Conflicts mean generated files were hand-edited after generation. Decide: keep the hand-edit (move the logic to an ai-authored file first) or overwrite with \`--approve\`.
115
+ 4. Apply: \`${runCmd} swallowkit machine apply scaffold --plan <planId>\`
116
+ 5. Verify: \`${runCmd} swallowkit machine verify project\`
117
+
118
+ ## Guardrail
119
+
120
+ Never hand-edit managed artifacts to implement schema changes — always change the model
121
+ and regenerate. Hand-edits are detected as drift and block unattended overwrites.
122
+ `,
123
+ };
124
+ const addAuth = {
125
+ fileName: "add-auth.md",
126
+ title: "Add authentication (plan/apply with config ownership rules)",
127
+ skillName: "swallowkit-add-auth",
128
+ skillDescription: "Add authentication (custom-jwt, Azure Static Web Apps built-in, or external-token) to a SwallowKit project via plan/apply auth, including the config ownership rules (never hand-write auth.schemes; hand-edit policies and allowedProviders after apply) and post-apply steps. Use when asked to add login, authentication, authorization, roles, or a named auth scheme.",
129
+ content: `# Workflow: Add authentication
130
+
131
+ Goal: introduce an auth scheme deterministically and finish the manual follow-ups.
132
+
133
+ ## Config ownership (critical)
134
+
135
+ - \`auth.schemes\` is **owned by plan/apply auth. Never hand-write scheme entries** —
136
+ a pre-written scheme makes planning fail with \`already exists\`.
137
+ - \`auth.authorization.policies\` and \`swa.allowedProviders\` are **hand-edited after
138
+ apply** (the config is an extension point; this is the expected workflow).
139
+
140
+ ## Steps
141
+
142
+ 1. Check what already exists: \`${runCmd} swallowkit machine inspect capabilities\`
143
+ (authentication section) and the current \`auth\` block in swallowkit.config.
144
+ 2. Plan (writes nothing):
145
+ \`${runCmd} swallowkit machine plan auth --provider <custom-jwt|swa|external-token> [--scheme <name>] [--allowed-providers github,aad]\`
146
+ 3. Apply:
147
+ \`${runCmd} swallowkit machine apply auth --plan <planId>\`
148
+ 4. Follow the returned \`nextActions\`:
149
+ - Define \`auth.authorization.policies\` referencing the scheme (hand-edit).
150
+ - swa: confirm \`swa.allowedProviders\` — generated login URLs use the first entry.
151
+ - external-token: implement the generated verifier stub. It fails closed and
152
+ **verify passes with the stub**, so a green verify does not mean the auth
153
+ flow works (a \`auth-verifier-stub\` warning is surfaced while unmodified).
154
+ 5. Add \`authPolicy\` to models that need guards, then re-run plan/apply scaffold
155
+ for them.
156
+ 6. Verify: \`${runCmd} swallowkit machine verify project\`
157
+
158
+ ## Scope guardrail
159
+
160
+ Generated CRUD enforces authentication and roles but does **not** scope rows to
161
+ the caller. Owner-scoped behavior belongs in ai-authored endpoints that derive
162
+ the scoping key from the verified principal, never from the request body.
163
+ `,
164
+ };
165
+ const verifyRepair = {
166
+ fileName: "verify-and-repair.md",
167
+ title: "Verify and repair loop",
168
+ skillName: "swallowkit-verify-repair",
169
+ skillDescription: "Converge a SwallowKit project to a verified state: run structure/drift/typecheck (and build/lint/test) checks, read evidence with explain failure, repair, and repeat. Use after any code or schema change, when verification fails, when the build/lint/tests are broken, or before finishing a task.",
170
+ content: `# Workflow: Verify and repair
171
+
172
+ Goal: converge the project to a verified state after any change.
173
+
174
+ ## Loop
175
+
176
+ 1. \`${runCmd} swallowkit machine verify project\`
177
+ - default checks: structure, drift, typecheck (+ project-specific checks from swallowkit.config \`verify.checks\`)
178
+ - opt-in heavier checks: \`--checks structure,drift,typecheck,build,lint,test\`
179
+ 2. If \`summary.done\` is false:
180
+ - \`${runCmd} swallowkit machine explain failure\` → evidence (logTail, findings, violations) and suggestedActions per check.
181
+ - Repair:
182
+ - \`drift\` failures → follow each finding's \`repairAction\` (usually re-run plan/apply scaffold).
183
+ - \`structure\` failures → follow \`suggestedFix\` per violation.
184
+ - \`typecheck\`/\`build\`/\`lint\`/\`test\` failures → fix the code in ai-authored files.
185
+ 3. Repeat until \`summary.done: true\`.
186
+
187
+ ## Exit criteria
188
+
189
+ Stop and ask a human when:
190
+ - the same check fails 3 times in a row with the same evidence, or
191
+ - a repair would require overwriting hand-edited files (\`requires-human\`).
192
+ `,
193
+ };
194
+ const provision = {
195
+ fileName: "provision.md",
196
+ title: "Provision Azure resources (plan/apply with approval gate)",
197
+ skillName: "swallowkit-provision",
198
+ skillDescription: "Provision Azure resources (Static Web Apps, Functions, Cosmos DB) for a SwallowKit project using the two-phase plan/apply flow with a mandatory human approval gate. Use when asked to deploy infrastructure, provision Azure, create resource groups, or run Bicep deployments.",
199
+ content: `# Workflow: Provision Azure resources
200
+
201
+ Goal: deploy the Bicep infrastructure with an explicit human approval gate.
202
+
203
+ ## Rules
204
+
205
+ - Provisioning **always** requires human approval — \`plan provision\` returns
206
+ \`status: "requires-human"\` and \`requiresApproval: true\` by design.
207
+ - Never pass \`--approve\` to \`apply provision\` unless a human explicitly
208
+ instructed you to provision in this session.
209
+ - Inspect infra locally first — no \`az\` calls are needed for inspection.
210
+
211
+ ## Steps
212
+
213
+ 1. Inspect the infrastructure definition (pure local Bicep analysis):
214
+ \`${runCmd} swallowkit machine inspect infra\`
215
+ - review parameters, modules, outputs, and container wiring warnings.
216
+ 2. Compute the provisioning plan (no resources are created):
217
+ \`${runCmd} swallowkit machine plan provision -g <resource-group> --location <region>\`
218
+ - optional: \`--what-if\` to include an \`az deployment ... what-if\` preview.
219
+ - the plan lists the exact \`az\` commands that would run.
220
+ 3. Present the plan to the human and wait for explicit approval.
221
+ 4. Only after approval:
222
+ \`${runCmd} swallowkit machine apply provision --plan <planId> --approve\`
223
+ 5. Verify the deployment outputs and report them.
224
+
225
+ ## Terminal states
226
+
227
+ \`apply provision\` without \`--approve\` fails with \`approval-required\` —
228
+ this is the guardrail working as intended, not an error to work around.
229
+ `,
230
+ };
231
+ const index = {
232
+ fileName: "README.md",
233
+ title: "SwallowKit agent workflows",
234
+ content: `# SwallowKit Agent Workflows
235
+
236
+ Agent-agnostic runbooks for autonomous development loops. Machine-readable
237
+ interfaces (\`swallowkit machine ...\` / MCP \`swallowkit_*\` tools) return a
238
+ \`status\` terminal state and \`nextActions\`, so agents can chain steps without
239
+ parsing human-oriented output.
240
+
241
+ These runbooks are also installed as Agent Skills (agentskills.io format)
242
+ under \`.github/skills/\` so skills-aware agents load them automatically.
243
+
244
+ | Workflow | File | Skill |
245
+ |----------|------|-------|
246
+ | Add a new model | [add-model.md](./add-model.md) | \`swallowkit-add-model\` |
247
+ | Modify an existing model | [modify-model.md](./modify-model.md) | \`swallowkit-modify-model\` |
248
+ | Add authentication | [add-auth.md](./add-auth.md) | \`swallowkit-add-auth\` |
249
+ | Verify and repair | [verify-and-repair.md](./verify-and-repair.md) | \`swallowkit-verify-repair\` |
250
+ | Provision Azure resources | [provision.md](./provision.md) | \`swallowkit-provision\` |
251
+
252
+ ## Responsibility boundary (summary)
253
+
254
+ - **ai-authored** (write freely): \`shared/models/\`, business logic, custom pages/components, tests.
255
+ - **deterministic** (never hand-edit): artifacts generated by SwallowKit (see \`.swallowkit/artifacts.json\`) and \`.swallowkit/\` metadata. Change models/config and regenerate via plan/apply.
256
+ - **shared** (edit outside markers): \`infra/main.bicep\`, \`functions/function_app.py\`, \`shared/index.ts\`.
257
+
258
+ Full machine-readable contract: \`${runCmd} swallowkit machine inspect boundaries\`
259
+ `,
260
+ };
261
+ return [index, addModel, modifyModel, addAuth, verifyRepair, provision];
262
+ }
263
+ exports.WORKFLOWS_DIR = path.join(".swallowkit", "workflows");
264
+ exports.SKILLS_DIR = path.join(".github", "skills");
265
+ /** `.swallowkit/workflows/*.md` を書き出し、書き込んだ相対パスを返す。 */
266
+ function writeWorkflowDocs(projectDir, runCmd) {
267
+ const dir = path.join(projectDir, exports.WORKFLOWS_DIR);
268
+ fs.mkdirSync(dir, { recursive: true });
269
+ const written = [];
270
+ for (const doc of buildWorkflowDocs(runCmd)) {
271
+ fs.writeFileSync(path.join(dir, doc.fileName), doc.content, "utf-8");
272
+ written.push(path.posix.join(".swallowkit", "workflows", doc.fileName));
273
+ }
274
+ return written;
275
+ }
276
+ /** Agent Skills (agentskills.io) の SKILL.md コンテンツを組み立てる。 */
277
+ function buildAgentSkills(runCmd) {
278
+ return buildWorkflowDocs(runCmd)
279
+ .filter((doc) => Boolean(doc.skillName && doc.skillDescription))
280
+ .map((doc) => ({
281
+ skillName: doc.skillName,
282
+ content: `---\nname: ${doc.skillName}\ndescription: ${doc.skillDescription}\nmetadata:\n generator: swallowkit\n---\n\n${doc.content}`,
283
+ }));
284
+ }
285
+ /**
286
+ * `.github/skills/<name>/SKILL.md` を書き出し、書き込んだ相対パスを返す。
287
+ * agentskills.io 仕様: ディレクトリ名は frontmatter の name と一致必須。
288
+ */
289
+ function writeAgentSkills(projectDir, runCmd) {
290
+ const written = [];
291
+ for (const skill of buildAgentSkills(runCmd)) {
292
+ const dir = path.join(projectDir, exports.SKILLS_DIR, skill.skillName);
293
+ fs.mkdirSync(dir, { recursive: true });
294
+ fs.writeFileSync(path.join(dir, "SKILL.md"), skill.content, "utf-8");
295
+ written.push(path.posix.join(".github", "skills", skill.skillName, "SKILL.md"));
296
+ }
297
+ return written;
298
+ }
299
+ //# sourceMappingURL=workflows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflows.js","sourceRoot":"","sources":["../../../src/core/project/workflows.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBH,8CA4NC;AAMD,8CASC;AAGD,4CASC;AAMD,4CASC;AA3RD,uCAAyB;AACzB,2CAA6B;AAoB7B,SAAgB,iBAAiB,CAAC,MAAc;IAC9C,MAAM,QAAQ,GAAgB;QAC5B,QAAQ,EAAE,cAAc;QACxB,KAAK,EAAE,mCAAmC;QAC1C,SAAS,EAAE,sBAAsB;QACjC,gBAAgB,EACd,8PAA8P;QAChQ,OAAO,EAAE;;;;;;;;+BAQkB,MAAM;;;;;OAK9B,MAAM;;;OAGN,MAAM;;;OAGN,MAAM;;OAEN,MAAM;mCACsB,MAAM;;kBAEvB,MAAM;;;;;;;;;;;;CAYvB;KACE,CAAC;IAEF,MAAM,WAAW,GAAgB;QAC/B,QAAQ,EAAE,iBAAiB;QAC3B,KAAK,EAAE,iCAAiC;QACxC,SAAS,EAAE,yBAAyB;QACpC,gBAAgB,EACd,wSAAwS;QAC1S,OAAO,EAAE;;;;;;;;OAQN,MAAM;;;OAGN,MAAM;;cAEC,MAAM;eACL,MAAM;;;;;;CAMpB;KACE,CAAC;IAEF,MAAM,OAAO,GAAgB;QAC3B,QAAQ,EAAE,aAAa;QACvB,KAAK,EAAE,6DAA6D;QACpE,SAAS,EAAE,qBAAqB;QAChC,gBAAgB,EACd,4WAA4W;QAC9W,OAAO,EAAE;;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