candor-ts 0.5.0 → 0.5.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/AGENTS.md CHANGED
@@ -9,6 +9,12 @@ chains by hand.
9
9
  > the *installed* version — always prefer that over a vendored or fetched copy, which can describe
10
10
  > a different candor-ts than the one you are running.
11
11
 
12
+ > **Staying current is your job, not candor's.** candor never phones home — it audits and denies the
13
+ > Net effect, so it will not reach the network to check itself. `candor-ts --version` prints the
14
+ > installed build, the spec contract it speaks, and the upgrade line (`npm install -g
15
+ > candor-ts@latest`) — fully offline. You have the network: read the installed version here, compare
16
+ > it against npm, and upgrade if it is stale. Every command is offline.
17
+
12
18
  The language-agnostic consumption contract is
13
19
  [candor-spec/AGENTS.md](https://github.com/tombaldwin/candor-spec/blob/main/AGENTS.md); this file is
14
20
  the TypeScript-specific production + query surface.
package/README.md CHANGED
@@ -20,6 +20,8 @@ node scan.mjs <project-dir> # tsconfig.json honored; tests exclu
20
20
  # <dir>/.candor/report.json + .callgraph.json
21
21
  node scan.mjs . --policy .candor/policy # the §6.2 gate: exit 1 on violation, 2 if unreadable
22
22
 
23
+ node scan.mjs --version # installed build + spec contract (offline), + upgrade line
24
+
23
25
  node query.mjs show .candor/report db.save 1 # a function's effects (match ladder)
24
26
  node query.mjs where .candor/report Net 1 # direct sources vs inheritors
25
27
  node query.mjs callers .candor/report db.save 1 # the blast radius (transitive callers)
@@ -28,6 +30,8 @@ node query.mjs whatif .candor/report db.save Net policy # pre-edit gate verdi
28
30
  node query.mjs diff .candor/report baseline 1 # per-function effect delta (exit 1 on a gain)
29
31
  ```
30
32
 
33
+ **Staying current:** check your installed version and upgrade — [candor/AGENTS.md §2a](https://github.com/tombaldwin/candor/blob/main/AGENTS.md#2a-staying-current--check-the-version-upgrade). `npx -y candor-ts --version` prints the build, the spec, and the upgrade one-liner (offline; candor never phones home).
34
+
31
35
  Function names are module-qualified with `.` segments (`src.db.save`), so policy scopes read
32
36
  naturally:
33
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "candor-ts",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "candor for TypeScript — per-function side effects, transitively, with a policy gate (candor-spec 0.5)",
5
5
  "type": "module",
6
6
  "dependencies": {
package/scan.mjs CHANGED
@@ -30,12 +30,29 @@ import { isTestPath, kappa, kappaKnows, commandHeadEffects, hostLiteral, tablesI
30
30
 
31
31
  const ENGINE_DIR = path.dirname(fileURLToPath(import.meta.url));
32
32
 
33
+ // The single version + spec sources, read once. PKG_VERSION is the bare semver from package.json
34
+ // (e.g. "0.5.0"); ENGINE_VERSION (below) prefixes it for the report envelope's `version` field, and
35
+ // `--version` prints the bare form. SPEC_VERSION is the spec contract this build speaks — the SAME
36
+ // literal stamped into the envelope's `spec` field, so the doc lines and the report can never drift.
37
+ // Reused, never re-littered.
38
+ const PKG_VERSION = JSON.parse(fs.readFileSync(path.join(ENGINE_DIR, "package.json"), "utf8")).version;
39
+ const SPEC_VERSION = "0.5";
40
+
41
+ // --version: a print-and-exit MODE, handled before the main arg walk so it never depends on a target.
42
+ // Fully OFFLINE — candor never phones home. Staying current is the AGENT's job: read the installed
43
+ // build + upgrade line here, then (the agent has the network) compare against npm and upgrade.
44
+ if (process.argv.includes("--version")) {
45
+ console.log(`candor-ts ${PKG_VERSION} (spec ${SPEC_VERSION})`);
46
+ console.log("upgrade: npm install -g candor-ts@latest");
47
+ process.exit(0);
48
+ }
49
+
33
50
  // ---- args ----------------------------------------------------------------------------------------
34
51
  // ONE pass: the first non-flag is the target; value-taking flags consume the next arg and FAIL on a
35
52
  // missing/flag-shaped value; an unknown flag fails; flags may precede the target. `--agents` is a
36
53
  // flag (a print-and-exit MODE) — it must NOT fire when it is the VALUE of --out/--policy, which the
37
54
  // value-consuming skip handles, nor produce a "lying unknown flag" error for a real flag given first.
38
- const usage = "usage: candor-ts <dir | file.ts | tsconfig.json> [--out <prefix>] [--policy <file>] [--allow-js] [--agents]";
55
+ const usage = "usage: candor-ts <dir | file.ts | tsconfig.json> [--out <prefix>] [--policy <file>] [--allow-js] [--agents] [--version]";
39
56
  const argv = process.argv.slice(2);
40
57
  let target = null, outPrefix = null, policyPath = process.env.CANDOR_POLICY ?? null, allowJs = false, wantAgents = false;
41
58
  for (let i = 0; i < argv.length; i++) {
@@ -175,7 +192,7 @@ fs.mkdirSync(path.dirname(path.resolve(outPrefix)), { recursive: true });
175
192
  // ONE version source: package.json. A second hardcoded literal (the envelope's, the --agents
176
193
  // banner's) that drifted from this would make the engine distrust its OWN reports at the §2.1
177
194
  // staleness check (`d.candor?.version !== ENGINE_VERSION`), silently downgrading every chained dep.
178
- const ENGINE_VERSION = `candor-ts-${JSON.parse(fs.readFileSync(path.join(ENGINE_DIR, "package.json"), "utf8")).version}`;
195
+ const ENGINE_VERSION = `candor-ts-${PKG_VERSION}`;
179
196
  const crossDeps = new Map(); // hash -> {inferred:Set, hosts:[], cmds:[], paths:[], tables:[]}
180
197
  // Packages a loaded sibling report COVERS — exempt from the κ ledger even when a call joins no
181
198
  // entry (reports omit pure functions: the silence is the purity claim, SPEC §2 rule 3 — the
@@ -822,7 +839,7 @@ for (const [name, rec] of fns) {
822
839
  }
823
840
  // `package` names what this report COVERS — a consumer chaining it registers coverage even when
824
841
  // `functions` is empty (an all-pure package's report is its purity claim, SPEC §2 rule 3).
825
- const envelope = { candor: { version: ENGINE_VERSION, toolchain: `node-${process.versions.node}`, spec: "0.5" },
842
+ const envelope = { candor: { version: ENGINE_VERSION, toolchain: `node-${process.versions.node}`, spec: SPEC_VERSION },
826
843
  package: pkgName, functions };
827
844
  const cg = {};
828
845
  for (const [name, rec] of fns) cg[name] = [...rec.edges].sort();