@causyne/agent 0.0.0-stage → 1.10.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/LICENSE +102 -0
- package/README.md +31 -2
- package/SECURITY.md +24 -0
- package/bin/causyne.js +13 -0
- package/docs/ARCHITECTURE.md +63 -0
- package/docs/PROVENANCE.md +29 -0
- package/docs/SECURITY_REVIEW.md +89 -0
- package/docs/THIRD_PARTY_NOTICES.md +49 -0
- package/native-skills/ai-engineering/context-window-management/SKILL.md +43 -0
- package/native-skills/ai-engineering/llm-evaluation/SKILL.md +46 -0
- package/native-skills/ai-engineering/model-cost-and-latency/SKILL.md +46 -0
- package/native-skills/ai-engineering/prompt-construction/SKILL.md +42 -0
- package/native-skills/ai-engineering/retrieval-augmented-generation/SKILL.md +42 -0
- package/native-skills/ai-engineering/structured-output-and-schemas/SKILL.md +45 -0
- package/native-skills/ai-engineering/tool-calling-agents/SKILL.md +43 -0
- package/native-skills/android/app-performance-profiling/SKILL.md +42 -0
- package/native-skills/android/background-work-scheduling/SKILL.md +47 -0
- package/native-skills/android/compose-state-and-recomposition/SKILL.md +43 -0
- package/native-skills/android/gradle-build-configuration/SKILL.md +41 -0
- package/native-skills/android/lifecycle-and-leaks/SKILL.md +46 -0
- package/native-skills/android/play-store-release/SKILL.md +43 -0
- package/native-skills/android/room-and-persistence/SKILL.md +40 -0
- package/native-skills/backend/authentication-and-sessions/SKILL.md +45 -0
- package/native-skills/backend/background-jobs-and-queues/SKILL.md +42 -0
- package/native-skills/backend/caching-strategy/SKILL.md +44 -0
- package/native-skills/backend/graceful-shutdown/SKILL.md +42 -0
- package/native-skills/backend/rate-limiting-and-quotas/SKILL.md +40 -0
- package/native-skills/backend/rest-api-design/SKILL.md +40 -0
- package/native-skills/backend/webhook-delivery-and-receipt/SKILL.md +43 -0
- package/native-skills/cloud/cost-optimisation/SKILL.md +46 -0
- package/native-skills/cloud/iam-least-privilege/SKILL.md +43 -0
- package/native-skills/cloud/infrastructure-as-code/SKILL.md +43 -0
- package/native-skills/cloud/multi-region-and-failover/SKILL.md +43 -0
- package/native-skills/cloud/serverless-patterns/SKILL.md +47 -0
- package/native-skills/data/data-quality-monitoring/SKILL.md +51 -0
- package/native-skills/data/etl-pipeline-reliability/SKILL.md +43 -0
- package/native-skills/data/exploratory-analysis/SKILL.md +43 -0
- package/native-skills/data/metric-definition/SKILL.md +42 -0
- package/native-skills/data/notebook-to-production/SKILL.md +43 -0
- package/native-skills/database/backup-and-recovery/SKILL.md +43 -0
- package/native-skills/database/connection-pooling/SKILL.md +42 -0
- package/native-skills/database/data-integrity-and-constraints/SKILL.md +42 -0
- package/native-skills/database/query-optimisation/SKILL.md +38 -0
- package/native-skills/database/safe-migrations/SKILL.md +47 -0
- package/native-skills/database/schema-design/SKILL.md +38 -0
- package/native-skills/database/transactions-and-isolation/SKILL.md +41 -0
- package/native-skills/design/colour-system-construction/SKILL.md +38 -0
- package/native-skills/design/design-direction-brief/SKILL.md +41 -0
- package/native-skills/design/motion-and-transitions/SKILL.md +38 -0
- package/native-skills/design/responsive-strategy/SKILL.md +39 -0
- package/native-skills/design/spacing-and-rhythm/SKILL.md +38 -0
- package/native-skills/design/type-scale-and-hierarchy/SKILL.md +39 -0
- package/native-skills/design/visual-qa-loop/SKILL.md +42 -0
- package/native-skills/devops/docker-multi-stage-builds/SKILL.md +60 -0
- package/native-skills/devops/github-actions-ci/SKILL.md +60 -0
- package/native-skills/devops/incident-triage/SKILL.md +38 -0
- package/native-skills/devops/kubernetes-deployment-hardening/SKILL.md +64 -0
- package/native-skills/devops/observability-baseline/SKILL.md +38 -0
- package/native-skills/devops/secret-management/SKILL.md +40 -0
- package/native-skills/devops/terraform-state-and-modules/SKILL.md +36 -0
- package/native-skills/devops/zero-downtime-deploys/SKILL.md +40 -0
- package/native-skills/git/bisect-regression-hunt/SKILL.md +43 -0
- package/native-skills/git/branch-strategy/SKILL.md +39 -0
- package/native-skills/git/commit-hygiene/SKILL.md +41 -0
- package/native-skills/git/history-recovery/SKILL.md +44 -0
- package/native-skills/git/large-repository-surgery/SKILL.md +46 -0
- package/native-skills/git/merge-conflict-resolution/SKILL.md +42 -0
- package/native-skills/media/cinematic-3d-shot/SKILL.md +104 -0
- package/native-skills/mobile/app-startup-optimisation/SKILL.md +41 -0
- package/native-skills/mobile/cross-platform-tradeoffs/SKILL.md +42 -0
- package/native-skills/mobile/deep-linking/SKILL.md +39 -0
- package/native-skills/mobile/mobile-storage-security/SKILL.md +45 -0
- package/native-skills/mobile/offline-first-sync/SKILL.md +42 -0
- package/native-skills/mobile/push-notifications/SKILL.md +38 -0
- package/native-skills/performance/algorithmic-complexity/SKILL.md +43 -0
- package/native-skills/performance/concurrency-and-parallelism/SKILL.md +42 -0
- package/native-skills/performance/load-testing/SKILL.md +42 -0
- package/native-skills/performance/memory-and-leak-hunting/SKILL.md +41 -0
- package/native-skills/performance/network-and-payload-efficiency/SKILL.md +42 -0
- package/native-skills/performance/profiling-methodology/SKILL.md +46 -0
- package/native-skills/python/async-correctness/SKILL.md +40 -0
- package/native-skills/python/cli-tool-construction/SKILL.md +44 -0
- package/native-skills/python/data-processing-pipelines/SKILL.md +38 -0
- package/native-skills/python/environment-isolation/SKILL.md +41 -0
- package/native-skills/python/packaging-and-distribution/SKILL.md +56 -0
- package/native-skills/python/pytest-suite-design/SKILL.md +39 -0
- package/native-skills/python/type-hints-and-static-checking/SKILL.md +42 -0
- package/native-skills/security/authorization-model/SKILL.md +42 -0
- package/native-skills/security/crypto-usage/SKILL.md +48 -0
- package/native-skills/security/dependency-supply-chain/SKILL.md +42 -0
- package/native-skills/security/input-validation-and-injection/SKILL.md +44 -0
- package/native-skills/security/secure-file-uploads/SKILL.md +46 -0
- package/native-skills/security/security-headers-and-csp/SKILL.md +44 -0
- package/native-skills/security/threat-modelling/SKILL.md +46 -0
- package/native-skills/testing/end-to-end-test-stability/SKILL.md +42 -0
- package/native-skills/testing/property-based-testing/SKILL.md +46 -0
- package/native-skills/testing/regression-test-from-a-bug/SKILL.md +41 -0
- package/native-skills/testing/snapshot-and-visual-regression/SKILL.md +42 -0
- package/native-skills/testing/test-doubles-and-mocking/SKILL.md +43 -0
- package/native-skills/testing/test-strategy-and-pyramid/SKILL.md +39 -0
- package/native-skills/testing/writing-good-assertions/SKILL.md +42 -0
- package/native-skills/web/accessible-components/SKILL.md +45 -0
- package/native-skills/web/api-client-resilience/SKILL.md +39 -0
- package/native-skills/web/bundle-size-reduction/SKILL.md +38 -0
- package/native-skills/web/core-web-vitals/SKILL.md +40 -0
- package/native-skills/web/css-layout-systems/SKILL.md +41 -0
- package/native-skills/web/form-validation-ux/SKILL.md +39 -0
- package/native-skills/web/react-state-architecture/SKILL.md +41 -0
- package/native-skills/web/ssr-hydration-correctness/SKILL.md +45 -0
- package/package.json +68 -4
- package/src/agentLoop.js +2458 -0
- package/src/appChannel.js +109 -0
- package/src/approvalGrants.js +66 -0
- package/src/auditLog.js +52 -0
- package/src/autoUpdate.js +12 -0
- package/src/capabilities.js +36 -0
- package/src/checkpoints.js +1199 -0
- package/src/cliMode.js +638 -0
- package/src/commands.js +805 -0
- package/src/compiledSkills.js +540 -0
- package/src/config.js +130 -0
- package/src/contextManager.js +498 -0
- package/src/cortex/autoCondenser.js +192 -0
- package/src/cortex/provisioner.js +27 -0
- package/src/cortex/vectorDb.js +447 -0
- package/src/designPalettes.js +99 -0
- package/src/devMode.js +6 -0
- package/src/embodimentSession.js +180 -0
- package/src/entrypoint.js +194 -0
- package/src/execSafe.js +21 -0
- package/src/gitSnapshot.js +378 -0
- package/src/mcp/jsonRpc.js +165 -0
- package/src/mcp/mcpClient.js +136 -0
- package/src/mcp/mcpRegistry.js +207 -0
- package/src/memory.js +62 -0
- package/src/memoryManager.js +124 -0
- package/src/modelCatalogue.js +132 -0
- package/src/modelIds.js +42 -0
- package/src/modelRouter.js +145 -0
- package/src/outputStore.js +246 -0
- package/src/perception.js +124 -0
- package/src/planCache.js +437 -0
- package/src/procSignal.js +32 -0
- package/src/providers/anthropic.js +408 -0
- package/src/providers/base.js +328 -0
- package/src/providers/dashscope-byok.js +86 -0
- package/src/providers/deepseek.js +80 -0
- package/src/providers/factory.js +37 -0
- package/src/providers/gemini.js +346 -0
- package/src/providers/moonshot.js +73 -0
- package/src/providers/muse.js +169 -0
- package/src/providers/ollama.js +104 -0
- package/src/providers/openai-compatible.js +84 -0
- package/src/providers/openai.js +20 -0
- package/src/providers/qwen-byok.js +76 -0
- package/src/providers/xai.js +73 -0
- package/src/provisioning/capabilityConsent.js +24 -0
- package/src/provisioning/capabilityProvisioner.js +271 -0
- package/src/provisioning/capabilityTools.js +29 -0
- package/src/reporting.js +373 -0
- package/src/sandbox.js +529 -0
- package/src/sessionStore.js +279 -0
- package/src/skillsManager.js +288 -0
- package/src/slopDetector.js +307 -0
- package/src/taskBuffer.js +45 -0
- package/src/taskShape.js +241 -0
- package/src/textDiff.js +150 -0
- package/src/tokenTracker.js +560 -0
- package/src/tool-scripts/ax_snapshot.applescript +39 -0
- package/src/tool-scripts/ax_snapshot.ps1 +10 -0
- package/src/tool-scripts/desktop_act.applescript +58 -0
- package/src/tool-scripts/resolve_automator.py +119 -0
- package/src/toolPacks.js +524 -0
- package/src/tools/archive.js +63 -0
- package/src/tools/astryxOracle.js +78 -0
- package/src/tools/axSnapshot.js +165 -0
- package/src/tools/blenderAutomator.js +349 -0
- package/src/tools/browserAutomator.js +252 -0
- package/src/tools/checkSystemSpecs.js +64 -0
- package/src/tools/clipboard.js +36 -0
- package/src/tools/codeSearchAst.js +101 -0
- package/src/tools/codeSearcher.js +230 -0
- package/src/tools/codeTools.js +262 -0
- package/src/tools/codebaseSearch.js +75 -0
- package/src/tools/createSkill.js +129 -0
- package/src/tools/deferredMcpSearch.js +246 -0
- package/src/tools/desktopAct.js +208 -0
- package/src/tools/desktopOpen.js +34 -0
- package/src/tools/dynamicLoader.js +44 -0
- package/src/tools/executeProceduralMedia.js +93 -0
- package/src/tools/fsDelete.js +51 -0
- package/src/tools/fsEdit.js +105 -0
- package/src/tools/fsFind.js +128 -0
- package/src/tools/fsList.js +77 -0
- package/src/tools/fsMove.js +57 -0
- package/src/tools/fsRead.js +87 -0
- package/src/tools/fsSearch.js +198 -0
- package/src/tools/fsWrite.js +41 -0
- package/src/tools/gameAiBehaviorTree.js +208 -0
- package/src/tools/gameAnimationRig.js +194 -0
- package/src/tools/gameAssetFetcher.js +372 -0
- package/src/tools/gameAssetHarvester.js +210 -0
- package/src/tools/gameAudioSynth.js +267 -0
- package/src/tools/gameBuilder.js +886 -0
- package/src/tools/gameCanvasAudit.js +101 -0
- package/src/tools/gameCinematicSequencer.js +151 -0
- package/src/tools/gameDataForge.js +124 -0
- package/src/tools/gameDialogueTreeGen.js +166 -0
- package/src/tools/gameEconomyBalancer.js +161 -0
- package/src/tools/gameEntitySpawner.js +207 -0
- package/src/tools/gameLoreForge.js +153 -0
- package/src/tools/gameQuestArcBuilder.js +152 -0
- package/src/tools/gameSceneBuilder.js +158 -0
- package/src/tools/gameShaderForge.js +181 -0
- package/src/tools/gameTilemapGenerator.js +164 -0
- package/src/tools/gameUiHudBuilder.js +292 -0
- package/src/tools/gameVfxEmitterGen.js +108 -0
- package/src/tools/gameWebRuntimeInspector.js +91 -0
- package/src/tools/generateMediaViaApi.js +358 -0
- package/src/tools/gitExec.js +54 -0
- package/src/tools/godotAutomator.js +437 -0
- package/src/tools/manageLocalAiDependencies.js +220 -0
- package/src/tools/memoryWrite.js +99 -0
- package/src/tools/multiEdit.js +107 -0
- package/src/tools/palmierAutomator.js +104 -0
- package/src/tools/pdfReader.js +112 -0
- package/src/tools/persistentShell.js +148 -0
- package/src/tools/printer.js +316 -0
- package/src/tools/procTerm.js +91 -0
- package/src/tools/processList.js +52 -0
- package/src/tools/readNativeSkill.js +39 -0
- package/src/tools/registry.js +277 -0
- package/src/tools/resolveAutomator.js +102 -0
- package/src/tools/screenshot.js +75 -0
- package/src/tools/subagentOrchestrator.js +305 -0
- package/src/tools/sysRun.js +125 -0
- package/src/tools/todoWrite.js +75 -0
- package/src/tools/toolDispatch.js +127 -0
- package/src/tools/toolForge.js +124 -0
- package/src/tools/updatePlan.js +88 -0
- package/src/tools/viewImage.js +82 -0
- package/src/tools/visionInspector.js +154 -0
- package/src/tools/webFetch.js +74 -0
- package/src/tools/webSearch.js +82 -0
- package/src/tui/ask.js +164 -0
- package/src/tui/banner.js +158 -0
- package/src/tui/block.js +152 -0
- package/src/tui/chatRenderer.js +953 -0
- package/src/tui/completion.js +424 -0
- package/src/tui/dialogs.js +606 -0
- package/src/tui/diff.js +296 -0
- package/src/tui/history.js +135 -0
- package/src/tui/home.js +217 -0
- package/src/tui/invocation.js +105 -0
- package/src/tui/keys.js +443 -0
- package/src/tui/lineEditor.js +256 -0
- package/src/tui/overlay.js +256 -0
- package/src/tui/prompt.js +1258 -0
- package/src/tui/selectList.js +335 -0
- package/src/tui/stage.js +330 -0
- package/src/tui/stageSurface.js +609 -0
- package/src/tui/statusLine.js +254 -0
- package/src/tui/text.js +345 -0
- package/src/tui/theme.js +393 -0
- package/src/tui/toolDisplay.js +176 -0
- package/src/tui/transcript.js +235 -0
- package/src/tui/viewport.js +337 -0
- package/src/uncertainty.js +271 -0
- package/src/userSkills.js +265 -0
- package/src/utils/cli_ui.js +0 -0
- package/src/utils/inquirer.js +12 -0
- package/src/utils/paths.js +37 -0
- package/src/version.js +38 -0
- package/src/vfeTracker.js +220 -0
package/src/textDiff.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// A unified diff, in pure JavaScript.
|
|
2
|
+
//
|
|
3
|
+
// The git backend gets patches from git itself. This exists so the NATIVE
|
|
4
|
+
// backend — the fallback for a machine with no git, or a workspace that is not
|
|
5
|
+
// a repository — can answer the same question. Without it, REVIEW would show
|
|
6
|
+
// line counts on one machine and real changes on another, which is the kind of
|
|
7
|
+
// inconsistency that makes a feature feel broken rather than degraded.
|
|
8
|
+
//
|
|
9
|
+
// No dependency: this is a standard LCS over lines, which is what `diff -u`
|
|
10
|
+
// computes. Bounded, because a checkpoint diff is a UI affordance and must
|
|
11
|
+
// never become the reason a request times out.
|
|
12
|
+
|
|
13
|
+
/** Above this many lines on either side, fall back to counts without a patch. */
|
|
14
|
+
const MAX_DIFF_LINES = 4000;
|
|
15
|
+
|
|
16
|
+
/** Context lines around each change, matching `diff -u` and git's default. */
|
|
17
|
+
const CONTEXT = 3;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Longest common subsequence over two line arrays.
|
|
21
|
+
*
|
|
22
|
+
* Classic dynamic programming. O(n*m) in time and memory, which is why
|
|
23
|
+
* MAX_DIFF_LINES exists — at the cap this is 16M cells, still well under a
|
|
24
|
+
* second, and anything larger is not something a human reads in a dialog.
|
|
25
|
+
*/
|
|
26
|
+
function lcsTable(a, b) {
|
|
27
|
+
const table = [];
|
|
28
|
+
for (let i = 0; i <= a.length; i++) table.push(new Uint32Array(b.length + 1));
|
|
29
|
+
for (let i = a.length - 1; i >= 0; i--) {
|
|
30
|
+
for (let j = b.length - 1; j >= 0; j--) {
|
|
31
|
+
table[i][j] = a[i] === b[j]
|
|
32
|
+
? table[i + 1][j + 1] + 1
|
|
33
|
+
: Math.max(table[i + 1][j], table[i][j + 1]);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return table;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Walk the table into a flat edit script: ' ' keep, '-' remove, '+' add. */
|
|
40
|
+
function editScript(a, b) {
|
|
41
|
+
const table = lcsTable(a, b);
|
|
42
|
+
const ops = [];
|
|
43
|
+
let i = 0;
|
|
44
|
+
let j = 0;
|
|
45
|
+
while (i < a.length && j < b.length) {
|
|
46
|
+
if (a[i] === b[j]) { ops.push([' ', a[i]]); i++; j++; }
|
|
47
|
+
else if (table[i + 1][j] >= table[i][j + 1]) { ops.push(['-', a[i]]); i++; }
|
|
48
|
+
else { ops.push(['+', b[j]]); j++; }
|
|
49
|
+
}
|
|
50
|
+
while (i < a.length) ops.push(['-', a[i++]]);
|
|
51
|
+
while (j < b.length) ops.push(['+', b[j++]]);
|
|
52
|
+
return ops;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function splitLines(text) {
|
|
56
|
+
if (text === '') return [];
|
|
57
|
+
return text.replace(/\n$/, '').split('\n');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A unified diff of `before` → `after`.
|
|
62
|
+
*
|
|
63
|
+
* @returns {{patch: string, additions: number, deletions: number, truncated: boolean}}
|
|
64
|
+
*/
|
|
65
|
+
export function unifiedDiff(before, after, pathLabel = 'file') {
|
|
66
|
+
const a = splitLines(before);
|
|
67
|
+
const b = splitLines(after);
|
|
68
|
+
|
|
69
|
+
if (a.length > MAX_DIFF_LINES || b.length > MAX_DIFF_LINES) {
|
|
70
|
+
// Counting without the table keeps a huge file cheap: the exact per-line
|
|
71
|
+
// patch is not worth an O(n*m) allocation nobody will read.
|
|
72
|
+
return {
|
|
73
|
+
patch: '',
|
|
74
|
+
additions: b.length,
|
|
75
|
+
deletions: a.length,
|
|
76
|
+
truncated: true
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const ops = editScript(a, b);
|
|
81
|
+
let additions = 0;
|
|
82
|
+
let deletions = 0;
|
|
83
|
+
for (const [kind] of ops) {
|
|
84
|
+
if (kind === '+') additions++;
|
|
85
|
+
else if (kind === '-') deletions++;
|
|
86
|
+
}
|
|
87
|
+
if (additions === 0 && deletions === 0) {
|
|
88
|
+
return { patch: '', additions: 0, deletions: 0, truncated: false };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Group changes into hunks with CONTEXT lines of surrounding text, so the
|
|
92
|
+
// output is readable rather than the whole file with markers.
|
|
93
|
+
const lines = [`--- a/${pathLabel}`, `+++ b/${pathLabel}`];
|
|
94
|
+
let index = 0;
|
|
95
|
+
let oldLine = 1;
|
|
96
|
+
let newLine = 1;
|
|
97
|
+
|
|
98
|
+
while (index < ops.length) {
|
|
99
|
+
if (ops[index][0] === ' ') {
|
|
100
|
+
if (ops[index][0] === ' ') { oldLine++; newLine++; }
|
|
101
|
+
index++;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Walk back for leading context, then forward to the end of the change.
|
|
106
|
+
const start = Math.max(0, index - CONTEXT);
|
|
107
|
+
let end = index;
|
|
108
|
+
let quiet = 0;
|
|
109
|
+
while (end < ops.length && quiet <= CONTEXT * 2) {
|
|
110
|
+
quiet = ops[end][0] === ' ' ? quiet + 1 : 0;
|
|
111
|
+
end++;
|
|
112
|
+
}
|
|
113
|
+
end = Math.min(ops.length, end);
|
|
114
|
+
|
|
115
|
+
let oldStart = oldLine;
|
|
116
|
+
let newStart = newLine;
|
|
117
|
+
for (let k = start; k < index; k++) {
|
|
118
|
+
if (ops[k][0] !== '+') oldStart--;
|
|
119
|
+
if (ops[k][0] !== '-') newStart--;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
let oldCount = 0;
|
|
123
|
+
let newCount = 0;
|
|
124
|
+
const body = [];
|
|
125
|
+
for (let k = start; k < end; k++) {
|
|
126
|
+
const [kind, text] = ops[k];
|
|
127
|
+
if (kind !== '+') oldCount++;
|
|
128
|
+
if (kind !== '-') newCount++;
|
|
129
|
+
body.push(`${kind}${text}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
lines.push(`@@ -${Math.max(1, oldStart)},${oldCount} +${Math.max(1, newStart)},${newCount} @@`);
|
|
133
|
+
lines.push(...body);
|
|
134
|
+
|
|
135
|
+
for (let k = index; k < end; k++) {
|
|
136
|
+
if (ops[k][0] !== '+') oldLine++;
|
|
137
|
+
if (ops[k][0] !== '-') newLine++;
|
|
138
|
+
}
|
|
139
|
+
index = end;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return { patch: lines.join('\n'), additions, deletions, truncated: false };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Binary content has no useful line diff — detected the way git detects it. */
|
|
146
|
+
export function looksBinary(buffer) {
|
|
147
|
+
if (!buffer || buffer.length === 0) return false;
|
|
148
|
+
const sample = buffer.subarray(0, Math.min(8000, buffer.length));
|
|
149
|
+
return sample.includes(0);
|
|
150
|
+
}
|