candor-ts 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +4 -8
- package/PROVE-IT.md +1 -3
- package/README.md +1 -1
- package/package.json +1 -1
- package/scan.mjs +20 -2
package/AGENTS.md
CHANGED
|
@@ -9,15 +9,11 @@ the TypeScript-specific production + query surface.
|
|
|
9
9
|
|
|
10
10
|
## Produce a report
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
On npm (needs node ≥ 20):
|
|
13
13
|
|
|
14
14
|
```sh
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
( cd /tmp/candor-ts && npm install --no-fund --no-audit )
|
|
18
|
-
|
|
19
|
-
node /tmp/candor-ts/scan.mjs <project-dir> # tsconfig.json honored; tests/node_modules excluded
|
|
20
|
-
node /tmp/candor-ts/scan.mjs <dir> --allow-js # also analyze .js/.mjs sources (walks the tree)
|
|
15
|
+
npx -y candor-ts <project-dir> # tsconfig.json honored; tests/node_modules excluded
|
|
16
|
+
npx -y candor-ts <dir> --allow-js # also analyze .js/.mjs sources (walks the tree)
|
|
21
17
|
```
|
|
22
18
|
|
|
23
19
|
This writes `<project-dir>/.candor/report.json` and `.candor/report.callgraph.json` (override
|
|
@@ -46,7 +42,7 @@ downgraded to `Unknown` rather than silently trusted (spec §2.1). Caveat: a typ
|
|
|
46
42
|
## Query it (same names/shapes as the Rust and JVM engines — candor-spec §3.1)
|
|
47
43
|
|
|
48
44
|
```sh
|
|
49
|
-
Q() {
|
|
45
|
+
Q() { npx -y candor-ts-query "$@"; }; P=".candor/report" # a function — works in bash AND zsh
|
|
50
46
|
Q show $P <fn-query> 1 # a function's effects (+ hosts/tables when visible)
|
|
51
47
|
Q where $P <Effect> 1 # {effect, directly, inherited}
|
|
52
48
|
Q callers $P <fn-query> 1 # the BLAST RADIUS: {of, direct, transitive} — works for pure fns
|
package/PROVE-IT.md
CHANGED
|
@@ -36,9 +36,7 @@ enclosing function). Also note roughly how
|
|
|
36
36
|
many file-reads/searches it took you.
|
|
37
37
|
|
|
38
38
|
STEP 3 — Run candor-ts:
|
|
39
|
-
|
|
40
|
-
(cd /tmp/candor-ts && npm install --no-fund --no-audit)
|
|
41
|
-
node /tmp/candor-ts/scan.mjs .
|
|
39
|
+
npx -y candor-ts .
|
|
42
40
|
It writes .candor/report.json (per-function transitive effects) and .candor/report.callgraph.json
|
|
43
41
|
(every analyzed function's direct callees, pure ones included).
|
|
44
42
|
|
package/README.md
CHANGED
|
@@ -106,4 +106,4 @@ spec §7.13: generated effect chains through every encoded call form, any silent
|
|
|
106
106
|
conformance-held. The npm classifier tier is
|
|
107
107
|
deliberately curated and will keep growing case-by-case. Entry points (Nest/Next populations),
|
|
108
108
|
`unknownWhy` origins, `reachable`, cross-package inheritance (`CANDOR_DEPS` + the spec §2 `hash`,
|
|
109
|
-
version-trusted per §2.1), and `--allow-js` are all in.
|
|
109
|
+
version-trusted per §2.1), and `--allow-js` are all in. On npm: `npx -y candor-ts <dir>`.
|
package/package.json
CHANGED
package/scan.mjs
CHANGED
|
@@ -22,8 +22,12 @@
|
|
|
22
22
|
import ts from "typescript";
|
|
23
23
|
import fs from "node:fs";
|
|
24
24
|
import path from "node:path";
|
|
25
|
+
import { fileURLToPath } from "node:url";
|
|
26
|
+
import { createRequire } from "node:module";
|
|
25
27
|
import { parsePolicy, evaluatePolicy } from "./policy.mjs";
|
|
26
28
|
|
|
29
|
+
const ENGINE_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
30
|
+
|
|
27
31
|
// ---- args ----------------------------------------------------------------------------------------
|
|
28
32
|
const argv = process.argv.slice(2);
|
|
29
33
|
if (argv.length === 0) {
|
|
@@ -83,6 +87,20 @@ if (stat.isFile() && /tsconfig.*\.json$/.test(path.basename(target))) {
|
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
89
|
if (fileNames.length === 0) { console.error(`candor-ts: no TypeScript sources under ${target}`); process.exit(2); }
|
|
90
|
+
// Builtin typings FALLBACK: the engine ships @types/node as its own dependency, so a target that
|
|
91
|
+
// hasn't installed it still resolves node:fs/node:net/… (found by the first npx-distribution
|
|
92
|
+
// probe: a bare fixture read Unknown for fs.readFileSync because nothing supplied the builtin
|
|
93
|
+
// types). Resolved via the module system, NOT a fixed relative path — npm HOISTS dependencies, so
|
|
94
|
+
// in an npx/install tree @types/node sits BESIDE candor-ts, not inside it (the second probe's
|
|
95
|
+
// catch). The TARGET's own @types win when present.
|
|
96
|
+
if (!compilerOptions.typeRoots) {
|
|
97
|
+
const roots = [path.join(rootDir, "node_modules", "@types")];
|
|
98
|
+
try {
|
|
99
|
+
const req = createRequire(path.join(ENGINE_DIR, "scan.mjs"));
|
|
100
|
+
roots.push(path.dirname(path.dirname(req.resolve("@types/node/package.json"))));
|
|
101
|
+
} catch {}
|
|
102
|
+
compilerOptions.typeRoots = roots;
|
|
103
|
+
}
|
|
86
104
|
if (!outPrefix) outPrefix = path.join(rootDir, ".candor", "report");
|
|
87
105
|
// The scanned package's name — the first half of the cross-package join key (SPEC §2 `hash`).
|
|
88
106
|
let pkgName = path.basename(rootDir);
|
|
@@ -121,7 +139,7 @@ fs.mkdirSync(path.dirname(path.resolve(outPrefix)), { recursive: true });
|
|
|
121
139
|
// scan and a .d.ts resolution). Version-aware trust (§2.1): a report from a DIFFERENT engine
|
|
122
140
|
// version is downgraded to Unknown rather than silently trusted. Duplicate hashes (two same-named
|
|
123
141
|
// exports in one package) UNION — a sound over-approximation, documented.
|
|
124
|
-
const ENGINE_VERSION = "candor-ts-0.4.
|
|
142
|
+
const ENGINE_VERSION = "candor-ts-0.4.2";
|
|
125
143
|
const crossDeps = new Map(); // hash -> {inferred:Set, hosts:[], cmds:[], paths:[], tables:[]}
|
|
126
144
|
// Packages a loaded sibling report COVERS — exempt from the κ ledger even when a call joins no
|
|
127
145
|
// entry (reports omit pure functions: the silence is the purity claim, SPEC §2 rule 3 — the
|
|
@@ -765,7 +783,7 @@ for (const [name, rec] of fns) {
|
|
|
765
783
|
}
|
|
766
784
|
// `package` names what this report COVERS — a consumer chaining it registers coverage even when
|
|
767
785
|
// `functions` is empty (an all-pure package's report is its purity claim, SPEC §2 rule 3).
|
|
768
|
-
const envelope = { candor: { version: "candor-ts-0.4.
|
|
786
|
+
const envelope = { candor: { version: "candor-ts-0.4.2", toolchain: `node-${process.versions.node}`, spec: "0.4" },
|
|
769
787
|
package: pkgName, functions };
|
|
770
788
|
fs.writeFileSync(`${outPrefix}.json`, JSON.stringify(envelope, null, 1));
|
|
771
789
|
const cg = {};
|