farna-bootstrapper 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/LICENSE +30 -0
  3. package/NOTICE +42 -0
  4. package/README.md +1102 -2
  5. package/SECURITY.md +65 -0
  6. package/dist/cli/commands/check.d.ts +58 -0
  7. package/dist/cli/commands/check.js +198 -0
  8. package/dist/cli/commands/generate.d.ts +75 -0
  9. package/dist/cli/commands/generate.js +218 -0
  10. package/dist/cli/commands/init.d.ts +52 -0
  11. package/dist/cli/commands/init.js +271 -0
  12. package/dist/cli/main.d.ts +2 -0
  13. package/dist/cli/main.js +51 -0
  14. package/dist/cli/program.d.ts +23 -0
  15. package/dist/cli/program.js +183 -0
  16. package/dist/compose/resolve.d.ts +161 -0
  17. package/dist/compose/resolve.js +576 -0
  18. package/dist/config/load.d.ts +4 -0
  19. package/dist/config/load.js +45 -0
  20. package/dist/config/schema.d.ts +22 -0
  21. package/dist/config/schema.js +46 -0
  22. package/dist/core/constants.d.ts +279 -0
  23. package/dist/core/constants.js +351 -0
  24. package/dist/core/errors.d.ts +44 -0
  25. package/dist/core/errors.js +75 -0
  26. package/dist/core/fs.d.ts +31 -0
  27. package/dist/core/fs.js +169 -0
  28. package/dist/core/json.d.ts +22 -0
  29. package/dist/core/json.js +174 -0
  30. package/dist/core/paths.d.ts +45 -0
  31. package/dist/core/paths.js +110 -0
  32. package/dist/core/text.d.ts +10 -0
  33. package/dist/core/text.js +27 -0
  34. package/dist/index.d.ts +10 -0
  35. package/dist/index.js +1 -0
  36. package/dist/lock/lockfile.d.ts +230 -0
  37. package/dist/lock/lockfile.js +333 -0
  38. package/dist/materialise/source-tree.d.ts +77 -0
  39. package/dist/materialise/source-tree.js +267 -0
  40. package/dist/permissions/permissions.d.ts +128 -0
  41. package/dist/permissions/permissions.js +452 -0
  42. package/dist/render/commit.d.ts +59 -0
  43. package/dist/render/commit.js +279 -0
  44. package/dist/render/generate-lock.d.ts +9 -0
  45. package/dist/render/generate-lock.js +203 -0
  46. package/dist/render/identity.d.ts +23 -0
  47. package/dist/render/identity.js +396 -0
  48. package/dist/render/orphans.d.ts +59 -0
  49. package/dist/render/orphans.js +234 -0
  50. package/dist/render/port.d.ts +96 -0
  51. package/dist/render/port.js +1 -0
  52. package/dist/render/prepare.d.ts +33 -0
  53. package/dist/render/prepare.js +139 -0
  54. package/dist/render/root-cleanliness.d.ts +28 -0
  55. package/dist/render/root-cleanliness.js +76 -0
  56. package/dist/render/stage.d.ts +36 -0
  57. package/dist/render/stage.js +92 -0
  58. package/dist/render/staging.d.ts +16 -0
  59. package/dist/render/staging.js +94 -0
  60. package/dist/render/structured.d.ts +35 -0
  61. package/dist/render/structured.js +258 -0
  62. package/dist/render/upstream.d.ts +41 -0
  63. package/dist/render/upstream.js +179 -0
  64. package/dist/report/format.d.ts +7 -0
  65. package/dist/report/format.js +97 -0
  66. package/dist/report/warnings.d.ts +21 -0
  67. package/dist/report/warnings.js +24 -0
  68. package/dist/source/digest.d.ts +18 -0
  69. package/dist/source/digest.js +77 -0
  70. package/dist/source/frontmatter.d.ts +12 -0
  71. package/dist/source/frontmatter.js +29 -0
  72. package/dist/source/load.d.ts +103 -0
  73. package/dist/source/load.js +676 -0
  74. package/dist/source/schema.d.ts +154 -0
  75. package/dist/source/schema.js +292 -0
  76. package/dist/source/yaml.d.ts +10 -0
  77. package/dist/source/yaml.js +49 -0
  78. package/dist/verify/containment.d.ts +22 -0
  79. package/dist/verify/containment.js +753 -0
  80. package/package.json +79 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,107 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
6
+ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Before 1.0.0, a minor
7
+ release may contain a breaking change; every change of that kind is listed under **Changed**.
8
+
9
+ ## [0.1.1] - 2026-11-22
10
+
11
+ ### Added
12
+
13
+ - **Persona `mode`.** A persona may declare `mode: primary`, `subagent` or `all`, which both
14
+ OpenCode targets emit as the per-agent `mode`. The default when the key is absent is `subagent`,
15
+ so an existing source renders byte for byte as before. The value composes with `extends`: a
16
+ derived persona inherits its base's mode and may override it.
17
+ - **`W117_PERSONA_MODE_IGNORED`.** Claude Code has no primary/subagent mode, so a persona that
18
+ declares `mode` on the `claudecode` target is reported at info severity, naming the persona and
19
+ the target, and the emitted Claude Code file carries no `mode` key.
20
+
21
+ Both OpenCode examples now declare `mode: primary` on their live persona, and the README documents
22
+ the field, its composition and the Claude Code warning.
23
+
24
+ ## [0.1.0] - 2026-11-22
25
+
26
+ The first public release. `farna-bootstrapper` compiles named agent personas and their resources
27
+ into the configuration a coding harness reads, records what it wrote, and proves the committed
28
+ output still matches the source.
29
+
30
+ ### Added
31
+
32
+ - **Three commands.** `init` creates the `.farna/` source root, the empty resource directories, and
33
+ the `.gitignore` and `.gitattributes` lines the generated files need. `generate` renders,
34
+ verifies and writes the managed files plus `.farna/lock.json`; `--dry-run`, `--adopt` and
35
+ `--json` are supported. `check` re-renders into a temporary directory and exits `1` on any drift.
36
+ - **Three targets.** `claudecode` writes `.claude/agents/<id>.md`; `opencode` (OpenCode V2, package
37
+ `@opencode/cli`) and `opencodev1` (OpenCode V1, package `opencode-ai`) both write
38
+ `.opencode/agents/<id>.md` in each major's own shapes. Exactly one target is configured per run.
39
+ - **OpenCode V1 support (`opencodev1`).** The V1 target writes OpenCode 1.x shapes: V1 agent
40
+ frontmatter with `name` and the per-tool `permission` map, the flat `mcp.<name>` map with
41
+ `enabled: true`, V1 command frontmatter and the `RulesyncHooksPlugin` module. Profile mode works
42
+ for both OpenCode targets, and a target switch rewrites the recorded paths in place rather than
43
+ orphaning them. Configuring both OpenCode targets in one run is `F001`. `examples/opencode-v1/`
44
+ is the V1 profile-mode example; `examples/opencode-v2/` is the V2 profile-mode example and uses
45
+ `@opencode/cli`.
46
+ - **Agent and profile modes.** Agent mode is the default and carries every persona per agent.
47
+ Profile mode, supported for both OpenCode targets, makes exactly one persona live so it can own
48
+ the workspace: `opencode.jsonc` at the repository root, plus its skills, commands and hooks under
49
+ `.opencode/`. `targets.opencode.active` selects the persona, and `--persona` overrides it for one
50
+ run. Every resolved-but-not-live persona is reported (`notLive`).
51
+ - **Persona composition.** A persona may extend one base persona. Rules and permissions are unioned
52
+ by `(kind, id)`, the stricter permission value wins, and two different concrete models in one
53
+ composed set are refused.
54
+ - **Six resource kinds plus a model class.** `rule`, `permission`, `mcp`, `skill`, `command` and
55
+ `hook` are strict sources; a persona names its model class in the persona file. MCP credentials
56
+ are environment references only.
57
+ - **Permission mapping.** Canonical categories map to each target's own byte form: Claude Code's
58
+ `Read`/`Write`/`Edit`/`Bash`/`Agent` entries and per-agent `tools`/`disallowedTools`; OpenCode's
59
+ ordered `{ action, resource, effect }` records. A category neither target can carry is refused rather
60
+ than emitted as an inert string. An opt-in Claude Code `tools` allow-list is reported when it
61
+ narrows the tool set.
62
+ - **Ownership with an explicit record.** `.farna/lock.json` records every managed path with its
63
+ size and SHA-256, each persona's composition and digests, the source warnings, and the pinned
64
+ renderer identity. It contains no timestamps, hostnames or absolute paths. `generate` removes a
65
+ recorded orphan only when it is in a managed location, is still a regular file, still has the
66
+ recorded bytes, and is recorded. `opencode.jsonc` is owned by its `mcp` key only, edited in
67
+ place so the user's own keys and comments survive.
68
+ - **Renderer pin.** `rulesync` is pinned to exactly `43.11.0` with a tarball integrity, imported by
69
+ one module behind a port. A different version is refused; a different npm-recorded integrity is
70
+ refused; when no integrity can be found the version check still applies and
71
+ `W114_RENDERER_INTEGRITY_UNVERIFIED` names the gap.
72
+ - **Fail-closed generation.** Every gate runs before the first byte is written. Managed files are
73
+ staged and renamed; a caught write failure restores what it replaced and names anything it could
74
+ not restore. One `generate` runs at a time through a local lock.
75
+ - **Release packaging.** The package publishes the ESM library types entry, the CLI `bin`, the
76
+ README, CHANGELOG, LICENSE, NOTICE and SECURITY.md. Publishing uses npm provenance.
77
+ - **No telemetry, no phone-home, no Farna Control dependency.** Generation and checking make no
78
+ network request of their own, and a hook, MCP server or command the tool writes is never executed
79
+ by it.
80
+
81
+ ### Known limitations
82
+
83
+ - **One target per run.** More than one configured target is refused; the lockfile and mode plan
84
+ are per-target.
85
+ - **No `doctor` command.** `--dry-run` prints the plan, but there is no capability-report command.
86
+ - **`claudecode` profile mode is not implemented**, and the workspace resource kinds (`mcp`,
87
+ `skill`, `command`, `hook`) are not carried by `claudecode` at all in this release.
88
+ - **Both OpenCode targets carry the workspace resource kinds in profile mode only.** Agent mode
89
+ refuses a reference with `F001` rather than emitting it workspace-wide. A hook OpenCode cannot
90
+ represent (`session-end`, or a matcher on a non-tool event) is reported (`W101`) and not emitted.
91
+ - **No cross-target single run, no `patch`/`replaceWith`, no per-target filters, no `--strict`, no
92
+ `.farna/local.jsonc` override, no region ownership (`CLAUDE.md`/`AGENTS.md`).** `opencode.jsonc`
93
+ is the only structured file, and the only key it owns is `mcp`.
94
+ - **TOCTOU and crash windows remain.** A symlink swapped in between the `lstat` preflight and the
95
+ write is not detected; a process kill between two renames can leave a mixed tree that `check`
96
+ reports and a re-run repairs.
97
+ - **The renderer pin is provenance, not a sandbox.** A renderer patched in place with the same
98
+ version and tarball integrity is not detected.
99
+ - **No coverage threshold.** CI enforces lint, type-check, tests (with a minimum count and
100
+ real-renderer suite assertions), a dependency audit at `moderate`, and the published-tarball
101
+ contents.
102
+ - **Windows test skips.** The symlink regression suites (creating a symlink needs a privilege the
103
+ runner does not grant), the POSIX mode assertions, the FIFO cases and the install-layout suite are
104
+ skipped on Windows; CI runs them on Linux.
105
+
106
+ [0.1.1]: https://github.com/farnalabs/farna-bootstrapper/releases/tag/v0.1.1
107
+ [0.1.0]: https://github.com/farnalabs/farna-bootstrapper/releases/tag/v0.1.0
package/LICENSE ADDED
@@ -0,0 +1,30 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Farnalabs Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ Third-party software
24
+ --------------------
25
+
26
+ This project depends on rulesync (https://github.com/dyoshikawa/rulesync),
27
+ which is licensed under the MIT License, Copyright (c) 2024 dyoshikawa.
28
+ rulesync is used unmodified as a library; the renderer is pinned exactly and is
29
+ imported by exactly one module. The third-party licence text is reproduced in
30
+ NOTICE.
package/NOTICE ADDED
@@ -0,0 +1,42 @@
1
+ farna-bootstrapper
2
+ Copyright (c) 2026 Farnalabs Ltd
3
+
4
+ This product is licensed under the MIT License. The full text is in LICENSE.
5
+
6
+ This product includes software developed by third parties:
7
+
8
+ rulesync
9
+ https://github.com/dyoshikawa/rulesync
10
+ MIT License
11
+ Copyright (c) 2024 dyoshikawa
12
+
13
+ rulesync is used unmodified as a library dependency. Its version and tarball
14
+ integrity are pinned in package.json and recorded by the generated
15
+ .farna/lock.json. The licence text below is reproduced from the rulesync
16
+ package (node_modules/rulesync/LICENSE) as distributed with this release.
17
+
18
+ -------------------------------------------------------------------------------
19
+ rulesync
20
+
21
+ MIT License
22
+
23
+ Copyright (c) 2024 dyoshikawa
24
+
25
+ Permission is hereby granted, free of charge, to any person obtaining a copy
26
+ of this software and associated documentation files (the "Software"), to deal
27
+ in the Software without restriction, including without limitation the rights
28
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29
+ copies of the Software, and to permit persons to whom the Software is
30
+ furnished to do so, subject to the following conditions:
31
+
32
+ The above copyright notice and this permission notice shall be included in all
33
+ copies or substantial portions of the Software.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41
+ SOFTWARE.
42
+ -------------------------------------------------------------------------------