etymd 0.2.1 → 0.3.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/CHANGELOG.md +71 -2
- package/README.md +276 -61
- package/dist/{approve-X3AW7KLD.js → approve-JEOEC2MV.js} +6 -4
- package/dist/audit-GYZ5YZ7U.js +12 -0
- package/dist/{brief-RT6KE4CN.js → brief-ZK7TXAC4.js} +6 -4
- package/dist/{chunk-4UZBCCFJ.js → chunk-3NYDVB4Z.js} +123 -25
- package/dist/chunk-CRJHIXJH.js +5 -0
- package/dist/chunk-EF6BPBG6.js +22 -0
- package/dist/chunk-LT67FU2Y.js +59 -0
- package/dist/{chunk-E2Q7WFPN.js → chunk-MKYPLNLH.js} +8 -5
- package/dist/{chunk-EUIHYD6F.js → chunk-MMPV67FW.js} +2 -2
- package/dist/{chunk-C4Z6NXDO.js → chunk-NFENQ3IK.js} +1 -1
- package/dist/{chunk-ANCCGYSH.js → chunk-NMZ3RHWW.js} +31 -59
- package/dist/{chunk-FZSIOCOZ.js → chunk-R74SJ7HS.js} +1 -1
- package/dist/{chunk-LBRNZZZF.js → chunk-TADKOW6P.js} +1 -99
- package/dist/{chunk-SS7VGLJ5.js → chunk-V3DPLOOM.js} +71 -15
- package/dist/{chunk-KBF3SW3N.js → chunk-WWBF4Y7K.js} +1 -1
- package/dist/{chunk-6W3J4PJ6.js → chunk-XTAX4YNT.js} +2 -2
- package/dist/chunk-YLNQQZ5F.js +102 -0
- package/dist/cli.js +50 -16
- package/dist/config-MX7OYI7F.js +4 -0
- package/dist/{context-GYCLR3TG.js → context-4DGXO7JR.js} +5 -3
- package/dist/doctor-C2RTL2QV.js +19 -0
- package/dist/{fleet-IS6YWDDV.js → fleet-YZGR4UC2.js} +243 -10
- package/dist/gates-ILE4PXDA.js +272 -0
- package/dist/generate-IYCQETQB.js +4 -0
- package/dist/index.d.ts +113 -33
- package/dist/index.js +777 -267
- package/dist/{init-ISEFZWPV.js → init-OVLO4OBZ.js} +8 -5
- package/dist/ledger-TMIV45AA.js +5 -0
- package/dist/{scan-ADZ2RKYY.js → scan-RAJUFTQR.js} +6 -4
- package/dist/scan-ZYZ7XDSJ.js +5 -0
- package/dist/screen-U7JMWZPS.js +134 -0
- package/package.json +2 -2
- package/dist/audit-YH74YZFQ.js +0 -9
- package/dist/doctor-EAA4IP4Y.js +0 -16
- package/dist/gates-3NPKF4IZ.js +0 -71
- package/dist/ledger-RHQJH5EA.js +0 -4
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execFile } from 'node:child_process';
|
|
3
|
+
import { promises } from 'node:fs';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
|
|
6
|
+
var pExecFile = promisify(execFile);
|
|
7
|
+
async function pathExists(p) {
|
|
8
|
+
try {
|
|
9
|
+
await promises.access(p);
|
|
10
|
+
return true;
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async function readJson(p) {
|
|
16
|
+
try {
|
|
17
|
+
const raw = await promises.readFile(p, "utf8");
|
|
18
|
+
return JSON.parse(raw);
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async function readText(p) {
|
|
24
|
+
try {
|
|
25
|
+
return await promises.readFile(p, "utf8");
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function isDirectory(p) {
|
|
31
|
+
try {
|
|
32
|
+
return (await promises.stat(p)).isDirectory();
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function git(root, args) {
|
|
38
|
+
try {
|
|
39
|
+
const { stdout } = await pExecFile("git", args, { cwd: root, timeout: 4e3 });
|
|
40
|
+
return stdout.trim();
|
|
41
|
+
} catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function wordCount(text) {
|
|
46
|
+
const m = text.trim().match(/\S+/g);
|
|
47
|
+
return m ? m.length : 0;
|
|
48
|
+
}
|
|
49
|
+
function approxTokens(words) {
|
|
50
|
+
return Math.round(words / 0.75);
|
|
51
|
+
}
|
|
52
|
+
var CI_ENV_VARS = [
|
|
53
|
+
"CI",
|
|
54
|
+
"GITHUB_ACTIONS",
|
|
55
|
+
"GITLAB_CI",
|
|
56
|
+
"BUILDKITE",
|
|
57
|
+
"CIRCLECI",
|
|
58
|
+
"JENKINS_URL",
|
|
59
|
+
"TF_BUILD"
|
|
60
|
+
];
|
|
61
|
+
function isCiEnvironment() {
|
|
62
|
+
return CI_ENV_VARS.some((v) => Boolean(process.env[v]));
|
|
63
|
+
}
|
|
64
|
+
function normalizeRelPath(p) {
|
|
65
|
+
return p.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
|
|
66
|
+
}
|
|
67
|
+
function globToRegExp(glob) {
|
|
68
|
+
let re = "";
|
|
69
|
+
for (let i = 0; i < glob.length; i++) {
|
|
70
|
+
const c = glob[i];
|
|
71
|
+
if (c === "*") {
|
|
72
|
+
if (glob[i + 1] === "*") {
|
|
73
|
+
i += 1;
|
|
74
|
+
if (glob[i + 1] === "/") {
|
|
75
|
+
i += 1;
|
|
76
|
+
re += "(?:.*/)?";
|
|
77
|
+
} else {
|
|
78
|
+
re += ".*";
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
re += "[^/]*";
|
|
82
|
+
}
|
|
83
|
+
} else if (c === "?") {
|
|
84
|
+
re += "[^/]";
|
|
85
|
+
} else {
|
|
86
|
+
re += c.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return new RegExp(`^${re}$`);
|
|
90
|
+
}
|
|
91
|
+
function matchesGlob(p, glob) {
|
|
92
|
+
const target = normalizeRelPath(p);
|
|
93
|
+
const pattern = normalizeRelPath(glob);
|
|
94
|
+
if (!pattern) return false;
|
|
95
|
+
if (!/[*?]/.test(pattern)) return target === pattern || target.startsWith(pattern + "/");
|
|
96
|
+
return globToRegExp(pattern).test(target);
|
|
97
|
+
}
|
|
98
|
+
function matchesAnyGlob(p, globs) {
|
|
99
|
+
return globs.some((g) => matchesGlob(p, g));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { approxTokens, git, isCiEnvironment, isDirectory, matchesAnyGlob, normalizeRelPath, pathExists, readJson, readText, wordCount };
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { VERSION } from './chunk-
|
|
2
|
+
import { VERSION } from './chunk-NFENQ3IK.js';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { Command } from 'commander';
|
|
5
5
|
import pc from 'picocolors';
|
|
@@ -31,7 +31,7 @@ program.command("audit").description("Verify every instruction claim against the
|
|
|
31
31
|
"exit non-zero when findings at/above this tier exist (risk|gap|polish)"
|
|
32
32
|
).action(
|
|
33
33
|
(opts, cmd) => action(async () => {
|
|
34
|
-
const { run } = await import('./audit-
|
|
34
|
+
const { run } = await import('./audit-GYZ5YZ7U.js');
|
|
35
35
|
await run({
|
|
36
36
|
cwd: resolveCwd(cmd),
|
|
37
37
|
json: opts.json,
|
|
@@ -44,7 +44,7 @@ program.command("audit").description("Verify every instruction claim against the
|
|
|
44
44
|
);
|
|
45
45
|
program.command("init").description("Onboard the truth guard: approve the baseline; scaffold AGENTS.md only if missing").option("-y, --yes", "accept defaults without prompting (never overwrites)").action(
|
|
46
46
|
(opts, cmd) => action(async () => {
|
|
47
|
-
const { run } = await import('./init-
|
|
47
|
+
const { run } = await import('./init-OVLO4OBZ.js');
|
|
48
48
|
await run({ cwd: resolveCwd(cmd), yes: opts.yes });
|
|
49
49
|
})
|
|
50
50
|
);
|
|
@@ -52,49 +52,49 @@ program.command("approve").description(
|
|
|
52
52
|
"Re-approve the committed baseline after intentional structural changes (non-interactive)"
|
|
53
53
|
).action(
|
|
54
54
|
(_opts, cmd) => action(async () => {
|
|
55
|
-
const { run } = await import('./approve-
|
|
55
|
+
const { run } = await import('./approve-JEOEC2MV.js');
|
|
56
56
|
await run({ cwd: resolveCwd(cmd) });
|
|
57
57
|
})
|
|
58
58
|
);
|
|
59
59
|
program.command("scan").description("Deterministically reckon the project into a facts index").option("--json", "print the raw facts as JSON").option("--no-save", "do not write the .etymd cache").action(
|
|
60
60
|
(opts, cmd) => action(async () => {
|
|
61
|
-
const { run } = await import('./scan-
|
|
61
|
+
const { run } = await import('./scan-RAJUFTQR.js');
|
|
62
62
|
await run({ cwd: resolveCwd(cmd), json: opts.json, save: opts.save });
|
|
63
63
|
})
|
|
64
64
|
);
|
|
65
65
|
program.command("doctor").description('Alias for `audit --truth` \u2014 "are the recorded instructions still true?"').option("--json", "print findings as JSON").action(
|
|
66
66
|
(opts, cmd) => action(async () => {
|
|
67
|
-
const { run } = await import('./doctor-
|
|
67
|
+
const { run } = await import('./doctor-C2RTL2QV.js');
|
|
68
68
|
await run({ cwd: resolveCwd(cmd), json: opts.json });
|
|
69
69
|
})
|
|
70
70
|
);
|
|
71
71
|
program.command("context").description("Measure the always-loaded context footprint and flag extraction candidates").option("--json", "print the budget as JSON").action(
|
|
72
72
|
(opts, cmd) => action(async () => {
|
|
73
|
-
const { run } = await import('./context-
|
|
73
|
+
const { run } = await import('./context-4DGXO7JR.js');
|
|
74
74
|
await run({ cwd: resolveCwd(cmd), json: opts.json });
|
|
75
75
|
})
|
|
76
76
|
);
|
|
77
77
|
program.command("brief").description("Emit a grounded briefing for the in-repo agent to complete the semantic layer").option("--human", "write a human onboarding brief instead of the agent briefing").action(
|
|
78
78
|
(opts, cmd) => action(async () => {
|
|
79
|
-
const { run } = await import('./brief-
|
|
79
|
+
const { run } = await import('./brief-ZK7TXAC4.js');
|
|
80
80
|
await run({ cwd: resolveCwd(cmd), human: opts.human });
|
|
81
81
|
})
|
|
82
82
|
);
|
|
83
83
|
program.command("ledger").description("List every tracked finding grouped by status (open \xB7 accepted \xB7 dismissed \xB7 \u2026)").option("--json", "print the raw ledger as JSON").action(
|
|
84
84
|
(opts, cmd) => action(async () => {
|
|
85
|
-
const { list } = await import('./ledger-
|
|
85
|
+
const { list } = await import('./ledger-TMIV45AA.js');
|
|
86
86
|
await list({ cwd: resolveCwd(cmd), json: opts.json });
|
|
87
87
|
})
|
|
88
88
|
);
|
|
89
89
|
program.command("dismiss").argument("<finding-id>", "the finding id (from `etymd audit`) to dismiss").description("Dismiss a finding as a false positive / not applicable (hidden from future audits)").requiredOption("--reason <text>", "why it is dismissed \u2014 recorded so the decision survives").action(
|
|
90
90
|
(id, opts, cmd) => action(async () => {
|
|
91
|
-
const { dismiss } = await import('./ledger-
|
|
91
|
+
const { dismiss } = await import('./ledger-TMIV45AA.js');
|
|
92
92
|
await dismiss({ cwd: resolveCwd(cmd), id, reason: opts.reason });
|
|
93
93
|
})
|
|
94
94
|
);
|
|
95
95
|
program.command("accept").argument("<finding-id>", "the finding id (from `etymd audit`) to accept").description("Accept a real finding as a known trade-off (hidden from future audits)").option("--reason <text>", "optional note on why the trade-off is accepted").action(
|
|
96
96
|
(id, opts, cmd) => action(async () => {
|
|
97
|
-
const { accept } = await import('./ledger-
|
|
97
|
+
const { accept } = await import('./ledger-TMIV45AA.js');
|
|
98
98
|
await accept({ cwd: resolveCwd(cmd), id, reason: opts.reason });
|
|
99
99
|
})
|
|
100
100
|
);
|
|
@@ -111,7 +111,7 @@ var fleet = program.command("fleet").description(
|
|
|
111
111
|
"exit non-zero when findings at/above this tier exist (risk|gap|polish)"
|
|
112
112
|
).action(
|
|
113
113
|
(opts, cmd) => action(async () => {
|
|
114
|
-
const { sweep } = await import('./fleet-
|
|
114
|
+
const { sweep } = await import('./fleet-YZGR4UC2.js');
|
|
115
115
|
await sweep({
|
|
116
116
|
cwd: resolveCwd(cmd),
|
|
117
117
|
manifest: opts.manifest,
|
|
@@ -126,16 +126,35 @@ var fleet = program.command("fleet").description(
|
|
|
126
126
|
);
|
|
127
127
|
fleet.command("check").description("Validate the manifest pair only \u2014 no lenses: dangling mappings, duplicates, leaks").option("--manifest <file>", "the fleet manifest \u2014 required unless the cwd holds registry.json").option("--json", "print the findings as JSON (EXPERIMENTAL through 0.2.x)").action(
|
|
128
128
|
(_opts, cmd) => action(async () => {
|
|
129
|
-
const { check } = await import('./fleet-
|
|
129
|
+
const { check } = await import('./fleet-YZGR4UC2.js');
|
|
130
130
|
const opts = cmd.optsWithGlobals();
|
|
131
131
|
await check({ cwd: resolveCwd(cmd), manifest: opts.manifest, json: opts.json });
|
|
132
132
|
})
|
|
133
133
|
);
|
|
134
|
+
fleet.command("add").argument("<dir>", "directory of the project to register").description("Register a project \u2014 refuses to write an entry missing a mandatory field").option("--name <name>", "registered name (defaults to the directory's basename)").option("--kind <kind>", "entry kind (defaults to a value derived from the scan)").option("--profile <profile>", "personal | corp (default: personal)").option(
|
|
135
|
+
"--trust <level>",
|
|
136
|
+
"public-repo | public-bound | private \u2014 mandatory for personal entries"
|
|
137
|
+
).option("-y, --yes", "skip prompts; every mandatory value must be passed as a flag").option("--manifest <file>", "the fleet manifest \u2014 required unless the cwd holds registry.json").action(
|
|
138
|
+
(dir, opts, cmd) => action(async () => {
|
|
139
|
+
const { add } = await import('./fleet-YZGR4UC2.js');
|
|
140
|
+
const shared = cmd.optsWithGlobals();
|
|
141
|
+
await add({
|
|
142
|
+
cwd: resolveCwd(cmd),
|
|
143
|
+
manifest: shared.manifest,
|
|
144
|
+
target: dir,
|
|
145
|
+
name: opts.name,
|
|
146
|
+
kind: opts.kind,
|
|
147
|
+
profile: opts.profile,
|
|
148
|
+
trust: opts.trust,
|
|
149
|
+
yes: opts.yes
|
|
150
|
+
});
|
|
151
|
+
})
|
|
152
|
+
);
|
|
134
153
|
fleet.command("dismiss").argument("<name>", "the registered project name").argument("<finding-id>", "the finding id (from `etymd fleet`) to dismiss").description(
|
|
135
154
|
"Dismiss a project's finding from any cwd \u2014 corp ledgers persist beside the manifest"
|
|
136
155
|
).requiredOption("--reason <text>", "why it is dismissed \u2014 recorded so the decision survives").option("--manifest <file>", "the fleet manifest \u2014 required unless the cwd holds registry.json").action(
|
|
137
156
|
(name, id, _opts, cmd) => action(async () => {
|
|
138
|
-
const { dismiss } = await import('./fleet-
|
|
157
|
+
const { dismiss } = await import('./fleet-YZGR4UC2.js');
|
|
139
158
|
const opts = cmd.optsWithGlobals();
|
|
140
159
|
await dismiss({
|
|
141
160
|
cwd: resolveCwd(cmd),
|
|
@@ -150,14 +169,29 @@ fleet.command("accept").argument("<name>", "the registered project name").argume
|
|
|
150
169
|
"Accept a project's finding as a known trade-off \u2014 corp ledgers persist beside the manifest"
|
|
151
170
|
).option("--reason <text>", "optional note on why the trade-off is accepted").option("--manifest <file>", "the fleet manifest \u2014 required unless the cwd holds registry.json").action(
|
|
152
171
|
(name, id, _opts, cmd) => action(async () => {
|
|
153
|
-
const { accept } = await import('./fleet-
|
|
172
|
+
const { accept } = await import('./fleet-YZGR4UC2.js');
|
|
154
173
|
const opts = cmd.optsWithGlobals();
|
|
155
174
|
await accept({ cwd: resolveCwd(cmd), manifest: opts.manifest, name, id, reason: opts.reason });
|
|
156
175
|
})
|
|
157
176
|
);
|
|
177
|
+
program.command("screen").description(
|
|
178
|
+
"Content screen: check for text that must never be published. Bring your own patterns \u2014 etymd ships none."
|
|
179
|
+
).option("--staged", "screen what a commit is about to add (default)").option("--tree", "screen every tracked file \u2014 what is about to leave the machine").option("--message <file>", "screen a commit message (the commit-msg hook's $1)").option("--dir <dir>", "screen an unpacked build artifact \u2014 what actually ships").option("--patterns <file>", "pattern file (default: ~/.config/etymd/screen-patterns)").option("--advisory", "report without failing").action(
|
|
180
|
+
(opts, cmd) => action(async () => {
|
|
181
|
+
const { run } = await import('./screen-U7JMWZPS.js');
|
|
182
|
+
const scope = opts.message ? "message" : opts.dir ? "dir" : opts.tree ? "tree" : "staged";
|
|
183
|
+
await run({
|
|
184
|
+
cwd: resolveCwd(cmd),
|
|
185
|
+
scope,
|
|
186
|
+
target: opts.message ?? opts.dir,
|
|
187
|
+
patterns: opts.patterns,
|
|
188
|
+
advisory: opts.advisory
|
|
189
|
+
});
|
|
190
|
+
})
|
|
191
|
+
);
|
|
158
192
|
program.command("gates").description("Install the local git-hook gates (process \u2192 pre-commit, correctness \u2192 pre-push)").option("--ci", "note about the CI review gate (ships later; local gates install now)").option("-y, --yes", "skip prompts; never overwrites a hand-edited hook").action(
|
|
159
193
|
(opts, cmd) => action(async () => {
|
|
160
|
-
const { run } = await import('./gates-
|
|
194
|
+
const { run } = await import('./gates-ILE4PXDA.js');
|
|
161
195
|
await run({ cwd: resolveCwd(cmd), ci: opts.ci, yes: opts.yes });
|
|
162
196
|
})
|
|
163
197
|
);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import './chunk-
|
|
4
|
-
import { print, renderContext } from './chunk-
|
|
2
|
+
import { measureContext } from './chunk-LT67FU2Y.js';
|
|
3
|
+
import { readConfig } from './chunk-NMZ3RHWW.js';
|
|
4
|
+
import { print, renderContext } from './chunk-TADKOW6P.js';
|
|
5
|
+
import './chunk-R74SJ7HS.js';
|
|
6
|
+
import './chunk-YLNQQZ5F.js';
|
|
5
7
|
|
|
6
8
|
// src/commands/context.ts
|
|
7
9
|
async function run(opts) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { run } from './chunk-XTAX4YNT.js';
|
|
3
|
+
import './chunk-V3DPLOOM.js';
|
|
4
|
+
import './chunk-LT67FU2Y.js';
|
|
5
|
+
import './chunk-WWBF4Y7K.js';
|
|
6
|
+
import './chunk-NMZ3RHWW.js';
|
|
7
|
+
import './chunk-TADKOW6P.js';
|
|
8
|
+
import './chunk-R74SJ7HS.js';
|
|
9
|
+
import './chunk-MKYPLNLH.js';
|
|
10
|
+
import './chunk-NFENQ3IK.js';
|
|
11
|
+
import './chunk-CRJHIXJH.js';
|
|
12
|
+
import './chunk-YLNQQZ5F.js';
|
|
13
|
+
|
|
14
|
+
// src/commands/doctor.ts
|
|
15
|
+
async function run2(opts) {
|
|
16
|
+
await run({ cwd: opts.cwd, json: opts.json, truth: true });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { run2 as run };
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { dismiss, accept } from './chunk-
|
|
3
|
-
import { parseFailOnTier, meetsFailOn, runAudit } from './chunk-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import './chunk-
|
|
7
|
-
import './chunk-
|
|
8
|
-
import { ETYMD_DIR } from './chunk-
|
|
9
|
-
import {
|
|
2
|
+
import { dismiss, accept } from './chunk-MMPV67FW.js';
|
|
3
|
+
import { parseFailOnTier, meetsFailOn, runAudit } from './chunk-V3DPLOOM.js';
|
|
4
|
+
import './chunk-LT67FU2Y.js';
|
|
5
|
+
import { readLedger } from './chunk-WWBF4Y7K.js';
|
|
6
|
+
import { DEFAULT_CONFIG } from './chunk-NMZ3RHWW.js';
|
|
7
|
+
import { print, theme, section, renderFleetRows, renderFleetNotes, renderFindings, TIER_BADGE, glyph } from './chunk-TADKOW6P.js';
|
|
8
|
+
import { ETYMD_DIR } from './chunk-R74SJ7HS.js';
|
|
9
|
+
import { scanProject } from './chunk-MKYPLNLH.js';
|
|
10
|
+
import './chunk-NFENQ3IK.js';
|
|
11
|
+
import './chunk-CRJHIXJH.js';
|
|
12
|
+
import { readText, pathExists, git, isDirectory } from './chunk-YLNQQZ5F.js';
|
|
10
13
|
import { promises } from 'node:fs';
|
|
11
14
|
import path from 'node:path';
|
|
15
|
+
import { select, isCancel, cancel, text, confirm } from '@clack/prompts';
|
|
12
16
|
import os from 'node:os';
|
|
13
17
|
import { execFile } from 'node:child_process';
|
|
14
18
|
import { promisify } from 'node:util';
|
|
15
19
|
|
|
20
|
+
var FLEET_TRUST_VALUES = ["public-repo", "public-bound", "private"];
|
|
21
|
+
function isFleetTrust(value) {
|
|
22
|
+
return typeof value === "string" && FLEET_TRUST_VALUES.includes(value);
|
|
23
|
+
}
|
|
16
24
|
function expandTilde(p) {
|
|
17
25
|
if (p === "~") return os.homedir();
|
|
18
26
|
if (p.startsWith("~/")) return path.join(os.homedir(), p.slice(2));
|
|
@@ -108,7 +116,10 @@ function loadRegistryEntries(projects, manifest, manifestFile) {
|
|
|
108
116
|
private: rec.private === true,
|
|
109
117
|
path: asString(rec.path),
|
|
110
118
|
upstream: asString(rec.upstream),
|
|
111
|
-
|
|
119
|
+
// An unknown value is NOT coerced to a default: trust gates content screening, so a typo
|
|
120
|
+
// must surface as "undeclared" (a finding) rather than quietly picking an answer.
|
|
121
|
+
trust: isFleetTrust(rec.trust) ? rec.trust : void 0,
|
|
122
|
+
trustRaw: asString(rec.trust),
|
|
112
123
|
staleAfterDays: typeof rec.staleAfterDays === "number" ? rec.staleAfterDays : void 0,
|
|
113
124
|
stateBudget: typeof rec.stateBudget === "number" ? rec.stateBudget : void 0,
|
|
114
125
|
contract,
|
|
@@ -225,6 +236,24 @@ async function loadFleetManifest(manifestPath) {
|
|
|
225
236
|
manifest.machineProfile = local.data.machineProfile === "corp" || local.data.machineProfile === "personal" ? local.data.machineProfile : void 0;
|
|
226
237
|
const rootRaw = asString(local.data.root) ?? asString(parsed.root);
|
|
227
238
|
if (rootRaw) manifest.root = path.resolve(dir, expandTilde(rootRaw));
|
|
239
|
+
const orientationRec = asRecord(parsed.orientation);
|
|
240
|
+
if (orientationRec) {
|
|
241
|
+
const orientationRoot = asString(orientationRec.root);
|
|
242
|
+
if (orientationRoot) manifest.orientation = { root: orientationRoot };
|
|
243
|
+
else {
|
|
244
|
+
manifest.problems.push({
|
|
245
|
+
kind: "bad-shape",
|
|
246
|
+
file: manifestFile,
|
|
247
|
+
detail: "`orientation` declares no `root` name \u2014 the fleet's orientation cannot be resolved"
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
} else if (parsed.orientation !== void 0) {
|
|
251
|
+
manifest.problems.push({
|
|
252
|
+
kind: "bad-shape",
|
|
253
|
+
file: manifestFile,
|
|
254
|
+
detail: '`orientation` must be an object (`{ "root": "<name>" }`) \u2014 ignored'
|
|
255
|
+
});
|
|
256
|
+
}
|
|
228
257
|
loadRegistryEntries(parsed.projects, manifest, manifestFile);
|
|
229
258
|
} else if (Array.isArray(parsed.sources)) {
|
|
230
259
|
manifest.shape = "corpus";
|
|
@@ -367,6 +396,19 @@ async function checkManifest(manifest) {
|
|
|
367
396
|
);
|
|
368
397
|
}
|
|
369
398
|
seen.add(entry.name);
|
|
399
|
+
if (entry.profile !== "corp" && !entry.private && !entry.trust) {
|
|
400
|
+
const bad = entry.trustRaw;
|
|
401
|
+
findings.push(
|
|
402
|
+
finding(
|
|
403
|
+
`${FLEET_LENS}/${bad ? "unknown-trust" : "undeclared-trust"}:${entry.name}`,
|
|
404
|
+
"risk",
|
|
405
|
+
bad ? `\`${entry.name}\` declares unknown trust \`${bad}\`` : `\`${entry.name}\` declares no \`trust\``,
|
|
406
|
+
[`${manifestFile}: ${entry.name}${bad ? `.trust = ${bad}` : " has no trust field"}`],
|
|
407
|
+
"Trust decides whether content screening applies. An unanswered entry is not a private one \u2014 publishing exposes ALL history, so a repo that went public without ever answering is exactly what a default would hide.",
|
|
408
|
+
`Declare one of ${FLEET_TRUST_VALUES.map((t) => `\`${t}\``).join(", ")}.`
|
|
409
|
+
)
|
|
410
|
+
);
|
|
411
|
+
}
|
|
370
412
|
if (entry.private && entry.path) {
|
|
371
413
|
findings.push(
|
|
372
414
|
finding(
|
|
@@ -421,6 +463,18 @@ async function checkManifest(manifest) {
|
|
|
421
463
|
}
|
|
422
464
|
}
|
|
423
465
|
}
|
|
466
|
+
if (manifest.orientation && !seen.has(manifest.orientation.root)) {
|
|
467
|
+
findings.push(
|
|
468
|
+
finding(
|
|
469
|
+
`${FLEET_LENS}/dangling-orientation:${manifest.orientation.root}`,
|
|
470
|
+
"gap",
|
|
471
|
+
`\`orientation.root\` names \`${manifest.orientation.root}\`, which is not a registered name`,
|
|
472
|
+
[`${manifestFile}: orientation.root = ${manifest.orientation.root}`],
|
|
473
|
+
"Every entry is guided by the orientation root implicitly \u2014 if it resolves to nothing, the whole fleet's orientation is a claim nothing can follow.",
|
|
474
|
+
"Point it at a registered name, or drop the block if this fleet has no orientation root."
|
|
475
|
+
)
|
|
476
|
+
);
|
|
477
|
+
}
|
|
424
478
|
for (const name of Object.keys(manifest.localDirs)) {
|
|
425
479
|
if (manifest.shape === "registry" && !seen.has(name)) {
|
|
426
480
|
findings.push(
|
|
@@ -631,6 +685,52 @@ async function checkCorpEmails(manifest, findings, disclosures) {
|
|
|
631
685
|
}
|
|
632
686
|
}
|
|
633
687
|
}
|
|
688
|
+
async function checkGateDrift(manifest, findings, disclosures) {
|
|
689
|
+
const { planWorkflow } = await import('./generate-IYCQETQB.js');
|
|
690
|
+
const { scanProject: scanProject2 } = await import('./scan-ZYZ7XDSJ.js');
|
|
691
|
+
const { readConfig } = await import('./config-MX7OYI7F.js');
|
|
692
|
+
for (const entry of manifest.entries) {
|
|
693
|
+
const root = entry.resolvedRoot;
|
|
694
|
+
if (!root || !await isDirectory(root)) continue;
|
|
695
|
+
if (entry.profile === "corp" || entry.private) continue;
|
|
696
|
+
const facts = await scanProject2(root);
|
|
697
|
+
if (!facts.git.isRepo) continue;
|
|
698
|
+
if (facts.hooks.source === "husky" || facts.hooks.source === "husky-legacy") {
|
|
699
|
+
disclosures.push(
|
|
700
|
+
`${entry.name}: hooks managed by ${facts.hooks.source} \u2014 gate drift not comparable against the .githooks pack`
|
|
701
|
+
);
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
const { config } = await readConfig(root);
|
|
705
|
+
const planned = (await planWorkflow(root, facts, { agents: false, gates: true, gateConfig: config.gates })).filter((f) => f.executable);
|
|
706
|
+
const missing = planned.filter((f) => !f.exists).map((f) => f.path);
|
|
707
|
+
const stale = planned.filter((f) => f.exists && f.differs).map((f) => f.path);
|
|
708
|
+
if (missing.length) {
|
|
709
|
+
findings.push(
|
|
710
|
+
finding(
|
|
711
|
+
`${FLEET_LENS}/gate-missing:${entry.name}`,
|
|
712
|
+
"gap",
|
|
713
|
+
`\`${entry.name}\` is missing ${missing.length} gate${missing.length === 1 ? "" : "s"} the pack would install`,
|
|
714
|
+
missing.map((m) => `${entry.name}: no ${m}`),
|
|
715
|
+
"A gate absent in one repo is invisible from inside it \u2014 every commit there skips a check its siblings run.",
|
|
716
|
+
"Run `etymd gates` in that repo."
|
|
717
|
+
)
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
if (stale.length) {
|
|
721
|
+
findings.push(
|
|
722
|
+
finding(
|
|
723
|
+
`${FLEET_LENS}/gate-stale:${entry.name}`,
|
|
724
|
+
"polish",
|
|
725
|
+
`\`${entry.name}\` has ${stale.length} gate${stale.length === 1 ? "" : "s"} that differ from what its own inputs generate`,
|
|
726
|
+
stale.map((s) => `${entry.name}: ${s}`),
|
|
727
|
+
"A hand-edited or outdated hook drifts from the pack silently \u2014 the repo believes it runs checks the file no longer contains.",
|
|
728
|
+
"Re-run `etymd gates` (it asks before overwriting), or record the intent in .etymd/config.json."
|
|
729
|
+
)
|
|
730
|
+
);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
634
734
|
async function collectWallFindings(manifest) {
|
|
635
735
|
const findings = [];
|
|
636
736
|
const disclosures = [];
|
|
@@ -639,6 +739,7 @@ async function collectWallFindings(manifest) {
|
|
|
639
739
|
await checkManifestRepoMachinePaths(manifest, findings, disclosures);
|
|
640
740
|
await checkHygieneNeedles(manifest, findings, disclosures);
|
|
641
741
|
await checkCorpEmails(manifest, findings, disclosures);
|
|
742
|
+
await checkGateDrift(manifest, findings, disclosures);
|
|
642
743
|
return { findings, disclosures };
|
|
643
744
|
}
|
|
644
745
|
function stateAgeDays(facts) {
|
|
@@ -971,6 +1072,138 @@ async function check(opts) {
|
|
|
971
1072
|
renderFindings(findings);
|
|
972
1073
|
renderFleetNotes([], disclosures);
|
|
973
1074
|
}
|
|
1075
|
+
async function add(opts) {
|
|
1076
|
+
const { manifest, autoNote } = await loadManifest(opts.cwd, opts.manifest);
|
|
1077
|
+
if (autoNote) print(` ${theme.dim(`\u25E6 ${autoNote}`)}`);
|
|
1078
|
+
if (manifest.shape !== "registry") {
|
|
1079
|
+
throw new Error("`fleet add` targets the registry shape \u2014 this manifest is a legacy corpus");
|
|
1080
|
+
}
|
|
1081
|
+
const raw = await readText(manifest.manifestPath);
|
|
1082
|
+
if (raw === null) throw new Error(`cannot read ${manifest.manifestPath}`);
|
|
1083
|
+
const absTarget = path.resolve(opts.cwd, opts.target);
|
|
1084
|
+
if (!await pathExists(absTarget)) throw new Error(`no such directory: ${absTarget}`);
|
|
1085
|
+
const name = opts.name ?? path.basename(absTarget);
|
|
1086
|
+
if (manifest.entries.some((e) => e.name === name)) {
|
|
1087
|
+
throw new Error(`\`${name}\` is already registered \u2014 resolution is keyed by name`);
|
|
1088
|
+
}
|
|
1089
|
+
const facts = await scanProject(absTarget);
|
|
1090
|
+
const remote = facts.git.isRepo ? await git(absTarget, ["remote", "get-url", "origin"]) : null;
|
|
1091
|
+
section(`Fleet add ${theme.dim(`\xB7 ${name} \xB7 ${absTarget}`)}`);
|
|
1092
|
+
let profile = opts.profile;
|
|
1093
|
+
if (!profile && !opts.yes) {
|
|
1094
|
+
const picked = await select({
|
|
1095
|
+
message: "Which side of the wall does this belong to?",
|
|
1096
|
+
initialValue: "personal",
|
|
1097
|
+
options: [
|
|
1098
|
+
{ value: "personal", label: "personal \u2014 your own work" },
|
|
1099
|
+
{ value: "corp", label: "corp \u2014 employer work (alias-only, machine-pinned)" }
|
|
1100
|
+
]
|
|
1101
|
+
});
|
|
1102
|
+
if (isCancel(picked)) {
|
|
1103
|
+
cancel("No entry written.");
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
profile = picked;
|
|
1107
|
+
}
|
|
1108
|
+
profile = profile ?? "personal";
|
|
1109
|
+
if (profile !== "personal" && profile !== "corp") {
|
|
1110
|
+
throw new Error(`--profile must be personal or corp, got \`${profile}\``);
|
|
1111
|
+
}
|
|
1112
|
+
const derivedKind = facts.commands.build || facts.commands.test ? "tool" : "repo";
|
|
1113
|
+
let kind = opts.kind;
|
|
1114
|
+
if (!kind && !opts.yes) {
|
|
1115
|
+
const known = [...new Set(manifest.entries.map((e) => e.kind).filter(Boolean))];
|
|
1116
|
+
const choices = [.../* @__PURE__ */ new Set([derivedKind, ...known])];
|
|
1117
|
+
const picked = await select({
|
|
1118
|
+
message: "Kind?",
|
|
1119
|
+
initialValue: derivedKind,
|
|
1120
|
+
options: [
|
|
1121
|
+
...choices.map((k) => ({
|
|
1122
|
+
value: k,
|
|
1123
|
+
label: k === derivedKind ? `${k} \u2014 matches this repo's shape` : k
|
|
1124
|
+
})),
|
|
1125
|
+
{ value: "", label: "something else\u2026" }
|
|
1126
|
+
]
|
|
1127
|
+
});
|
|
1128
|
+
if (isCancel(picked)) {
|
|
1129
|
+
cancel("No entry written.");
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
kind = picked;
|
|
1133
|
+
if (!kind) {
|
|
1134
|
+
const typed = await text({
|
|
1135
|
+
message: "Kind (free text):",
|
|
1136
|
+
validate: (v) => v.trim() ? void 0 : "a kind is required"
|
|
1137
|
+
});
|
|
1138
|
+
if (isCancel(typed)) {
|
|
1139
|
+
cancel("No entry written.");
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1142
|
+
kind = typed.trim();
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
kind = kind ?? derivedKind;
|
|
1146
|
+
let trust;
|
|
1147
|
+
if (profile === "personal") {
|
|
1148
|
+
trust = opts.trust;
|
|
1149
|
+
if (!trust && !opts.yes) {
|
|
1150
|
+
const picked = await select({
|
|
1151
|
+
message: "How exposed is this repo's history? (gates content screening)",
|
|
1152
|
+
options: [
|
|
1153
|
+
{ value: "private", label: "private \u2014 not destined to be published" },
|
|
1154
|
+
{ value: "public-bound", label: "public-bound \u2014 private now, plausibly public later" },
|
|
1155
|
+
{ value: "public-repo", label: "public-repo \u2014 already public" }
|
|
1156
|
+
]
|
|
1157
|
+
});
|
|
1158
|
+
if (isCancel(picked)) {
|
|
1159
|
+
cancel("No entry written.");
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
trust = picked;
|
|
1163
|
+
}
|
|
1164
|
+
if (!trust) {
|
|
1165
|
+
throw new Error(
|
|
1166
|
+
`\`${name}\` needs a trust level: pass --trust <${FLEET_TRUST_VALUES.join("|")}> (non-interactive runs cannot be prompted, and there is deliberately no default \u2014 trust gates content screening)`
|
|
1167
|
+
);
|
|
1168
|
+
}
|
|
1169
|
+
if (!isFleetTrust(trust)) {
|
|
1170
|
+
throw new Error(`--trust must be one of ${FLEET_TRUST_VALUES.join(", ")}, got \`${trust}\``);
|
|
1171
|
+
}
|
|
1172
|
+
} else if (opts.trust) {
|
|
1173
|
+
throw new Error("corp entries take no `trust` \u2014 `profile: corp` already implies it");
|
|
1174
|
+
}
|
|
1175
|
+
const entry = profile === "corp" ? { name, kind, profile, private: true } : {
|
|
1176
|
+
name,
|
|
1177
|
+
kind,
|
|
1178
|
+
profile,
|
|
1179
|
+
path: path.relative(manifest.root ?? manifest.dir, absTarget),
|
|
1180
|
+
trust,
|
|
1181
|
+
contract: {},
|
|
1182
|
+
links: {},
|
|
1183
|
+
// The scan does not collect remotes (they are not a workflow fact), so read it here —
|
|
1184
|
+
// recorded when present, simply absent when the repo has no origin yet.
|
|
1185
|
+
...remote ? { remote } : {}
|
|
1186
|
+
};
|
|
1187
|
+
print(` ${glyph.bullet} ${theme.dim("entry")}`);
|
|
1188
|
+
print(
|
|
1189
|
+
JSON.stringify(entry, null, 2).split("\n").map((l) => ` ${theme.dim(l)}`).join("\n")
|
|
1190
|
+
);
|
|
1191
|
+
if (!opts.yes) {
|
|
1192
|
+
const ok = await confirm({
|
|
1193
|
+
message: `Write this entry to ${path.basename(manifest.manifestPath)}?`
|
|
1194
|
+
});
|
|
1195
|
+
if (isCancel(ok) || !ok) {
|
|
1196
|
+
cancel("No entry written.");
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
const doc = JSON.parse(raw);
|
|
1201
|
+
if (!Array.isArray(doc.projects)) throw new Error("manifest has no `projects` array to append to");
|
|
1202
|
+
doc.projects.push(entry);
|
|
1203
|
+
await promises.writeFile(manifest.manifestPath, JSON.stringify(doc, null, 2) + "\n", "utf8");
|
|
1204
|
+
print(` ${glyph.ok} ${theme.dim("registered")} ${theme.info(name)}`);
|
|
1205
|
+
print(` ${theme.dim(`verify with \`etymd fleet check --manifest ${manifest.manifestPath}\``)}`);
|
|
1206
|
+
}
|
|
974
1207
|
async function resolveFleetFinding(opts, status) {
|
|
975
1208
|
if (status === "dismissed" && !opts.reason?.trim()) {
|
|
976
1209
|
throw new Error('dismiss needs a reason: etymd fleet dismiss <name> <id> --reason "\u2026"');
|
|
@@ -1001,4 +1234,4 @@ async function accept2(opts) {
|
|
|
1001
1234
|
await resolveFleetFinding(opts, "accepted");
|
|
1002
1235
|
}
|
|
1003
1236
|
|
|
1004
|
-
export { accept2 as accept, check, dismiss2 as dismiss, sweep };
|
|
1237
|
+
export { accept2 as accept, add, check, dismiss2 as dismiss, sweep };
|