monoforge 0.0.0-stage → 1.0.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.
Files changed (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -2
  3. package/bin/forge.mjs +98 -0
  4. package/package.json +56 -4
  5. package/packs/README.md +62 -0
  6. package/packs/public/forge-shapes/index.mjs +161 -0
  7. package/packs/public/forge-shapes/pack.json +13 -0
  8. package/packs/public/forge-shapes/test/fixtures/bad-publish/.github/workflows/publish.yml +11 -0
  9. package/packs/public/forge-shapes/test/fixtures/bad-publish/.monoforge-stamp.json +12 -0
  10. package/packs/public/forge-shapes/test/fixtures/bad-publish/README.md +3 -0
  11. package/packs/public/forge-shapes/test/fixtures/bad-publish/bin/probe.mjs +2 -0
  12. package/packs/public/forge-shapes/test/fixtures/bad-publish/package.json +14 -0
  13. package/packs/public/forge-shapes/test/fixtures/clean/.github/workflows/publish.yml +12 -0
  14. package/packs/public/forge-shapes/test/fixtures/clean/.monoforge-stamp.json +12 -0
  15. package/packs/public/forge-shapes/test/fixtures/clean/README.md +3 -0
  16. package/packs/public/forge-shapes/test/fixtures/clean/bin/probe.mjs +2 -0
  17. package/packs/public/forge-shapes/test/fixtures/clean/package.json +14 -0
  18. package/packs/public/forge-shapes/test/fixtures/missing-file/.github/workflows/publish.yml +12 -0
  19. package/packs/public/forge-shapes/test/fixtures/missing-file/.monoforge-stamp.json +13 -0
  20. package/packs/public/forge-shapes/test/fixtures/missing-file/README.md +3 -0
  21. package/packs/public/forge-shapes/test/fixtures/missing-file/bin/probe.mjs +2 -0
  22. package/packs/public/forge-shapes/test/fixtures/missing-file/package.json +14 -0
  23. package/packs/public/forge-shapes/test/fixtures/token/.github/workflows/publish.yml +12 -0
  24. package/packs/public/forge-shapes/test/fixtures/token/.monoforge-stamp.json +12 -0
  25. package/packs/public/forge-shapes/test/fixtures/token/README.md +3 -0
  26. package/packs/public/forge-shapes/test/fixtures/token/bin/probe.mjs +2 -0
  27. package/packs/public/forge-shapes/test/fixtures/token/package.json +14 -0
  28. package/packs/public/forge-shapes/test/fixtures/unfilled/.github/workflows/publish.yml +12 -0
  29. package/packs/public/forge-shapes/test/fixtures/unfilled/.monoforge-stamp.json +12 -0
  30. package/packs/public/forge-shapes/test/fixtures/unfilled/README.md +3 -0
  31. package/packs/public/forge-shapes/test/fixtures/unfilled/bin/probe.mjs +2 -0
  32. package/packs/public/forge-shapes/test/fixtures/unfilled/package.json +14 -0
  33. package/packs/public/forge-shapes/test/run.mjs +67 -0
  34. package/spec/refusals.json +35 -0
  35. package/src/cut.mjs +244 -0
  36. package/src/doctor.mjs +253 -0
  37. package/src/fs-adapter.mjs +143 -0
  38. package/src/fs-node.mjs +15 -0
  39. package/src/harness.mjs +118 -0
  40. package/src/index.mjs +19 -0
  41. package/src/lint-packs.mjs +77 -0
  42. package/src/lock.mjs +37 -0
  43. package/src/packs.mjs +200 -0
  44. package/src/paths.mjs +48 -0
  45. package/src/refusals.mjs +45 -0
  46. package/src/sha256.mjs +61 -0
  47. package/src/stamp.mjs +215 -0
  48. package/src/templates.mjs +147 -0
  49. package/src/workers.mjs +16 -0
  50. package/templates/monoforge/AGENTS.md +30 -0
  51. package/templates/monoforge/CHANGELOG.md +19 -0
  52. package/templates/monoforge/DEPLOY.md +53 -0
  53. package/templates/monoforge/LICENSE +21 -0
  54. package/templates/monoforge/README.md +16 -0
  55. package/templates/monoforge/TEMPLATE.md +19 -0
  56. package/templates/monoforge/docs/Gemfile +5 -0
  57. package/templates/monoforge/docs/_config.yml +36 -0
  58. package/templates/monoforge/docs/_layouts/default.html +29 -0
  59. package/templates/monoforge/docs/assets/css/style.css +14 -0
  60. package/templates/monoforge/docs/freestruct.config.yml +7 -0
  61. package/templates/monoforge/docs/index.md +27 -0
  62. package/templates/monoforge/docs/search.md +28 -0
  63. package/templates/monoforge/functions/api/health.js +10 -0
  64. package/templates/monoforge/gitignore.tmpl +9 -0
  65. package/templates/monoforge/horcrux/HORCRUX.md +7 -0
  66. package/templates/monoforge/labs/.eyes/ledger.json +1 -0
  67. package/templates/monoforge/labs/.eyes/manifest.yml +5 -0
  68. package/templates/monoforge/labs/TASKS.md +11 -0
  69. package/templates/monoforge/scripts/build-docs.sh +12 -0
  70. package/templates/monoforge/scripts/check-docs-frontmatter.cjs +112 -0
  71. package/templates/monoforge/scripts/check-docs-links.cjs +81 -0
  72. package/templates/monoforge/scripts/check-docs-style.cjs +79 -0
  73. package/templates/monoforge/scripts/check-fiction-signatures.cjs +69 -0
  74. package/templates/monoforge/scripts/check-jekyll-filters.cjs +62 -0
  75. package/templates/monoforge/scripts/check-language.cjs +171 -0
  76. package/templates/monoforge/site/robots.txt +4 -0
  77. package/templates/monoforge/wrangler.toml +11 -0
  78. package/templates/monoforge-headless/.github/workflows/docs.yml +102 -0
  79. package/templates/monoforge-headless/.github/workflows/publish.yml +141 -0
  80. package/templates/monoforge-headless/.github/workflows/staging-ff-sync.yml +44 -0
  81. package/templates/monoforge-headless/.github/workflows/test.yml +21 -0
  82. package/templates/monoforge-headless/TEMPLATE.md +17 -0
@@ -0,0 +1,102 @@
1
+ name: docs
2
+
3
+ on:
4
+ push:
5
+ branches: [main, staging]
6
+ paths: ['docs/**', 'scripts/**', '.github/workflows/docs.yml']
7
+ workflow_dispatch:
8
+
9
+ # GitHub Pages deploy permissions (official deploy-pages action)
10
+ permissions:
11
+ contents: read
12
+ pages: write
13
+ id-token: write
14
+
15
+ # Allow only one concurrent deployment
16
+ concurrency:
17
+ group: pages
18
+ cancel-in-progress: false
19
+
20
+ jobs:
21
+ build:
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+
26
+ - uses: actions/setup-node@v4
27
+ with: { node-version: 20 }
28
+
29
+ # Docs truth gates (ported house checkers): frontmatter 5-field law,
30
+ # resolvable links, style law (no dashes in prose, language-tagged
31
+ # fences, no trailing ws), fiction-signature seeds, the two-argument
32
+ # Liquid filter trap, English-only prose.
33
+ - name: Docs gates
34
+ run: |
35
+ node scripts/check-docs-frontmatter.cjs
36
+ node scripts/check-docs-links.cjs
37
+ node scripts/check-docs-style.cjs
38
+ node scripts/check-fiction-signatures.cjs
39
+ node scripts/check-jekyll-filters.cjs
40
+ node scripts/check-language.cjs
41
+
42
+ - name: Setup Ruby
43
+ uses: ruby/setup-ruby@v1
44
+ with:
45
+ ruby-version: '3.3'
46
+ bundler-cache: true
47
+ cache-version: 1
48
+
49
+ - name: Setup Pages
50
+ id: pages
51
+ uses: actions/configure-pages@v4
52
+
53
+ - name: Install deps
54
+ working-directory: docs
55
+ run: bundle install
56
+
57
+ # House-measured: the pagefind npm package resolves a platform binary at
58
+ # install and an npx fallback DIED in CI ("Failed to install either of
59
+ # [pagefind_extended, pagefind]" - dhaupin/freestruct docs.yml note).
60
+ # The standalone musl tarball is the proven path (prestruct docs.yml).
61
+ - name: Download Pagefind
62
+ working-directory: docs
63
+ run: |
64
+ VERSION=$(curl -sL "https://api.github.com/repos/Pagefind/pagefind/releases/latest" | grep '"tag_name"' | sed 's/.*"v\([^\"]*\)".*/\1/')
65
+ curl -sL "https://github.com/Pagefind/pagefind/releases/download/v${VERSION}/pagefind-v${VERSION}-x86_64-unknown-linux-musl.tar.gz" -o pagefind.tar.gz
66
+ tar -xzf pagefind.tar.gz
67
+ rm pagefind.tar.gz
68
+
69
+ - name: Jekyll build
70
+ working-directory: docs
71
+ run: bundle exec jekyll build
72
+
73
+ # freestruct AFTER jekyll (post-render SEO layer; discovers
74
+ # docs/freestruct.config.yml + docs/_site by the engine's own rule) --
75
+ # --strict: broken links fail the build.
76
+ - name: Freestruct (strict)
77
+ run: npx --yes freestruct@1.1.0 --strict
78
+
79
+ # Pagefind LAST - index over the FINAL html (freestruct-injected)
80
+ - name: Index search with Pagefind
81
+ working-directory: docs
82
+ run: ./pagefind --site _site
83
+
84
+ - name: Upload artifact
85
+ id: upload-artifact
86
+ uses: actions/upload-pages-artifact@v3
87
+ with:
88
+ path: 'docs/_site'
89
+
90
+ deploy:
91
+ needs: build
92
+ # The integration branch is in the trigger list, so the trigger no longer
93
+ # keeps staging's docs out of production - this guard does (flowforge#30,
94
+ # point 3: the trap). Only a promotion to main deploys.
95
+ if: github.ref == 'refs/heads/main'
96
+ runs-on: ubuntu-latest
97
+ environment:
98
+ name: github-pages
99
+ url: ${{ steps.deployment.outputs.page_url }}
100
+ steps:
101
+ - id: deployment
102
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,141 @@
1
+ name: publish
2
+ # The release ladder (the family shape, receipt dhaupin/eyestruct@4e2b552).
3
+ # Three jobs drive a tag end to end: publish, cut the GH release, then verify
4
+ # the cut against what the registry and GitHub actually serve. The gap the
5
+ # shape closes: a publish step can go green while the registry result is
6
+ # wrong, because nothing asserted the tarball in between.
7
+ #
8
+ # Publish rides npm Trusted Publishing (OIDC): NO publish token exists
9
+ # anywhere. The `secrets.NPM_TOKEN` line this file used to carry was the
10
+ # family-law violation ("no publish tokens anywhere") this adoption removes.
11
+ # One-time setup per account: link the package to this repo under
12
+ # npmjs.com -> package Settings -> Publishing access (the OIDC flow needs
13
+ # that mapping to mint credentials). No secret is ever created.
14
+ #
15
+ # Scaffold: the adopter supplies package.json (the version truth) and its
16
+ # test script. `npm publish` runs prepublishOnly automatically, so a red
17
+ # battery cannot mint a tarball. The gate refuses 0.x (the family ladder:
18
+ # 0.x is the manual ship lane) and, on a tag push, a tag that disagrees with
19
+ # the packaged version. Every github context value reaches the script
20
+ # through env, never inline interpolation.
21
+ on:
22
+ push:
23
+ tags: ['v*']
24
+ workflow_dispatch:
25
+ inputs:
26
+ mode:
27
+ description: 'publish = registry cut | verify-only = re-run the trust ladder against what is already served'
28
+ required: false
29
+ default: 'publish'
30
+ type: choice
31
+ options: ['publish', 'verify-only']
32
+
33
+ permissions:
34
+ contents: write
35
+ id-token: write
36
+
37
+ jobs:
38
+ publish:
39
+ if: github.event_name == 'push' || inputs.mode != 'verify-only'
40
+ runs-on: ubuntu-latest
41
+ outputs:
42
+ version: ${{ steps.gate.outputs.version }}
43
+ tag: ${{ steps.gate.outputs.tag }}
44
+ steps:
45
+ # fetch-depth: 0 - the verify ladder's git archive needs the release
46
+ # commit reachable.
47
+ - uses: actions/checkout@v4
48
+ with: { fetch-depth: 0 }
49
+ - uses: actions/setup-node@v4
50
+ with:
51
+ node-version: 20
52
+ registry-url: https://registry.npmjs.org
53
+ - name: npm floor for trusted publishing (11.5.1+)
54
+ run: npm install -g npm@^11
55
+ - id: gate
56
+ name: the gate - 0.x refused, tag == packaged version
57
+ env:
58
+ TAG_REF: ${{ github.ref_name }}
59
+ EVENT_NAME: ${{ github.event_name }}
60
+ run: |
61
+ set -e
62
+ V="$(node -p "require('./package.json').version")"
63
+ case "$V" in
64
+ 0.*) echo "publish gate: refusing $V - the OIDC lane serves 1.0.0+ only (0.x is the manual ship lane)"; exit 1 ;;
65
+ esac
66
+ if [ "$EVENT_NAME" = "push" ] && [ "$TAG_REF" != "v$V" ]; then
67
+ echo "publish gate: refusing - tag $TAG_REF does not equal the packaged version v$V (a tag that lies about its version never cuts)"; exit 1
68
+ fi
69
+ echo "publish gate: v$V passes the 0.x refusal and the tag==version gate"
70
+ echo "version=$V" >> "$GITHUB_OUTPUT"
71
+ echo "tag=v$V" >> "$GITHUB_OUTPUT"
72
+ - name: Install
73
+ run: npm install --no-fund --no-audit
74
+ - name: npm publish (OIDC - no token secret involved)
75
+ # prepublishOnly rides this automatically: the adopter's test battery.
76
+ run: npm publish --provenance --access public
77
+
78
+ release:
79
+ needs: publish
80
+ runs-on: ubuntu-latest
81
+ steps:
82
+ - uses: actions/checkout@v4
83
+ # Notes are EXTRACTED from the CHANGELOG's own [version] section - a
84
+ # release body that disagrees with the changelog is drift, and an empty
85
+ # extraction refuses the cut. notes.md lives in RUNNER_TEMP: never a
86
+ # silent overwrite of a repo file that happens to carry the name.
87
+ - name: extract the release notes from the changelog (refuses empty)
88
+ env:
89
+ BLOCK_VERSION: ${{ needs.publish.outputs.version }}
90
+ run: |
91
+ set -e
92
+ NOTES="$(awk -v v="$BLOCK_VERSION" '
93
+ index($0, "## [" v "]") == 1 { grab=1; next }
94
+ grab && index($0, "## [") == 1 { exit }
95
+ grab { print }
96
+ ' CHANGELOG.md)"
97
+ if [ -z "$(printf '%s' "$NOTES" | tr -d '[:space:]')" ]; then
98
+ echo "release: no non-empty [${BLOCK_VERSION}] section in CHANGELOG.md - the tag and the changelog disagree"; exit 1
99
+ fi
100
+ printf '%s\n' "$NOTES" > "$RUNNER_TEMP/notes.md"
101
+ - name: cut the GH release from the tag (idempotent)
102
+ env:
103
+ GH_TOKEN: ${{ github.token }}
104
+ BLOCK_VERSION: ${{ needs.publish.outputs.version }}
105
+ BLOCK_TAG: ${{ needs.publish.outputs.tag }}
106
+ run: |
107
+ if gh release view "$BLOCK_TAG" > /dev/null 2>&1; then
108
+ echo "release $BLOCK_TAG already exists - not re-minting; the verify job judges its truth"
109
+ else
110
+ gh release create "$BLOCK_TAG" --title "__NAME__ $BLOCK_VERSION" --notes-file "$RUNNER_TEMP/notes.md"
111
+ fi
112
+
113
+ # The verify leg runs after a real cut, but ALSO stands alone in
114
+ # verify-only mode (publish skipped, release skipped, the ladder judged
115
+ # against what is already served and released).
116
+ verify:
117
+ needs: publish
118
+ if: >-
119
+ always() &&
120
+ (needs.publish.result == 'success' ||
121
+ (needs.publish.result == 'skipped' && inputs.mode == 'verify-only'))
122
+ runs-on: ubuntu-latest
123
+ permissions:
124
+ contents: read
125
+ steps:
126
+ - uses: actions/checkout@v4
127
+ - uses: actions/setup-node@v4
128
+ with: { node-version: 20 }
129
+ - name: the post-publish trust ladder
130
+ env:
131
+ GH_TOKEN: ${{ github.token }}
132
+ run: |
133
+ set -e
134
+ V="$(node -p "require('./package.json').version")"
135
+ SERVED="$(npm view __NAME__@"$V" version)"
136
+ if [ "$SERVED" != "$V" ]; then
137
+ echo "verify: the registry serves __NAME__@$SERVED but this tree is $V"; exit 1
138
+ fi
139
+ echo "PASS registry serves __NAME__@$V"
140
+ gh release view "v$V" > /dev/null
141
+ echo "PASS GH release v$V exists"
@@ -0,0 +1,44 @@
1
+ # staging-ff-sync - after a promotion to main, fast-forward the permanent
2
+ # staging integration branch to main (monoforge#20, the family staging flow).
3
+ #
4
+ # A merge-commit promotion puts a commit on main that staging lacks, so the
5
+ # two drift by one on every promotion even when the flow is followed exactly.
6
+ # This job is the required sync step: staging is a mirror of the integration
7
+ # state, never a second line of history, so a fast-forward is the only move -
8
+ # never a merge, never a force-push.
9
+ #
10
+ # Non-destructive by construction: `git push origin origin/main:staging` with
11
+ # a fast-forward-only refspec. If staging has moved ahead of main the push is
12
+ # refused and this job fails loudly, which is the signal that a commit landed
13
+ # on staging that main does not have.
14
+
15
+ name: Sync staging to main
16
+
17
+ on:
18
+ push:
19
+ branches: [main]
20
+ workflow_dispatch:
21
+
22
+ permissions:
23
+ contents: write
24
+
25
+ concurrency:
26
+ group: staging-ff-sync
27
+ cancel-in-progress: false
28
+
29
+ jobs:
30
+ ff-sync:
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - name: Fast-forward staging to main
34
+ env:
35
+ TOKEN: ${{ secrets.GITHUB_TOKEN }}
36
+ run: |
37
+ set -euo pipefail
38
+ git init -q .
39
+ git remote add origin "https://x-access-token:${TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
40
+ git fetch -q origin main staging
41
+ # Fast-forward only: the refspec requires staging to be an ancestor
42
+ # of main. `git push` refuses a non-fast-forward update, so a
43
+ # divergence fails the job instead of rewriting history.
44
+ git push origin origin/main:refs/heads/staging
@@ -0,0 +1,21 @@
1
+ name: test
2
+ on:
3
+ push: { branches: [main, staging] }
4
+ pull_request: { branches: [main, staging] }
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v4
10
+ - uses: actions/setup-node@v4
11
+ with: { node-version: 20 }
12
+ - run: npm install --no-fund --no-audit
13
+ - run: npm test
14
+ - name: lint the repo's own conformance fixtures + shipped packs through the CLI
15
+ run: |
16
+ node bin/cli.mjs lint test/fixtures/good/packs
17
+ if node bin/cli.mjs lint test/fixtures/bad/packs >/dev/null 2>&1; then
18
+ echo "lint should have failed on broken fixtures"; exit 1
19
+ fi
20
+ # dogfood: the repo's own packs tree (the crashtest scenario pack) is itself SPEC-v1 shaped
21
+ node bin/cli.mjs lint packs
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: monoforge-headless
3
+ description: >
4
+ CI only - the .github/ battery (test, docs, publish), no scaffold.
5
+ chain: []
6
+ ---
7
+
8
+ # monoforge-headless
9
+
10
+ CI only - the .github/ battery (test, docs, publish), no scaffold.
11
+
12
+ GENERATED metadata for the template layer - `stamp` resolves this profile by reading this file's `chain:`.
13
+
14
+ This profile is a leaf: it carries its files and chains nothing. A repo that
15
+ brings its own docs tree still inherits the gates, the docs lane, and the
16
+ release ladder by stamping this profile alone (`factory.json.profile =
17
+ "monoforge-headless"`).