@davidahmann/mill 0.1.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.
Files changed (184) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +335 -0
  3. package/dist/audit/repository.d.ts +8 -0
  4. package/dist/audit/repository.d.ts.map +1 -0
  5. package/dist/audit/repository.js +232 -0
  6. package/dist/audit/repository.js.map +1 -0
  7. package/dist/cli-program.d.ts +12 -0
  8. package/dist/cli-program.d.ts.map +1 -0
  9. package/dist/cli-program.js +1020 -0
  10. package/dist/cli-program.js.map +1 -0
  11. package/dist/cli.d.ts +3 -0
  12. package/dist/cli.d.ts.map +1 -0
  13. package/dist/cli.js +7 -0
  14. package/dist/cli.js.map +1 -0
  15. package/dist/config/lock.d.ts +12 -0
  16. package/dist/config/lock.d.ts.map +1 -0
  17. package/dist/config/lock.js +83 -0
  18. package/dist/config/lock.js.map +1 -0
  19. package/dist/contracts/canonical.d.ts +7 -0
  20. package/dist/contracts/canonical.d.ts.map +1 -0
  21. package/dist/contracts/canonical.js +30 -0
  22. package/dist/contracts/canonical.js.map +1 -0
  23. package/dist/contracts/schemas.d.ts +2705 -0
  24. package/dist/contracts/schemas.d.ts.map +1 -0
  25. package/dist/contracts/schemas.js +988 -0
  26. package/dist/contracts/schemas.js.map +1 -0
  27. package/dist/doctor.d.ts +21 -0
  28. package/dist/doctor.d.ts.map +1 -0
  29. package/dist/doctor.js +138 -0
  30. package/dist/doctor.js.map +1 -0
  31. package/dist/errors.d.ts +18 -0
  32. package/dist/errors.d.ts.map +1 -0
  33. package/dist/errors.js +31 -0
  34. package/dist/errors.js.map +1 -0
  35. package/dist/index.d.ts +20 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +20 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/intake/prd.d.ts +14 -0
  40. package/dist/intake/prd.d.ts.map +1 -0
  41. package/dist/intake/prd.js +39 -0
  42. package/dist/intake/prd.js.map +1 -0
  43. package/dist/planning/impact.d.ts +59 -0
  44. package/dist/planning/impact.d.ts.map +1 -0
  45. package/dist/planning/impact.js +400 -0
  46. package/dist/planning/impact.js.map +1 -0
  47. package/dist/planning/specification.d.ts +42 -0
  48. package/dist/planning/specification.d.ts.map +1 -0
  49. package/dist/planning/specification.js +235 -0
  50. package/dist/planning/specification.js.map +1 -0
  51. package/dist/qualification/public-alpha.d.ts +16 -0
  52. package/dist/qualification/public-alpha.d.ts.map +1 -0
  53. package/dist/qualification/public-alpha.js +128 -0
  54. package/dist/qualification/public-alpha.js.map +1 -0
  55. package/dist/recipes/node-typescript-next-web.d.ts +19 -0
  56. package/dist/recipes/node-typescript-next-web.d.ts.map +1 -0
  57. package/dist/recipes/node-typescript-next-web.js +136 -0
  58. package/dist/recipes/node-typescript-next-web.js.map +1 -0
  59. package/dist/repository/integration.d.ts +58 -0
  60. package/dist/repository/integration.d.ts.map +1 -0
  61. package/dist/repository/integration.js +1385 -0
  62. package/dist/repository/integration.js.map +1 -0
  63. package/dist/repository/scan.d.ts +27 -0
  64. package/dist/repository/scan.d.ts.map +1 -0
  65. package/dist/repository/scan.js +388 -0
  66. package/dist/repository/scan.js.map +1 -0
  67. package/dist/result.d.ts +23 -0
  68. package/dist/result.d.ts.map +1 -0
  69. package/dist/result.js +24 -0
  70. package/dist/result.js.map +1 -0
  71. package/dist/runtime/codex.d.ts +28 -0
  72. package/dist/runtime/codex.d.ts.map +1 -0
  73. package/dist/runtime/codex.js +439 -0
  74. package/dist/runtime/codex.js.map +1 -0
  75. package/dist/runtime/context.d.ts +10 -0
  76. package/dist/runtime/context.d.ts.map +1 -0
  77. package/dist/runtime/context.js +151 -0
  78. package/dist/runtime/context.js.map +1 -0
  79. package/dist/runtime/delivery.d.ts +58 -0
  80. package/dist/runtime/delivery.d.ts.map +1 -0
  81. package/dist/runtime/delivery.js +1073 -0
  82. package/dist/runtime/delivery.js.map +1 -0
  83. package/dist/runtime/dependencies.d.ts +19 -0
  84. package/dist/runtime/dependencies.d.ts.map +1 -0
  85. package/dist/runtime/dependencies.js +495 -0
  86. package/dist/runtime/dependencies.js.map +1 -0
  87. package/dist/runtime/github.d.ts +112 -0
  88. package/dist/runtime/github.d.ts.map +1 -0
  89. package/dist/runtime/github.js +510 -0
  90. package/dist/runtime/github.js.map +1 -0
  91. package/dist/runtime/inputs.d.ts +24 -0
  92. package/dist/runtime/inputs.d.ts.map +1 -0
  93. package/dist/runtime/inputs.js +237 -0
  94. package/dist/runtime/inputs.js.map +1 -0
  95. package/dist/runtime/lease.d.ts +11 -0
  96. package/dist/runtime/lease.d.ts.map +1 -0
  97. package/dist/runtime/lease.js +52 -0
  98. package/dist/runtime/lease.js.map +1 -0
  99. package/dist/runtime/lifecycle.d.ts +87 -0
  100. package/dist/runtime/lifecycle.d.ts.map +1 -0
  101. package/dist/runtime/lifecycle.js +1024 -0
  102. package/dist/runtime/lifecycle.js.map +1 -0
  103. package/dist/runtime/process.d.ts +39 -0
  104. package/dist/runtime/process.d.ts.map +1 -0
  105. package/dist/runtime/process.js +304 -0
  106. package/dist/runtime/process.js.map +1 -0
  107. package/dist/runtime/repository.d.ts +36 -0
  108. package/dist/runtime/repository.d.ts.map +1 -0
  109. package/dist/runtime/repository.js +458 -0
  110. package/dist/runtime/repository.js.map +1 -0
  111. package/dist/runtime/state.d.ts +121 -0
  112. package/dist/runtime/state.d.ts.map +1 -0
  113. package/dist/runtime/state.js +1017 -0
  114. package/dist/runtime/state.js.map +1 -0
  115. package/dist/runtime/verifier.d.ts +31 -0
  116. package/dist/runtime/verifier.d.ts.map +1 -0
  117. package/dist/runtime/verifier.js +478 -0
  118. package/dist/runtime/verifier.js.map +1 -0
  119. package/dist/runtime/worker.d.ts +67 -0
  120. package/dist/runtime/worker.d.ts.map +1 -0
  121. package/dist/runtime/worker.js +34 -0
  122. package/dist/runtime/worker.js.map +1 -0
  123. package/dist/security/safe-path.d.ts +3 -0
  124. package/dist/security/safe-path.d.ts.map +1 -0
  125. package/dist/security/safe-path.js +102 -0
  126. package/dist/security/safe-path.js.map +1 -0
  127. package/dist/version.d.ts +4 -0
  128. package/dist/version.d.ts.map +1 -0
  129. package/dist/version.js +4 -0
  130. package/dist/version.js.map +1 -0
  131. package/dist/workflows/founder.d.ts +33 -0
  132. package/dist/workflows/founder.d.ts.map +1 -0
  133. package/dist/workflows/founder.js +422 -0
  134. package/dist/workflows/founder.js.map +1 -0
  135. package/package.json +79 -0
  136. package/recipes/node-typescript-next-web/.github/workflows/ci.yml +34 -0
  137. package/recipes/node-typescript-next-web/.node-version +1 -0
  138. package/recipes/node-typescript-next-web/.tool-versions +1 -0
  139. package/recipes/node-typescript-next-web/AGENTS.md +44 -0
  140. package/recipes/node-typescript-next-web/README.md +16 -0
  141. package/recipes/node-typescript-next-web/WORKFLOW.md +6 -0
  142. package/recipes/node-typescript-next-web/app/api/health/route.ts +5 -0
  143. package/recipes/node-typescript-next-web/app/layout.tsx +19 -0
  144. package/recipes/node-typescript-next-web/app/page.tsx +12 -0
  145. package/recipes/node-typescript-next-web/app/styles.css +21 -0
  146. package/recipes/node-typescript-next-web/docs/development.md +16 -0
  147. package/recipes/node-typescript-next-web/eslint.config.mjs +9 -0
  148. package/recipes/node-typescript-next-web/gitignore.template +5 -0
  149. package/recipes/node-typescript-next-web/next-env.d.ts +7 -0
  150. package/recipes/node-typescript-next-web/next.config.ts +11 -0
  151. package/recipes/node-typescript-next-web/package-lock.json +7540 -0
  152. package/recipes/node-typescript-next-web/package.json +39 -0
  153. package/recipes/node-typescript-next-web/playwright.config.ts +23 -0
  154. package/recipes/node-typescript-next-web/recipe.yaml +71 -0
  155. package/recipes/node-typescript-next-web/scripts/check-package.mjs +3 -0
  156. package/recipes/node-typescript-next-web/src/health.ts +3 -0
  157. package/recipes/node-typescript-next-web/test/browser/home.spec.ts +14 -0
  158. package/recipes/node-typescript-next-web/test/integration/health-route.test.ts +11 -0
  159. package/recipes/node-typescript-next-web/test/unit/health.test.ts +9 -0
  160. package/recipes/node-typescript-next-web/tsconfig.json +33 -0
  161. package/schemas/README.md +64 -0
  162. package/schemas/audit-report.schema.json +59 -0
  163. package/schemas/blueprint.schema.json +34 -0
  164. package/schemas/context-manifest.schema.json +88 -0
  165. package/schemas/delivery-record.schema.json +266 -0
  166. package/schemas/impact-manifest.schema.json +146 -0
  167. package/schemas/managed-repository.schema.json +36 -0
  168. package/schemas/mill-config.schema.json +212 -0
  169. package/schemas/mill-lock.schema.json +96 -0
  170. package/schemas/outcome-plan.schema.json +51 -0
  171. package/schemas/product-contract.schema.json +181 -0
  172. package/schemas/public-alpha-qualification.schema.json +391 -0
  173. package/schemas/recipe-manifest.schema.json +187 -0
  174. package/schemas/release-evidence.schema.json +170 -0
  175. package/schemas/repository-integration-plan.schema.json +156 -0
  176. package/schemas/review-result.schema.json +57 -0
  177. package/schemas/scenario-set.schema.json +84 -0
  178. package/schemas/source-manifest.schema.json +96 -0
  179. package/schemas/specification-proposal.schema.json +406 -0
  180. package/schemas/support-tuple.schema.json +107 -0
  181. package/schemas/task-packet.schema.json +395 -0
  182. package/schemas/validation-evidence.schema.json +125 -0
  183. package/schemas/worker-invocation.schema.json +119 -0
  184. package/schemas/worker-profile.schema.json +53 -0
@@ -0,0 +1,67 @@
1
+ import type { z } from "zod";
2
+ import type { reviewResultSchema, workerProfileSchema } from "../contracts/schemas.js";
3
+ import { workerInvocationSchema } from "../contracts/schemas.js";
4
+ import type { ContextManifest } from "./context.js";
5
+ import type { TaskPacket } from "./inputs.js";
6
+ import type { ActiveProcess } from "./process.js";
7
+ export interface ProviderUsage {
8
+ source: "measured" | "unavailable";
9
+ inputTokens?: number;
10
+ outputTokens?: number;
11
+ cost: "unavailable";
12
+ }
13
+ export type WorkerProfile = z.infer<typeof workerProfileSchema>;
14
+ export type WorkerInvocation = z.infer<typeof workerInvocationSchema>;
15
+ interface WorkerLifecycle {
16
+ signal?: AbortSignal;
17
+ onBeforeSpawn?: () => void;
18
+ onSpawn?: (process: ActiveProcess) => void;
19
+ onExit?: (process?: ActiveProcess) => void;
20
+ cancellationRequested?: () => boolean;
21
+ }
22
+ export interface BuilderWorkerInput extends WorkerLifecycle {
23
+ root: string;
24
+ task: TaskPacket;
25
+ manifest: ContextManifest;
26
+ deadlineMs: number;
27
+ maxOutputBytes: number;
28
+ repairFindings?: readonly Record<string, unknown>[];
29
+ }
30
+ export interface ReviewerWorkerInput extends WorkerLifecycle {
31
+ root: string;
32
+ task: TaskPacket;
33
+ manifest: ContextManifest;
34
+ candidateCommit: string;
35
+ deadlineMs: number;
36
+ maxOutputBytes: number;
37
+ }
38
+ export interface WorkerAdapter {
39
+ readonly id: "codex-cli";
40
+ profile(root: string, role: WorkerProfile["role"]): Promise<WorkerProfile>;
41
+ runBuilder(input: BuilderWorkerInput): Promise<{
42
+ usage: ProviderUsage;
43
+ threadId?: string;
44
+ }>;
45
+ runReviewer(input: ReviewerWorkerInput): Promise<{
46
+ review: z.infer<typeof reviewResultSchema>;
47
+ usage: ProviderUsage;
48
+ }>;
49
+ }
50
+ export declare function createWorkerInvocation(input: {
51
+ runId: string;
52
+ phase: WorkerInvocation["phase"];
53
+ attempt: number;
54
+ task: TaskPacket;
55
+ taskDigest: string;
56
+ manifest: ContextManifest;
57
+ baseCommit: string;
58
+ candidateCommit?: string;
59
+ impactManifestDigest?: string;
60
+ profile: WorkerProfile;
61
+ deadlineAt: string;
62
+ }): {
63
+ invocation: WorkerInvocation;
64
+ digest: string;
65
+ };
66
+ export {};
67
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/runtime/worker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,EAAE,e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IACnB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC;IACzB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC3E,UAAU,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC;QAC7C,KAAK,EAAE,aAAa,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;IACH,WAAW,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC;QAC/C,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;QAC3C,KAAK,EAAE,aAAa,CAAC;KACtB,CAAC,CAAC;CACJ;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,OAAO,EAAE,aAAa,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG;IAAE,UAAU,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CA+BnD"}
@@ -0,0 +1,34 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { workerInvocationSchema } from "../contracts/schemas.js";
3
+ import { canonicalDigest } from "../contracts/canonical.js";
4
+ export function createWorkerInvocation(input) {
5
+ const profileDigest = canonicalDigest(input.profile);
6
+ const contextEpoch = input.manifest.contextEpoch ??
7
+ canonicalDigest(input.manifest);
8
+ const invocation = workerInvocationSchema.parse({
9
+ schemaVersion: "1",
10
+ invocationId: randomUUID(),
11
+ runId: input.runId,
12
+ phase: input.phase,
13
+ attempt: input.attempt,
14
+ taskDigest: input.taskDigest,
15
+ contextEpoch,
16
+ baseCommit: input.baseCommit,
17
+ ...(input.candidateCommit === undefined
18
+ ? {}
19
+ : { candidateCommit: input.candidateCommit }),
20
+ ...(input.impactManifestDigest === undefined
21
+ ? {}
22
+ : { impactManifestDigest: input.impactManifestDigest }),
23
+ profile: input.profile,
24
+ profileDigest,
25
+ allowedPaths: input.profile.role === "reviewer" ? [] : input.task.allowedPaths,
26
+ deadlineAt: input.deadlineAt,
27
+ maxOutputBytes: input.task.budget.maxOutputBytes,
28
+ });
29
+ return {
30
+ invocation,
31
+ digest: canonicalDigest(invocation),
32
+ };
33
+ }
34
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/runtime/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAQzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAkB,MAAM,2BAA2B,CAAC;AAsD5E,MAAM,UAAU,sBAAsB,CAAC,KAYtC;IACC,MAAM,aAAa,GAAG,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrD,MAAM,YAAY,GAChB,KAAK,CAAC,QAAQ,CAAC,YAAY;QAC3B,eAAe,CAAC,KAAK,CAAC,QAAgC,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,sBAAsB,CAAC,KAAK,CAAC;QAC9C,aAAa,EAAE,GAAG;QAClB,YAAY,EAAE,UAAU,EAAE;QAC1B,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,YAAY;QACZ,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,GAAG,CAAC,KAAK,CAAC,eAAe,KAAK,SAAS;YACrC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,eAAe,EAAE,KAAK,CAAC,eAAe,EAAE,CAAC;QAC/C,GAAG,CAAC,KAAK,CAAC,oBAAoB,KAAK,SAAS;YAC1C,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,EAAE,CAAC;QACzD,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,aAAa;QACb,YAAY,EACV,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY;QAClE,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc;KACjD,CAAC,CAAC;IACH,OAAO;QACL,UAAU;QACV,MAAM,EAAE,eAAe,CAAC,UAAkC,CAAC;KAC5D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function isWithin(root: string, candidate: string): boolean;
2
+ export declare function safeReadText(root: string, requestedPath: string, maxBytes?: number): Promise<string>;
3
+ //# sourceMappingURL=safe-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-path.d.ts","sourceRoot":"","sources":["../../src/security/safe-path.ts"],"names":[],"mappings":"AAuCA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAQjE;AAED,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EACrB,QAAQ,SAAoB,GAC3B,OAAO,CAAC,MAAM,CAAC,CA8GjB"}
@@ -0,0 +1,102 @@
1
+ import { constants } from "node:fs";
2
+ import { lstat, open, realpath } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { ExitCode, MillError } from "../errors.js";
5
+ const DEFAULT_MAX_BYTES = 2 * 1024 * 1024;
6
+ const strictUtf8Decoder = new TextDecoder("utf-8", { fatal: true });
7
+ function filesystemCode(error) {
8
+ if (typeof error !== "object" || error === null || !("code" in error)) {
9
+ return undefined;
10
+ }
11
+ return typeof error.code === "string" ? error.code : undefined;
12
+ }
13
+ function inputFileError(error, requestedPath) {
14
+ const code = filesystemCode(error);
15
+ if (code === "ENOENT" || code === "ENOTDIR") {
16
+ return new MillError("FILE_NOT_FOUND", `Input file does not exist: ${requestedPath}`, ExitCode.data);
17
+ }
18
+ if (code === "EACCES" || code === "EPERM") {
19
+ return new MillError("FILE_NOT_READABLE", `Input file is not readable: ${requestedPath}`, ExitCode.data);
20
+ }
21
+ return new MillError("FILE_ACCESS_FAILED", `Input file could not be inspected: ${requestedPath}`, ExitCode.data);
22
+ }
23
+ export function isWithin(root, candidate) {
24
+ const relative = path.relative(root, candidate);
25
+ return (relative === "" ||
26
+ (relative !== ".." &&
27
+ !relative.startsWith(`..${path.sep}`) &&
28
+ !path.isAbsolute(relative)));
29
+ }
30
+ export async function safeReadText(root, requestedPath, maxBytes = DEFAULT_MAX_BYTES) {
31
+ const canonicalRoot = await realpath(root);
32
+ const resolved = path.resolve(canonicalRoot, requestedPath);
33
+ if (!isWithin(canonicalRoot, resolved)) {
34
+ throw new MillError("PATH_OUTSIDE_ROOT", `Path is outside the approved root: ${requestedPath}`, ExitCode.data);
35
+ }
36
+ let before;
37
+ try {
38
+ before = await lstat(resolved);
39
+ }
40
+ catch (error) {
41
+ throw inputFileError(error, requestedPath);
42
+ }
43
+ if (before.isSymbolicLink() || !before.isFile()) {
44
+ throw new MillError("UNSAFE_FILE_TYPE", `Expected a regular, non-symlink file: ${requestedPath}`, ExitCode.data);
45
+ }
46
+ if (before.size > maxBytes) {
47
+ throw new MillError("FILE_TOO_LARGE", `File exceeds the ${maxBytes}-byte inspection limit: ${requestedPath}`, ExitCode.data);
48
+ }
49
+ let canonicalFile;
50
+ try {
51
+ canonicalFile = await realpath(resolved);
52
+ }
53
+ catch (error) {
54
+ throw inputFileError(error, requestedPath);
55
+ }
56
+ if (!isWithin(canonicalRoot, canonicalFile)) {
57
+ throw new MillError("PATH_OUTSIDE_ROOT", `Resolved path is outside the approved root: ${requestedPath}`, ExitCode.data);
58
+ }
59
+ let handle;
60
+ try {
61
+ handle = await open(resolved, constants.O_RDONLY | constants.O_NOFOLLOW);
62
+ }
63
+ catch (error) {
64
+ throw inputFileError(error, requestedPath);
65
+ }
66
+ try {
67
+ const after = await handle.stat();
68
+ if (!after.isFile() ||
69
+ after.dev !== before.dev ||
70
+ after.ino !== before.ino ||
71
+ after.size !== before.size ||
72
+ after.mtimeMs !== before.mtimeMs ||
73
+ after.ctimeMs !== before.ctimeMs) {
74
+ throw new MillError("FILE_CHANGED_DURING_READ", `File identity changed during inspection: ${requestedPath}`, ExitCode.data);
75
+ }
76
+ if (after.size > maxBytes) {
77
+ throw new MillError("FILE_TOO_LARGE", `File exceeds the ${maxBytes}-byte inspection limit: ${requestedPath}`, ExitCode.data);
78
+ }
79
+ const bytes = await handle.readFile();
80
+ if (bytes.byteLength > maxBytes) {
81
+ throw new MillError("FILE_TOO_LARGE", `File exceeds the ${maxBytes}-byte inspection limit: ${requestedPath}`, ExitCode.data);
82
+ }
83
+ const final = await handle.stat();
84
+ if (final.dev !== after.dev ||
85
+ final.ino !== after.ino ||
86
+ final.size !== after.size ||
87
+ final.mtimeMs !== after.mtimeMs ||
88
+ final.ctimeMs !== after.ctimeMs) {
89
+ throw new MillError("FILE_CHANGED_DURING_READ", `File identity changed during inspection: ${requestedPath}`, ExitCode.data);
90
+ }
91
+ try {
92
+ return strictUtf8Decoder.decode(bytes);
93
+ }
94
+ catch (error) {
95
+ throw new MillError("INVALID_UTF8", `Expected valid UTF-8 text: ${requestedPath}`, ExitCode.data, { cause: String(error) });
96
+ }
97
+ }
98
+ finally {
99
+ await handle.close();
100
+ }
101
+ }
102
+ //# sourceMappingURL=safe-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-path.js","sourceRoot":"","sources":["../../src/security/safe-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1C,MAAM,iBAAiB,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAEpE,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC;QACtE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACjE,CAAC;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,aAAqB;IAC3D,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QAC5C,OAAO,IAAI,SAAS,CAClB,gBAAgB,EAChB,8BAA8B,aAAa,EAAE,EAC7C,QAAQ,CAAC,IAAI,CACd,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,OAAO,EAAE,C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AAS,CACjB,cAAc,EACd,8BAA8B,aAAa,EAAE,EAC7C,QAAQ,CAAC,IAAI,EACb,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CACzB,CAAC;QACJ,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const MILL_PACKAGE = "@davidahmann/mill";
2
+ export declare const MILL_VERSION = "0.1.4";
3
+ export declare const RESULT_SCHEMA_VERSION = "1";
4
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,sBAAsB,CAAC;AAChD,eAAO,MAAM,YAAY,UAAU,CAAC;AACpC,eAAO,MAAM,qBAAqB,MAAM,CAAC"}
@@ -0,0 +1,4 @@
1
+ export const MILL_PACKAGE = "@davidahmann/mill";
2
+ export const MILL_VERSION = "0.1.4";
3
+ export const RESULT_SCHEMA_VERSION = "1";
4
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAChD,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC;AACpC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { runStatus, startLocalRun } from "../runtime/lifecycle.js";
2
+ import { type DependencyPreparationResult } from "../runtime/dependencies.js";
3
+ export interface NextOutcome {
4
+ outcomeId: string;
5
+ title: string;
6
+ taskPath: string;
7
+ productContractDigest: string;
8
+ acceptanceIds: readonly string[];
9
+ }
10
+ export declare function nextReadyOutcome(root: string): Promise<NextOutcome>;
11
+ export declare function prepareRepositoryDependencies(root: string, attended: boolean): Promise<DependencyPreparationResult | undefined>;
12
+ export declare function startNextReadyOutcome(input: {
13
+ root: string;
14
+ approvalDigest: string;
15
+ }): Promise<{
16
+ outcome: NextOutcome;
17
+ result: Awaited<ReturnType<typeof startLocalRun>>;
18
+ }>;
19
+ export declare function startFounderDelivery(input: {
20
+ root: string;
21
+ prdPath: string;
22
+ attended: boolean;
23
+ draftPr: boolean;
24
+ }): Promise<{
25
+ outcome: NextOutcome;
26
+ stage: string;
27
+ run?: Awaited<ReturnType<typeof runStatus>>["run"];
28
+ pullRequestUrl?: string;
29
+ deliveryProposalDigest?: string;
30
+ nextAction: string;
31
+ dependencyPreparation?: DependencyPreparationResult;
32
+ }>;
33
+ //# sourceMappingURL=founder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"founder.d.ts","sourceRoot":"","sources":["../../src/workflows/founder.ts"],"names":[],"mappings":"AAiBA,OAAO,EAKL,SAAS,EACT,aAAa,EAEd,MAAM,yBAAyB,CAAC;AAWjC,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,4BAA4B,CAAC;AAIpC,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA8BzE;AAED,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAalD;AAyID,wBAAsB,qBAAqB,CAAC,KAAK,EAAE;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,OAAO,CAAC;IACV,OAAO,EAAE,WAAW,CAAC;I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