oc-harness-setup 0.3.2 → 0.4.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/.docs/unwired-routing.md +16 -15
- package/AGENTS.md +105 -68
- package/CHANGELOG.md +91 -0
- package/GLOSSARY.md +46 -0
- package/LICENSE +1 -1
- package/README.md +48 -61
- package/agents/cleaner.md +86 -0
- package/agents/critic.md +79 -0
- package/agents/historian.md +92 -0
- package/agents/maintainer.md +106 -0
- package/agents/ops.md +69 -0
- package/agents/orchestrator.md +48 -18
- package/agents/researcher.md +72 -0
- package/agents/verifier.md +84 -0
- package/agents/worker.md +87 -0
- package/bin/cli.js +349 -133
- package/commands/close.md +11 -0
- package/commands/evolve.md +11 -0
- package/commands/fast.md +11 -0
- package/commands/goal.md +11 -0
- package/commands/search.md +11 -0
- package/commands/swarm.md +11 -0
- package/opencode.jsonc +42 -80
- package/package.json +13 -6
- package/reference/README.md +12 -14
- package/reference/canon.md +71 -0
- package/reference/context.md +35 -0
- package/reference/enforcement.md +6 -0
- package/reference/flow.md +19 -0
- package/reference/gates.md +23 -0
- package/reference/harness.md +15 -0
- package/reference/hygiene.md +13 -0
- package/reference/memory.md +13 -0
- package/reference/models.md +19 -24
- package/reference/phases.md +23 -0
- package/reference/repos.md +49 -0
- package/reference/tools.md +35 -0
- package/scripts/harness-doctor.ps1 +83 -0
- package/skills/close/SKILL.md +36 -0
- package/skills/evolve/SKILL.md +76 -0
- package/skills/fast/SKILL.md +36 -0
- package/skills/goal/SKILL.md +65 -0
- package/skills/search/SKILL.md +68 -0
- package/skills/swarm/SKILL.md +69 -0
- package/state-seed/lessons.md +22 -0
- package/state-seed/template.md +12 -0
- package/agents/build.md +0 -20
- package/agents/explore.md +0 -26
- package/agents/general.md +0 -19
- package/agents/plan.md +0 -29
- package/agents/reviewer.md +0 -22
- package/agents/vault.md +0 -73
- package/commands/build.md +0 -7
- package/commands/checkpoint.md +0 -7
- package/commands/code-simplify.md +0 -7
- package/commands/gauntlet.md +0 -7
- package/commands/handoff.md +0 -7
- package/commands/keeper.md +0 -7
- package/commands/kill.md +0 -11
- package/commands/plan.md +0 -7
- package/commands/retro.md +0 -15
- package/commands/review.md +0 -7
- package/commands/ship.md +0 -7
- package/commands/spec.md +0 -7
- package/commands/test.md +0 -7
- package/commands/webperf.md +0 -7
- package/reference/auto-mandate.md +0 -11
- package/reference/backup-convention.md +0 -9
- package/reference/clean-mandate.md +0 -13
- package/reference/editor-parity.md +0 -7
- package/reference/gc-scripts.md +0 -8
- package/reference/intent-routing.md +0 -14
- package/reference/lifecycle.md +0 -15
- package/reference/model-keeper.md +0 -46
- package/reference/model-test.md +0 -176
- package/reference/oc-source-map.md +0 -162
- package/reference/owner-pin.md +0 -31
- package/reference/roster.md +0 -15
- package/reference/session-scope.md +0 -9
- package/reference/session-state.md +0 -13
- package/reference/swarm.md +0 -32
- package/scripts/backup-config.ps1 +0 -42
- package/scripts/gc-branch.ps1 +0 -196
- package/scripts/gc-bump.ps1 +0 -198
- package/scripts/gc-clean.ps1 +0 -648
- package/scripts/gc-commit.ps1 +0 -143
- package/scripts/gc-merge.ps1 +0 -272
- package/scripts/gc-pr.ps1 +0 -190
- package/scripts/gc-push.ps1 +0 -111
- package/scripts/gc-read.ps1 +0 -150
- package/scripts/gc-rebase.ps1 +0 -162
- package/scripts/gc-release.ps1 +0 -225
- package/scripts/gc-stage.ps1 +0 -103
- package/scripts/gc-status.ps1 +0 -127
- package/scripts/gc-sync.ps1 +0 -65
- package/scripts/gc.core.ps1 +0 -715
- package/scripts/gc.smoke.ps1 +0 -779
- package/scripts/interrupt-session.ps1 +0 -65
- package/scripts/logbook/README.md +0 -108
- package/scripts/logbook/logbook.test.ts +0 -440
- package/scripts/logbook/logbook.ts +0 -797
- package/scripts/pirep/README.md +0 -147
- package/scripts/pirep/pirep.test.ts +0 -735
- package/scripts/pirep/pirep.ts +0 -836
- package/scripts/testflight/README.md +0 -112
- package/scripts/testflight/testflight.test.ts +0 -512
- package/scripts/testflight/testflight.ts +0 -806
- package/skills/_shared/SOURCES.md +0 -26
- package/skills/_shared/references/accessibility-checklist.md +0 -160
- package/skills/_shared/references/definition-of-done.md +0 -67
- package/skills/_shared/references/observability-checklist.md +0 -92
- package/skills/_shared/references/orchestration-patterns.md +0 -155
- package/skills/_shared/references/performance-checklist.md +0 -236
- package/skills/_shared/references/security-checklist.md +0 -245
- package/skills/_shared/references/testing-patterns.md +0 -235
- package/skills/api-and-interface-design/SKILL.md +0 -14
- package/skills/browser-testing-with-devtools/SKILL.md +0 -303
- package/skills/code-simplification/SKILL.md +0 -14
- package/skills/creative-writing/SKILL.md +0 -96
- package/skills/debugging-and-error-recovery/SKILL.md +0 -15
- package/skills/flight-deck/SKILL.md +0 -17
- package/skills/frontend-ui-engineering/SKILL.md +0 -16
- package/skills/gauntlet/SKILL.md +0 -21
- package/skills/git-ceremony/SKILL.md +0 -27
- package/skills/grilling/SKILL.md +0 -18
- package/skills/observability-and-instrumentation/SKILL.md +0 -18
- package/skills/performance-optimization/SKILL.md +0 -16
- package/skills/pilot-report/SKILL.md +0 -18
- package/skills/planning-and-task-breakdown/SKILL.md +0 -16
- package/skills/security-and-hardening/SKILL.md +0 -18
- package/skills/source-driven-development/SKILL.md +0 -16
- package/skills/spec-driven-development/SKILL.md +0 -26
- package/skills/test-driven-development/SKILL.md +0 -18
- package/skills/test-flight/SKILL.md +0 -14
- package/skills/writing-for-agents/SKILL-MECHANICS.md +0 -22
- package/skills/writing-for-agents/SKILL.md +0 -89
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
# testflight
|
|
2
|
-
|
|
3
|
-
**Check the artifact you are about to publish — not the checkout you built it in.**
|
|
4
|
-
|
|
5
|
-
Your working copy lies to you. It has `node_modules` full of packages that a
|
|
6
|
-
consumer's install will never produce, it has files that `.gitignore` or `files`
|
|
7
|
-
will quietly drop, and it has paths that only exist on your machine.
|
|
8
|
-
|
|
9
|
-
`npm pack --dry-run` will not catch any of it. It lists files. It does not
|
|
10
|
-
install them and it does not resolve them.
|
|
11
|
-
|
|
12
|
-
Test Flight packs the real tarball, installs it into an empty project, and loads
|
|
13
|
-
it. Then it tells you, in plain language, what a user would have hit.
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
testflight . # pack, inspect, install, resolve
|
|
17
|
-
testflight . --no-install # static checks only — fast, no network
|
|
18
|
-
testflight . --import # also load the declared entry points
|
|
19
|
-
testflight ./pkg-1.0.0.tgz # check a tarball you already have
|
|
20
|
-
testflight . --json
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Exit codes: `0` clean (warnings allowed) · `1` findings · `2` could not run.
|
|
24
|
-
|
|
25
|
-
## The two bugs this exists for
|
|
26
|
-
|
|
27
|
-
Both shipped in a real package. Both passed `npm pack --dry-run` with a clean
|
|
28
|
-
file list. Both worked perfectly on the machine they were built on.
|
|
29
|
-
|
|
30
|
-
**The optional peer.** A package declared `@opentui/solid` in
|
|
31
|
-
`peerDependencies`, then listed it in `peerDependenciesMeta` as `optional: true`
|
|
32
|
-
so local development would stop complaining. npm believes you: it skips optional
|
|
33
|
-
peers at install time. The package installed cleanly and died on first import
|
|
34
|
-
with `Cannot find package '@opentui/solid'`. The fix is one `npm deprecate`, and
|
|
35
|
-
the only reliable way to have caught it was to install the thing.
|
|
36
|
-
|
|
37
|
-
**The duplicated peer.** A plugin bundled its own copy of a module the host also
|
|
38
|
-
provides. Two instances load, module identity differs, and state shared across
|
|
39
|
-
that boundary silently stops working — no error, no warning, just a component
|
|
40
|
-
that renders fine and never updates. The checkout cannot show you this, because
|
|
41
|
-
the checkout only has one copy.
|
|
42
|
-
|
|
43
|
-
Neither is exotic. Both are one line of manifest.
|
|
44
|
-
|
|
45
|
-
## What it actually does
|
|
46
|
-
|
|
47
|
-
1. **Packs the real tarball.** `npm pack`, not the working directory.
|
|
48
|
-
2. **Extracts it and reads the published `package.json`.** `files`, `main`,
|
|
49
|
-
`exports`, and `peerDependencies` as npm rewrote them — including anything a
|
|
50
|
-
`prepack` script generated.
|
|
51
|
-
3. **Verifies every declared entry point is inside the tarball.** The most
|
|
52
|
-
common release bug there is: a `files` whitelist that forgot the build
|
|
53
|
-
directory. The package installs, and importing it throws.
|
|
54
|
-
4. **Checks the peer relationships.** A peer that is also a runtime
|
|
55
|
-
dependency is a second copy waiting to happen. A peer marked optional that
|
|
56
|
-
shipped code statically imports is a guaranteed install-time crash.
|
|
57
|
-
5. **Greps the packed bytes for machine-specific paths.** `file:///C:/...`,
|
|
58
|
-
`/Users/<name>/`, `C:/Users/<name>/`. A path that names one machine is a package
|
|
59
|
-
that works on one machine.
|
|
60
|
-
6. **Installs into a throwaway project and confirms every peer resolved.** The
|
|
61
|
-
step that `--dry-run` cannot do, and the step that catches the first bug
|
|
62
|
-
above.
|
|
63
|
-
|
|
64
|
-
## What it checks
|
|
65
|
-
|
|
66
|
-
| Code | Severity | Meaning |
|
|
67
|
-
|---|---|---|
|
|
68
|
-
| `TF001` | fail | A declared entry point is not in the tarball (usually a missing `files` entry) |
|
|
69
|
-
| `TF002` | fail / warn | A required peer marked optional that shipped code imports |
|
|
70
|
-
| `TF003` | fail | A peer that is also a runtime dependency — two copies at runtime |
|
|
71
|
-
| `TF004` | fail | A declared `bin` that is not packed |
|
|
72
|
-
| `TF005` | warn | A peer bundled inside the tarball |
|
|
73
|
-
| `TF010`–`TF014` | fail / warn | Packed files reference a machine-specific path |
|
|
74
|
-
| `TF020` | fail | `npm install` of the tarball failed in a clean project |
|
|
75
|
-
| `TF021` | info | An optional peer was skipped — correct, if nothing imports it |
|
|
76
|
-
| `TF022` | fail | A required peer did not resolve after a clean install |
|
|
77
|
-
| `TF023` | fail | The package itself is absent after install |
|
|
78
|
-
| `TF030` | fail / warn | A declared entry point threw when imported |
|
|
79
|
-
|
|
80
|
-
## What it cannot check
|
|
81
|
-
|
|
82
|
-
This matters more than the list above, so it is not buried.
|
|
83
|
-
|
|
84
|
-
- **Modules the host injects.** A plugin can load perfectly here and still fail
|
|
85
|
-
inside a bundled host binary that carries its own copy of a shared library.
|
|
86
|
-
Test Flight cannot reproduce that runtime; it can only tell you that the
|
|
87
|
-
packaging is not the cause. A green run is not "it works in the host".
|
|
88
|
-
- **Behaviour.** It proves the package loads. It does not prove it does anything
|
|
89
|
-
correct.
|
|
90
|
-
- **Dependency security.** That is a different tool's job.
|
|
91
|
-
|
|
92
|
-
Every run prints the first of these as a reminder. A check that overstates what
|
|
93
|
-
it proved is worse than no check.
|
|
94
|
-
|
|
95
|
-
## Wiring
|
|
96
|
-
|
|
97
|
-
- **CLI**, run through `bun`. No daemon, no server, no MCP.
|
|
98
|
-
- **Trigger:** the `test-flight` skill tells the agent to run this before any
|
|
99
|
-
publish.
|
|
100
|
-
- **Shim:** `~/.local/bin/testflight`.
|
|
101
|
-
- **Sandbox:** a fresh directory under the system temp dir, deleted afterwards
|
|
102
|
-
unless `--keep` is passed.
|
|
103
|
-
|
|
104
|
-
## Tests
|
|
105
|
-
|
|
106
|
-
```bash
|
|
107
|
-
cd scripts/testflight && bun test
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
38 tests. The manifest analyser and path scanner are tested as pure functions;
|
|
111
|
-
the end-to-end tests build real fixture packages, pack them, and assert that the
|
|
112
|
-
optional-peer release and the missing-`files` release are both caught.
|
|
@@ -1,512 +0,0 @@
|
|
|
1
|
-
import { afterAll, describe, expect, test } from "bun:test";
|
|
2
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
5
|
-
import {
|
|
6
|
-
analyseManifest,
|
|
7
|
-
check,
|
|
8
|
-
collectEntryPaths,
|
|
9
|
-
firstLines,
|
|
10
|
-
formatReport,
|
|
11
|
-
readTexts,
|
|
12
|
-
scanContents,
|
|
13
|
-
sortFindings,
|
|
14
|
-
summarise,
|
|
15
|
-
walkFiles,
|
|
16
|
-
type Finding,
|
|
17
|
-
type PackedFile,
|
|
18
|
-
} from "./testflight";
|
|
19
|
-
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
21
|
-
// helpers
|
|
22
|
-
// ---------------------------------------------------------------------------
|
|
23
|
-
|
|
24
|
-
const sandboxes: string[] = [];
|
|
25
|
-
|
|
26
|
-
function sandbox(): string {
|
|
27
|
-
const dir = mkdtempSync(join(tmpdir(), "testflight-test-"));
|
|
28
|
-
sandboxes.push(dir);
|
|
29
|
-
return dir;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
afterAll(() => {
|
|
33
|
-
for (const dir of sandboxes) {
|
|
34
|
-
try {
|
|
35
|
-
rmSync(dir, { recursive: true, force: true });
|
|
36
|
-
} catch {
|
|
37
|
-
/* the OS temp dir is cleaned up eventually */
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
/** A file list as `walkFiles` would produce, without touching the disk. */
|
|
43
|
-
function packed(paths: string[], size = 10): PackedFile[] {
|
|
44
|
-
return paths.map((path) => ({ path, size, abs: join("Z:\\nonexistent", path) }));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function writePackage(dir: string, manifest: Record<string, unknown>, files: Record<string, string>) {
|
|
48
|
-
mkdirSync(dir, { recursive: true });
|
|
49
|
-
writeFileSync(join(dir, "package.json"), JSON.stringify(manifest, null, 2));
|
|
50
|
-
for (const [rel, content] of Object.entries(files)) {
|
|
51
|
-
const abs = join(dir, ...rel.split("/"));
|
|
52
|
-
mkdirSync(dirname(abs), { recursive: true });
|
|
53
|
-
writeFileSync(abs, content);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const codes = (findings: Finding[]) => findings.map((f) => f.code);
|
|
58
|
-
const find = (findings: Finding[], code: string) => findings.find((f) => f.code === code);
|
|
59
|
-
|
|
60
|
-
// ---------------------------------------------------------------------------
|
|
61
|
-
// collectEntryPaths
|
|
62
|
-
// ---------------------------------------------------------------------------
|
|
63
|
-
|
|
64
|
-
describe("collectEntryPaths", () => {
|
|
65
|
-
test("reads the plain string fields", () => {
|
|
66
|
-
const refs = collectEntryPaths({ main: "./dist/index.js", types: "dist/index.d.ts" });
|
|
67
|
-
expect(refs.map((r) => r.path)).toEqual(["dist/index.js", "dist/index.d.ts"]);
|
|
68
|
-
expect(refs.map((r) => r.field)).toEqual(["main", "types"]);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test("walks nested exports and their conditions", () => {
|
|
72
|
-
const refs = collectEntryPaths({
|
|
73
|
-
exports: {
|
|
74
|
-
".": { types: "./src/index.ts", import: "./src/index.ts" },
|
|
75
|
-
"./tui": { import: ["./src/tui/index.tsx", "./src/tui/fallback.ts"] },
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
expect(refs.map((r) => r.path).sort()).toEqual([
|
|
79
|
-
"src/index.ts",
|
|
80
|
-
"src/tui/fallback.ts",
|
|
81
|
-
"src/tui/index.tsx",
|
|
82
|
-
]);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test("skips wildcard patterns, which promise a shape and not a file", () => {
|
|
86
|
-
const refs = collectEntryPaths({ exports: { "./*": "./dist/*.js" } });
|
|
87
|
-
expect(refs).toHaveLength(0);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
test("reads bin as a string and as a map", () => {
|
|
91
|
-
expect(collectEntryPaths({ bin: "./cli.js" })[0].path).toBe("cli.js");
|
|
92
|
-
const mapped = collectEntryPaths({ bin: { testflight: "bin/run.js" } });
|
|
93
|
-
expect(mapped[0].path).toBe("bin/run.js");
|
|
94
|
-
expect(mapped[0].field).toBe("bin.testflight");
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test("ignores non-relative and empty values", () => {
|
|
98
|
-
expect(collectEntryPaths({ main: "" })).toHaveLength(0);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// ---------------------------------------------------------------------------
|
|
103
|
-
// analyseManifest — TF001..TF005
|
|
104
|
-
// ---------------------------------------------------------------------------
|
|
105
|
-
|
|
106
|
-
describe("analyseManifest", () => {
|
|
107
|
-
test("TF001: an entry point missing from the tarball is a failure", () => {
|
|
108
|
-
const findings = analyseManifest(
|
|
109
|
-
{ name: "x", main: "./dist/index.js", files: ["src"] },
|
|
110
|
-
packed(["package.json", "src/index.ts"]),
|
|
111
|
-
);
|
|
112
|
-
const finding = find(findings, "TF001");
|
|
113
|
-
expect(finding?.severity).toBe("error");
|
|
114
|
-
expect(finding?.title).toContain("dist/index.js");
|
|
115
|
-
expect(finding?.detail).toContain("files");
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
test("TF001: a directory entry point is satisfied by its contents", () => {
|
|
119
|
-
const findings = analyseManifest(
|
|
120
|
-
{ name: "x", main: "lib" },
|
|
121
|
-
packed(["package.json", "lib/index.js"]),
|
|
122
|
-
);
|
|
123
|
-
expect(codes(findings)).not.toContain("TF001");
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test("TF001: a case mismatch names both spellings", () => {
|
|
127
|
-
const findings = analyseManifest(
|
|
128
|
-
{ name: "x", main: "./dist/Index.js" },
|
|
129
|
-
packed(["package.json", "dist/index.js"]),
|
|
130
|
-
);
|
|
131
|
-
const finding = find(findings, "TF001");
|
|
132
|
-
expect(finding?.detail).toContain("dist/index.js");
|
|
133
|
-
expect(finding?.detail).toMatch(/case/i);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
test("TF002: an optional peer that shipped code imports is a failure", () => {
|
|
137
|
-
// This is the oc-flight-deck@0.1.0 release, reproduced.
|
|
138
|
-
const texts = new Map([
|
|
139
|
-
["src/index.ts", `import { render } from "@opentui/solid";\nexport const boot = render;`],
|
|
140
|
-
]);
|
|
141
|
-
const findings = analyseManifest(
|
|
142
|
-
{
|
|
143
|
-
name: "oc-flight-deck",
|
|
144
|
-
peerDependencies: { "@opentui/solid": ">=0.5.10" },
|
|
145
|
-
peerDependenciesMeta: { "@opentui/solid": { optional: true } },
|
|
146
|
-
},
|
|
147
|
-
packed(["package.json", "src/index.ts"]),
|
|
148
|
-
texts,
|
|
149
|
-
);
|
|
150
|
-
const finding = find(findings, "TF002");
|
|
151
|
-
expect(finding?.severity).toBe("error");
|
|
152
|
-
expect(finding?.title).toContain("@opentui/solid");
|
|
153
|
-
expect(finding?.evidence?.some((e) => e.includes("src/index.ts:1"))).toBe(true);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
test("TF002: require() counts as a static import too", () => {
|
|
157
|
-
const texts = new Map([["index.js", `const s = require("@opentui/solid");`]]);
|
|
158
|
-
const findings = analyseManifest(
|
|
159
|
-
{
|
|
160
|
-
name: "x",
|
|
161
|
-
peerDependencies: { "@opentui/solid": "*" },
|
|
162
|
-
peerDependenciesMeta: { "@opentui/solid": { optional: true } },
|
|
163
|
-
},
|
|
164
|
-
packed(["index.js"]),
|
|
165
|
-
texts,
|
|
166
|
-
);
|
|
167
|
-
expect(find(findings, "TF002")?.severity).toBe("error");
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
test("TF002: a dynamic import is only a warning", () => {
|
|
171
|
-
const texts = new Map([["index.js", `const load = () => import("@opentui/solid");`]]);
|
|
172
|
-
const findings = analyseManifest(
|
|
173
|
-
{
|
|
174
|
-
name: "x",
|
|
175
|
-
peerDependencies: { "@opentui/solid": "*" },
|
|
176
|
-
peerDependenciesMeta: { "@opentui/solid": { optional: true } },
|
|
177
|
-
},
|
|
178
|
-
packed(["index.js"]),
|
|
179
|
-
texts,
|
|
180
|
-
);
|
|
181
|
-
expect(find(findings, "TF002")?.severity).toBe("warn");
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
test("TF002: an unreferenced optional peer is informational, not a failure", () => {
|
|
185
|
-
const findings = analyseManifest(
|
|
186
|
-
{
|
|
187
|
-
name: "x",
|
|
188
|
-
peerDependencies: { "some-optional": "*" },
|
|
189
|
-
peerDependenciesMeta: { "some-optional": { optional: true } },
|
|
190
|
-
},
|
|
191
|
-
packed(["index.js"]),
|
|
192
|
-
new Map([["index.js", "export const nothing = 1;"]]),
|
|
193
|
-
);
|
|
194
|
-
expect(find(findings, "TF002")?.severity).toBe("info");
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
test("TF002: does not fire when the peer is not declared a peer at all", () => {
|
|
198
|
-
const findings = analyseManifest(
|
|
199
|
-
{ name: "x", peerDependenciesMeta: { ghost: { optional: true } } },
|
|
200
|
-
packed(["index.js"]),
|
|
201
|
-
new Map(),
|
|
202
|
-
);
|
|
203
|
-
expect(codes(findings)).not.toContain("TF002");
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
test("TF003: a peer that is also a runtime dependency is a failure", () => {
|
|
207
|
-
const findings = analyseManifest(
|
|
208
|
-
{ name: "x", peerDependencies: { "solid-js": ">=1.9.0" }, dependencies: { "solid-js": "^1.9.0" } },
|
|
209
|
-
packed(["package.json"]),
|
|
210
|
-
);
|
|
211
|
-
const finding = find(findings, "TF003");
|
|
212
|
-
expect(finding?.severity).toBe("error");
|
|
213
|
-
expect(finding?.evidence?.length).toBe(2);
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
test("TF003: a devDependency is not a duplicate instance and is not flagged", () => {
|
|
217
|
-
// oc-flight-deck ships solid-js as a peer *and* a devDependency. That is
|
|
218
|
-
// correct: devDependencies are not installed for consumers.
|
|
219
|
-
const findings = analyseManifest(
|
|
220
|
-
{
|
|
221
|
-
name: "oc-flight-deck",
|
|
222
|
-
peerDependencies: { "solid-js": ">=1.9.0" },
|
|
223
|
-
devDependencies: { "solid-js": "1.9.15" },
|
|
224
|
-
},
|
|
225
|
-
packed(["package.json"]),
|
|
226
|
-
);
|
|
227
|
-
expect(codes(findings)).not.toContain("TF003");
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
test("TF004: a declared bin that is not packed is a failure", () => {
|
|
231
|
-
const findings = analyseManifest(
|
|
232
|
-
{ name: "x", bin: { thing: "./bin/thing.js" } },
|
|
233
|
-
packed(["package.json"]),
|
|
234
|
-
);
|
|
235
|
-
expect(find(findings, "TF004")?.severity).toBe("error");
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
test("TF005: a peer bundled into the tarball is a warning", () => {
|
|
239
|
-
const findings = analyseManifest(
|
|
240
|
-
{ name: "x", peerDependencies: { "solid-js": "*" } },
|
|
241
|
-
packed(["package.json", "node_modules/solid-js/package.json"]),
|
|
242
|
-
);
|
|
243
|
-
expect(find(findings, "TF005")?.severity).toBe("warn");
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
test("TF000: a consistent package reports ok and nothing else", () => {
|
|
247
|
-
const findings = analyseManifest(
|
|
248
|
-
{ name: "x", main: "./dist/index.js" },
|
|
249
|
-
packed(["package.json", "dist/index.js"]),
|
|
250
|
-
);
|
|
251
|
-
expect(codes(findings)).toEqual(["TF000"]);
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
// ---------------------------------------------------------------------------
|
|
256
|
-
// scanContents — machine-specific paths
|
|
257
|
-
// ---------------------------------------------------------------------------
|
|
258
|
-
|
|
259
|
-
describe("scanContents", () => {
|
|
260
|
-
test("does not mistake an https URL for a Windows drive", () => {
|
|
261
|
-
// Regression: the first version flagged `https://github.com/...` because
|
|
262
|
-
// "s:" looked like a drive letter. That turned a clean package red.
|
|
263
|
-
const texts = new Map([
|
|
264
|
-
["package.json", `{"url":"git+https://github.com/alice/oc-flight-deck.git"}`],
|
|
265
|
-
["README.md", `See [the docs](https://opencode.ai/v2/docs/build/plugins/cli).`],
|
|
266
|
-
]);
|
|
267
|
-
expect(scanContents(texts)).toHaveLength(0);
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
test("flags a file:// URL pointing at a real host path as an error", () => {
|
|
271
|
-
const texts = new Map([["src/config.ts", `const p = "file:///C:/Users/alice/project";`]]);
|
|
272
|
-
const findings = scanContents(texts);
|
|
273
|
-
expect(findings[0]?.severity).toBe("error");
|
|
274
|
-
expect(findings[0]?.evidence?.[0]).toContain("src/config.ts:1");
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
test("flags a bare absolute Windows path as a warning", () => {
|
|
278
|
-
const texts = new Map([["src/config.ts", 'const home = "C:\\Users\\alice\\thing";']]);
|
|
279
|
-
const findings = scanContents(texts);
|
|
280
|
-
expect(findings[0]?.severity).toBe("warn");
|
|
281
|
-
expect(findings[0]?.title).toContain("absolute Windows path");
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
test("flags a bare POSIX home path as a warning", () => {
|
|
285
|
-
const texts = new Map([["README.md", "copy it to /Users/alice/.config/opencode"]]);
|
|
286
|
-
const findings = scanContents(texts);
|
|
287
|
-
expect(findings[0]?.severity).toBe("warn");
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
test("a plain file:// URL is a warning, not a failure", () => {
|
|
291
|
-
const findings = scanContents(new Map([["docs.md", "see file:///tmp/out.txt"]]));
|
|
292
|
-
expect(findings[0]?.severity).toBe("warn");
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
test("caps evidence so a repeated path cannot flood the report", () => {
|
|
296
|
-
const line = "C:\\Users\\alice\\thing\n";
|
|
297
|
-
const texts = new Map([["a.txt", line.repeat(50)]]);
|
|
298
|
-
expect(scanContents(texts)[0]?.evidence?.length).toBe(5);
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
test("a clean package produces no path findings", () => {
|
|
302
|
-
expect(scanContents(new Map([["src/index.ts", "export const x = 1;"]]))).toHaveLength(0);
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
// ---------------------------------------------------------------------------
|
|
307
|
-
// file walking and text reading
|
|
308
|
-
// ---------------------------------------------------------------------------
|
|
309
|
-
|
|
310
|
-
describe("walkFiles", () => {
|
|
311
|
-
test("returns relative POSIX paths and skips .git", () => {
|
|
312
|
-
const dir = sandbox();
|
|
313
|
-
writePackage(dir, { name: "x", version: "1.0.0" }, { "src/index.js": "1", "docs/a.md": "2" });
|
|
314
|
-
mkdirSync(join(dir, ".git"), { recursive: true });
|
|
315
|
-
writeFileSync(join(dir, ".git", "HEAD"), "ref: refs/heads/main");
|
|
316
|
-
|
|
317
|
-
const paths = walkFiles(dir).map((f) => f.path);
|
|
318
|
-
expect(paths).toContain("src/index.js");
|
|
319
|
-
expect(paths).toContain("docs/a.md");
|
|
320
|
-
expect(paths.some((p) => p.startsWith(".git/"))).toBe(false);
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
describe("readTexts", () => {
|
|
325
|
-
test("reads text files and skips source maps", () => {
|
|
326
|
-
const dir = sandbox();
|
|
327
|
-
writePackage(
|
|
328
|
-
dir,
|
|
329
|
-
{ name: "x", version: "1.0.0" },
|
|
330
|
-
{ "a.js": "const a = 1;", "a.js.map": '{"version":3}', "logo.png": "binary" },
|
|
331
|
-
);
|
|
332
|
-
const texts = readTexts(walkFiles(dir));
|
|
333
|
-
expect(texts.has("a.js")).toBe(true);
|
|
334
|
-
expect(texts.has("a.js.map")).toBe(false);
|
|
335
|
-
expect(texts.has("logo.png")).toBe(false);
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
// ---------------------------------------------------------------------------
|
|
340
|
-
// reporting helpers
|
|
341
|
-
// ---------------------------------------------------------------------------
|
|
342
|
-
|
|
343
|
-
describe("reporting", () => {
|
|
344
|
-
test("summarise counts by severity", () => {
|
|
345
|
-
const findings: Finding[] = [
|
|
346
|
-
{ code: "A", severity: "error", title: "t", detail: "d" },
|
|
347
|
-
{ code: "B", severity: "warn", title: "t", detail: "d" },
|
|
348
|
-
{ code: "C", severity: "warn", title: "t", detail: "d" },
|
|
349
|
-
{ code: "D", severity: "info", title: "t", detail: "d" },
|
|
350
|
-
];
|
|
351
|
-
expect(summarise(findings)).toEqual({ errors: 1, warnings: 2, infos: 1 });
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
test("sortFindings puts failures first", () => {
|
|
355
|
-
const findings: Finding[] = [
|
|
356
|
-
{ code: "I", severity: "info", title: "t", detail: "d" },
|
|
357
|
-
{ code: "E", severity: "error", title: "t", detail: "d" },
|
|
358
|
-
{ code: "W", severity: "warn", title: "t", detail: "d" },
|
|
359
|
-
];
|
|
360
|
-
expect(sortFindings(findings).map((f) => f.code)).toEqual(["E", "W", "I"]);
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
test("firstLines drops blanks and gives up after n", () => {
|
|
364
|
-
expect(firstLines("a\n\n b \nc\nd", 2)).toBe("a\nb");
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
test("formatReport names the failure and refuses to bless the package", () => {
|
|
368
|
-
const report = formatReport({
|
|
369
|
-
findings: [{ code: "TF001", severity: "error", title: "Entry point missing", detail: "d" }],
|
|
370
|
-
sandbox: null,
|
|
371
|
-
packageName: "x",
|
|
372
|
-
packageVersion: "1.0.0",
|
|
373
|
-
fileCount: 3,
|
|
374
|
-
failed: true,
|
|
375
|
-
});
|
|
376
|
-
expect(report).toContain("TF001");
|
|
377
|
-
expect(report).toContain("not safe to publish");
|
|
378
|
-
expect(report).toContain("Does not prove host-runtime behaviour");
|
|
379
|
-
});
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
// ---------------------------------------------------------------------------
|
|
383
|
-
// End to end against real tarballs
|
|
384
|
-
// ---------------------------------------------------------------------------
|
|
385
|
-
|
|
386
|
-
describe("check — end to end", () => {
|
|
387
|
-
test("catches the oc-flight-deck@0.1.0 optional-peer release", async () => {
|
|
388
|
-
const dir = sandbox();
|
|
389
|
-
writePackage(
|
|
390
|
-
dir,
|
|
391
|
-
{
|
|
392
|
-
name: "flight-deck-lookalike",
|
|
393
|
-
version: "0.1.0",
|
|
394
|
-
exports: { ".": { import: "./src/index.ts" } },
|
|
395
|
-
files: ["src"],
|
|
396
|
-
peerDependencies: { "@opentui/solid": ">=0.5.10" },
|
|
397
|
-
peerDependenciesMeta: { "@opentui/solid": { optional: true } },
|
|
398
|
-
},
|
|
399
|
-
{ "src/index.ts": `import { render } from "@opentui/solid";\nexport default render;` },
|
|
400
|
-
);
|
|
401
|
-
|
|
402
|
-
const result = await check(dir, { json: false, keep: false, noInstall: true, doImport: false });
|
|
403
|
-
expect(result.failed).toBe(true);
|
|
404
|
-
expect(result.fatal).toBeUndefined();
|
|
405
|
-
expect(codes(result.findings)).toContain("TF002");
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
test("catches a build directory left out of the files whitelist", async () => {
|
|
409
|
-
const dir = sandbox();
|
|
410
|
-
writePackage(
|
|
411
|
-
dir,
|
|
412
|
-
{ name: "missing-dist", version: "1.0.0", main: "./dist/index.js", files: ["src"] },
|
|
413
|
-
{ "src/index.ts": "export const x = 1;" },
|
|
414
|
-
);
|
|
415
|
-
|
|
416
|
-
const result = await check(dir, { json: false, keep: false, noInstall: true, doImport: false });
|
|
417
|
-
expect(result.failed).toBe(true);
|
|
418
|
-
expect(codes(result.findings)).toContain("TF001");
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
test("reads the published manifest, not the checkout's", async () => {
|
|
422
|
-
// npm rewrites `files` into the tarball's own package.json; the check must
|
|
423
|
-
// judge what ships. A `prepack` script proves the tarball is the input.
|
|
424
|
-
const dir = sandbox();
|
|
425
|
-
writePackage(
|
|
426
|
-
dir,
|
|
427
|
-
{ name: "prepacked", version: "1.0.0", main: "./dist/index.js" },
|
|
428
|
-
{ "src/index.ts": "export const x = 1;" },
|
|
429
|
-
);
|
|
430
|
-
writeFileSync(
|
|
431
|
-
join(dir, "package.json"),
|
|
432
|
-
JSON.stringify(
|
|
433
|
-
{
|
|
434
|
-
name: "prepacked",
|
|
435
|
-
version: "1.0.0",
|
|
436
|
-
main: "./dist/index.js",
|
|
437
|
-
scripts: { prepack: "node -e \"require('fs').mkdirSync('dist');require('fs').writeFileSync('dist/index.js','')\"" },
|
|
438
|
-
},
|
|
439
|
-
null,
|
|
440
|
-
2,
|
|
441
|
-
),
|
|
442
|
-
);
|
|
443
|
-
|
|
444
|
-
const result = await check(dir, { json: false, keep: false, noInstall: true, doImport: false });
|
|
445
|
-
expect(codes(result.findings)).not.toContain("TF001");
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
test("a clean package passes with only the ok marker", async () => {
|
|
449
|
-
const dir = sandbox();
|
|
450
|
-
writePackage(
|
|
451
|
-
dir,
|
|
452
|
-
{ name: "clean-fixture", version: "1.0.0", main: "./src/index.js", files: ["src"] },
|
|
453
|
-
{ "src/index.js": "export const x = 1;" },
|
|
454
|
-
);
|
|
455
|
-
|
|
456
|
-
const result = await check(dir, { json: false, keep: false, noInstall: true, doImport: false });
|
|
457
|
-
expect(result.failed).toBe(false);
|
|
458
|
-
expect(codes(result.findings)).toEqual(["TF000"]);
|
|
459
|
-
expect(result.packageName).toBe("clean-fixture");
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
test("a missing target is a fatal, not a finding", async () => {
|
|
463
|
-
const result = await check(join(sandbox(), "nope"), {
|
|
464
|
-
json: false,
|
|
465
|
-
keep: false,
|
|
466
|
-
noInstall: true,
|
|
467
|
-
doImport: false,
|
|
468
|
-
});
|
|
469
|
-
expect(result.fatal).toContain("no such file or directory");
|
|
470
|
-
});
|
|
471
|
-
|
|
472
|
-
test("--keep leaves the sandbox behind", async () => {
|
|
473
|
-
const dir = sandbox();
|
|
474
|
-
writePackage(
|
|
475
|
-
dir,
|
|
476
|
-
{ name: "keep-fixture", version: "1.0.0", main: "./src/index.js", files: ["src"] },
|
|
477
|
-
{ "src/index.js": "export const x = 1;" },
|
|
478
|
-
);
|
|
479
|
-
|
|
480
|
-
const result = await check(dir, {
|
|
481
|
-
json: false,
|
|
482
|
-
keep: true,
|
|
483
|
-
noInstall: true,
|
|
484
|
-
doImport: false,
|
|
485
|
-
});
|
|
486
|
-
expect(result.sandbox).toBeTruthy();
|
|
487
|
-
const kept = result.sandbox as string;
|
|
488
|
-
expect(existsSync(kept)).toBe(true);
|
|
489
|
-
// The tarball, the extracted tree, and the sandbox manifest all survive.
|
|
490
|
-
expect(existsSync(join(kept, "pkg", "package", "package.json"))).toBe(true);
|
|
491
|
-
expect(walkFiles(kept).some((f) => f.path.endsWith(".tgz"))).toBe(true);
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
test("installs a dependency-free package for real and passes it", async () => {
|
|
495
|
-
// The step `npm pack --dry-run` cannot do. No dependencies means this
|
|
496
|
-
// resolves offline, so the test stays hermetic.
|
|
497
|
-
const dir = sandbox();
|
|
498
|
-
writePackage(
|
|
499
|
-
dir,
|
|
500
|
-
{ name: "installs-cleanly", version: "1.0.0", main: "./src/index.js", files: ["src"] },
|
|
501
|
-
{ "src/index.js": "module.exports = { ok: true };" },
|
|
502
|
-
);
|
|
503
|
-
|
|
504
|
-
const result = await check(dir, { json: false, keep: false, noInstall: false, doImport: false });
|
|
505
|
-
if (find(result.findings, "TF020")) {
|
|
506
|
-
// Offline or no npm on PATH: report it rather than pretending.
|
|
507
|
-
expect(find(result.findings, "TF020")?.severity).toBe("warn");
|
|
508
|
-
} else {
|
|
509
|
-
expect(result.failed).toBe(false);
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
});
|