@karmaniverous/stan-core 0.4.6 → 0.5.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.
- package/README.md +1 -1
- package/dist/cjs/classifier-ClvtQeTy.js +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/mjs/classifier-Bqzr65UC.js +1 -0
- package/dist/mjs/index.js +1 -1
- package/dist/stan.system.md +109 -29
- package/dist/types/index.d.ts +9 -5
- package/package.json +2 -2
- package/dist/cjs/classifier-D1njCQ3L.js +0 -1
- package/dist/mjs/classifier-DeYwffC_.js +0 -1
package/dist/stan.system.md
CHANGED
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
6. Coverage: one Patch per changed file. Full Listings are not required by default in normal replies; include them only on explicit request. Diagnostics replies require Full Listings only (no patches). Skip listings for deletions.
|
|
12
12
|
7. Services‑first: ports & adapters; thin adapters; pure services; co‑located tests.
|
|
13
13
|
8. Long‑file rule: ~300 LOC threshold; propose splits or justify exceptions; record plan/justification in stan.todo.md.
|
|
14
|
-
9. Fence hygiene:
|
|
14
|
+
9. Fence hygiene: wrap code blocks in tilde fences (default `~~~~`), bump to `~`×(N+1) when content contains `~`×N; re‑scan after composing.
|
|
15
|
+
|
|
16
|
+
**Table of Contents**
|
|
15
17
|
|
|
16
18
|
- Role
|
|
17
19
|
- Vocabulary aliases
|
|
@@ -280,22 +282,26 @@ When the unexpected happens, a short design iteration almost always produces a b
|
|
|
280
282
|
# Dependency Bug Report
|
|
281
283
|
|
|
282
284
|
Purpose
|
|
285
|
+
|
|
283
286
|
- When a dependency fails, offer a concise, valid‑Markdown bug report that upstream (human or STAN) can consume.
|
|
284
287
|
- Keep the report self‑contained (short excerpts inline). Prefer links for large evidence; defer artifacts to a later iteration.
|
|
285
288
|
|
|
286
289
|
Fence hygiene
|
|
287
|
-
|
|
290
|
+
|
|
291
|
+
- When presenting this template in chat, wrap the entire template body in a fence chosen by the Fence Hygiene (Quick How‑To) algorithm and re‑scan before sending. Do not rely on a fixed tilde count.
|
|
288
292
|
|
|
289
293
|
Canonical template (copy/paste the body; wrap per fence‑hygiene rules)
|
|
290
294
|
|
|
291
295
|
# Dependency Bug Report — <package>@<version>
|
|
292
296
|
|
|
293
297
|
## Summary
|
|
298
|
+
|
|
294
299
|
- What: <1–2 sentences describing the failure in downstream usage>
|
|
295
300
|
- Where: <downstream repo name> (<relative paths>)
|
|
296
301
|
- Impact: <blocking | partial | annoyance>; Scope: <modules affected>
|
|
297
302
|
|
|
298
303
|
## Environment
|
|
304
|
+
|
|
299
305
|
- Downstream repo: <name> @ <commit or tag>
|
|
300
306
|
- Node: <x.y.z> (<os/arch>)
|
|
301
307
|
- Package manager: <npm|pnpm|yarn> <version>
|
|
@@ -303,11 +309,13 @@ Canonical template (copy/paste the body; wrap per fence‑hygiene rules)
|
|
|
303
309
|
- Tooling: TypeScript <x.y>, Bundler <rollup/vite/webpack>, ESLint/TSConfig notes (if relevant)
|
|
304
310
|
|
|
305
311
|
## Reproduction (minimal)
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
312
|
+
|
|
313
|
+
1. <command or step>
|
|
314
|
+
2. <command or step>
|
|
315
|
+
3. Observe: <expected vs actual>
|
|
309
316
|
|
|
310
317
|
Example:
|
|
318
|
+
|
|
311
319
|
```bash
|
|
312
320
|
pnpm i
|
|
313
321
|
pnpm run build
|
|
@@ -316,12 +324,15 @@ pnpm run build
|
|
|
316
324
|
```
|
|
317
325
|
|
|
318
326
|
## Evidence (concise)
|
|
327
|
+
|
|
319
328
|
Primary error excerpt:
|
|
329
|
+
|
|
320
330
|
```text
|
|
321
331
|
<copy the minimal error lines + 2–5 lines of context>
|
|
322
332
|
```
|
|
323
333
|
|
|
324
334
|
If a minimal code change triggers it, show the tiniest diff:
|
|
335
|
+
|
|
325
336
|
```diff
|
|
326
337
|
diff --git a/src/example.ts b/src/example.ts
|
|
327
338
|
--- a/src/example.ts
|
|
@@ -332,29 +343,35 @@ diff --git a/src/example.ts b/src/example.ts
|
|
|
332
343
|
```
|
|
333
344
|
|
|
334
345
|
## Root cause hypothesis (best‑effort)
|
|
346
|
+
|
|
335
347
|
- <e.g., subpath export missing; ESM/CJS mismatch; types not published; side effects; changed API signature>
|
|
336
348
|
- Why we think so: <brief rationale, links to docs/source lines>
|
|
337
349
|
|
|
338
350
|
## Proposed fix (what we need from upstream)
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
351
|
+
|
|
352
|
+
1. <concrete change, e.g., “add subpath export ./mutator in package.json”>
|
|
353
|
+
2. <build/output change, e.g., “publish .d.ts alongside JS outputs”>
|
|
354
|
+
3. <docs note or migration guidance, if applicable>
|
|
342
355
|
|
|
343
356
|
## Acceptance criteria
|
|
357
|
+
|
|
344
358
|
- After publishing:
|
|
345
359
|
- <import/build/test> succeeds without local hacks.
|
|
346
360
|
- TypeScript resolves types without path alias overrides.
|
|
347
361
|
- No <specific error codes/warnings> remain in a fresh install.
|
|
348
362
|
|
|
349
363
|
## Attachments or links (evidence)
|
|
364
|
+
|
|
350
365
|
- Preferred: links to logs, a minimal repro repo, or a PR that demonstrates the issue clearly.
|
|
351
366
|
- Avoid bundling artifacts in the same message as this report to prevent ingestion confusion by tools that auto‑process archives.
|
|
352
367
|
|
|
353
368
|
## Notes for downstream (we’ll handle)
|
|
369
|
+
|
|
354
370
|
- <local pin/guard we will apply temporarily; removed after fix>
|
|
355
371
|
- <config/doc updates we’ll make once published>
|
|
356
372
|
|
|
357
373
|
## Maintainer contact
|
|
374
|
+
|
|
358
375
|
- Upstream repo: <url>
|
|
359
376
|
- Issue link (if already filed): <url or “to be filed”>
|
|
360
377
|
|
|
@@ -946,6 +963,51 @@ Notes
|
|
|
946
963
|
- Reserved denials remain in effect (e.g., do not place content under `/<stanPath>/diff/**`, `/<stanPath>/patch/**`, or archive outputs in `/<stanPath>/output/**`).
|
|
947
964
|
- The facet‑aware editing guard still applies: do not propose edits under an inactive facet this run; enable the facet first and emit patches next turn.
|
|
948
965
|
|
|
966
|
+
# STAN assistant guide — creation & upkeep policy
|
|
967
|
+
|
|
968
|
+
This repository SHOULD include a “STAN assistant guide” document at
|
|
969
|
+
`guides/stan-assistant-guide.md`, unless the project prompt explicitly declares
|
|
970
|
+
a different single, stable path for the guide (in which case, that declared path
|
|
971
|
+
is authoritative).
|
|
972
|
+
|
|
973
|
+
The assistant guide exists to let STAN assistants use and integrate the library
|
|
974
|
+
effectively without consulting external type definition files or other project
|
|
975
|
+
documentation.
|
|
976
|
+
|
|
977
|
+
Policy
|
|
978
|
+
|
|
979
|
+
- Creation (required):
|
|
980
|
+
- If the assistant guide is missing, create it as part of the first change set
|
|
981
|
+
where you would otherwise rely on it (e.g., when adding/altering public APIs,
|
|
982
|
+
adapters, configuration, or key workflows).
|
|
983
|
+
- Prefer creating it in the same turn as the first relevant code changes so it
|
|
984
|
+
cannot drift from reality.
|
|
985
|
+
- Maintenance (required):
|
|
986
|
+
- Treat the guide as a maintained artifact, not a one-off doc.
|
|
987
|
+
- Whenever a change set materially affects how an assistant should use the
|
|
988
|
+
library (public exports, configuration shape/semantics, runtime invariants,
|
|
989
|
+
query contracts, paging tokens, projection behavior, adapter
|
|
990
|
+
responsibilities, or common pitfalls), update the guide in the same change
|
|
991
|
+
set.
|
|
992
|
+
- When deprecating/renaming APIs or changing semantics, update the guide and
|
|
993
|
+
include migration guidance (old → new), but keep it concise.
|
|
994
|
+
- Intent (what the guide must enable):
|
|
995
|
+
- Provide a self-contained description of the “mental model” (runtime behavior
|
|
996
|
+
and invariants) and the minimum working patterns (how to configure, how to
|
|
997
|
+
call core entrypoints, how to integrate a provider/adapter).
|
|
998
|
+
- Include only the information required to use the library correctly; omit
|
|
999
|
+
narrative or historical context.
|
|
1000
|
+
- Constraints (how to keep it effective and reusable):
|
|
1001
|
+
- Keep it compact: “as short as possible, but as long as necessary.”
|
|
1002
|
+
- Make it self-contained: do not require readers to import or open `.d.ts`
|
|
1003
|
+
files, TypeDoc pages, or other repo docs to understand core contracts.
|
|
1004
|
+
- Avoid duplicating durable requirements or the dev plan:
|
|
1005
|
+
- Requirements belong in `stan.requirements.md`.
|
|
1006
|
+
- Work tracking belongs in `stan.todo.md`.
|
|
1007
|
+
- The assistant guide should focus on usage contracts and integration.
|
|
1008
|
+
- Define any acronyms locally on first use within the guide (especially if
|
|
1009
|
+
used outside generic type parameters).
|
|
1010
|
+
|
|
949
1011
|
# Default Task (when files are provided with no extra prompt)
|
|
950
1012
|
|
|
951
1013
|
Primary objective — Plan-first
|
|
@@ -1012,7 +1074,7 @@ If info is insufficient to proceed without critical assumptions, abort and clari
|
|
|
1012
1074
|
## Commit message output
|
|
1013
1075
|
|
|
1014
1076
|
- MANDATORY: Commit message MUST be wrapped in a fenced code block.
|
|
1015
|
-
- Use a
|
|
1077
|
+
- Use a tilde fence (default `~~~~`, or longer per the fence hygiene rule if needed).
|
|
1016
1078
|
- Do not annotate with a language tag; the block must contain only the commit message text.
|
|
1017
1079
|
- Emit the commit message once, at the end of the reply.
|
|
1018
1080
|
- This rule applies to every change set, regardless of size.
|
|
@@ -1024,7 +1086,7 @@ If info is insufficient to proceed without critical assumptions, abort and clari
|
|
|
1024
1086
|
- “When: <UTC timestamp>”
|
|
1025
1087
|
- “Why: <short reason>”
|
|
1026
1088
|
- “What changed:” bulleted file list with terse notes
|
|
1027
|
-
- The fenced commit message MUST be placed in a code block fence that satisfies the
|
|
1089
|
+
- The fenced commit message MUST be placed in a code block fence that satisfies the tilde fence hygiene rule (see Response Format).
|
|
1028
1090
|
- When patches are impractical, provide Full Listings for changed files, followed by the commit message. Do not emit unified diffs in that mode.
|
|
1029
1091
|
|
|
1030
1092
|
Exception — patch failure diagnostics:
|
|
@@ -1036,29 +1098,47 @@ Exception — patch failure diagnostics:
|
|
|
1036
1098
|
|
|
1037
1099
|
# Fence Hygiene (Quick How‑To)
|
|
1038
1100
|
|
|
1039
|
-
Goal: prevent
|
|
1101
|
+
Goal: prevent broken Markdown when emitting fenced blocks, especially diffs and
|
|
1102
|
+
Markdown listings that contain embedded backtick fences.
|
|
1040
1103
|
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1104
|
+
Default wrapper
|
|
1105
|
+
|
|
1106
|
+
- Use **tilde fences** for all fenced code blocks we emit (Patch blocks, Full
|
|
1107
|
+
Listings, templates/examples, and Commit Message blocks).
|
|
1108
|
+
- Start with a **default fence of `~~~~`** (4 tildes). Tilde fences are valid
|
|
1109
|
+
Markdown but rare in code/docs, so collisions are much less common than with
|
|
1110
|
+
backtick fences.
|
|
1111
|
+
|
|
1112
|
+
Algorithm (tilde-based)
|
|
1113
|
+
|
|
1114
|
+
1) Scan every block you will emit. Compute the maximum contiguous run of `~`
|
|
1115
|
+
characters that appears anywhere in that block’s content.
|
|
1116
|
+
2) Choose the outer fence length as `N = max(4, maxInnerTildes + 1)`.
|
|
1117
|
+
3) Emit the block wrapped in `~`×N.
|
|
1118
|
+
4) Re‑scan after composing. If any block’s outer fence is `<= maxInnerTildes`,
|
|
1119
|
+
bump N and re‑emit.
|
|
1045
1120
|
|
|
1046
1121
|
Hard rule (applies everywhere)
|
|
1047
|
-
- Do not rely on a fixed
|
|
1048
|
-
- This applies to
|
|
1122
|
+
- Do not rely on a fixed tilde count. Always compute, then re‑scan.
|
|
1123
|
+
- This applies to Patch blocks, Full Listings, the Dependency Bug Report
|
|
1124
|
+
template, patch-failure diagnostics envelopes, and any example that includes
|
|
1125
|
+
fenced blocks.
|
|
1049
1126
|
|
|
1050
1127
|
# Response Format (MANDATORY)
|
|
1051
1128
|
|
|
1052
1129
|
CRITICAL: Fence Hygiene (Nested Code Blocks) and Coverage
|
|
1053
1130
|
|
|
1054
|
-
-
|
|
1131
|
+
- Use **tilde fences** for all fenced blocks emitted in replies (Patch blocks,
|
|
1132
|
+
Full Listings, and Commit Message). Default is `~~~~`.
|
|
1133
|
+
- You MUST compute fence lengths dynamically to ensure that each outer fence has
|
|
1134
|
+
one more `~` than any `~` run it contains (minimum 4).
|
|
1055
1135
|
- Algorithm:
|
|
1056
1136
|
1. Collect all code blocks you will emit (every “Patch” per file; any optional “Full Listing” blocks, if requested).
|
|
1057
|
-
2. For each block, scan its content and compute the maximum run of consecutive
|
|
1058
|
-
3. Choose the fence length for that block as
|
|
1059
|
-
4. If a block contains other fenced blocks (e.g., an example that itself shows fences), treat those inner fences as part of the scan. If the inner
|
|
1137
|
+
2. For each block, scan its content and compute the maximum run of consecutive `~` characters appearing anywhere inside (including literals in examples).
|
|
1138
|
+
3. Choose the fence length for that block as `max(4, maxInnerTildes + 1)`.
|
|
1139
|
+
4. If a block contains other fenced blocks (e.g., an example that itself shows fences), treat those inner fences as part of the scan. If the inner content uses `~`×N, the enclosing block must use at least `~`×(N+1).
|
|
1060
1140
|
5. If a file has both a “Patch” and an optional “Full Listing”, use the larger fence length for both blocks.
|
|
1061
|
-
6. Never emit a block whose outer fence length is less than or equal to the maximum
|
|
1141
|
+
6. Never emit a block whose outer fence length is less than or equal to the maximum `~` run inside it.
|
|
1062
1142
|
7. After composing the message, rescan each block and verify the rule holds; if not, increase fence lengths and re‑emit.
|
|
1063
1143
|
|
|
1064
1144
|
General Markdown formatting
|
|
@@ -1092,10 +1172,10 @@ Use these headings exactly; wrap each Patch (and optional Full Listing, when app
|
|
|
1092
1172
|
|
|
1093
1173
|
<change summary>
|
|
1094
1174
|
|
|
1095
|
-
|
|
1175
|
+
~~~~
|
|
1096
1176
|
### File Ops
|
|
1097
1177
|
<one operation per line>
|
|
1098
|
-
|
|
1178
|
+
~~~~
|
|
1099
1179
|
|
|
1100
1180
|
## Input Data Changes
|
|
1101
1181
|
|
|
@@ -1127,17 +1207,17 @@ Use these headings exactly; wrap each Patch (and optional Full Listing, when app
|
|
|
1127
1207
|
|
|
1128
1208
|
## Commit Message
|
|
1129
1209
|
|
|
1130
|
-
- Output the commit message at the end of the reply wrapped in a fenced code block. Do not annotate with a language tag. Apply the
|
|
1210
|
+
- Output the commit message at the end of the reply wrapped in a fenced code block. Do not annotate with a language tag. Apply the tilde fence-hygiene rule. The block contains only the commit message (subject + body), no surrounding prose.
|
|
1131
1211
|
|
|
1132
1212
|
## Validation
|
|
1133
1213
|
|
|
1134
1214
|
- Normal replies:
|
|
1135
1215
|
- Confirm one Patch block per changed file (and zero Full Listings).
|
|
1136
|
-
- Confirm fence lengths obey the
|
|
1216
|
+
- Confirm fence lengths obey the tilde fence hygiene rule for every block.
|
|
1137
1217
|
- Confirm that no Patch would cause any file to exceed 300 LOC; pivoted decomposition patches instead.
|
|
1138
1218
|
- Diagnostics replies (after patch‑failure envelopes):
|
|
1139
1219
|
- Confirm that the reply contains Full Listings only (no patches), one per affected file (union across envelopes).
|
|
1140
|
-
- Confirm fence lengths obey the
|
|
1220
|
+
- Confirm fence lengths obey the tilde fence hygiene rule for every block.
|
|
1141
1221
|
- Confirm that no listed file exceeds 300 LOC; if it would, pivoted decomposition + listings for the decomposed files instead.
|
|
1142
1222
|
|
|
1143
1223
|
---
|
|
@@ -1160,7 +1240,7 @@ Before sending a reply, verify all of the following:
|
|
|
1160
1240
|
- Diagnostics replies (after patch‑failure envelopes): Do NOT emit a Commit Message.
|
|
1161
1241
|
|
|
1162
1242
|
3. Fence hygiene (+1 rule)
|
|
1163
|
-
- For every fenced block, the outer fence is strictly longer than any internal
|
|
1243
|
+
- For every fenced block, the outer fence is strictly longer than any internal `~` run (minimum 4).
|
|
1164
1244
|
- Patches, optional Full Listings, and commit message all satisfy the +1 rule.
|
|
1165
1245
|
4. Section headings
|
|
1166
1246
|
- Headings match the template exactly (names and order).
|
|
@@ -1169,7 +1249,7 @@ Before sending a reply, verify all of the following:
|
|
|
1169
1249
|
- Normal replies: If any Patch block is present, there MUST also be a Patch for <stanPath>/system/stan.todo.md that reflects the change set (unless the change set is deletions‑only or explicitly plan‑only). The “Commit Message” MUST be present and last.
|
|
1170
1250
|
- Diagnostics replies: Skip Commit Message; listings‑only for the affected files.
|
|
1171
1251
|
6. Nested-code templates (hard gate)
|
|
1172
|
-
- Any template or example that contains nested fenced code blocks (e.g., the Dependency Bug Report or a patch failure diagnostics envelope) MUST pass the fence‑hygiene scan: compute N =
|
|
1252
|
+
- Any template or example that contains nested fenced code blocks (e.g., the Dependency Bug Report or a patch failure diagnostics envelope) MUST pass the fence‑hygiene scan: compute N = max(4, maxInnerTildes + 1), apply that tilde fence, then re‑scan before sending. If any collision remains, STOP and re‑emit. If any check fails, STOP and re‑emit after fixing. Do not send a reply that fails these checks.
|
|
1173
1253
|
7. Dev plan “Completed” (append‑only; last)
|
|
1174
1254
|
- If `.stan/system/stan.todo.md` is patched:
|
|
1175
1255
|
- “Completed” is still the final major section of the document.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ type CreateArchiveOptions = {
|
|
|
48
48
|
* });
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
-
declare
|
|
51
|
+
declare function createArchive(cwd: string, stanPath: string, options?: CreateArchiveOptions): Promise<string>;
|
|
52
52
|
|
|
53
53
|
/** Public default STAN path for consumers and internal use. */
|
|
54
54
|
declare const DEFAULT_STAN_PATH = ".stan";
|
|
@@ -137,13 +137,13 @@ type SnapshotUpdateMode = 'never' | 'createIfMissing' | 'replace';
|
|
|
137
137
|
* ```
|
|
138
138
|
* @returns Absolute path to the `.archive.snapshot.json` file.
|
|
139
139
|
*/
|
|
140
|
-
declare
|
|
140
|
+
declare function writeArchiveSnapshot({ cwd, stanPath, includes, excludes, anchors, }: {
|
|
141
141
|
cwd: string;
|
|
142
142
|
stanPath: string;
|
|
143
143
|
includes?: string[];
|
|
144
144
|
excludes?: string[];
|
|
145
145
|
anchors?: string[];
|
|
146
|
-
})
|
|
146
|
+
}): Promise<string>;
|
|
147
147
|
/**
|
|
148
148
|
* Create a diff tar at <stanPath>/output/<baseName>.diff.tar.
|
|
149
149
|
* - If snapshot exists: include only changed files.
|
|
@@ -177,7 +177,7 @@ declare const writeArchiveSnapshot: ({ cwd, stanPath, includes, excludes, anchor
|
|
|
177
177
|
* });
|
|
178
178
|
* ```
|
|
179
179
|
*/
|
|
180
|
-
declare
|
|
180
|
+
declare function createArchiveDiff({ cwd, stanPath, baseName, includes, excludes, updateSnapshot, includeOutputDirInDiff, anchors, onArchiveWarnings, }: {
|
|
181
181
|
cwd: string;
|
|
182
182
|
stanPath: string;
|
|
183
183
|
baseName: string;
|
|
@@ -187,7 +187,7 @@ declare const createArchiveDiff: ({ cwd, stanPath, baseName, includes, excludes,
|
|
|
187
187
|
includeOutputDirInDiff?: boolean;
|
|
188
188
|
anchors?: string[];
|
|
189
189
|
onArchiveWarnings?: (text: string) => void;
|
|
190
|
-
})
|
|
190
|
+
}): Promise<{
|
|
191
191
|
diffPath: string;
|
|
192
192
|
}>;
|
|
193
193
|
|
|
@@ -246,6 +246,10 @@ type FileOp = {
|
|
|
246
246
|
verb: 'mv';
|
|
247
247
|
src: string;
|
|
248
248
|
dest: string;
|
|
249
|
+
} | {
|
|
250
|
+
verb: 'cp';
|
|
251
|
+
src: string;
|
|
252
|
+
dest: string;
|
|
249
253
|
} | {
|
|
250
254
|
verb: 'rm';
|
|
251
255
|
src: string;
|
package/package.json
CHANGED
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
]
|
|
131
131
|
},
|
|
132
132
|
"npm": {
|
|
133
|
-
"publish":
|
|
133
|
+
"publish": false
|
|
134
134
|
}
|
|
135
135
|
},
|
|
136
136
|
"repository": {
|
|
@@ -152,5 +152,5 @@
|
|
|
152
152
|
},
|
|
153
153
|
"type": "module",
|
|
154
154
|
"types": "dist/index.d.ts",
|
|
155
|
-
"version": "0.
|
|
155
|
+
"version": "0.5.0"
|
|
156
156
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var t=require("node:fs/promises"),e=require("node:path");const n=1048576;exports.classifyForArchive=async(r,s)=>{const i=[],a=[],o=[];await Promise.all(s.map(async s=>{const c=s.replace(/\\/g,"/");const l=e.resolve(r,s);let h=0;try{h=(await t.stat(l)).size}catch{return}let u,p=!1;try{p=await(async e=>{try{const n=await t.open(e,"r");try{const t=Buffer.allocUnsafe(8192),{bytesRead:e}=await n.read(t,0,t.length,0);for(let n=0;n<e;n+=1)if(0===t[n])return!0;return!1}finally{await n.close().catch(()=>{})}}catch{return!1}})(l)}catch{p=!1}if(p)return void a.push({path:c,size:h});i.push(c);try{if(h<=n||h<5*n){u=(t=>{const e=t.replace(/\r\n/g,"\n");return 0===e.length?0:e.split("\n").length})(await t.readFile(l,"utf8"))}}catch{}(h>n||"number"==typeof u&&u>3e3)&&o.push({path:c,size:h,loc:u})}));const c=[];if(a.length>0){c.push(`Binary files excluded from archive (${a.length.toString()}):`);for(const t of a)c.push(` - ${t.path} (${t.size.toString()} bytes)`);c.push("")}if(o.length>0){c.push(`Large text files (included; consider excludes if unwanted) (${o.length.toString()}):`);for(const t of o){const e=[` - ${t.path}`,`(${t.size.toString()} bytes)`];"number"==typeof t.loc&&e.push(`${t.loc.toString()} LOC`),c.push(e.join(" "))}c.push(""),c.push(`Thresholds: size > ${n.toString()} bytes or LOC > ${3e3.toString()}`)}0===c.length&&c.push("No archive warnings.");const l=c.join("\n")+(c.length?"\n":"");return{textFiles:i,excludedBinaries:a,largeText:o,warningsBody:l}};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{stat as t,readFile as e,open as n}from"node:fs/promises";import{resolve as r}from"node:path";const s=1048576,o=async(o,i)=>{const a=[],c=[],h=[];await Promise.all(i.map(async i=>{const l=i.replace(/\\/g,"/");const u=r(o,i);let p=0;try{p=(await t(u)).size}catch{return}let f,g=!1;try{g=await(async t=>{try{const e=await n(t,"r");try{const t=Buffer.allocUnsafe(8192),{bytesRead:n}=await e.read(t,0,t.length,0);for(let e=0;e<n;e+=1)if(0===t[e])return!0;return!1}finally{await e.close().catch(()=>{})}}catch{return!1}})(u)}catch{g=!1}if(g)return void c.push({path:l,size:p});a.push(l);try{if(p<=s||p<5*s){f=(t=>{const e=t.replace(/\r\n/g,"\n");return 0===e.length?0:e.split("\n").length})(await e(u,"utf8"))}}catch{}(p>s||"number"==typeof f&&f>3e3)&&h.push({path:l,size:p,loc:f})}));const l=[];if(c.length>0){l.push(`Binary files excluded from archive (${c.length.toString()}):`);for(const t of c)l.push(` - ${t.path} (${t.size.toString()} bytes)`);l.push("")}if(h.length>0){l.push(`Large text files (included; consider excludes if unwanted) (${h.length.toString()}):`);for(const t of h){const e=[` - ${t.path}`,`(${t.size.toString()} bytes)`];"number"==typeof t.loc&&e.push(`${t.loc.toString()} LOC`),l.push(e.join(" "))}l.push(""),l.push(`Thresholds: size > ${s.toString()} bytes or LOC > ${3e3.toString()}`)}0===l.length&&l.push("No archive warnings.");const u=l.join("\n")+(l.length?"\n":"");return{textFiles:a,excludedBinaries:c,largeText:h,warningsBody:u}};export{o as classifyForArchive};
|