@kabmo-labs/kabmo 0.38.1 → 0.38.2
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.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +219 -219
- package/dist/client/static/js/{CsvGrid-t1n057vw.js → CsvGrid-4dpsfdrf.js} +1 -1
- package/dist/client/static/js/{DocxView-c9g6teks.js → DocxView-crdgc0jd.js} +1 -1
- package/dist/client/static/js/{DrawioView-gd14j54m.js → DrawioView-1ts9y0yk.js} +1 -1
- package/dist/client/static/js/{ImageView-57f1ecdp.js → ImageView-w2hyp129.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-x7srbpz1.js → LayoutWrapper-pdvfkncm.js} +1 -1
- package/dist/client/static/js/{Modal-0bn3f77b.js → Modal-2sx1tgqr.js} +1 -1
- package/dist/client/static/js/{PdfView-cybz0xbj.js → PdfView-72c123a9.js} +1 -1
- package/dist/client/static/js/{SessionsView-gx5q68tp.js → SessionsView-a8921ysr.js} +1 -1
- package/dist/client/static/js/{SheetView-1kk5y326.js → SheetView-8xh69wgk.js} +1 -1
- package/dist/client/static/js/{SvgPreview-mp4tk37p.js → SvgPreview-z3fm87h6.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-78qb3can.js → abnfDiagram-O67JEVCF-25r2p3vh.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-n0fr4hb6.js → architectureDiagram-NJMV4G6O-z3n19xwk.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-2xemfrzh.js → blockDiagram-BEXU5L5S-vzamgz9s.js} +1 -1
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-zxfdx3eb.js → c4Diagram-YGBWAQC7-jejafgn0.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-z9sasy3k.js → classDiagram-v2-NBCMYWYE-qfa6mj0q.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-9byp0czh.js → cose-bilkent-JH36ORCC-9vzdgmk1.js} +1 -1
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-gnm129fx.js → cynefinDiagram-VND7K2PF-a3k3w1t5.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-sc5tfv1w.js → dagre-6A5THRUB-gf04dvxj.js} +1 -1
- package/dist/client/static/js/{diagram-22UHCM2B-hq11eek7.js → diagram-22UHCM2B-a9e0a684.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-7bk532gd.js → diagram-3UASUU5V-fb73gfjd.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-yt8wxttm.js → diagram-ATOU4E4O-yb9n3t30.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-n3978w6p.js → diagram-CDSNMT55-adhbhw28.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-004x4gyw.js → diagram-MLGK6HIB-v4yxyb8r.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-498nt489.js → diagram-MPIPVDR6-94ttsqy2.js} +1 -1
- package/dist/client/static/js/{dockerfile-6hbcmkc8.js → dockerfile-mrranatf.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-5fkmymqn.js → ebnfDiagram-ZINNZB2B-jj4f3pyq.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-6xrfa2kd.js → elk-276RUBZZ-mtnkhyte.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-byz4zbkn.js → erDiagram-OPXOYQCR-18qdkhm5.js} +1 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-zmz4grtx.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-4fkw1k01.js → ganttDiagram-FUAMR5RP-vz28h061.js} +1 -1
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-19g84yw8.js → gitGraphDiagram-X574FWY7-cgq3r4rz.js} +1 -1
- package/dist/client/static/js/{index-3y6krykq.js → index-12p63902.js} +1 -1
- package/dist/client/static/js/{index-1j1s91c4.js → index-1c7294vk.js} +1 -1
- package/dist/client/static/js/{index-sjnnv1gd.js → index-2xb54jt3.js} +1 -1
- package/dist/client/static/js/{index-57z8mtmx.js → index-4hsxaa87.js} +1 -1
- package/dist/client/static/js/{index-zj45wj1x.js → index-5v9v41ap.js} +2 -2
- package/dist/client/static/js/{index-e99ec2f0.js → index-6d5qj0kb.js} +1 -1
- package/dist/client/static/js/{index-gxtgyya0.js → index-6j9h1fa7.js} +1 -1
- package/dist/client/static/js/{index-7kafzae0.js → index-6k2x281j.js} +2 -2
- package/dist/client/static/js/{index-j314me09.js → index-6rt7gs1j.js} +1 -1
- package/dist/client/static/js/{index-dd4q54y0.js → index-737w2mqf.js} +1 -1
- package/dist/client/static/js/{index-kdgcbt17.js → index-95t1hwr8.js} +1 -1
- package/dist/client/static/js/{index-fpf1jkwd.js → index-a5ptb956.js} +1 -1
- package/dist/client/static/js/{index-pfwd0160.js → index-aa6qdgmv.js} +1 -1
- package/dist/client/static/js/{index-jbwns6sc.js → index-ajtd1q1h.js} +1 -1
- package/dist/client/static/js/{index-m4bjsyj2.js → index-arvqarv3.js} +1 -1
- package/dist/client/static/js/{index-89a2702q.js → index-bgcp21ed.js} +1 -1
- package/dist/client/static/js/{index-epbqzayj.js → index-d146s9g3.js} +1 -1
- package/dist/client/static/js/{index-3wpsr2bc.js → index-d8kjsgpt.js} +7 -7
- package/dist/client/static/js/{index-rgdhyry3.js → index-dr7nhha9.js} +1 -1
- package/dist/client/static/js/{index-20vhkcb9.js → index-enxfdvdq.js} +1 -1
- package/dist/client/static/js/{index-e3w46vsc.js → index-fqhpxzyb.js} +1 -1
- package/dist/client/static/js/{index-cj9193d5.js → index-gbdvr4rt.js} +1 -1
- package/dist/client/static/js/{index-baet2nv8.js → index-hp8kfk9z.js} +1 -1
- package/dist/client/static/js/{index-5gn56236.js → index-kf9t3mzv.js} +1 -1
- package/dist/client/static/js/{index-0v8b5pzb.js → index-naz3px72.js} +1 -1
- package/dist/client/static/js/{index-4jbbdq6n.js → index-njqpkcvw.js} +1 -1
- package/dist/client/static/js/{index-qntytvt0.js → index-qxb8k6py.js} +1 -1
- package/dist/client/static/js/{index-bhng2dax.js → index-rtd9frp1.js} +1 -1
- package/dist/client/static/js/{index-ehnztdd2.js → index-s16h2nmv.js} +1 -1
- package/dist/client/static/js/{index-74scnfpk.js → index-s910y31q.js} +1 -1
- package/dist/client/static/js/{index-8j90mdgz.js → index-we2ezmn7.js} +1 -1
- package/dist/client/static/js/{index-zw7qjx65.js → index-y5y7smet.js} +1 -1
- package/dist/client/static/js/{index-4qt2e84b.js → index-z72wf7q4.js} +1 -1
- package/dist/client/static/js/{index-g252205p.js → index-zdbvm01f.js} +1 -1
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-aw6ter0a.js → infoDiagram-VRGFBTTK-jjwckbr9.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-62gst5wh.js → ishikawaDiagram-OU5B5YK6-qzk5gejf.js} +1 -1
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-6kgv5a4j.js → journeyDiagram-ZHPQQLJL-maccpg3q.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-8p3515b7.js → kanban-definition-PNTS6WVX-xv2azgws.js} +1 -1
- package/dist/client/static/js/{mermaid.core-b6ga2y8y.js → mermaid.core-e4ys760s.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-na9e9b4a.js → mindmap-definition-NLK3R4M7-b779wz81.js} +1 -1
- package/dist/client/static/js/one-dark-pro-kckm8epj.js +1 -0
- package/dist/client/static/js/one-light-0v7rg9a7.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-d1hk7fnq.js → pegDiagram-GJSIUBJH-8sgdmhnw.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-7b9f4x0y.js → pieDiagram-5QR66LMP-nz6n95d6.js} +1 -1
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-q4wxgmhg.js → quadrantDiagram-O4NWA36T-47dpygk5.js} +1 -1
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-jngq1qx4.js → railroadDiagram-XR7U4H2S-wv0bvwve.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-6xph3b72.js → requirementDiagram-PLB6GJNP-w3r8r837.js} +1 -1
- package/dist/client/static/js/{rust-w6hen2h4.js → rust-42c4h7e4.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-ncfzgdj8.js → sankeyDiagram-IPEJSGJF-t55rjgad.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-sqz0yfg0.js → sequenceDiagram-PO4LG4MO-yfwjwy37.js} +1 -1
- package/dist/client/static/js/{sizeCapture-INFHLROL-vt8qp04d.js → sizeCapture-INFHLROL-nq6hy7ce.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-myjtrmfe.js → stateDiagram-v2-GCMORJYK-4xy0atqh.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-z9vx7z4j.js → swimlanes-2SLR337P-np47cy1q.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-5vha7thx.js → swimlanesDiagram-TC7HE7FX-56rk9kxv.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-z815np57.js → timeline-definition-EJHVYXUP-rb0gnm35.js} +1 -1
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-06ntggng.js → usecaseDiagram-POWQR4AR-gatkznan.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-nmtaf5rp.js → vennDiagram-UO4OBE2U-r3f5xjjq.js} +1 -1
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-zgsxmak8.js → wardleyDiagram-VNRHLVJA-tpass65t.js} +1 -1
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-8bg9qdra.js → xychartDiagram-PMCCYNJV-8xkh67cw.js} +1 -1
- package/package.json +1 -1
- package/src/server/lib/changes/capture-fs.server.ts +0 -8
- package/src/server/lib/changes/capture.server.ts +1 -2
- package/src/server/lib/changes/classify-command.test.ts +20 -0
- package/src/server/lib/changes/classify-command.ts +46 -23
- package/src/server/lib/changes/classify-git.ts +12 -11
- package/src/server/lib/changes/classify-tokenize.ts +9 -1
- package/src/server/lib/changes/scan.server.ts +19 -14
- package/dist/client/static/js/flowDiagram-KWPJA3E3-s3fbfwrz.js +0 -1
- package/dist/client/static/js/one-dark-pro-xp6ssk4z.js +0 -1
- package/dist/client/static/js/one-light-xgab7b02.js +0 -1
|
@@ -61,6 +61,8 @@ export interface CommandPlan {
|
|
|
61
61
|
opaque: boolean;
|
|
62
62
|
/** Every command is a known read-only verb and there is no output redirect. */
|
|
63
63
|
readOnly: boolean;
|
|
64
|
+
/** An opaque command whose effect a filesystem scan can reconcile. */
|
|
65
|
+
scan: boolean;
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
/** Verbs that never write a file. */
|
|
@@ -95,6 +97,21 @@ const OPAQUE: Record<string, true> = {
|
|
|
95
97
|
watch: true,
|
|
96
98
|
};
|
|
97
99
|
|
|
100
|
+
/** Opaque verbs whose effect a filesystem scan can reconcile. */
|
|
101
|
+
const SCAN_VERBS: Record<string, true> = {
|
|
102
|
+
make: true, cargo: true, go: true, sh: true, bash: true, zsh: true,
|
|
103
|
+
python: true, python3: true, node: true, deno: true, xargs: true,
|
|
104
|
+
sudo: true, eval: true, source: true, '.': true,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** Package managers scan only for the subcommands that write the tree. */
|
|
108
|
+
const SCAN_PACKAGE_VERBS: Record<string, true> = {
|
|
109
|
+
npm: true, pnpm: true, yarn: true, bun: true,
|
|
110
|
+
};
|
|
111
|
+
const SCAN_PACKAGE_SUBCOMMANDS: Record<string, true> = {
|
|
112
|
+
install: true, i: true, add: true, remove: true, uninstall: true,
|
|
113
|
+
};
|
|
114
|
+
|
|
98
115
|
/** Classify one already-parsed `argv` (the shell trace's `simple` node). */
|
|
99
116
|
export function classifyArgv(argv: readonly string[], cwd: string, home: string): CommandPlan {
|
|
100
117
|
return classifySimple({ words: [...argv], redirects: [] }, cwd, home);
|
|
@@ -105,6 +122,7 @@ export function classifyCommand(script: string, cwd: string, home: string): Comm
|
|
|
105
122
|
const mutations: CommandMutation[] = [];
|
|
106
123
|
let opaque = false;
|
|
107
124
|
let readOnly = true;
|
|
125
|
+
let scan = false;
|
|
108
126
|
let currentCwd = cwd;
|
|
109
127
|
for (const command of splitCommands(tokenizeCommand(stripHeredocs(script)))) {
|
|
110
128
|
const verb = command.words[0] ? path.basename(command.words[0]) : '';
|
|
@@ -121,14 +139,16 @@ export function classifyCommand(script: string, cwd: string, home: string): Comm
|
|
|
121
139
|
mutations.push(...result.mutations);
|
|
122
140
|
if (result.opaque) opaque = true;
|
|
123
141
|
if (!result.readOnly) readOnly = false;
|
|
142
|
+
if (result.scan) scan = true;
|
|
124
143
|
}
|
|
125
|
-
return { mutations: dedupe(mutations), opaque, readOnly };
|
|
144
|
+
return { mutations: dedupe(mutations), opaque, readOnly, scan };
|
|
126
145
|
}
|
|
127
146
|
|
|
128
147
|
function classifySimple(command: SimpleCommand, cwd: string, home: string): CommandPlan {
|
|
129
148
|
const mutations: CommandMutation[] = [];
|
|
130
149
|
let opaque = false;
|
|
131
150
|
let readOnly = true;
|
|
151
|
+
let scan = false;
|
|
132
152
|
|
|
133
153
|
const add = (op: MutationOp, raw: string, from?: string): void => {
|
|
134
154
|
// `/dev/null` and friends are redirect sinks, not working-tree mutations.
|
|
@@ -147,35 +167,37 @@ function classifySimple(command: SimpleCommand, cwd: string, home: string): Comm
|
|
|
147
167
|
}
|
|
148
168
|
|
|
149
169
|
const argv = command.words;
|
|
150
|
-
if (argv.length === 0) return { mutations, opaque, readOnly };
|
|
170
|
+
if (argv.length === 0) return { mutations, opaque, readOnly, scan };
|
|
151
171
|
const verb = path.basename(argv[0]);
|
|
152
172
|
const args = argv.slice(1);
|
|
153
173
|
|
|
154
|
-
if (READ_ONLY[verb] === true) return { mutations, opaque, readOnly };
|
|
174
|
+
if (READ_ONLY[verb] === true) return { mutations, opaque, readOnly, scan };
|
|
175
|
+
if (SCAN_VERBS[verb] === true) scan = true;
|
|
176
|
+
if (SCAN_PACKAGE_VERBS[verb] === true && SCAN_PACKAGE_SUBCOMMANDS[args[0] ?? ''] === true) scan = true;
|
|
155
177
|
|
|
156
178
|
if (verb === 'sed' || verb === 'gsed' || verb === 'perl') {
|
|
157
179
|
const inPlace = args.some((arg) => arg === '-i' || arg.startsWith('-i') || arg === '--in-place' || arg.startsWith('--in-place='));
|
|
158
|
-
if (!inPlace) return { mutations, opaque, readOnly };
|
|
180
|
+
if (!inPlace) return { mutations, opaque, readOnly, scan };
|
|
159
181
|
for (const file of scriptFiles(args)) add('update', file);
|
|
160
|
-
return { mutations, opaque, readOnly };
|
|
182
|
+
return { mutations, opaque, readOnly, scan };
|
|
161
183
|
}
|
|
162
184
|
if (verb === 'awk' || verb === 'gawk') {
|
|
163
185
|
const index = args.findIndex((arg) => arg === '-i' || arg === 'inplace');
|
|
164
|
-
if (index === -1) return { mutations, opaque, readOnly };
|
|
186
|
+
if (index === -1) return { mutations, opaque, readOnly, scan };
|
|
165
187
|
// `-i inplace` is two tokens; the program follows, then the files.
|
|
166
188
|
const programAt = args[index] === '-i' && args[index + 1] === 'inplace' ? index + 2 : index + 1;
|
|
167
189
|
for (const file of args.slice(programAt + 1).filter((arg) => !arg.startsWith('-'))) add('update', file);
|
|
168
|
-
return { mutations, opaque, readOnly };
|
|
190
|
+
return { mutations, opaque, readOnly, scan };
|
|
169
191
|
}
|
|
170
192
|
if (verb === 'rm' || verb === 'rmdir' || verb === 'unlink') {
|
|
171
193
|
for (const file of nonFlagArgs(args)) add('delete', file);
|
|
172
|
-
return { mutations, opaque, readOnly };
|
|
194
|
+
return { mutations, opaque, readOnly, scan };
|
|
173
195
|
}
|
|
174
196
|
if (verb === 'mv') {
|
|
175
197
|
const files = nonFlagArgs(args);
|
|
176
198
|
if (files.length < 2) {
|
|
177
199
|
opaque = true;
|
|
178
|
-
return { mutations, opaque, readOnly };
|
|
200
|
+
return { mutations, opaque, readOnly, scan };
|
|
179
201
|
}
|
|
180
202
|
const dest = files[files.length - 1];
|
|
181
203
|
const sources = files.slice(0, -1);
|
|
@@ -190,13 +212,13 @@ function classifySimple(command: SimpleCommand, cwd: string, home: string): Comm
|
|
|
190
212
|
mutations.push({ op: 'rename', path: to, from });
|
|
191
213
|
readOnly = false;
|
|
192
214
|
}
|
|
193
|
-
return { mutations, opaque, readOnly };
|
|
215
|
+
return { mutations, opaque, readOnly, scan };
|
|
194
216
|
}
|
|
195
217
|
if (verb === 'cp') {
|
|
196
218
|
const files = nonFlagArgs(args);
|
|
197
219
|
if (files.length < 2) {
|
|
198
220
|
opaque = true;
|
|
199
|
-
return { mutations, opaque, readOnly };
|
|
221
|
+
return { mutations, opaque, readOnly, scan };
|
|
200
222
|
}
|
|
201
223
|
const dest = files[files.length - 1];
|
|
202
224
|
const sources = files.slice(0, -1);
|
|
@@ -210,63 +232,64 @@ function classifySimple(command: SimpleCommand, cwd: string, home: string): Comm
|
|
|
210
232
|
mutations.push({ op: 'update', path: to });
|
|
211
233
|
readOnly = false;
|
|
212
234
|
}
|
|
213
|
-
return { mutations, opaque, readOnly };
|
|
235
|
+
return { mutations, opaque, readOnly, scan };
|
|
214
236
|
}
|
|
215
237
|
if (verb === 'tee' || verb === 'touch') {
|
|
216
238
|
for (const file of nonFlagArgs(args)) add('update', file);
|
|
217
|
-
return { mutations, opaque, readOnly };
|
|
239
|
+
return { mutations, opaque, readOnly, scan };
|
|
218
240
|
}
|
|
219
241
|
if (verb === 'truncate') {
|
|
220
242
|
for (const file of truncateFiles(args)) add('update', file);
|
|
221
|
-
return { mutations, opaque, readOnly };
|
|
243
|
+
return { mutations, opaque, readOnly, scan };
|
|
222
244
|
}
|
|
223
245
|
if (verb === 'install' || verb === 'ln') {
|
|
224
246
|
const files = nonFlagArgs(args);
|
|
225
247
|
const file = files[files.length - 1];
|
|
226
248
|
if (file) add(verb === 'ln' ? 'create' : 'update', file);
|
|
227
249
|
else opaque = true;
|
|
228
|
-
return { mutations, opaque, readOnly };
|
|
250
|
+
return { mutations, opaque, readOnly, scan };
|
|
229
251
|
}
|
|
230
252
|
if (verb === 'dd') {
|
|
231
253
|
for (const arg of args) {
|
|
232
254
|
if (arg.startsWith('of=')) add('update', arg.slice(3));
|
|
233
255
|
}
|
|
234
|
-
return { mutations, opaque, readOnly };
|
|
256
|
+
return { mutations, opaque, readOnly, scan };
|
|
235
257
|
}
|
|
236
258
|
if (verb === 'sort') {
|
|
237
259
|
const out = flagValue(args, '-o') ?? flagValue(args, '--output');
|
|
238
260
|
if (out) add('update', out);
|
|
239
|
-
return { mutations, opaque, readOnly };
|
|
261
|
+
return { mutations, opaque, readOnly, scan };
|
|
240
262
|
}
|
|
241
263
|
if (verb === 'uniq') {
|
|
242
264
|
const files = nonFlagArgs(args);
|
|
243
265
|
if (files.length >= 2) add('update', files[1]);
|
|
244
|
-
return { mutations, opaque, readOnly };
|
|
266
|
+
return { mutations, opaque, readOnly, scan };
|
|
245
267
|
}
|
|
246
268
|
if (verb === 'curl' || verb === 'wget') {
|
|
247
269
|
const out = flagValue(args, '-o') ?? flagValue(args, '--output') ?? flagValue(args, '-O');
|
|
248
270
|
if (out) add('update', out);
|
|
249
|
-
return { mutations, opaque, readOnly };
|
|
271
|
+
return { mutations, opaque, readOnly, scan };
|
|
250
272
|
}
|
|
251
273
|
if (verb === 'find') {
|
|
252
274
|
const mutating = args.some((arg) => arg === '-delete' || arg === '-exec' || arg === '-execdir' || arg === '-ok' || arg === '-okdir');
|
|
253
275
|
if (mutating) {
|
|
254
276
|
opaque = true;
|
|
255
277
|
readOnly = false;
|
|
278
|
+
scan = true;
|
|
256
279
|
}
|
|
257
|
-
return { mutations, opaque, readOnly };
|
|
280
|
+
return { mutations, opaque, readOnly, scan };
|
|
258
281
|
}
|
|
259
282
|
if (verb === 'git') {
|
|
260
|
-
return classifyGit(args, cwd, home, mutations, opaque, readOnly);
|
|
283
|
+
return classifyGit(args, cwd, home, mutations, opaque, readOnly, scan);
|
|
261
284
|
}
|
|
262
285
|
if (OPAQUE[verb] === true) {
|
|
263
286
|
opaque = true;
|
|
264
287
|
readOnly = false;
|
|
265
|
-
return { mutations, opaque, readOnly };
|
|
288
|
+
return { mutations, opaque, readOnly, scan };
|
|
266
289
|
}
|
|
267
290
|
|
|
268
291
|
// An unknown verb is not assumed harmless.
|
|
269
292
|
opaque = true;
|
|
270
293
|
readOnly = false;
|
|
271
|
-
return { mutations, opaque, readOnly };
|
|
294
|
+
return { mutations, opaque, readOnly, scan };
|
|
272
295
|
}
|
|
@@ -41,10 +41,11 @@ export function classifyGit(
|
|
|
41
41
|
mutations: CommandMutation[],
|
|
42
42
|
opaque: boolean,
|
|
43
43
|
readOnly: boolean,
|
|
44
|
+
scan: boolean,
|
|
44
45
|
): CommandPlan {
|
|
45
46
|
const sub = args[0];
|
|
46
|
-
if (!sub) return { mutations, opaque, readOnly };
|
|
47
|
-
if (GIT_READ_ONLY[sub] === true) return { mutations, opaque, readOnly };
|
|
47
|
+
if (!sub) return { mutations, opaque, readOnly, scan };
|
|
48
|
+
if (GIT_READ_ONLY[sub] === true) return { mutations, opaque, readOnly, scan };
|
|
48
49
|
|
|
49
50
|
const add = (op: MutationOp, raw: string, from?: string): void => {
|
|
50
51
|
if (isSpecialFile(raw)) return;
|
|
@@ -59,30 +60,30 @@ export function classifyGit(
|
|
|
59
60
|
|
|
60
61
|
if (sub === 'mv') {
|
|
61
62
|
const files = nonFlagArgs(args.slice(1));
|
|
62
|
-
if (files.length < 2) return { mutations, opaque: true, readOnly: false };
|
|
63
|
+
if (files.length < 2) return { mutations, opaque: true, readOnly: false, scan: true };
|
|
63
64
|
const from = resolvePath(cwd, home, files[0]);
|
|
64
65
|
const to = resolvePath(cwd, home, files[files.length - 1]);
|
|
65
|
-
if (!from || !to) return { mutations, opaque: true, readOnly: false };
|
|
66
|
+
if (!from || !to) return { mutations, opaque: true, readOnly: false, scan: true };
|
|
66
67
|
mutations.push({ op: 'rename', path: to, from });
|
|
67
|
-
return { mutations, opaque, readOnly: false };
|
|
68
|
+
return { mutations, opaque, readOnly: false, scan };
|
|
68
69
|
}
|
|
69
70
|
if (sub === 'rm') {
|
|
70
71
|
for (const file of nonFlagArgs(args.slice(1))) add('delete', file);
|
|
71
|
-
return { mutations, opaque, readOnly };
|
|
72
|
+
return { mutations, opaque, readOnly, scan };
|
|
72
73
|
}
|
|
73
74
|
if (sub === 'checkout' || sub === 'restore') {
|
|
74
75
|
const separator = args.indexOf('--');
|
|
75
76
|
if (separator !== -1) {
|
|
76
77
|
for (const file of args.slice(separator + 1)) add('update', file);
|
|
77
|
-
return { mutations, opaque, readOnly };
|
|
78
|
+
return { mutations, opaque, readOnly, scan };
|
|
78
79
|
}
|
|
79
80
|
if (sub === 'restore') {
|
|
80
81
|
for (const file of nonFlagArgs(args.slice(1))) add('update', file);
|
|
81
|
-
return { mutations, opaque, readOnly };
|
|
82
|
+
return { mutations, opaque, readOnly, scan };
|
|
82
83
|
}
|
|
83
|
-
return { mutations, opaque: true, readOnly: false };
|
|
84
|
+
return { mutations, opaque: true, readOnly: false, scan: true };
|
|
84
85
|
}
|
|
85
|
-
if (GIT_OPAQUE[sub] === true) return { mutations, opaque: true, readOnly: false };
|
|
86
|
+
if (GIT_OPAQUE[sub] === true) return { mutations, opaque: true, readOnly: false, scan: true };
|
|
86
87
|
|
|
87
|
-
return { mutations, opaque: true, readOnly: false };
|
|
88
|
+
return { mutations, opaque: true, readOnly: false, scan: true };
|
|
88
89
|
}
|
|
@@ -41,10 +41,18 @@ export function tokenizeCommand(script: string): Token[] {
|
|
|
41
41
|
|
|
42
42
|
for (let i = 0; i < script.length; i++) {
|
|
43
43
|
const ch = script[i];
|
|
44
|
-
if (ch === ' ' || ch === '\t' || ch === '\
|
|
44
|
+
if (ch === ' ' || ch === '\t' || ch === '\r') {
|
|
45
45
|
flush();
|
|
46
46
|
continue;
|
|
47
47
|
}
|
|
48
|
+
// A newline is a command separator, not whitespace: `printf > a` and
|
|
49
|
+
// `python3 - <<PY` on separate lines are two commands, and merging them
|
|
50
|
+
// made the second one invisible to the classifier.
|
|
51
|
+
if (ch === '\n') {
|
|
52
|
+
flush();
|
|
53
|
+
tokens.push({ kind: 'op', value: ';' });
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
48
56
|
if (ch === '#' && !hasWord) {
|
|
49
57
|
while (i < script.length && script[i] !== '\n') i++;
|
|
50
58
|
continue;
|
|
@@ -94,22 +94,11 @@ export async function takeGitScan(cwd: string): Promise<GitScan | null> {
|
|
|
94
94
|
* skipped rather than journaled as a text diff.
|
|
95
95
|
*/
|
|
96
96
|
export async function takeDirScan(cwd: string): Promise<GitScan | null> {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
entries = await readdir(cwd, { withFileTypes: true });
|
|
100
|
-
} catch {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
97
|
+
const files: string[] = [];
|
|
98
|
+
let truncated = await walkFiles(cwd, files, SCAN_BUDGET_FILES);
|
|
103
99
|
const dirty = new Map<string, string | null>();
|
|
104
100
|
let bytes = 0;
|
|
105
|
-
|
|
106
|
-
for (const entry of entries) {
|
|
107
|
-
if (!entry.isFile()) continue;
|
|
108
|
-
if (dirty.size >= SCAN_BUDGET_FILES) {
|
|
109
|
-
truncated = true;
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
const absolute = path.join(cwd, entry.name);
|
|
101
|
+
for (const absolute of files) {
|
|
113
102
|
const info = await stat(absolute).catch(() => null);
|
|
114
103
|
if (!info) continue;
|
|
115
104
|
if (bytes + info.size > DIR_SCAN_MAX_BYTES) {
|
|
@@ -124,6 +113,22 @@ export async function takeDirScan(cwd: string): Promise<GitScan | null> {
|
|
|
124
113
|
return { root: cwd, dirty, truncated };
|
|
125
114
|
}
|
|
126
115
|
|
|
116
|
+
/** Recursive file walk, bounded; `node_modules` and `.git` are skipped. */
|
|
117
|
+
async function walkFiles(dir: string, out: string[], budget: number): Promise<boolean> {
|
|
118
|
+
const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
119
|
+
for (const entry of entries) {
|
|
120
|
+
if (out.length >= budget) return true;
|
|
121
|
+
if (entry.name === 'node_modules' || entry.name === '.git') continue;
|
|
122
|
+
const absolute = path.join(dir, entry.name);
|
|
123
|
+
if (entry.isDirectory()) {
|
|
124
|
+
if (await walkFiles(absolute, out, budget)) return true;
|
|
125
|
+
} else if (entry.isFile()) {
|
|
126
|
+
out.push(absolute);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
|
|
127
132
|
/** Git first (exact for tracked files), then the directory scan. */
|
|
128
133
|
export async function takeScan(cwd: string): Promise<GitScan | null> {
|
|
129
134
|
const git = await takeGitScan(cwd);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./index-zj45wj1x.js";import"./index-kdgcbt17.js";import{ah}from"./index-e3w46vsc.js";export{ah as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{MA}from"./index-3wpsr2bc.js";export{MA as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LA}from"./index-3wpsr2bc.js";export{LA as default};
|