carveout 0.1.1 → 0.2.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 (78) hide show
  1. package/AGENTS.md +21 -3
  2. package/NOTICE.md +2 -1
  3. package/README.md +248 -473
  4. package/dist/src/account.d.ts +37 -0
  5. package/dist/src/account.js +275 -0
  6. package/dist/src/api.d.ts +162 -0
  7. package/dist/src/api.js +134 -0
  8. package/dist/src/carve.d.ts +788 -0
  9. package/dist/src/carve.js +1721 -125
  10. package/dist/src/cli.d.ts +10 -0
  11. package/dist/src/cli.js +674 -47
  12. package/dist/src/command.d.ts +10 -0
  13. package/dist/src/core.d.ts +11 -0
  14. package/dist/src/cut.d.ts +78 -0
  15. package/dist/src/cut.js +25 -7
  16. package/dist/src/extract/compiler-config.d.ts +49 -0
  17. package/dist/src/extract/fixture.d.ts +103 -0
  18. package/dist/src/extract/hash.d.ts +6 -0
  19. package/dist/src/extract/package-registry.d.ts +47 -0
  20. package/dist/src/extract/package-types.d.ts +52 -0
  21. package/dist/src/extract/surface.d.ts +44 -0
  22. package/dist/src/extract/typescript.d.ts +180 -0
  23. package/dist/src/gate.d.ts +55 -0
  24. package/dist/src/gate.js +1 -0
  25. package/dist/src/graph.d.ts +142 -0
  26. package/dist/src/graph.js +4 -3
  27. package/dist/src/impact.d.ts +113 -0
  28. package/dist/src/imports.d.ts +67 -0
  29. package/dist/src/mergeback.d.ts +182 -0
  30. package/dist/src/mergeback.js +580 -35
  31. package/dist/src/platform.d.ts +69 -0
  32. package/dist/src/platform.js +184 -0
  33. package/dist/src/policy.d.ts +181 -0
  34. package/dist/src/policy.js +716 -230
  35. package/dist/src/project/build.d.ts +23 -0
  36. package/dist/src/project/catalog.d.ts +25 -0
  37. package/dist/src/project/project.d.ts +287 -0
  38. package/dist/src/project/project.js +479 -52
  39. package/dist/src/project/provenance.d.ts +73 -0
  40. package/dist/src/project/provenance.js +12 -0
  41. package/dist/src/project/runner.d.ts +19 -0
  42. package/dist/src/project/secrets.d.ts +64 -0
  43. package/dist/src/project/vitest-config.d.ts +70 -0
  44. package/dist/src/project/vitest-config.js +291 -0
  45. package/dist/src/pseudonyms/aliases.d.ts +107 -0
  46. package/dist/src/pseudonyms/aliases.js +394 -0
  47. package/dist/src/pseudonyms/draft.d.ts +64 -0
  48. package/dist/src/pseudonyms/draft.js +284 -0
  49. package/dist/src/pseudonyms/folder.d.ts +172 -0
  50. package/dist/src/pseudonyms/folder.js +527 -0
  51. package/dist/src/pseudonyms/index.d.ts +11 -0
  52. package/dist/src/pseudonyms/index.js +11 -0
  53. package/dist/src/pseudonyms/vocabulary.d.ts +113 -0
  54. package/dist/src/pseudonyms/vocabulary.js +522 -0
  55. package/dist/src/readiness.d.ts +71 -0
  56. package/dist/src/readiness.js +131 -0
  57. package/dist/src/receipt.d.ts +154 -0
  58. package/dist/src/receipt.js +296 -0
  59. package/dist/src/sandbox.d.ts +53 -0
  60. package/dist/src/sandbox.js +154 -0
  61. package/dist/src/slice/analysis.d.ts +75 -0
  62. package/dist/src/slice/externals.d.ts +51 -0
  63. package/dist/src/slice/graph.d.ts +69 -0
  64. package/dist/src/slice/manifest.d.ts +262 -0
  65. package/dist/src/slice/manifest.js +4 -3
  66. package/dist/src/slice/reach.d.ts +204 -0
  67. package/dist/src/slice/reach.js +11 -5
  68. package/dist/src/slice/report.d.ts +49 -0
  69. package/dist/src/slice/report.js +5 -2
  70. package/dist/src/specifiers.d.ts +48 -0
  71. package/dist/src/status.d.ts +46 -0
  72. package/dist/src/status.js +3 -2
  73. package/dist/src/test-integrity.d.ts +54 -0
  74. package/dist/src/test-integrity.js +812 -0
  75. package/package.json +24 -5
  76. package/skills/carveout/SKILL.md +518 -0
  77. package/skills/carveout-gate/SKILL.md +98 -0
  78. package/SKILL.md +0 -423
@@ -0,0 +1,182 @@
1
+ /**
2
+ * Moving changes between a slice and its repository, both ways.
3
+ *
4
+ * `applyPatch` brings a repository patch into a slice: it applies the
5
+ * patch to a scratch clone at the cut's commit, cuts again in memory with
6
+ * the recorded request, and writes the slice's files the patch touched as
7
+ * that cut writes them, imports rewritten. A module the patch adds past
8
+ * the cut's reach joins the slice as an entry of its own, with its tests.
9
+ * Paths outside the slice and stubs the change would need are reported;
10
+ * nothing else in the folder or its record changes, so `patch` still diffs
11
+ * against the cut's commit.
12
+ *
13
+ * `mergeProject` takes a slice's edits the other way: `patch`, then
14
+ * `git apply --3way` into a checkout the caller names, then a verify
15
+ * command there. It never picks a checkout on its own.
16
+ */
17
+ import { type CutResult, type Patch } from "./carve.js";
18
+ import { type SandboxSpec } from "./sandbox.js";
19
+ export interface Applied {
20
+ /** Slice files the patch changed, now as a cut of the patched repository writes them. */
21
+ readonly changed: readonly string[];
22
+ /** Files the patch adds that a cut of the patched repository reaches. */
23
+ readonly added: readonly string[];
24
+ readonly deleted: readonly string[];
25
+ /** Paths the patch touches that the slice does not hold. */
26
+ readonly outside: readonly string[];
27
+ /**
28
+ * Stubs a cut of the patched repository writes differently: what the
29
+ * change needs from the modules the slice cuts. Written only when asked.
30
+ */
31
+ readonly stubs: readonly {
32
+ path: string;
33
+ detail: string;
34
+ written: boolean;
35
+ }[];
36
+ /** Slice files the folder had edited, the change merged into them (three-way). */
37
+ readonly merged: readonly string[];
38
+ /**
39
+ * Slice files where the folder's edit and the change overlap: left as the
40
+ * folder had them, for a person to merge.
41
+ */
42
+ readonly conflicts: readonly string[];
43
+ /**
44
+ * Names the repository goes by that what the command wrote into a folder
45
+ * in pseudonyms still holds (a term the cut found nowhere, so has no
46
+ * placeholder for; a binary file): the folder must not go out as it is.
47
+ * By term, with the folder paths it is in.
48
+ */
49
+ readonly leaks: readonly {
50
+ readonly term: string;
51
+ readonly files: readonly string[];
52
+ }[];
53
+ /**
54
+ * Slice files not written: in the folder's names their text would not
55
+ * map back to the repository's byte for byte (a mixed-case name, a
56
+ * placeholder word the repository's text holds), so a patch of them
57
+ * would rewrite the repository's. Left as the folder had them.
58
+ */
59
+ readonly unmapped: readonly string[];
60
+ }
61
+ export declare function applyPatch(dir: string, patchText: string, options?: {
62
+ readonly stubs?: boolean;
63
+ readonly log?: (line: string) => void;
64
+ /** The repository's checkout; else the one the record names. */
65
+ readonly repo?: string;
66
+ /** The cut's receipt file; else the one `CARVEOUT_HOME` keeps for its id. */
67
+ readonly receipt?: string;
68
+ /** No receipt: the folder's own record is all there is. */
69
+ readonly noReceipt?: boolean;
70
+ /**
71
+ * Filled with each slice file the command wrote, by repository path:
72
+ * the hash of the file as the cut of the patched repository writes it,
73
+ * in the repository's names and in the folder's, whatever the folder's
74
+ * own edits merged into it. What `refresh` moves the folder's base to.
75
+ */
76
+ readonly written?: Map<string, {
77
+ readonly folderPath: string;
78
+ readonly sha256: string;
79
+ readonly folderSha256: string;
80
+ }>;
81
+ }): Promise<Applied>;
82
+ export interface MergeStep {
83
+ readonly step: "patch" | "apply" | "setup" | "verify";
84
+ readonly ok: boolean;
85
+ readonly output: string;
86
+ }
87
+ export interface Merge {
88
+ readonly patch: Patch;
89
+ readonly steps: readonly MergeStep[];
90
+ readonly ok: boolean;
91
+ }
92
+ /** The install a lockfile names, lifecycle scripts off; null with no package.json. */
93
+ export declare function installCommand(root: string): string | null;
94
+ /**
95
+ * The folder's edits merged into `into`, a checkout of the repository the
96
+ * caller chose: `git apply --3way` there, then `verify` as a shell command
97
+ * at its root. Stops at the first step that fails.
98
+ */
99
+ export declare function mergeProject(dir: string, options: {
100
+ readonly into: string;
101
+ readonly verify?: string;
102
+ /** The repository's checkout to diff against; else `into`, else the record's. */
103
+ readonly repo?: string;
104
+ /** Paths and globs the hand-off policy lets through. */
105
+ readonly allow?: readonly string[];
106
+ /** Environment variables the verify command is given, by name. */
107
+ readonly verifyEnv?: readonly string[];
108
+ /** The cut's receipt file; else the one `CARVEOUT_HOME` keeps for its id. */
109
+ readonly receipt?: string;
110
+ /** No receipt: judge the folder by its own record. */
111
+ readonly noReceipt?: boolean;
112
+ /**
113
+ * Verify in a container (`sandbox.ts`) on a copy of the checkout as the
114
+ * patch left it (tracked and unignored files: no `node_modules`, no
115
+ * ignored `.env`): `verifySetup` (else an install the lockfile names,
116
+ * scripts off) with a network, then `verify` with none.
117
+ */
118
+ readonly sandbox?: SandboxSpec;
119
+ /** The install before a sandboxed verify, run with a network; else one the lockfile names, scripts off. */
120
+ readonly verifySetup?: string;
121
+ }): Promise<Merge>;
122
+ export interface Widened {
123
+ /** The new, wider folder. */
124
+ readonly out: string;
125
+ readonly cut: CutResult;
126
+ /** The contributor's work in the folder widened, as a patch for the repository. */
127
+ readonly patch: Patch;
128
+ /** That work, brought into the new folder; null when there was none. */
129
+ readonly applied: Applied | null;
130
+ }
131
+ /**
132
+ * A folder cut again, wider, with the contributor's work in it: a change
133
+ * that turns out to need a module the slice cut. The work so far is taken
134
+ * as a patch (`patchProject`: none of its code runs, and a file the policy
135
+ * holds stops the widening), the cut is made again with the entries added
136
+ * and every other bound as it was, its pseudonyms keep the placeholders the
137
+ * folder had where they fit, and the work is applied to the new folder in
138
+ * its names. The old folder is left as it was.
139
+ */
140
+ export declare function widenProject(dir: string, options: {
141
+ readonly entries: readonly string[];
142
+ readonly out?: string;
143
+ readonly maxDepth?: number;
144
+ readonly maxFiles?: number;
145
+ readonly receipt?: string;
146
+ readonly noReceipt?: boolean;
147
+ readonly repo?: string;
148
+ readonly allow?: readonly string[];
149
+ readonly log?: (line: string) => void;
150
+ }): Promise<Widened>;
151
+ /**
152
+ * The repository's commits since the cut, brought into the folder: the
153
+ * change from the cut's commit to the checkout's HEAD in the packages the
154
+ * slice holds files of and in the modules it stubs, applied as `apply`
155
+ * applies a patch (the folder's own edits merged, an overlap left for a
156
+ * person, the stubs the change needs written). For a job long enough that
157
+ * the repository moves under it. Null when nothing it reads has moved.
158
+ */
159
+ export declare function refreshProject(dir: string, options?: {
160
+ readonly repo?: string;
161
+ readonly receipt?: string;
162
+ readonly noReceipt?: boolean;
163
+ readonly log?: (line: string) => void;
164
+ /**
165
+ * Slice files the folder's holder merged by hand after an overlap, by
166
+ * repository path: the folder's text stands as resolved, the change
167
+ * leaves them alone, and their base moves to the new commit.
168
+ */
169
+ readonly resolved?: readonly string[];
170
+ }): Promise<{
171
+ readonly from: string;
172
+ readonly to: string;
173
+ readonly applied: Applied;
174
+ /** Files taken as resolved whose text leaves out some of the repository's change to them. */
175
+ readonly droppedUpstream?: readonly string[];
176
+ /** Files taken as resolved where the repository changed the same lines: no merge can say what the folder's text keeps. */
177
+ readonly overlapResolved?: readonly string[];
178
+ /** Copied folders' files the repository changed, left as the folder holds them. */
179
+ readonly copiedLeft?: readonly string[];
180
+ /** Copied folders' files the folder had not edited, taken as the repository has them. */
181
+ readonly copiedTaken?: readonly string[];
182
+ } | null>;