@henols/c64-re-tools 2.7.1 → 2.8.0-rc.1
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/package.json +1 -1
- package/skills/c64-assembler/SKILL.md +23 -38
- package/skills/c64-assembler/scripts/assembler.ts +114 -16
- package/skills/c64-basic/SKILL.md +11 -31
- package/skills/c64-basic/scripts/basic.ts +4 -1
- package/skills/c64-development/SKILL.md +2 -2
- package/skills/c64-disk/SKILL.md +11 -32
- package/skills/c64-docs/SKILL.md +27 -45
- package/skills/c64-docs/references/page-types.md +20 -18
- package/skills/c64-docs/references/style.md +10 -4
- package/skills/c64-docs/scripts/docs.ts +13 -2
- package/skills/c64-docs/scripts/lib/reference.ts +47 -5
- package/skills/c64-knowledge/SKILL.md +138 -267
- package/skills/c64-knowledge/references/batches.md +48 -0
- package/skills/c64-knowledge/references/coverage.md +29 -0
- package/skills/c64-knowledge/references/source-knowledge.md +72 -0
- package/skills/c64-knowledge/references/start-screen.md +44 -0
- package/skills/c64-knowledge/scripts/knowledge.ts +266 -61
- package/skills/c64-knowledge/scripts/lib/check.ts +133 -0
- package/skills/c64-knowledge/scripts/lib/listing.ts +72 -8
- package/skills/c64-memory-map/SKILL.md +11 -32
- package/skills/c64-packer/SKILL.md +11 -31
- package/skills/c64-provenance/SKILL.md +40 -62
- package/skills/c64-provenance/scripts/lib/leftovers.ts +8 -3
- package/skills/c64-provenance/scripts/provenance.ts +64 -55
- package/skills/c64-reverse-engineering/SKILL.md +20 -47
- package/skills/c64-reverse-engineering/references/comment-check.md +42 -0
- package/skills/c64-reverse-engineering/references/versions.md +47 -0
- package/skills/c64-source/SKILL.md +43 -237
- package/skills/c64-source/references/export.md +50 -0
- package/skills/c64-source/references/loader.md +78 -0
- package/skills/c64-source/references/source-format.md +46 -0
- package/skills/c64-source/scripts/lib/export.ts +20 -7
- package/skills/c64-source/scripts/lib/loader.ts +4 -82
- package/skills/c64-source/scripts/source.ts +48 -51
- package/skills/c64-static-analysis/SKILL.md +51 -52
- package/skills/c64-static-analysis/scripts/lib/coverage.ts +55 -2
- package/skills/c64-static-analysis/scripts/lib/idioms.ts +28 -9
- package/skills/c64-static-analysis/scripts/static-analysis.ts +69 -15
- package/skills/c64-testing/SKILL.md +72 -58
- package/skills/c64-testing/references/recording-format.md +5 -80
- package/skills/c64-testing/references/scenario-format.md +4 -12
- package/skills/c64-testing/scripts/lib/play.ts +16 -8
- package/skills/c64-testing/scripts/lib/recording.ts +74 -9
- package/skills/c64-testing/scripts/lib/replay.ts +4 -0
- package/skills/c64-testing/scripts/lib/runs.ts +112 -1
- package/skills/c64-testing/scripts/lib/scenario.ts +12 -6
- package/skills/c64-testing/scripts/lib/start-screen.ts +27 -0
- package/skills/c64-testing/scripts/testing.ts +34 -13
- package/skills/c64-unpacker/SKILL.md +10 -30
- package/skills/emulator/SKILL.md +7 -36
- package/src/build-name.ts +12 -1
- package/src/knowledge/history.ts +8 -0
- package/src/knowledge/program.ts +73 -1
- package/src/knowledge/read.ts +46 -2
- package/src/knowledge/recording-files.ts +32 -0
- package/src/knowledge/schema.ts +3 -1
- package/src/knowledge/separate.ts +90 -3
- package/src/knowledge/start-screen.ts +99 -17
- package/src/knowledge/text.ts +2 -1
- package/src/knowledge/write.ts +15 -8
- package/src/loader.ts +167 -0
- package/src/native/decompiler/analyze.ts +7 -6
- package/src/native/decompiler/walk.ts +32 -2
- package/src/native/dxa.ts +4 -4
- package/src/native/types.ts +32 -4
- package/src/script.ts +87 -17
- package/skills/c64-export/SKILL.md +0 -63
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// The comment check: a sample of comments for one seed and the verdict of
|
|
2
|
+
// each item. knowledge.ts reads and writes the files; these functions check
|
|
3
|
+
// each verdict and count the result, so the files stay consistent.
|
|
4
|
+
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
|
|
7
|
+
import { SYMBOL_NAME } from "#src/c64.ts";
|
|
8
|
+
import { Refusal } from "#src/errors.ts";
|
|
9
|
+
|
|
10
|
+
export const CHECK_VERDICTS = ["correct", "wrong", "unsure"] as const;
|
|
11
|
+
export type CheckVerdict = (typeof CHECK_VERDICTS)[number];
|
|
12
|
+
/** The classes of a wrong comment, as the instructions of the check name them. */
|
|
13
|
+
export const CHECK_CLASSES = ["callers", "bits", "registers", "bounds", "units", "paths", "tables", "hardware", "place", "scope"] as const;
|
|
14
|
+
export type CheckClass = (typeof CHECK_CLASSES)[number];
|
|
15
|
+
|
|
16
|
+
/** One comment of a sample, in the output shape of the knowledge script. */
|
|
17
|
+
export interface SampleItem {
|
|
18
|
+
address: string;
|
|
19
|
+
placement: string;
|
|
20
|
+
text: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
[field: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface Sample {
|
|
26
|
+
seed: number;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
revision: string;
|
|
29
|
+
space?: string;
|
|
30
|
+
population: number;
|
|
31
|
+
comments: SampleItem[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Verdict {
|
|
35
|
+
address: string;
|
|
36
|
+
placement: string;
|
|
37
|
+
verdict: CheckVerdict;
|
|
38
|
+
class?: CheckClass;
|
|
39
|
+
why?: string;
|
|
40
|
+
text?: string;
|
|
41
|
+
name?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface Verdicts {
|
|
45
|
+
seed: number;
|
|
46
|
+
revision: string;
|
|
47
|
+
items: Verdict[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The comments of a sample: the first count rows in the order of a hash of the seed and the place of each row,
|
|
52
|
+
* in address order. A changed text or another row does not move a row.
|
|
53
|
+
*/
|
|
54
|
+
export function pickSample<T extends { space: string; address: number; placement: string }>(rows: readonly T[], seed: number, count: number): T[] {
|
|
55
|
+
const key = (row: T) => createHash("sha256").update(`${seed}:${row.space}:${row.address}:${row.placement}`).digest("hex");
|
|
56
|
+
return rows
|
|
57
|
+
.map((row) => ({ row, key: key(row) }))
|
|
58
|
+
.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))
|
|
59
|
+
.slice(0, count)
|
|
60
|
+
.map((item) => item.row)
|
|
61
|
+
.sort((a, b) => a.address - b.address || a.placement.localeCompare(b.placement));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The folder of the check of a seed, relative to the project folder. */
|
|
65
|
+
export const checkFolder = (seed: number) => `runs/comment-check-${seed}`;
|
|
66
|
+
|
|
67
|
+
/** A seed from the name of a check folder, or undefined for another folder. */
|
|
68
|
+
export function seedOfFolder(name: string): number | undefined {
|
|
69
|
+
const match = /^comment-check-(\d{1,6})$/.exec(name);
|
|
70
|
+
return match === null ? undefined : Number(match[1]);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface VerdictRequest {
|
|
74
|
+
address: string;
|
|
75
|
+
placement?: string;
|
|
76
|
+
verdict: CheckVerdict;
|
|
77
|
+
class?: CheckClass;
|
|
78
|
+
why?: string;
|
|
79
|
+
text?: string;
|
|
80
|
+
name?: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The verdicts with the verdict of one item of the sample added, or in place of its earlier verdict. */
|
|
84
|
+
export function withVerdict(sample: Sample, verdicts: Verdicts | undefined, request: VerdictRequest): Verdicts {
|
|
85
|
+
const at = sample.comments.filter((item) => item.address === request.address && (request.placement === undefined || item.placement === request.placement));
|
|
86
|
+
const place = `${request.address}${request.placement === undefined ? "" : ` (${request.placement})`}`;
|
|
87
|
+
if (at.length === 0) throw new Refusal("not-found", `The sample of seed ${sample.seed} has no comment at ${place}. Give the address of an item of the sample: get the items with checks ${sample.seed}.`);
|
|
88
|
+
if (at.length > 1) throw new Refusal("invalid-input", `The sample of seed ${sample.seed} has a line and a side comment at ${request.address}. Give --placement line or --placement side.`);
|
|
89
|
+
const item = at[0]!;
|
|
90
|
+
const { verdict } = request;
|
|
91
|
+
const extra = (["class", "text", "name"] as const).filter((field) => request[field] !== undefined);
|
|
92
|
+
if (verdict !== "wrong" && extra.length > 0) throw new Refusal("invalid-input", `A verdict ${verdict} takes no --${extra.join(", --")}. Only a verdict wrong takes --class, --text and --name.`);
|
|
93
|
+
if (verdict === "wrong" && request.class === undefined) throw new Refusal("invalid-input", `A verdict wrong needs --class: one of ${CHECK_CLASSES.join(", ")}.`);
|
|
94
|
+
if (verdict !== "correct" && (request.why === undefined || request.why.trim() === "")) {
|
|
95
|
+
throw new Refusal("invalid-input", verdict === "wrong" ? "A verdict wrong needs --why: the evidence, with the addresses and the instructions." : "A verdict unsure needs --why: the run that can show the claim.");
|
|
96
|
+
}
|
|
97
|
+
if (verdict === "wrong" && request.text === undefined && request.name === undefined) throw new Refusal("invalid-input", "A verdict wrong needs --text with the correct comment, --name with the correct name, or both.");
|
|
98
|
+
if (request.name !== undefined && !SYMBOL_NAME.test(request.name)) throw new Refusal("invalid-input", `--name ${JSON.stringify(request.name)} is not a label: give a letter or an underscore, then letters, digits or underscores.`);
|
|
99
|
+
const written: Verdict = { address: item.address, placement: item.placement, verdict };
|
|
100
|
+
for (const field of ["class", "why", "text", "name"] as const) if (request[field] !== undefined) (written as unknown as Record<string, string>)[field] = request[field]!;
|
|
101
|
+
const kept = (verdicts?.items ?? []).filter((other) => other.address !== item.address || other.placement !== item.placement);
|
|
102
|
+
// The items in the sequence of the sample.
|
|
103
|
+
const order = (verdict: Verdict) => sample.comments.findIndex((other) => other.address === verdict.address && other.placement === verdict.placement);
|
|
104
|
+
return { seed: sample.seed, revision: sample.revision, items: [...kept, written].sort((a, b) => order(a) - order(b)) };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The counts of a check, and each item of the sample with its verdict when it has one: the correct text and name of a wrong item are its correction. */
|
|
108
|
+
export function checkResult(sample: Sample, verdicts: Verdicts | undefined) {
|
|
109
|
+
const items = sample.comments.map((item) => {
|
|
110
|
+
const found = verdicts?.items.find((verdict) => verdict.address === item.address && verdict.placement === item.placement);
|
|
111
|
+
if (found === undefined) return item;
|
|
112
|
+
const correction = { ...(found.text === undefined ? {} : { text: found.text }), ...(found.name === undefined ? {} : { name: found.name }) };
|
|
113
|
+
return {
|
|
114
|
+
...item,
|
|
115
|
+
verdict: found.verdict,
|
|
116
|
+
...(found.class === undefined ? {} : { class: found.class }),
|
|
117
|
+
...(found.why === undefined ? {} : { why: found.why }),
|
|
118
|
+
...(Object.keys(correction).length === 0 ? {} : { correction }),
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
const count = (verdict: CheckVerdict) => items.filter((item) => item.verdict === verdict).length;
|
|
122
|
+
return {
|
|
123
|
+
seed: sample.seed,
|
|
124
|
+
createdAt: sample.createdAt,
|
|
125
|
+
revision: sample.revision,
|
|
126
|
+
sampled: items.length,
|
|
127
|
+
checked: items.filter((item) => item.verdict !== undefined).length,
|
|
128
|
+
correct: count("correct"),
|
|
129
|
+
wrong: count("wrong"),
|
|
130
|
+
unsure: count("unsure"),
|
|
131
|
+
items,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// the bytes from coverage files, and the references in and out. Nothing here
|
|
4
4
|
// reads files: knowledge.ts gives the lookups.
|
|
5
5
|
|
|
6
|
-
import { COVERAGE, formatC64Address, formatC64Byte } from "#src/c64.ts";
|
|
6
|
+
import { COVERAGE, formatC64Address, formatC64Byte, POINTER_TABLE_TYPES, pointerTableEntries, type PointerTableType } from "#src/c64.ts";
|
|
7
7
|
import { instructionWith, MODE_LENGTH, OPCODES, type Mode } from "#src/opcodes.ts";
|
|
8
8
|
|
|
9
9
|
export interface ListingSource {
|
|
@@ -42,7 +42,10 @@ export interface ListingLine {
|
|
|
42
42
|
comment?: string;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
type Region = ListingSource["regions"][number];
|
|
46
|
+
|
|
45
47
|
const CODE = new Set(["code", "jumps"]);
|
|
48
|
+
const TABLES = new Set<string>(["words", ...POINTER_TABLE_TYPES]);
|
|
46
49
|
const DATA_PER_LINE = 8;
|
|
47
50
|
|
|
48
51
|
/** The access class of bytes from the coverage: x, r and w as they occur, or - for none. */
|
|
@@ -76,9 +79,45 @@ function operandOf(mode: Mode, address: number, low: number, high: number, sourc
|
|
|
76
79
|
return MODE_LENGTH[mode] === 3 ? named(low | (high << 8), 4) : named(low, 2);
|
|
77
80
|
}
|
|
78
81
|
|
|
79
|
-
/**
|
|
80
|
-
|
|
82
|
+
/**
|
|
83
|
+
* The values of a table region as c64-source writes them: a word of a words or an address table
|
|
84
|
+
* as one !word value, and each byte of a split table as <target or >target. A byte of no entry has no value.
|
|
85
|
+
*/
|
|
86
|
+
function tableValues(region: Region, source: ListingSource): Map<number, { length: 1 | 2; text: string }> {
|
|
87
|
+
const values = new Map<number, { length: 1 | 2; text: string }>();
|
|
88
|
+
const present = (address: number) => source.byteAt(address) !== undefined;
|
|
89
|
+
const byteAt = (address: number) => source.byteAt(address) ?? 0;
|
|
90
|
+
if (region.type === "words") {
|
|
91
|
+
for (let address = region.start; address + 1 <= region.end; address += 2) {
|
|
92
|
+
if (present(address) && present(address + 1)) values.set(address, { length: 2, text: formatC64Address(byteAt(address) | (byteAt(address + 1) << 8)) });
|
|
93
|
+
}
|
|
94
|
+
return values;
|
|
95
|
+
}
|
|
96
|
+
const rts = region.type === "rts-addresses" || region.type === "rts-addresses-split";
|
|
97
|
+
const split = region.type === "addresses-split" || region.type === "rts-addresses-split";
|
|
98
|
+
for (const entry of pointerTableEntries({ start: region.start, end: region.end, type: region.type as PointerTableType }, byteAt)) {
|
|
99
|
+
if (!present(entry.low) || !present(entry.high)) continue;
|
|
100
|
+
const target = targetName(entry.target, source) ?? formatC64Address(entry.target);
|
|
101
|
+
const text = rts ? `${target}-1` : target;
|
|
102
|
+
if (!split) {
|
|
103
|
+
values.set(entry.low, { length: 2, text });
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const part = /^[$A-Za-z_.0-9]+$/.test(text) ? text : `(${text})`;
|
|
107
|
+
values.set(entry.low, { length: 1, text: `<${part}` });
|
|
108
|
+
values.set(entry.high, { length: 1, text: `>${part}` });
|
|
109
|
+
}
|
|
110
|
+
return values;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The lines of start..end: instructions in code regions, decoded from the
|
|
115
|
+
* region start, tables as their values, and bytes elsewhere. With `code`, only
|
|
116
|
+
* the instructions of the code regions.
|
|
117
|
+
*/
|
|
118
|
+
export function listing(source: ListingSource, start: number, end: number, options: { code?: boolean } = {}): ListingLine[] {
|
|
81
119
|
const lines: ListingLine[] = [];
|
|
120
|
+
const data = options.code !== true;
|
|
82
121
|
const line = (address: number, length: number, text: string): ListingLine => {
|
|
83
122
|
const bytes = Array.from({ length }, (_, offset) => source.byteAt(address + offset)!.toString(16).padStart(2, "0")).join(" ");
|
|
84
123
|
const label = source.nameOf(address);
|
|
@@ -107,9 +146,11 @@ export function listing(source: ListingSource, start: number, end: number): List
|
|
|
107
146
|
};
|
|
108
147
|
};
|
|
109
148
|
const regionAt = (address: number) => source.regions.find((region) => address >= region.start && address <= region.end);
|
|
110
|
-
|
|
149
|
+
const tables = new Map<Region, ReturnType<typeof tableValues>>();
|
|
150
|
+
const valuesOf = (region: Region) => tables.get(region) ?? tables.set(region, tableValues(region, source)).get(region)!;
|
|
151
|
+
// Start at the code or table region that holds the first address, so the instructions and the words keep their boundaries.
|
|
111
152
|
const first = regionAt(start);
|
|
112
|
-
let address = first !== undefined && CODE.has(first.type) ? first.start : start;
|
|
153
|
+
let address = first !== undefined && (CODE.has(first.type) || TABLES.has(first.type)) ? first.start : start;
|
|
113
154
|
while (address <= end) {
|
|
114
155
|
const byte = source.byteAt(address);
|
|
115
156
|
if (byte === undefined) {
|
|
@@ -129,14 +170,37 @@ export function listing(source: ListingSource, start: number, end: number): List
|
|
|
129
170
|
continue;
|
|
130
171
|
}
|
|
131
172
|
}
|
|
132
|
-
//
|
|
173
|
+
// Table values of one size up to the next label, region edge or end of the line. A label inside a word gives its bytes.
|
|
174
|
+
const table = region !== undefined && TABLES.has(region.type) ? valuesOf(region) : undefined;
|
|
175
|
+
// Before the start, step over the values of a table one at a time, so the first line starts at the first value from the start.
|
|
176
|
+
if (address < start) {
|
|
177
|
+
address += table?.get(address)?.length ?? 1;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (table !== undefined) {
|
|
181
|
+
const size = table.get(address)?.length;
|
|
182
|
+
const texts: string[] = [];
|
|
183
|
+
let at = address;
|
|
184
|
+
while (size !== undefined && at <= end && texts.length * size < DATA_PER_LINE) {
|
|
185
|
+
const value = table.get(at);
|
|
186
|
+
if (value?.length !== size || (at !== address && source.nameOf(at) !== undefined) || (size === 2 && source.nameOf(at + 1) !== undefined)) break;
|
|
187
|
+
texts.push(value.text);
|
|
188
|
+
at += size;
|
|
189
|
+
}
|
|
190
|
+
if (texts.length > 0) {
|
|
191
|
+
if (data) lines.push(line(address, at - address, `${size === 2 ? "!word" : "!byte"} ${texts.join(",")}`));
|
|
192
|
+
address = at;
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// Bytes up to the next label, table value, region edge or end of the line.
|
|
133
197
|
const values: number[] = [];
|
|
134
198
|
let at = address;
|
|
135
|
-
while (at <= end && values.length < DATA_PER_LINE && source.byteAt(at) !== undefined && (at === address || (source.nameOf(at) === undefined && regionAt(at) === region))) {
|
|
199
|
+
while (at <= end && values.length < DATA_PER_LINE && source.byteAt(at) !== undefined && (at === address || (source.nameOf(at) === undefined && regionAt(at) === region && table?.has(at) !== true))) {
|
|
136
200
|
values.push(source.byteAt(at)!);
|
|
137
201
|
at++;
|
|
138
202
|
}
|
|
139
|
-
if (
|
|
203
|
+
if (data) lines.push(line(address, values.length, `!byte ${values.map(formatC64Byte).join(",")}`));
|
|
140
204
|
address = at;
|
|
141
205
|
}
|
|
142
206
|
return lines;
|
|
@@ -48,12 +48,11 @@ To get the command list, run the script with no arguments.
|
|
|
48
48
|
- A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
|
|
49
49
|
- Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
|
|
50
50
|
- Write each file that you make for your work in `.c64-re-tools/local/` of the project. Git ignores that folder. Examples are results, batches, step files, runs, snapshots and memory dumps.
|
|
51
|
-
- The script refuses an `--out` path in `.c64-re-tools/knowledge
|
|
51
|
+
- The script refuses an `--out` path in `.c64-re-tools/knowledge/`. Change the project knowledge only with the commands that change it.
|
|
52
52
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
53
53
|
- When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
|
|
54
|
-
- A coverage map can stay in `.c64-re-tools/local/`.
|
|
55
|
-
-
|
|
56
|
-
- Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
|
|
54
|
+
- A coverage map can stay in `.c64-re-tools/local/`. Do not move a coverage map after you put it into the project knowledge.
|
|
55
|
+
- To keep a run as evidence, use the command that keeps a run. It copies the run, its results and its snapshot files into `runs/<name>/`, and it changes the paths in the copy. Then git keeps them, and another person can do the run again.
|
|
57
56
|
- A shell redirect (`>`) is relative to the working directory, not to the project folder. From the folder above the project, write `<folder>/.c64-re-tools/local/result.json`.
|
|
58
57
|
|
|
59
58
|
## Flags
|
|
@@ -116,7 +115,7 @@ When the list is cut, `hint` gives the full count, and `nextAction` runs `list`
|
|
|
116
115
|
|
|
117
116
|
### `export`
|
|
118
117
|
|
|
119
|
-
Writes all platform names to the project file at `--out`, as an ACME include file. Each
|
|
118
|
+
Writes all platform names to the project file at `--out`, as an ACME include file. Each name has its meaning as a comment.
|
|
120
119
|
|
|
121
120
|
`body` holds `names` (the number of names) and the file as `out`, `bytes` and `sha256`.
|
|
122
121
|
|
|
@@ -128,24 +127,15 @@ Include the file with `!source` in source that you write by hand.
|
|
|
128
127
|
|
|
129
128
|
Each command prints one JSON envelope on one line on stdout. Notes go to stderr.
|
|
130
129
|
|
|
131
|
-
On success, the exit code is 0:
|
|
132
|
-
|
|
133
|
-
```json
|
|
134
|
-
{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
On failure, the exit code is 2:
|
|
138
|
-
|
|
139
|
-
```json
|
|
140
|
-
{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}
|
|
141
|
-
```
|
|
142
|
-
|
|
130
|
+
- On success, the exit code is 0: `{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}`
|
|
131
|
+
- On failure, the exit code is 2: `{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}`
|
|
143
132
|
- `body` holds the result. The section of each command gives the fields of its body.
|
|
144
133
|
- A check gives its verdict in `body.result`: `PASS`, `FAIL` or `INCONCLUSIVE`. The exit code is 0 for each verdict. Thus read `body.result`, not the exit code.
|
|
145
|
-
- `error` is one sentence. It tells what is wrong.
|
|
146
|
-
- `
|
|
147
|
-
- `
|
|
148
|
-
- `
|
|
134
|
+
- `error` is one sentence. It tells what is wrong. `hint` tells what to do or what to examine. Read it before your next step.
|
|
135
|
+
- `nextAction` is a full command line. It runs from any directory. Run it when it agrees with your task.
|
|
136
|
+
- A list has `count`, `listed` and `rest`. `listed` holds at most `--max-listed` items. `rest` tells how to get the other items. A file that the command wrote has `out`, `bytes` and `sha256`.
|
|
137
|
+
- To get only some fields of `body`, give `--fields <path>,<path>`, for example `--fields count,listed.start`. A path through a list gives that field of each item. Do not write code to filter an envelope.
|
|
138
|
+
- To get the command list, run the script with no arguments. To get the subjects and the flags of one command, run `<command> --help`.
|
|
149
139
|
|
|
150
140
|
| `code` | Action |
|
|
151
141
|
|---|---|
|
|
@@ -153,14 +143,3 @@ On failure, the exit code is 2:
|
|
|
153
143
|
| `invalid-input`, `not-found` | Correct the call as `hint` tells. Then run the command again. |
|
|
154
144
|
| `operation-failed` | Give `error` and `hint` to the user. |
|
|
155
145
|
| Another code | Do as `hint` tells. |
|
|
156
|
-
|
|
157
|
-
These fields have the same meaning in each body:
|
|
158
|
-
|
|
159
|
-
| Field | Meaning |
|
|
160
|
-
|---|---|
|
|
161
|
-
| `out`, `bytes`, `sha256` | A file that the command wrote: its path, its size and its SHA-256. |
|
|
162
|
-
| `count`, `listed`, `rest` | A list. `count` is the number of items. `listed` holds the first items, at most `--max-listed`. `rest` tells how to get the other items. |
|
|
163
|
-
|
|
164
|
-
To get the command list, run the script with no arguments. The envelope has `command: "help"`, and `body.commands` gives the name, the summary and the synopsis of each command.
|
|
165
|
-
To get the subjects and the flags of one command, run `<command> --help`. Then `body.subjects` and `body.options` give them.
|
|
166
|
-
|
|
@@ -47,12 +47,11 @@ To get the command list, run the script with no arguments.
|
|
|
47
47
|
- A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
|
|
48
48
|
- Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
|
|
49
49
|
- Write each file that you make for your work in `.c64-re-tools/local/` of the project. Git ignores that folder. Examples are results, batches, step files, runs, snapshots and memory dumps.
|
|
50
|
-
- The script refuses an `--out` path in `.c64-re-tools/knowledge
|
|
50
|
+
- The script refuses an `--out` path in `.c64-re-tools/knowledge/`. Change the project knowledge only with the commands that change it.
|
|
51
51
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
52
52
|
- When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
|
|
53
|
-
- A coverage map can stay in `.c64-re-tools/local/`.
|
|
54
|
-
-
|
|
55
|
-
- Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
|
|
53
|
+
- A coverage map can stay in `.c64-re-tools/local/`. Do not move a coverage map after you put it into the project knowledge.
|
|
54
|
+
- To keep a run as evidence, use the command that keeps a run. It copies the run, its results and its snapshot files into `runs/<name>/`, and it changes the paths in the copy. Then git keeps them, and another person can do the run again.
|
|
56
55
|
- A shell redirect (`>`) is relative to the working directory, not to the project folder. From the folder above the project, write `<folder>/.c64-re-tools/local/result.json`.
|
|
57
56
|
|
|
58
57
|
---
|
|
@@ -98,7 +97,7 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
98
97
|
Traps:
|
|
99
98
|
|
|
100
99
|
- The unpacker starts with `SYS 2061`, at `$080d`. A BASIC program at `$0801` often has its entry at `$080d` too. Then the CPU gets to `$080d` two times: first before the unpack, then at the start of the program. To examine the program at its entry in the emulator, stop at `$080d`, run one frame, and stop at `$080d` again.
|
|
101
|
-
-
|
|
100
|
+
- A program that loads into `$0334` to `$03ff` or into the zero page can fail, because the unpacker uses these addresses while it runs. Then the command fails with `operation-failed`, or the check gives `FAIL`. Give the result to the user.
|
|
102
101
|
- `invalid-input` for the entry: the entry is below `$0400`. The unpacker runs there. A program with an entry below `$0400` needs a different packer.
|
|
103
102
|
- `invalid-input` with "There is no SYS address": the first input has no BASIC line with `SYS` and a number. Give `--entry`.
|
|
104
103
|
- `operation-failed` with "Exomizer could not pack the program": `hint` gives the last output of Exomizer. Change the inputs, or give the message to the user.
|
|
@@ -121,24 +120,15 @@ The packed program and the check result do not go into the project knowledge.
|
|
|
121
120
|
|
|
122
121
|
Each command prints one JSON envelope on one line on stdout. Notes go to stderr.
|
|
123
122
|
|
|
124
|
-
On success, the exit code is 0:
|
|
125
|
-
|
|
126
|
-
```json
|
|
127
|
-
{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
On failure, the exit code is 2:
|
|
131
|
-
|
|
132
|
-
```json
|
|
133
|
-
{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}
|
|
134
|
-
```
|
|
135
|
-
|
|
123
|
+
- On success, the exit code is 0: `{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}`
|
|
124
|
+
- On failure, the exit code is 2: `{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}`
|
|
136
125
|
- `body` holds the result. The section of each command gives the fields of its body.
|
|
137
126
|
- A check gives its verdict in `body.result`: `PASS`, `FAIL` or `INCONCLUSIVE`. The exit code is 0 for each verdict. Thus read `body.result`, not the exit code.
|
|
138
|
-
- `error` is one sentence. It tells what is wrong.
|
|
139
|
-
- `
|
|
140
|
-
- `
|
|
141
|
-
- `
|
|
127
|
+
- `error` is one sentence. It tells what is wrong. `hint` tells what to do or what to examine. Read it before your next step.
|
|
128
|
+
- `nextAction` is a full command line. It runs from any directory. Run it when it agrees with your task.
|
|
129
|
+
- A list has `count`, `listed` and `rest`. `listed` holds at most `--max-listed` items. `rest` tells how to get the other items. A file that the command wrote has `out`, `bytes` and `sha256`.
|
|
130
|
+
- To get only some fields of `body`, give `--fields <path>,<path>`, for example `--fields count,listed.start`. A path through a list gives that field of each item. Do not write code to filter an envelope.
|
|
131
|
+
- To get the command list, run the script with no arguments. To get the subjects and the flags of one command, run `<command> --help`.
|
|
142
132
|
|
|
143
133
|
| `code` | Action |
|
|
144
134
|
|---|---|
|
|
@@ -146,13 +136,3 @@ On failure, the exit code is 2:
|
|
|
146
136
|
| `invalid-input`, `not-found` | Correct the call as `hint` tells. Then run the command again. |
|
|
147
137
|
| `operation-failed` | Give `error` and `hint` to the user. |
|
|
148
138
|
| Another code | Do as `hint` tells. |
|
|
149
|
-
|
|
150
|
-
These fields have the same meaning in each body:
|
|
151
|
-
|
|
152
|
-
| Field | Meaning |
|
|
153
|
-
|---|---|
|
|
154
|
-
| `out`, `bytes`, `sha256` | A file that the command wrote: its path, its size and its SHA-256. |
|
|
155
|
-
| `count`, `listed`, `rest` | A list. `count` is the number of items. `listed` holds the first items, at most `--max-listed`. `rest` tells how to get the other items. |
|
|
156
|
-
|
|
157
|
-
To get the command list, run the script with no arguments. The envelope has `command: "help"`, and `body.commands` gives the name, the summary and the synopsis of each command.
|
|
158
|
-
To get the subjects and the flags of one command, run `<command> --help`. Then `body.subjects` and `body.options` give them.
|