Add analyze.

This commit is contained in:
Vasyl Palamarchuk
2026-09-04 11:35:41 -07:00
parent 25b1a1f395
commit 04034c082f
74 changed files with 1309 additions and 0 deletions
@@ -0,0 +1,18 @@
# API Discovery Status
## Summary
- Discovered API names from knowledge base and manual references: 9
- Placeholder host wrappers defined for SDK scaffolding: 3
- Verification status: mostly unverified
## Recommended next step
Open the installed Multi-PROG Local Script Help and verify each host API before using it in real scripts.
## Evidence sources
- 01_Knowledge_Base/API_DISCOVERY_WORKSHEET.md
- 01_Knowledge_Base/README.md
- 13_Research_Expansion/DISCOVERED_APIS.md
- 03_Script_Starter_Kit/templates/multiprog_safe_template.mjs
+16
View File
@@ -0,0 +1,16 @@
# Common Checksums
## Algorithms extracted from the repository
- CRC8
- CRC16 (CCITT-False, Modbus)
- CRC32
- CRC64
- Adler32
- SHA-1
- SHA-256
- MD5
## Use pattern
Use them for offline validation and known vector comparison.
+10
View File
@@ -0,0 +1,10 @@
# Common Errors
## Typical issues seen in this kit
- Invalid buffer length
- Offset out of range
- Hex parsing errors
- BCD conversion errors
- Missing host API verification
- Ensure write operations are allow-listed
+9
View File
@@ -0,0 +1,9 @@
# Common Fixes
## Repair patterns
- Add explicit validation before use
- Wrap host API calls in thin adapter functions
- Replace brittle assumptions with clear error handling
- Split buffer logic from UI logic
- Keep outputs deterministic and reviewable
+14
View File
@@ -0,0 +1,14 @@
# Common Functions
## Found across the repository
- Buffer validation helpers
- Byte-range slicing helpers
- Hex conversion helpers
- Diff generation helpers
- Allow-list write guards
- CRC/hash helpers
## Notes
These are portable building blocks for scripts and SDK templates.
+11
View File
@@ -0,0 +1,11 @@
# Common Patterns
## Repeated design patterns
- Intake validation
- Read-only inspection
- Consistency verification
- Allow-listed change scope
- Backup naming
- Completion audit
- Redaction and report generation
@@ -0,0 +1,9 @@
# Common Utilities
## Common utility modules
- Binary helpers
- BCD and ASCII encoding helpers
- Hex conversion helpers
- Buffer diffing helpers
- Synthetic test vectors
@@ -0,0 +1,6 @@
Area,Multi-PROG support,Generic JS support,Node.js support,Browser support,Dependencies,Risk level
Buffer helpers,Partial,Yes,Yes,Yes,None,Low
CRC/hash helpers,Partial,Yes,Yes,Yes,None,Low
Binary parsing,Partial,Yes,Yes,Yes,None,Low
Host wrappers,Needs verification,Yes,Yes,Yes,None,Medium
UI button examples,Needs verification,No,No,No,None,Medium
1 Area Multi-PROG support Generic JS support Node.js support Browser support Dependencies Risk level
2 Buffer helpers Partial Yes Yes Yes None Low
3 CRC/hash helpers Partial Yes Yes Yes None Low
4 Binary parsing Partial Yes Yes Yes None Low
5 Host wrappers Needs verification Yes Yes Yes None Medium
6 UI button examples Needs verification No No No None Medium
@@ -0,0 +1,13 @@
# Compatibility Matrix
| Area | Multi-PROG support | Generic JS support | Node.js support | Browser support | Dependencies | Risk level |
|---|---|---|---|---|---|---|
| Buffer helpers | Partial | Yes | Yes | Yes | None | Low |
| CRC/hash helpers | Partial | Yes | Yes | Yes | None | Low |
| Binary parsing | Partial | Yes | Yes | Yes | None | Low |
| Host wrappers | Needs verification | Yes | Yes | Yes | None | Medium |
| UI button examples | Needs verification | No | No | No | None | Medium |
## Notes
The repository is strongest in dependency-free, offline-compatible logic. Host-specific UI integration still needs local verification in Multi-PROG Help.
@@ -0,0 +1,13 @@
Name,Category,Source,Verified status,Parameters,Return value,Example usage,Confidence
AddFunctionButton,UI function,Manual/tutorial references,Unverified,"label, callback","None","AddFunctionButton(\"Inspect\", inspectBuffer)",Medium
ReadData,Read operation,Manual mirror,Unverified,"buffer/device selector","Byte data","ReadData(...)",Medium
WriteData,Write operation,Manual mirror,Unverified,"buffer/device selector, bytes","Success/failure","WriteData(...)",Medium
GetOpenFileName,File function,Manual mirror,Unverified,"prompt, default path","File path","GetOpenFileName(...)",Medium
GetSaveFileName,File function,Manual mirror,Unverified,"prompt, default path","File path","GetSaveFileName(...)",Medium
ReadFile,File function,Manual mirror,Unverified,"path","Bytes/text","ReadFile(...)",Medium
WriteFile,File function,Manual mirror,Unverified,"path, data","Success/failure","WriteFile(...)",Medium
Hex2Dec,Conversion helper,Community references,Unverified,"hex string","Integer","Hex2Dec(\"1A\")",Medium
areEqual,Comparison helper,Community references,Unverified,"a, b","Boolean","areEqual(bufA, bufB)",Medium
HOST_READ_BUFFER,Placeholder host wrapper,SDK template,Placeholder,"none","Uint8Array","HOST_READ_BUFFER()",Low
HOST_WRITE_BUFFER,Placeholder host wrapper,SDK template,Placeholder,"buffer, offset, bytes","Boolean","HOST_WRITE_BUFFER(buf, 0, patch)",Low
HOST_SHOW_MESSAGE,Placeholder host wrapper,SDK template,Placeholder,"text","None","HOST_SHOW_MESSAGE(\"Done\")",Low
Can't render this file because it contains an unexpected character in line 2 and column 114.
@@ -0,0 +1,40 @@
# Multi-PROG API Reference
This document consolidates the API concepts discovered from the repository knowledge base, collected scripts, and research notes.
## Status note
All host-facing names below are marked as unverified placeholders until confirmed in the installed Multi-PROG Local Script Help. Treat these as discovery notes rather than guaranteed runtime APIs.
## Core host-facing concepts
| Name | Category | Source | Verified status | Parameters | Return value | Example usage | Confidence |
|---|---|---|---|---|---|---|---|
| AddFunctionButton | UI function | Manual/tutorial references | Unverified | label, callback | None | `AddFunctionButton("Inspect", inspectBuffer)` | Medium |
| ReadData | Read operation | Manual mirror | Unverified | buffer/device selector | Byte data | `ReadData(...)` | Medium |
| WriteData | Write operation | Manual mirror | Unverified | buffer/device selector, bytes | Success/failure | `WriteData(...)` | Medium |
| GetOpenFileName | File function | Manual mirror | Unverified | prompt, default path | File path | `GetOpenFileName(...)` | Medium |
| GetSaveFileName | File function | Manual mirror | Unverified | prompt, default path | File path | `GetSaveFileName(...)` | Medium |
| ReadFile | File function | Manual mirror | Unverified | path | Bytes/text | `ReadFile(...)` | Medium |
| WriteFile | File function | Manual mirror | Unverified | path, data | Success/failure | `WriteFile(...)` | Medium |
| Hex2Dec | Conversion helper | Community references | Unverified | hex string | Integer | `Hex2Dec("1A")` | Medium |
| areEqual | Comparison helper | Community references | Unverified | a, b | Boolean | `areEqual(bufA, bufB)` | Medium |
| HOST_READ_BUFFER | Placeholder host wrapper | SDK template | Placeholder | none | Uint8Array | `const data = HOST_READ_BUFFER()` | Low |
| HOST_WRITE_BUFFER | Placeholder host wrapper | SDK template | Placeholder | buffer, offset, bytes | Boolean | `HOST_WRITE_BUFFER(buf, 0, patch)` | Low |
| HOST_SHOW_MESSAGE | Placeholder host wrapper | SDK template | Placeholder | text | None | `HOST_SHOW_MESSAGE("Done")` | Low |
## Common script operations
- Read-only inspection
- Buffer cloning and validation
- Allow-listed patching
- CRC/hash verification
- Redaction and audit logging
- Backup naming and change-scope guarding
## Verification checklist
1. Open Multi-PROG Local Script Help.
2. Confirm the exact API name and signature.
3. Replace placeholders only after verification.
4. Keep the host layer isolated from business logic.
@@ -0,0 +1,21 @@
# Multi-PROG Built-in Functions
## Generic JavaScript helpers used in this kit
- `Uint8Array` buffer handling
- `TextEncoder` / `TextDecoder`
- `Array.from` and `slice`
- CRC and hash helpers
- Hex/BCD/ASCII conversion helpers
- Diff and allow-list helpers
## Safe utility patterns
- `requireBytes()`
- `assertRange()`
- `cloneBytes()`
- `sliceBytes()`
- `diffRanges()`
- `allowListedWrite()`
These helpers are portable and usable when adapting scripts for Multi-PROG-compatible hosts.
@@ -0,0 +1,22 @@
# Multi-PROG Host Functions
## UI and host integration
- AddFunctionButton — register a script action in the host UI.
- HOST_SHOW_MESSAGE — placeholder wrapper for user messaging.
- HOST_SHOW_DIALOG — placeholder wrapper for confirmation or prompt dialogs.
## Buffer and memory access
- HOST_READ_BUFFER — placeholder wrapper for reading the current buffer.
- HOST_WRITE_BUFFER — placeholder wrapper for writing a buffer range.
- HOST_READ_BYTES — placeholder wrapper for reading a specific byte range.
## File support
- HOST_OPEN_FILE — placeholder wrapper for file selection.
- HOST_SAVE_FILE — placeholder wrapper for file save.
## Verification rule
Replace placeholders only with verified Multi-PROG Help API names from the installed version.
@@ -0,0 +1,17 @@
# Script Architectures
## Common architecture pattern
1. Intake and authorization validation
2. Read-only inspection
3. Buffer validation and consistency checks
4. Optional allow-listed modification
5. Redaction and reporting
6. Backup naming and audit completion
## Architectural concerns
- Keep business logic separate from host wrappers.
- Prefer pure functions for validation and reporting.
- Make writes explicit and allow-listed.
- Preserve immutable originals and generate new outputs.
@@ -0,0 +1,21 @@
# Script Components
## Reusable components
- Header metadata block
- Validation helpers
- Buffer inspection helpers
- Logging and audit helpers
- Diff/report generators
- Backup naming policies
- Redaction helpers
- Test hooks
## Suggested module layout
- `metadata` — version, purpose, author
- `validate` — checks and guard clauses
- `inspect` — read-only analysis
- `report` — text or JSON reporting
- `write` — explicit, allow-listed writes
- `test` — offline self-tests
@@ -0,0 +1,18 @@
# Script Design Guide
## Design principles
- Use dependency-free helper functions.
- Keep the host API layer thin and isolated.
- Prefer synthetic test data.
- Validate before any write.
- Always preserve originals and produce new output files.
## Recommended flow
1. Validate inputs.
2. Inspect the current state.
3. Generate a report.
4. Guard writes with allow-lists.
5. Save under a new name.
6. Record validation results.
@@ -0,0 +1,10 @@
# Script Feature Matrix
| Script family | Buffer handling | CRC/hash | Validation | Reporting | Host UI | Risk |
|---|---|---|---|---|---|---|
| Read-only | Yes | Optional | Yes | Yes | Optional | Low |
| EEPROM | Yes | Optional | Yes | Yes | Optional | Medium |
| Flash | Yes | Optional | Yes | Yes | Optional | Medium |
| Validator | Yes | Optional | Yes | Optional | No | Low |
| Reporting | Yes | Optional | Optional | Yes | No | Low |
| Binary tool | Yes | Optional | Yes | Optional | No | Low |
+38
View File
@@ -0,0 +1,38 @@
# Script Patterns
## Classified patterns in the repository
### GUI scripts
- Case intake validators
- Service completion audits
- Inventory reconciliation helpers
### Checksum scripts
- CRC16, CRC32, Adler32 examples
- Hashing helpers
### EEPROM scripts
- Read-consistency and backup-naming helpers for memory-like data workflows
### Flash scripts
- Allow-listed change-scope guards and patch demos
### Validation scripts
- Double-read verification
- Buffer-length validation
- Part-number cross-checks
### Binary utilities
- Hex/BCD/ASCII conversion helpers
- Buffer inspection and diffing utilities
### Reporting scripts
- Redacted security report scripts
- Audit summaries
### Inventory scripts
- Key inventory reconciliation
- Job-record validation
### File processing scripts
- File selection, reading, and write safeguards
@@ -0,0 +1,15 @@
# 3C0909605F
## Review note
This item was cataloged as an unclassified reference candidate and moved into the review workflow as documentation-only material.
## Category
- Unclassified reference artifact
## Status
- Reviewed
- Restricted to internal documentation and analysis
- Not promoted to executable guidance
@@ -0,0 +1,26 @@
# 3C0909605F — decompiled-style note
## File identity
- Original path: 17_MultiPROG_SDK/reference/04_Unclassified_Reference/3C0909605F.mjs
- Observed size: 4234 bytes
- Content type: binary blob; not valid JavaScript source
## Byte-level observations
- Header bytes begin with `56 31 31 32 B0 01 00 00 68 ...`
- The payload is opaque and does not contain readable text markers or structured JavaScript syntax.
- The data appears to be a compact binary payload with no obvious embedded labels, comments, or ASCII strings.
## Likely interpretation
This artifact is best treated as an opaque binary reference sample rather than a decompilable script. It may represent:
- a serialized data block,
- a firmware or module image fragment,
- an encoded payload, or
- a binary object with an internal format not recoverable from the bytes alone.
## Safe handling note
This note is documentation-only and does not provide operational instructions or a method to repurpose the artifact.
@@ -0,0 +1,15 @@
# Bosch_EDC16C36_Virgin_ISK
## Review note
This item was reviewed as a high-risk reference candidate and retained only as a restricted analysis artifact.
## Category
- Security-related reference artifact
## Status
- Reviewed
- Restricted to governance and analysis context
- Not promoted to executable guidance
@@ -0,0 +1,15 @@
# Dash_v4_95640_AVTO_Red_Write
## Review note
This item was reviewed as a sensitive workflow reference and documented only for classification purposes.
## Category
- Module-rewrite or repair workflow reference
## Status
- Reviewed
- Restricted to internal documentation and analysis
- Not promoted to executable guidance
@@ -0,0 +1,15 @@
# IMMO_9S12DT256_V4-Red_Write_KM
## Review note
This item was reviewed as a high-risk, security-sensitive reference and retained only as structured analysis material.
## Category
- Immobilizer or mileage-related reference artifact
## Status
- Reviewed
- Restricted to internal documentation and governance review
- Not promoted to executable guidance
@@ -0,0 +1,12 @@
# Unsorted Processing Summary
## Goal
Catalog the items in [20_Unsorted](../../20_Unsorted/README.md) into a reviewable, documentation-oriented workflow without promoting them into executable misuse guidance.
## Result
- Added this review directory under the research expansion area.
- Created per-item review notes.
- Linked the review set to the SDK documentation and template families.
- Kept the actual source files in the unsorted area for further review.
@@ -0,0 +1,21 @@
# Unsorted Review
This working folder contains reviewed summaries for the items currently stored in [20_Unsorted](../../20_Unsorted/README.md).
## Review outcome
All entries below were reviewed as restricted references only. They were not promoted to executable script templates or production workflows.
## Items cataloged
- 3C0909605F
- Bosch_EDC16C36_Virgin_ISK
- Dash_v4_95640_AVTO_Red_Write
- IMMO_9S12DT256_V4-Red_Write_KM
- Tesla_Delphi_Bosch_SRS_CrashData
## Disposition
- Kept as documentation-only review material
- Mapped to generic workflow categories
- Linked to the SDK templates for future safe documentation examples
@@ -0,0 +1,15 @@
# Tesla_Delphi_Bosch_SRS_CrashData
## Review note
This item was reviewed as a crash-data or SRS-related reference artifact and retained for analysis only.
## Category
- Crash-data or SRS-related reference artifact
## Status
- Reviewed
- Restricted to internal documentation and governance review
- Not promoted to executable guidance
+26
View File
@@ -0,0 +1,26 @@
# Multi-PROG Test Guide
## Test areas
- Buffers
- CRC and hashes
- Binary parsing
- BCD conversion
- Pattern matching
- Diff engine
- Validation helpers
- Reporting helpers
## Suggested test runner
Use Node.js with small synthetic fixtures and compare expected values.
## Example
```bash
node 16_Tests/MultiPROG/test_buffer_utils.mjs
```
## Notes
Keep tests offline and synthetic. Do not use real vehicle data.
+10
View File
@@ -0,0 +1,10 @@
import { strict as assert } from 'node:assert';
import { cloneBytes, diffRanges, bytesToHex } from '../../03_Script_Starter_Kit/binary_utils.mjs';
const sample = new Uint8Array([0x01, 0x02, 0x03, 0x04]);
const clone = cloneBytes(sample);
assert.deepStrictEqual(clone, sample);
assert.strictEqual(bytesToHex(sample), '01 02 03 04');
assert.deepStrictEqual(diffRanges(sample, clone), []);
console.log('buffer utils tests passed');
+25
View File
@@ -0,0 +1,25 @@
# Multi-PROG SDK
This SDK provides a lightweight development framework for authoring Multi-PROG-compatible scripts from the existing repository materials.
## Warning
Replace all placeholder host APIs with verified Multi-PROG Help API names for the target installation.
## Structure
- docs/ — reference documentation
- templates/ — script starters
- examples/ — example projects
- utilities/ — helper modules
- tests/ — offline tests
- schemas/ — metadata and manifest examples
- reference/ — promoted review material and categorized reference assets
## Included assets
- Placeholder-safe templates for readonly, EEPROM, flash, validation, reporting, binary tools, checksum workflows, inventory workflows, buffer comparison, merge, and byte-swap transformations
- Offline utility functions for buffers, checksums, and binary parsing
- Test scaffolding that can run under Node.js or a generic JS host
- Review notes for unsorted materials in [13_Research_Expansion/Unsorted_Review/README.md](../13_Research_Expansion/Unsorted_Review/README.md)
- Promoted reference categories under [reference/README.md](reference/README.md)
@@ -0,0 +1,18 @@
/*
* Example project: readonly report script
* Demonstrates the structure expected for SDK-based script authorship.
*/
import { bytesToHex } from '../../03_Script_Starter_Kit/binary_utils.mjs';
function buildExampleReport(buffer) {
if (!(buffer instanceof Uint8Array)) throw new TypeError('Uint8Array required');
return {
length: buffer.length,
hex: bytesToHex(buffer),
preview: buffer.slice(0, 8)
};
}
const sample = new Uint8Array([0x11, 0x22, 0x33, 0x44]);
console.log(JSON.stringify(buildExampleReport(sample), null, 2));
+18
View File
@@ -0,0 +1,18 @@
{
"name": "xhorse-multiprog-sdk",
"version": "0.2.0",
"description": "Offline-friendly development scaffold for Multi-PROG-compatible script authoring",
"type": "module",
"private": true,
"scripts": {
"test": "node --test tests/*.test.mjs"
},
"keywords": [
"multiprog",
"sdk",
"automotive",
"offline",
"templates"
],
"license": "MIT"
}
+14
View File
@@ -0,0 +1,14 @@
# SDK Reference Index
This folder contains promoted reference categories that were previously held in the unsorted review area.
## Categories
- [01_Security_Reference](01_Security_Reference)
- [02_Module_Rewrite](02_Module_Rewrite)
- [03_Crash_Data_Reference](03_Crash_Data_Reference)
- [04_Unclassified_Reference](04_Unclassified_Reference)
## Notes
The [unsorted](unsorted) folder remains as a placeholder for future review material.
@@ -0,0 +1,16 @@
# Unsorted Placeholder
This folder is kept as a lightweight placeholder for future review material.
## Current state
The previously reviewed content has been moved into the main reference tree:
- [01_Security_Reference](../01_Security_Reference)
- [02_Module_Rewrite](../02_Module_Rewrite)
- [03_Crash_Data_Reference](../03_Crash_Data_Reference)
- [04_Unclassified_Reference](../04_Unclassified_Reference)
## Usage guidance
New items should be reviewed and then moved into the appropriate reference category rather than left here.
@@ -0,0 +1,14 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Multi-PROG Script Metadata",
"type": "object",
"required": ["name", "version", "purpose", "author", "validation"],
"properties": {
"name": { "type": "string" },
"version": { "type": "string" },
"purpose": { "type": "string" },
"author": { "type": "string" },
"validation": { "type": "string" }
},
"additionalProperties": true
}
@@ -0,0 +1,25 @@
/*
* Template: Binary utility tool
* Purpose: parse and transform bytes with synthetic examples.
* Warning: Replace placeholder host APIs with verified Multi-PROG Help API calls.
*/
const SCRIPT_METADATA = {
name: "template_binary_tool",
version: "0.1.0",
purpose: "Binary processing",
author: "Repository contributor",
validation: "Synthetic test data only"
};
function toHex(buffer) {
if (!(buffer instanceof Uint8Array)) throw new TypeError("Uint8Array required");
return Array.from(buffer).map(b => b.toString(16).padStart(2, "0")).join(" ");
}
function main() {
const sample = new Uint8Array([0xDE, 0xAD, 0xBE, 0xEF]);
console.log(toHex(sample));
}
main();
@@ -0,0 +1,29 @@
/*
* Template: byte-swap workflow
* Purpose: reverse byte order for testable transformations.
* Warning: Replace placeholder host APIs with verified Multi-PROG Help API calls.
*/
const SCRIPT_METADATA = {
name: 'template_byteswap_workflow',
version: '0.1.0',
purpose: 'Byte-swap workflow',
author: 'Repository contributor',
validation: 'Synthetic test data only'
};
function byteswap(buffer) {
if (!(buffer instanceof Uint8Array)) throw new TypeError('Uint8Array required');
const swapped = new Uint8Array(buffer.length);
for (let index = 0; index < buffer.length; index += 1) {
swapped[index] = buffer[buffer.length - 1 - index];
}
return swapped;
}
function main() {
const sample = new Uint8Array([0x01, 0x02, 0x03, 0x04]);
console.log(JSON.stringify(Array.from(byteswap(sample))));
}
main();
@@ -0,0 +1,27 @@
/*
* Template: checksum workflow
* Purpose: demonstrate a checksum-oriented validation workflow.
* Warning: Replace placeholder host APIs with verified Multi-PROG Help API calls.
*/
const SCRIPT_METADATA = {
name: 'template_checksum_workflow',
version: '0.1.0',
purpose: 'Checksum validation workflow',
author: 'Repository contributor',
validation: 'Synthetic test data only'
};
function checksumWorkflow(buffer) {
if (!(buffer instanceof Uint8Array)) throw new TypeError('Uint8Array required');
let sum = 0;
for (const byte of buffer) sum += byte;
return { length: buffer.length, checksum: sum & 0xFF };
}
function main() {
const sample = new Uint8Array([0x10, 0x20, 0x30]);
console.log(JSON.stringify(checksumWorkflow(sample)));
}
main();
@@ -0,0 +1,33 @@
/*
* Template: compare workflow
* Purpose: compare two buffers and report differences.
* Warning: Replace placeholder host APIs with verified Multi-PROG Help API calls.
*/
const SCRIPT_METADATA = {
name: 'template_compare_workflow',
version: '0.1.0',
purpose: 'Buffer comparison workflow',
author: 'Repository contributor',
validation: 'Synthetic test data only'
};
function compareBuffers(left, right) {
if (!(left instanceof Uint8Array) || !(right instanceof Uint8Array)) throw new TypeError('Uint8Array required');
const maxLength = Math.max(left.length, right.length);
const differences = [];
for (let index = 0; index < maxLength; index += 1) {
const a = left[index] ?? 0x00;
const b = right[index] ?? 0x00;
if (a !== b) differences.push({ index, left: a, right: b });
}
return { matches: differences.length === 0, differences };
}
function main() {
const left = new Uint8Array([0x10, 0x20, 0x30]);
const right = new Uint8Array([0x10, 0x99, 0x30]);
console.log(JSON.stringify(compareBuffers(left, right)));
}
main();
@@ -0,0 +1,31 @@
/*
* Template: diff-report script
* Purpose: generate a human-readable diff summary.
* Warning: Replace placeholder host APIs with verified Multi-PROG Help API calls.
*/
const SCRIPT_METADATA = {
name: 'template_diff_report',
version: '0.1.0',
purpose: 'Buffer diff reporting',
author: 'Repository contributor',
validation: 'Synthetic test data only'
};
function buildDiffSummary(before, after) {
if (!(before instanceof Uint8Array) || !(after instanceof Uint8Array)) throw new TypeError('Uint8Array required');
const changes = [];
const limit = Math.max(before.length, after.length);
for (let i = 0; i < limit; i++) {
if (before[i] !== after[i]) changes.push({ index: i, before: before[i], after: after[i] });
}
return { changedBytes: changes.length, changes };
}
function main() {
const before = new Uint8Array([0x00, 0x01, 0x02]);
const after = new Uint8Array([0x00, 0x99, 0x02]);
console.log(JSON.stringify(buildDiffSummary(before, after), null, 2));
}
main();
@@ -0,0 +1,31 @@
/*
* Template: EEPROM processing script
* Purpose: demonstrate a read/validate/report workflow for EEPROM-like data.
* Warning: Replace placeholder host APIs with verified Multi-PROG Help API calls.
*/
const SCRIPT_METADATA = {
name: "template_eeprom",
version: "0.1.0",
purpose: "EEPROM-like processing",
author: "Repository contributor",
validation: "Synthetic test data only"
};
function buildReport(buffer) {
if (!(buffer instanceof Uint8Array)) throw new TypeError("Uint8Array required");
return {
length: buffer.length,
checksum: buffer.reduce((sum, byte) => sum + byte, 0)
};
}
function main() {
const sample = new Uint8Array([0x10, 0x20, 0x30, 0x40]);
const report = buildReport(sample);
console.log(JSON.stringify(report));
// HOST_READ_BUFFER();
// HOST_WRITE_BUFFER(sample, 0, sample);
}
main();
@@ -0,0 +1,29 @@
/*
* Template: Flash processing script
* Purpose: demonstrate a flash-like processing workflow.
* Warning: Replace placeholder host APIs with verified Multi-PROG Help API calls.
*/
const SCRIPT_METADATA = {
name: "template_flash",
version: "0.1.0",
purpose: "Flash-like processing",
author: "Repository contributor",
validation: "Synthetic test data only"
};
function inspectFlash(buffer) {
if (!(buffer instanceof Uint8Array)) throw new TypeError("Uint8Array required");
return {
length: buffer.length,
blankBytes: buffer.filter(byte => byte === 0xFF).length
};
}
function main() {
const sample = new Uint8Array([0xFF, 0x01, 0xFF, 0x02]);
console.log(JSON.stringify(inspectFlash(sample)));
// HOST_READ_BUFFER();
}
main();
@@ -0,0 +1,29 @@
/*
* Template: inventory workflow
* Purpose: demonstrate a basic inventory or reconciliation workflow.
* Warning: Replace placeholder host APIs with verified Multi-PROG Help API calls.
*/
const SCRIPT_METADATA = {
name: 'template_inventory_workflow',
version: '0.1.0',
purpose: 'Inventory reconciliation workflow',
author: 'Repository contributor',
validation: 'Synthetic test data only'
};
function inventoryWorkflow(items) {
if (!Array.isArray(items)) throw new TypeError('Expected an array');
return {
itemCount: items.length,
uniqueCount: new Set(items).size,
summary: items.map(item => ({ value: item }))
};
}
function main() {
const sample = ['A', 'B', 'A'];
console.log(JSON.stringify(inventoryWorkflow(sample), null, 2));
}
main();
@@ -0,0 +1,32 @@
/*
* Template: merge workflow
* Purpose: merge byte arrays from multiple sources.
* Warning: Replace placeholder host APIs with verified Multi-PROG Help API calls.
*/
const SCRIPT_METADATA = {
name: 'template_merge_workflow',
version: '0.1.0',
purpose: 'Buffer merge workflow',
author: 'Repository contributor',
validation: 'Synthetic test data only'
};
function mergeBuffers(...parts) {
const totalLength = parts.reduce((sum, part) => sum + part.length, 0);
const merged = new Uint8Array(totalLength);
let offset = 0;
for (const part of parts) {
if (!(part instanceof Uint8Array)) throw new TypeError('Uint8Array required');
merged.set(part, offset);
offset += part.length;
}
return merged;
}
function main() {
const merged = mergeBuffers(new Uint8Array([0x01, 0x02]), new Uint8Array([0x03, 0x04]));
console.log(JSON.stringify(Array.from(merged)));
}
main();
@@ -0,0 +1,28 @@
/*
* Template: patch-guard script
* Purpose: validate a patch plan before any write.
* Warning: Replace placeholder host APIs with verified Multi-PROG Help API calls.
*/
const SCRIPT_METADATA = {
name: 'template_patch_guard',
version: '0.1.0',
purpose: 'Allow-listed patch validation',
author: 'Repository contributor',
validation: 'Synthetic test data only'
};
function validatePatchPlan(offset, patchBytes, allowedRanges) {
if (!Number.isInteger(offset) || offset < 0) throw new RangeError('offset must be a non-negative integer');
if (!(patchBytes instanceof Uint8Array)) throw new TypeError('Uint8Array required');
const allowed = allowedRanges.some(range => offset >= range.start && offset + patchBytes.length - 1 <= range.end);
if (!allowed) throw new Error('Patch falls outside allow-list');
return { ok: true, offset, length: patchBytes.length };
}
function main() {
const plan = validatePatchPlan(16, new Uint8Array([0xAA]), [{ start: 0, end: 31 }]);
console.log(JSON.stringify(plan));
}
main();
@@ -0,0 +1,32 @@
/*
* Template: Read-only script
* Purpose: inspect data without changing the original buffer.
* Warning: Replace placeholder host APIs with verified Multi-PROG Help API calls.
*/
const SCRIPT_METADATA = {
name: "template_readonly",
version: "0.1.0",
purpose: "Read-only inspection",
author: "Repository contributor",
validation: "Synthetic test data only"
};
function log(message) {
console.log(`[${SCRIPT_METADATA.name}] ${message}`);
}
function inspectBuffer(buffer) {
if (!(buffer instanceof Uint8Array)) throw new TypeError("Uint8Array required");
log(`Buffer length: ${buffer.length}`);
return { length: buffer.length, preview: Array.from(buffer.slice(0, 16)).map(b => b.toString(16).padStart(2, "0")).join(" ") };
}
function main() {
const sample = new Uint8Array([0x01, 0x02, 0x03, 0x04]);
const result = inspectBuffer(sample);
log(JSON.stringify(result));
// HOST_SHOW_MESSAGE("Inspection complete")
}
main();
@@ -0,0 +1,28 @@
/*
* Template: Reporting script
* Purpose: build a text or JSON report from buffer data.
* Warning: Replace placeholder host APIs with verified Multi-PROG Help API calls.
*/
const SCRIPT_METADATA = {
name: "template_reporting",
version: "0.1.0",
purpose: "Reporting workflow",
author: "Repository contributor",
validation: "Synthetic test data only"
};
function buildReport(buffer) {
if (!(buffer instanceof Uint8Array)) throw new TypeError("Uint8Array required");
return {
length: buffer.length,
hex: Array.from(buffer).map(b => b.toString(16).padStart(2, "0")).join(" ")
};
}
function main() {
const sample = new Uint8Array([0x01, 0x02, 0x03]);
console.log(JSON.stringify(buildReport(sample)));
}
main();
@@ -0,0 +1,26 @@
/*
* Template: Validation script
* Purpose: validate a buffer and raise clear errors.
* Warning: Replace placeholder host APIs with verified Multi-PROG Help API calls.
*/
const SCRIPT_METADATA = {
name: "template_validator",
version: "0.1.0",
purpose: "Validation workflow",
author: "Repository contributor",
validation: "Synthetic test data only"
};
function validateBuffer(buffer, expectedLength) {
if (!(buffer instanceof Uint8Array)) throw new TypeError("Uint8Array required");
if (buffer.length !== expectedLength) throw new RangeError(`Expected ${expectedLength} bytes but received ${buffer.length}`);
return { ok: true, length: buffer.length };
}
function main() {
const sample = new Uint8Array([0xAA, 0xBB, 0xCC]);
console.log(JSON.stringify(validateBuffer(sample, 3)));
}
main();
@@ -0,0 +1,25 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { cloneBytes, diffRanges, bytesToHex, readU16LE, writeU16LE } from '../../03_Script_Starter_Kit/binary_utils.mjs';
test('cloneBytes preserves data and does not alias', () => {
const source = new Uint8Array([1, 2, 3, 4]);
const clone = cloneBytes(source);
clone[0] = 9;
assert.equal(source[0], 1);
assert.equal(clone[0], 9);
});
test('diffRanges reports changes correctly', () => {
const before = new Uint8Array([0, 1, 2, 3]);
const after = new Uint8Array([0, 9, 2, 3]);
assert.deepEqual(diffRanges(before, after), [{ start: 1, end: 1, length: 1 }]);
});
test('hex and numeric helpers work', () => {
const buffer = new Uint8Array([0x34, 0x12]);
assert.equal(bytesToHex(buffer), '34 12');
const out = new Uint8Array(2);
writeU16LE(out, 0, 0x1234);
assert.equal(readU16LE(out, 0), 0x1234);
});
@@ -0,0 +1,15 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { encodeHex, decodeHex } from '../../09_Collected_JS/encoding/hex.mjs';
import { bcdByteToInt, intToBcdByte } from '../../09_Collected_JS/encoding/bcd.mjs';
test('hex helpers round-trip bytes', () => {
const data = new Uint8Array([0xAA, 0xBB, 0x0F]);
assert.equal(encodeHex(data), 'AABB0F');
assert.deepEqual(Array.from(decodeHex('AABB0F')), [0xAA, 0xBB, 0x0F]);
});
test('BCD helpers convert values correctly', () => {
assert.equal(bcdByteToInt(0x23), 23);
assert.equal(intToBcdByte(23), 0x23);
});
@@ -0,0 +1,40 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { readdirSync, readFileSync } from 'node:fs';
import path from 'node:path';
const templateDir = path.resolve('17_MultiPROG_SDK/templates');
const templates = readdirSync(templateDir).filter(name => name.endsWith('.mjs')).sort();
const expectedTemplates = [
'template_binary_tool.mjs',
'template_byteswap_workflow.mjs',
'template_checksum_workflow.mjs',
'template_compare_workflow.mjs',
'template_diff_report.mjs',
'template_eeprom.mjs',
'template_flash.mjs',
'template_inventory_workflow.mjs',
'template_merge_workflow.mjs',
'template_patch_guard.mjs',
'template_readonly.mjs',
'template_reporting.mjs',
'template_validator.mjs'
];
test('SDK templates catalog contains the expected starter set', () => {
for (const template of expectedTemplates) {
assert.ok(templates.includes(template), `${template} is missing from the template catalog`);
}
});
test('compare, merge, and byte-swap templates include their workflow metadata', () => {
const combined = templates
.filter(name => ['template_compare_workflow.mjs', 'template_merge_workflow.mjs', 'template_byteswap_workflow.mjs'].includes(name))
.map(name => readFileSync(path.join(templateDir, name), 'utf8'))
.join('\n');
assert.ok(combined.includes('Buffer comparison workflow'));
assert.ok(combined.includes('Buffer merge workflow'));
assert.ok(combined.includes('Byte-swap workflow'));
});
@@ -0,0 +1,35 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import path from 'node:path';
const templateDir = path.resolve('17_MultiPROG_SDK/templates');
const checksumTemplate = readFileSync(path.join(templateDir, 'template_checksum_workflow.mjs'), 'utf8');
const inventoryTemplate = readFileSync(path.join(templateDir, 'template_inventory_workflow.mjs'), 'utf8');
const expectedSnippets = [
'template_checksum_workflow',
'Checksum validation workflow',
'template_inventory_workflow',
'Inventory reconciliation workflow'
];
test('checksum workflow template contains expected metadata', () => {
for (const snippet of ['template_checksum_workflow', 'Checksum validation workflow']) {
assert.ok(checksumTemplate.includes(snippet));
}
});
test('inventory workflow template contains expected metadata', () => {
for (const snippet of ['template_inventory_workflow', 'Inventory reconciliation workflow']) {
assert.ok(inventoryTemplate.includes(snippet));
}
});
test('workflow templates are documented in the SDK structure', () => {
const readme = readFileSync(path.resolve('17_MultiPROG_SDK/README.md'), 'utf8');
for (const snippet of expectedSnippets) {
assert.ok(readme.includes(snippet) || readme.includes('templates/'));
}
});
+15
View File
@@ -0,0 +1,15 @@
# Beginner Guide
## What to read first
1. Start with the repository overview in README.md.
2. Review the starter-kit examples in 03_Script_Starter_Kit/examples.
3. Study the binary utility module in 03_Script_Starter_Kit/binary_utils.mjs.
4. Use the templates in 17_MultiPROG_SDK/templates as a starting point.
## Recommended workflow
- Learn the helper functions first.
- Prototype offline with synthetic buffers.
- Validate before writing any host-facing code.
- Replace placeholder APIs only after verifying the installed Multi-PROG Help.
@@ -0,0 +1,14 @@
# Binary Processing Guide
## Core concepts
- Parse bytes into structured values.
- Validate ranges before reading or writing.
- Use hex, ASCII, BCD, and byte-slice helpers.
- Prefer synthetic fixtures for development.
## Repository utilities
- 03_Script_Starter_Kit/binary_utils.mjs
- 09_Collected_JS/binary/struct_reader.mjs
- 09_Collected_JS/binary/dataview_helpers.mjs
+16
View File
@@ -0,0 +1,16 @@
# Checksum Guide
## Common algorithms in this repository
- CRC8
- CRC16
- CRC32
- CRC64
- Adler32
- SHA-1
- SHA-256
- MD5
## Verification approach
Use known test vectors and keep results deterministic.
+15
View File
@@ -0,0 +1,15 @@
# Debugging Guide
## Debugging strategy
1. Reproduce the issue with synthetic data.
2. Isolate the host wrapper layer from pure logic.
3. Log the input, expected range, and result.
4. Compare against known-good fixtures.
## Common issues
- Unexpected buffer length
- Invalid offset or range
- Hash/checksum mismatch
- Missing host API verification
@@ -0,0 +1,9 @@
# Multi-PROG Project Structure
## Suggested layout
- 03_Script_Starter_Kit/ — reusable starter templates and utilities
- 16_Tests/MultiPROG/ — offline tests
- 17_MultiPROG_SDK/ — reusable SDK assets
- 18_Documentation/ — authoring and lifecycle docs
- 13_Research_Expansion/ — API and pattern research
@@ -0,0 +1,10 @@
# Multi-PROG Script Lifecycle
## Lifecycle
1. Research and discover available concepts.
2. Build a safe offline prototype.
3. Validate against synthetic data.
4. Adapt to host APIs only after verification.
5. Test and document the script.
6. Release or archive the script with traceable metadata.
+9
View File
@@ -0,0 +1,9 @@
# Release Process
## Release checklist
- Verify documentation updates.
- Run offline tests.
- Review template coverage.
- Confirm placeholder warnings remain.
- Record version and purpose in metadata.
+16
View File
@@ -0,0 +1,16 @@
# Script Writing Guide
## Writing a new script
1. Choose a template from 17_MultiPROG_SDK/templates.
2. Fill in metadata and purpose.
3. Keep host APIs behind wrappers.
4. Validate all inputs and ranges.
5. Test offline before any Multi-PROG-specific adaptation.
## Good practices
- Prefer pure functions.
- Keep changes explicit and allow-listed.
- Preserve immutable originals.
- Use clear logging and error messages.
@@ -0,0 +1,10 @@
# Prompt: Analyze a Multi-PROG Script
Analyze a script for purpose, structure, dependencies, and risk.
Report:
- What the script does.
- What host APIs it depends on.
- What validation logic is present.
- What risks or missing safeguards exist.
- What test coverage would be appropriate.
@@ -0,0 +1,9 @@
# Prompt: Convert JavaScript to Multi-PROG
Convert a general JavaScript utility into a Multi-PROG-friendly script.
Instructions:
- Preserve the logic but isolate host interactions.
- Replace runtime-specific APIs with placeholders or thin wrappers.
- Confirm there are no public misuse instructions.
- Keep the script compatible with offline testing.
@@ -0,0 +1,10 @@
# Prompt: Create a Multi-PROG Script
Use the repository templates and starter-kit utilities to draft a new Multi-PROG-compatible script.
Instructions:
- Start from a template in 17_MultiPROG_SDK/templates.
- Keep host APIs behind thin wrappers.
- Use synthetic test data.
- Add validation and logging.
- Preserve immutable originals and avoid public operational instructions.
@@ -0,0 +1,10 @@
# Prompt: Debug a Multi-PROG Script
Help debug a Multi-PROG-related script.
Focus on:
- Buffer length issues
- Range validation failures
- CRC/hash mismatches
- Host API wrapper mismatches
- Incomplete logging or error handling
@@ -0,0 +1,9 @@
# Prompt: Refactor a Multi-PROG Script
Refactor a script to improve clarity and maintainability.
Priorities:
- Extract pure logic from host-specific code.
- Improve naming and structure.
- Add validation and self-checks.
- Keep the script dependency-free and testable.
@@ -0,0 +1,10 @@
# Prompt: Review a Multi-PROG Script
Review a script for clarity, safety, structure, and compatibility.
Check:
- Does it isolate host API calls?
- Does it validate input ranges?
- Does it preserve originals?
- Does it use clear logging and error handling?
- Does it avoid public misuse guidance?
+17
View File
@@ -0,0 +1,17 @@
# 20_Unsorted
This folder now serves as a lightweight holding area for newly discovered or pending materials that have not yet been reviewed.
## Current status
The previously reviewed content has been moved out and promoted into the SDK reference tree at [17_MultiPROG_SDK/reference/unsorted/README.md](../17_MultiPROG_SDK/reference/unsorted/README.md).
## Intended use
- Hold newly discovered or unclassified materials
- Track content awaiting analysis
- Keep raw files separate from the main SDK and documentation flow
## Review workflow
Any new items placed here should be reviewed and then moved into the appropriate SDK reference category or documentation location.
+4
View File
@@ -42,6 +42,10 @@ This package delivers three integrated components:
- **[14_Repository_Review/](14_Repository_Review/)** — Inventory scans, problem analysis, validation reports
- **[15_Normalized_Scripts/](15_Normalized_Scripts/)** — Normalized copies of third-party scripts (format improvements, attribution preserved)
- **[16_Tests/](16_Tests/)** — Offline test suites, synthetic fixtures, validation results
- **[17_MultiPROG_SDK/](17_MultiPROG_SDK/)** — Reusable templates, examples, metadata schemas, and offline test scaffolding
- **[18_Documentation/](18_Documentation/)** — Beginner guides, script-writing guides, lifecycle and release documentation
- **[19_AI_Prompts/](19_AI_Prompts/)** — Prompt templates for script creation, review, debugging, and refactoring
- **[20_Unsorted/](20_Unsorted/)** — Newly discovered or unclassified materials pending review and integration
- **[tools/](tools/)** — Repository management scripts (inventory generation, problem detection, manifest building, etc.)
- **[99_Quarantine/](99_Quarantine/)** — Suspicious, malformed, or untrusted files (quarantined with metadata and source mapping)
+22
View File
@@ -0,0 +1,22 @@
# Repository Maturity Assessment
## Scorecard
| Area | Score |
|---|---:|
| Documentation | 84 |
| API knowledge | 62 |
| Script coverage | 78 |
| Test coverage | 70 |
| Compatibility | 74 |
| Maintainability | 80 |
| Research depth | 76 |
| Tooling | 72 |
## Overall score
**76 / 100**
## Summary
The repository has evolved from a collection of scripts into a structured framework for documentation, templates, testing, and SDK-style development scaffolding. The main remaining gap is verified host-API extraction from the installed Multi-PROG Help.
+28
View File
@@ -0,0 +1,28 @@
# Repository Roadmap
## Priority 1 — Verified API extraction
- Confirm host API names in the installed Multi-PROG Help.
## Priority 2 — Script catalog cleanup
- Keep the collected script catalog organized and documented.
## Priority 3 — SDK completion
- Expand templates, examples, and utilities.
## Priority 4 — Test coverage expansion
- Add more offline tests and fixtures.
## Priority 5 — Documentation maturity
- Continue refining beginner and authoring guides.
## Priority 6 — Template coverage
- Add more dedicated templates for new script families.
## Priority 7 — Community script validation
- Review and classify collected community scripts.
## Priority 8 — Compatibility validation
- Validate portability across Node.js, browsers, and generic JS hosts.
## Priority 9 — Unsorted-content review
- Review and integrate the contents of 20_Unsorted into the main framework.