monoforge 0.9.0 → 1.1.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/README.md +2 -8
- package/bin/forge.mjs +34 -1
- package/package.json +15 -6
- package/packs/README.md +50 -0
- package/packs/public/forge-shapes/index.mjs +161 -0
- package/packs/public/forge-shapes/pack.json +13 -0
- package/packs/public/forge-shapes/test/fixtures/bad-publish/.github/workflows/publish.yml +11 -0
- package/packs/public/forge-shapes/test/fixtures/bad-publish/.monoforge-stamp.json +12 -0
- package/packs/public/forge-shapes/test/fixtures/bad-publish/README.md +3 -0
- package/packs/public/forge-shapes/test/fixtures/bad-publish/bin/probe.mjs +2 -0
- package/packs/public/forge-shapes/test/fixtures/bad-publish/package.json +14 -0
- package/packs/public/forge-shapes/test/fixtures/clean/.github/workflows/publish.yml +12 -0
- package/packs/public/forge-shapes/test/fixtures/clean/.monoforge-stamp.json +12 -0
- package/packs/public/forge-shapes/test/fixtures/clean/README.md +3 -0
- package/packs/public/forge-shapes/test/fixtures/clean/bin/probe.mjs +2 -0
- package/packs/public/forge-shapes/test/fixtures/clean/package.json +14 -0
- package/packs/public/forge-shapes/test/fixtures/missing-file/.github/workflows/publish.yml +12 -0
- package/packs/public/forge-shapes/test/fixtures/missing-file/.monoforge-stamp.json +13 -0
- package/packs/public/forge-shapes/test/fixtures/missing-file/README.md +3 -0
- package/packs/public/forge-shapes/test/fixtures/missing-file/bin/probe.mjs +2 -0
- package/packs/public/forge-shapes/test/fixtures/missing-file/package.json +14 -0
- package/packs/public/forge-shapes/test/fixtures/token/.github/workflows/publish.yml +12 -0
- package/packs/public/forge-shapes/test/fixtures/token/.monoforge-stamp.json +12 -0
- package/packs/public/forge-shapes/test/fixtures/token/README.md +3 -0
- package/packs/public/forge-shapes/test/fixtures/token/bin/probe.mjs +2 -0
- package/packs/public/forge-shapes/test/fixtures/token/package.json +14 -0
- package/packs/public/forge-shapes/test/fixtures/unfilled/.github/workflows/publish.yml +12 -0
- package/packs/public/forge-shapes/test/fixtures/unfilled/.monoforge-stamp.json +12 -0
- package/packs/public/forge-shapes/test/fixtures/unfilled/README.md +3 -0
- package/packs/public/forge-shapes/test/fixtures/unfilled/bin/probe.mjs +2 -0
- package/packs/public/forge-shapes/test/fixtures/unfilled/package.json +14 -0
- package/packs/public/forge-shapes/test/run.mjs +67 -0
- package/spec/refusals.json +35 -0
- package/src/doctor.mjs +46 -23
- package/src/fs-adapter.mjs +143 -0
- package/src/fs-node.mjs +15 -0
- package/src/harness.mjs +118 -0
- package/src/index.mjs +16 -1
- package/src/lock.mjs +1 -1
- package/src/packs.mjs +200 -0
- package/src/paths.mjs +48 -0
- package/src/refusals.mjs +45 -0
- package/src/sha256.mjs +61 -0
- package/src/stamp.mjs +70 -51
- package/src/templates.mjs +28 -14
- package/src/workers.mjs +16 -0
- package/templates/monoforge/AGENTS.md +6 -15
- package/templates/monoforge/CHANGELOG.md +2 -5
- package/templates/monoforge/DEPLOY.md +13 -30
- package/templates/monoforge/README.md +1 -2
- package/templates/monoforge/TEMPLATE.md +1 -4
- package/templates/monoforge/docs/index.md +1 -2
- package/templates/monoforge/horcrux/HORCRUX.md +1 -5
- package/templates/monoforge/labs/TASKS.md +2 -6
- package/templates/monoforge/scripts/check-docs-frontmatter.cjs +1 -1
- package/templates/monoforge/scripts/check-fiction-signatures.cjs +1 -1
- package/templates/monoforge/scripts/unwrap-prose.cjs +178 -0
- package/templates/monoforge-headless/.github/workflows/docs.yml +15 -82
- package/templates/monoforge-headless/.github/workflows/publish.yml +11 -9
- package/templates/monoforge-headless/.github/workflows/test.yml +2 -2
- package/templates/monoforge-headless/TEMPLATE.md +1 -4
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# monoforge
|
|
1
|
+
# monoforge 1.1.0
|
|
2
2
|
|
|
3
3
|
The struct-family factory: stamp a fleet repo from proven template blocks, doctor it for truth, lock it verifiably.
|
|
4
4
|
|
|
@@ -28,13 +28,7 @@ factory.json:
|
|
|
28
28
|
}
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
`docsPath` defaults to `docs.creadev.org/<name>`. `profile` defaults to
|
|
32
|
-
`monoforge` (the full scaffold); set it to `monoforge-headless` to stamp only the
|
|
33
|
-
`.github/` battery - a repo that brings its own docs tree still inherits the
|
|
34
|
-
gates, the docs lane, and the release ladder. Profiles CHAIN (the coreforge
|
|
35
|
-
shape): `monoforge` composes `monoforge-headless` first, so the battery lives
|
|
36
|
-
once. `node src/templates.mjs --list` names the profiles;
|
|
37
|
-
`node src/templates.mjs --resolve <name>` prints the resolved file set.
|
|
31
|
+
`docsPath` defaults to `docs.creadev.org/<name>`. `profile` defaults to `monoforge` (the full scaffold); set it to `monoforge-headless` to stamp only the `.github/` battery - a repo that brings its own docs tree still inherits the gates, the docs lane, and the release ladder. Profiles CHAIN (the coreforge shape): `monoforge` composes `monoforge-headless` first, so the battery lives once. `node src/templates.mjs --list` names the profiles; `node src/templates.mjs --resolve <name>` prints the resolved file set.
|
|
38
32
|
|
|
39
33
|
Component families take a `scope` field (npm scope for the cut packages) plus a `cutlist.json` beside `factory.json`:
|
|
40
34
|
|
package/bin/forge.mjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// text, missing entries, and broken gates; the lock refuses a dirty tree.
|
|
5
5
|
import { resolve } from 'node:path'
|
|
6
6
|
import { readFileSync } from 'node:fs'
|
|
7
|
+
import '../src/fs-node.mjs' // install the node:fs storage adapter as the default
|
|
7
8
|
|
|
8
9
|
const Help = `monoforge - the struct-family factory
|
|
9
10
|
|
|
@@ -15,7 +16,13 @@ Usage:
|
|
|
15
16
|
monoforge doctor [dir] run the truth battery (default: cwd)
|
|
16
17
|
monoforge cut [dir] cut a component-family workspace (cutlist.json + factory.json required)
|
|
17
18
|
monoforge lock [dir] doctor, then archive with a checksum
|
|
18
|
-
monoforge lint-packs packstruct
|
|
19
|
+
monoforge lint-packs packstruct lint over the repo's own install (the factory's own packs)
|
|
20
|
+
monoforge packs [dir] run the check-profile packs over a tree (default: this repo)
|
|
21
|
+
monoforge loader <dir> load the packs under <dir> (the packstruct SPEC loader)
|
|
22
|
+
monoforge harness <verb> <dir> [--grant kind:scope]
|
|
23
|
+
the headless stamp harness (monoforge#23): drive
|
|
24
|
+
new|doctor|lock in-process and print the structured
|
|
25
|
+
result { verb, ok, verdicts, refusals, grant, receipt }
|
|
19
26
|
monoforge help this
|
|
20
27
|
|
|
21
28
|
factory.json (in <dir>, required):
|
|
@@ -53,6 +60,32 @@ if (cmd === 'new') {
|
|
|
53
60
|
if (!r.ok) { console.error(`lock: ${r.error}`); if (r.doctor) { for (const f of r.doctor.findings) console.log(` ${f.level.toUpperCase()} ${f.id}: ${f.message}`) } process.exit(1) }
|
|
54
61
|
console.log(`lock: OK (sha256 ${r.sha}...) archived ${r.archive}`)
|
|
55
62
|
process.exit(0)
|
|
63
|
+
} else if (cmd === 'harness') {
|
|
64
|
+
// The headless stamp harness (monoforge#23): the same verbs as an
|
|
65
|
+
// in-process, structured surface, so railyard's door drives the stamp loop
|
|
66
|
+
// and reads typed refusals (registered in spec/refusals.json) instead of
|
|
67
|
+
// prose. --grant kind:scope echoes the grant row for the audit ledger.
|
|
68
|
+
const { run } = await import('../src/harness.mjs')
|
|
69
|
+
const verb = process.argv[3] || 'doctor'
|
|
70
|
+
const target = resolve(process.argv[4] || '.')
|
|
71
|
+
const gi = process.argv.indexOf('--grant')
|
|
72
|
+
let grant = null
|
|
73
|
+
if (gi >= 0 && process.argv[gi + 1]) {
|
|
74
|
+
const [kind, ...rest] = process.argv[gi + 1].split(':')
|
|
75
|
+
grant = { kind, scope: rest.join(':') }
|
|
76
|
+
}
|
|
77
|
+
const r = await run(verb, target, { grant })
|
|
78
|
+
console.log(JSON.stringify(r, null, 2))
|
|
79
|
+
process.exit(r.ok ? 0 : 1)
|
|
80
|
+
} else if (cmd === 'packs') {
|
|
81
|
+
// The factory's own pack lane (monoforge#3): load packs/public, arm each with
|
|
82
|
+
// a read-only view of the tree, run it, print verdict rows. EXPLOITED fails.
|
|
83
|
+
const { spawnSync } = await import('node:child_process')
|
|
84
|
+
const r = spawnSync(process.execPath, [resolve(import.meta.dirname, '../scripts/run-packs.mjs'), ...process.argv.slice(3)], { stdio: 'inherit' })
|
|
85
|
+
process.exit(r.status ?? 1)
|
|
86
|
+
} else if (cmd === 'loader') {
|
|
87
|
+
const { runLoader } = await import('../src/packs.mjs')
|
|
88
|
+
process.exit(await runLoader(process.argv.slice(3)))
|
|
56
89
|
} else if (cmd === 'lint-packs') {
|
|
57
90
|
// The pack lint lane as a discoverable verb (mirrors crashtest's
|
|
58
91
|
// lint-packs, issue #32): ready now, honest exit 2 until the factory's
|
package/package.json
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monoforge",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "The struct-family factory: stamps a new fleet repo from proven template blocks, doctors it for truth, and locks it. Generated green is never shipped: the doctor refuses placeholder text and unverified gates.\n",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"monoforge": "bin/forge.mjs"
|
|
8
8
|
},
|
|
9
9
|
"exports": {
|
|
10
|
-
".": "./src/index.mjs"
|
|
10
|
+
".": "./src/index.mjs",
|
|
11
|
+
"./workers": "./src/workers.mjs",
|
|
12
|
+
"./harness": "./src/harness.mjs",
|
|
13
|
+
"./packs": "./src/packs.mjs"
|
|
11
14
|
},
|
|
12
15
|
"files": [
|
|
13
16
|
"bin/",
|
|
14
17
|
"src/",
|
|
15
|
-
"templates/"
|
|
18
|
+
"templates/",
|
|
19
|
+
"spec/",
|
|
20
|
+
"packs/"
|
|
16
21
|
],
|
|
17
22
|
"scripts": {
|
|
18
|
-
"test": "node test/run.mjs && node test/version-truth.mjs && node --test test/templates.test.cjs test/ship-from-download.test.cjs test/release-verify.test.cjs test/docs-frontmatter.test.cjs test/web-imports.test.cjs test/status.test.mjs",
|
|
23
|
+
"test": "node test/run.mjs && node test/version-truth.mjs && node test/distribution-run.mjs && node --test test/templates.test.cjs test/workers-compat.test.mjs test/harness.test.mjs test/packs.test.mjs test/ship-from-download.test.cjs test/release-verify.test.cjs test/docs-frontmatter.test.cjs test/web-imports.test.cjs test/status.test.mjs && node --test test/check-action-pins.test.cjs && node --test test/check-prestruct-pins.test.cjs",
|
|
19
24
|
"lint:packs": "node bin/forge.mjs lint-packs --deep",
|
|
25
|
+
"lint:pins": "node scripts/check-action-pins.cjs",
|
|
26
|
+
"conform:packs": "packstruct audit-conformance . --loader \"node src/packs.mjs {packs}\"",
|
|
27
|
+
"packs": "node scripts/run-packs.mjs",
|
|
20
28
|
"lint:docs": "node scripts/check-docs-frontmatter.cjs && node scripts/check-docs-links.cjs && node scripts/check-docs-style.cjs && node scripts/check-fiction-signatures.cjs && node scripts/check-jekyll-filters.cjs",
|
|
21
29
|
"lint:language": "node scripts/check-language.cjs",
|
|
22
|
-
"check": "npm test && npm run lint:docs && npm run lint:language",
|
|
30
|
+
"check": "npm test && npm run lint:docs && npm run lint:pins && npm run lint:prestruct-pins && npm run lint:language && npm run lint:packs && npm run conform:packs && npm run packs",
|
|
23
31
|
"prepublishOnly": "npm run check",
|
|
24
|
-
"icons:adopt": "node scripts/adopt-icons.mjs"
|
|
32
|
+
"icons:adopt": "node scripts/adopt-icons.mjs",
|
|
33
|
+
"lint:prestruct-pins": "node scripts/check-prestruct-pins.cjs"
|
|
25
34
|
},
|
|
26
35
|
"devDependencies": {
|
|
27
36
|
"eyestruct": "1.0.0",
|
package/packs/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# packs/ - the factory's own check packs
|
|
2
|
+
|
|
3
|
+
This directory is monoforge's home for [**packstruct**](https://packstruct.creadev.org) packs, in the family's two-seam split:
|
|
4
|
+
|
|
5
|
+
- **files** travel as an **artifact** (our `lock`: a `.tar.gz` + sha256 with a manifest inside)
|
|
6
|
+
- **judgment** travels as a **pack** (packstruct SPEC v1, `check` profile: `{ checks: [...] }`, pure reading over a tree)
|
|
7
|
+
|
|
8
|
+
A pack is a `pack.json` manifest plus the entry module it names. SPEC v1 has no field for files to write, so a pack can only ever READ a tree - which is exactly the doctor's lane. That is why the factory's portable judgment lives here and its file-copying lives in `templates/`.
|
|
9
|
+
|
|
10
|
+
## The two visibility folders
|
|
11
|
+
|
|
12
|
+
- `packs/public/` - tracked, reusable across targets. A pack that names its target's vocabulary takes it through `ctx`, so another repo can adopt the pack without editing it.
|
|
13
|
+
- `packs/local/` - gitignored, machine-private. Not used here.
|
|
14
|
+
|
|
15
|
+
## Run it
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm run lint:packs # packstruct lint packs --deep (manifest + entry shape)
|
|
19
|
+
npm run conform:packs # the spec's own loader harness (8/8 required)
|
|
20
|
+
npm run packs # run every pack over THIS repo, print the verdict rows
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
All three ride `npm run check`. `npm run packs` fails on a NEW `EXPLOITED` verdict; a `BOUNDED` row never reads as green but does not fail the lane.
|
|
24
|
+
|
|
25
|
+
## The pack(s) in this repo
|
|
26
|
+
|
|
27
|
+
### `forge-shapes` - the stamped-tree checks
|
|
28
|
+
|
|
29
|
+
Six pure-reading checks over a tree the factory stamped:
|
|
30
|
+
|
|
31
|
+
| Check | What it proves |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `forge/receipt-present` | the receipt ships and parses (identity + file list) |
|
|
34
|
+
| `forge/receipt-files-exist` | every file the receipt claims is on disk |
|
|
35
|
+
| `forge/truth-slot-clean` | no `FORGE-TODO` truth slot survived the stamp |
|
|
36
|
+
| `forge/stamp-token-clean` | no raw `__TOKEN__` survived the stamp |
|
|
37
|
+
| `forge/package-paths` | every `package.json` bin/exports/files entry resolves |
|
|
38
|
+
| `forge/publish-gate` | `publish.yml` refuses 0.x and carries no publish token |
|
|
39
|
+
|
|
40
|
+
Verdict taxonomy (family): `PASSED` / `BOUNDED` / `EXPLOITED`. The pack ships `test/fixtures/` proving each verdict both ways (SPEC section 4); its self-audit runs in `test/packs.test.mjs`.
|
|
41
|
+
|
|
42
|
+
## The loader
|
|
43
|
+
|
|
44
|
+
`src/packs.mjs` is the loader the spec's own harness grades:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npx packstruct audit-conformance . --loader "node src/packs.mjs {packs}"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Every refusal is instant, one-line, and names the pack (SPEC section 5). Exit 0 conforming / 1 violations / 2 usage.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// forge-shapes - the check-profile pack over a monoforge-stamped tree
|
|
2
|
+
// (monoforge#3). Pure reads: it opens the receipt and the files the receipt
|
|
3
|
+
// names, and reports what it finds. Zero network, zero writes.
|
|
4
|
+
//
|
|
5
|
+
// Why a pack when the doctor already checks this: the doctor is monoforge's
|
|
6
|
+
// own inline catalog, hard-wired to the factory. A pack is the PORTABLE
|
|
7
|
+
// judgment - the same claims, re-runnable by any host that loads it, against
|
|
8
|
+
// any stamped tree. The two are twins on purpose; the pack is the one that
|
|
9
|
+
// travels.
|
|
10
|
+
//
|
|
11
|
+
// THE CONTRACT with the target (ctx.forgeTree):
|
|
12
|
+
// root -> absolute path to the stamped tree, or null (the
|
|
13
|
+
// pack then dockets one BOUNDED row and audits
|
|
14
|
+
// nothing - an absent target is never a pass)
|
|
15
|
+
// exists(rel) -> boolean
|
|
16
|
+
// text(rel) -> string | null
|
|
17
|
+
//
|
|
18
|
+
// Verdict taxonomy (family): PASSED / BOUNDED / EXPLOITED. BOUNDED never
|
|
19
|
+
// reads as green.
|
|
20
|
+
|
|
21
|
+
export const PKG = 'packs/public/forge-shapes'
|
|
22
|
+
export const REQUIRED_KEYS = ['forgeTree']
|
|
23
|
+
|
|
24
|
+
const PACK = 'forge-shapes'
|
|
25
|
+
const TODO_MARK = 'FORGE-TODO'
|
|
26
|
+
|
|
27
|
+
class Verdicts {
|
|
28
|
+
constructor() { this.rows = [] }
|
|
29
|
+
passed(id, detail) { this.rows.push({ pack: PACK, id, verdict: 'PASSED', detail: String(detail || '').slice(0, 220) }) }
|
|
30
|
+
bounded(id, bound, detail) { this.rows.push({ pack: PACK, id, verdict: 'BOUNDED', bound, detail: String(detail || '').slice(0, 220) }) }
|
|
31
|
+
failed(id, fault) { this.rows.push({ pack: PACK, id, verdict: 'EXPLOITED', detail: String(fault.problem || JSON.stringify(fault)).slice(0, 220), fault }) }
|
|
32
|
+
get ok() { return !this.rows.some((r) => r.verdict === 'EXPLOITED') }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function take(ctx, key) {
|
|
36
|
+
const value = ctx?.[key]
|
|
37
|
+
if (value === undefined) throw new TypeError(`${PKG}: ctx[${JSON.stringify(key)}] is missing - the runner did not arm the ${key} contract`)
|
|
38
|
+
return value
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// The check ids this pack declares (SPEC section 7 census; the check profile's
|
|
42
|
+
// `checks[]`). Kept in sync with the run() bodies below - a drift here is a
|
|
43
|
+
// missing id, caught by the pack's own fixtures.
|
|
44
|
+
export const checks = [
|
|
45
|
+
{ id: 'forge/receipt-present' },
|
|
46
|
+
{ id: 'forge/receipt-files-exist' },
|
|
47
|
+
{ id: 'forge/truth-slot-clean' },
|
|
48
|
+
{ id: 'forge/stamp-token-clean' },
|
|
49
|
+
{ id: 'forge/package-paths' },
|
|
50
|
+
{ id: 'forge/publish-gate' },
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
export function run(ctx) {
|
|
54
|
+
for (const key of REQUIRED_KEYS) take(ctx, key)
|
|
55
|
+
const v = new Verdicts()
|
|
56
|
+
const tree = ctx.forgeTree
|
|
57
|
+
|
|
58
|
+
if (!tree || tree.root == null) {
|
|
59
|
+
v.bounded('forge/receipt-present', 'target-tree-absent', 'no stamped tree armed (set FORGE_TREE) - nothing was audited, nothing was passed')
|
|
60
|
+
return { ok: v.ok, rows: v.rows }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// --- receipt-present: the receipt ships and parses ---
|
|
64
|
+
const raw = tree.text('.monoforge-stamp.json')
|
|
65
|
+
if (raw == null) {
|
|
66
|
+
v.failed('forge/receipt-present', { problem: 'no .monoforge-stamp.json - the tree carries no stamp receipt, so nothing here proves it was minted by the factory' })
|
|
67
|
+
return { ok: v.ok, rows: v.rows }
|
|
68
|
+
}
|
|
69
|
+
let receipt
|
|
70
|
+
try {
|
|
71
|
+
receipt = JSON.parse(raw)
|
|
72
|
+
} catch (err) {
|
|
73
|
+
v.failed('forge/receipt-present', { problem: `.monoforge-stamp.json is unparseable: ${err.message}` })
|
|
74
|
+
return { ok: v.ok, rows: v.rows }
|
|
75
|
+
}
|
|
76
|
+
const files = Array.isArray(receipt.files) ? receipt.files : []
|
|
77
|
+
if (!receipt.name || !files.length) {
|
|
78
|
+
v.failed('forge/receipt-present', { problem: `receipt is missing its identity or file list (name=${JSON.stringify(receipt.name)}, files=${files.length})` })
|
|
79
|
+
return { ok: v.ok, rows: v.rows }
|
|
80
|
+
}
|
|
81
|
+
v.passed('forge/receipt-present', `receipt for "${receipt.name}" lists ${files.length} file(s)`)
|
|
82
|
+
|
|
83
|
+
// --- receipt-files-exist: every file the receipt claims is on disk ---
|
|
84
|
+
const missing = files.filter((f) => !tree.exists(f))
|
|
85
|
+
if (missing.length) {
|
|
86
|
+
v.failed('forge/receipt-files-exist', { problem: 'the receipt claims files that do not ship - a receipt is a promise about bytes', missing })
|
|
87
|
+
} else {
|
|
88
|
+
v.passed('forge/receipt-files-exist', `all ${files.length} receipted file(s) exist`)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// --- truth-slot-clean / stamp-token-clean: the shipped-placeholder law ---
|
|
92
|
+
const todoFiles = []
|
|
93
|
+
const tokenFiles = []
|
|
94
|
+
for (const rel of files) {
|
|
95
|
+
const text = tree.text(rel)
|
|
96
|
+
if (text == null) continue
|
|
97
|
+
const n = (text.match(new RegExp(TODO_MARK, 'g')) || []).length
|
|
98
|
+
if (n) todoFiles.push({ file: rel, count: n })
|
|
99
|
+
const rawTokens = text.match(/__[A-Z][A-Z0-9_]*__/g) || []
|
|
100
|
+
if (rawTokens.length) tokenFiles.push({ file: rel, tokens: [...new Set(rawTokens)] })
|
|
101
|
+
}
|
|
102
|
+
if (todoFiles.length) {
|
|
103
|
+
v.failed('forge/truth-slot-clean', { problem: 'a receipted file still carries a FORGE-TODO truth slot - a shipped placeholder is a shipped lie', files: todoFiles })
|
|
104
|
+
} else {
|
|
105
|
+
v.passed('forge/truth-slot-clean', `${files.length} receipted file(s): no unfilled FORGE-TODO slot`)
|
|
106
|
+
}
|
|
107
|
+
if (tokenFiles.length) {
|
|
108
|
+
v.failed('forge/stamp-token-clean', { problem: 'a receipted file still carries a raw __TOKEN__ - the stamp never finished', files: tokenFiles })
|
|
109
|
+
} else {
|
|
110
|
+
v.passed('forge/stamp-token-clean', `${files.length} receipted file(s): no raw stamp token survived`)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// --- package-paths: bin / exports / files entries all resolve ---
|
|
114
|
+
const pkgRaw = tree.text('package.json')
|
|
115
|
+
if (pkgRaw == null) {
|
|
116
|
+
v.bounded('forge/package-paths', 'package-json-absent', 'no package.json in the tree - this check cannot fire, so it does not pass')
|
|
117
|
+
} else {
|
|
118
|
+
let pkg
|
|
119
|
+
try { pkg = JSON.parse(pkgRaw) } catch (err) {
|
|
120
|
+
v.failed('forge/package-paths', { problem: `package.json is unparseable: ${err.message}` })
|
|
121
|
+
pkg = null
|
|
122
|
+
}
|
|
123
|
+
if (pkg) {
|
|
124
|
+
const broken = []
|
|
125
|
+
for (const [name, b] of Object.entries(pkg.bin || {})) if (!tree.exists(b)) broken.push({ key: `bin.${name}`, path: b })
|
|
126
|
+
for (const [key, val] of Object.entries(pkg.exports || {})) {
|
|
127
|
+
const p = typeof val === 'string' ? val : val?.import
|
|
128
|
+
if (p && !p.includes('*') && !tree.exists(p)) broken.push({ key: `exports.${key}`, path: p })
|
|
129
|
+
}
|
|
130
|
+
for (const f of pkg.files || []) {
|
|
131
|
+
if (f.startsWith('!') || f.includes('*')) continue
|
|
132
|
+
if (!tree.exists(f)) broken.push({ key: 'files', path: f })
|
|
133
|
+
}
|
|
134
|
+
if (broken.length) v.failed('forge/package-paths', { problem: 'a package.json bin/exports/files entry does not resolve (the crashtest#16 class)', broken })
|
|
135
|
+
else v.passed('forge/package-paths', 'every bin/exports/files entry resolves')
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// --- publish-gate: 0.x refusal present, no publish token ---
|
|
140
|
+
const pub = tree.text('.github/workflows/publish.yml')
|
|
141
|
+
if (pub == null) {
|
|
142
|
+
v.bounded('forge/publish-gate', 'publish-workflow-absent', 'no .github/workflows/publish.yml - a tree without a publish lane has no gate to grade')
|
|
143
|
+
} else {
|
|
144
|
+
const refusesZero = /startsWith\(['"]v0\.|0\.\*\)/.test(pub)
|
|
145
|
+
const codeLines = pub.split('\n').filter((l) => !/^\s*#/.test(l)).join('\n')
|
|
146
|
+
const hasToken = /secrets\.NPM_TOKEN|NODE_AUTH_TOKEN/.test(codeLines)
|
|
147
|
+
if (!refusesZero || hasToken) {
|
|
148
|
+
v.failed('forge/publish-gate', {
|
|
149
|
+
problem: 'the publish workflow does not refuse 0.x refs, or references a publish token (the family law is OIDC trusted publishing only)',
|
|
150
|
+
refusesZero,
|
|
151
|
+
hasToken,
|
|
152
|
+
})
|
|
153
|
+
} else {
|
|
154
|
+
v.passed('forge/publish-gate', 'publish.yml refuses 0.x refs and carries no publish token')
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return { ok: v.ok, rows: v.rows }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export default { checks, run, PKG, REQUIRED_KEYS }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"name": "forge-shapes",
|
|
4
|
+
"description": "File checks over a monoforge-stamped tree: the receipt ships and parses, every file the receipt claims exists, the truth-slot law holds (no FORGE-TODO, no raw __TOKEN__ survives), the package.json bin/exports/files entries all resolve, the publish workflow refuses 0.x refs and carries no publish token, and the docs gates the tree ships actually pass. Pure reads over a tree - zero network, zero writes.",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"entry": "index.mjs",
|
|
7
|
+
"env": {
|
|
8
|
+
"fs": {
|
|
9
|
+
"targets": [".monoforge-stamp.json", "package.json", ".github/workflows/publish.yml", "docs/**/*.md"]
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"implements": "packstruct@1"
|
|
13
|
+
}
|