bearings 0.3.0 → 0.3.2

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 CHANGED
@@ -1,6 +1,8 @@
1
1
  # bearings
2
2
 
3
- `bearings` is a small TypeScript CLI that helps you give your agents their bearings: it scaffolds an agent-friendly repository setup, exposes shared skills and commands to supported harnesses, records the generated files in a manifest, and leaves project-specific tailoring to your AI agent via `/setup-repo`.
3
+ `bearings` is a small TypeScript CLI that helps you give your agents their bearings: it scaffolds an agent-friendly repository setup, exposes shared skills and commands to supported harnesses, records every generated file in a manifest, and leaves project-specific tailoring to your AI agent via `/setup-repo`.
4
+
5
+ Requires Node >= 24.
4
6
 
5
7
  ## Quick Start
6
8
 
@@ -11,9 +13,11 @@ bearings verify
11
13
  ```
12
14
 
13
15
  1. `npx bearings init` writes the generic scaffold and prints the next step.
14
- 2. `/setup-repo` runs inside your AI agent to merge backups, fill placeholders, seed docs, and tailor skills.
16
+ 2. `/setup-repo` runs inside your AI agent to review backups, fill placeholders, seed docs, and tailor the setup.
15
17
  3. `bearings verify` checks the scaffold for drift, missing files, broken exposures, and unresolved setup warnings.
16
18
 
19
+ Re-run `npx bearings init` later to update an initialized repository. There is no separate `update` verb — `init` dispatches on manifest state (ADR-0001).
20
+
17
21
  ## What Gets Generated
18
22
 
19
23
  ```text
@@ -34,11 +38,6 @@ docs/
34
38
  refresh-repo-map.md
35
39
  setup-repo.md
36
40
  skills/
37
- repo-navigation/SKILL.md
38
- implementing-task/SKILL.md
39
- installing-dependencies/SKILL.md
40
- secrets-handling/SKILL.md
41
- enforcement-gates/SKILL.md
42
41
  commit-convention/SKILL.md
43
42
  defer-work/SKILL.md
44
43
  resurface-deferred-work/SKILL.md
@@ -51,9 +50,11 @@ docs/
51
50
  skills/*
52
51
  ```
53
52
 
53
+ Every file carries an `owner` in the manifest. `bearings`-owned files (`CLAUDE.md`, the ADR template, commands, skills) are package-maintained — the incoming template is their canonical update source. `agent`-owned files (`AGENTS.md`, the three maps, the two indexes) are yours; bearings never overwrites them without an explicit per-file decision.
54
+
54
55
  `/setup-repo` creates `docs/diagrams/c4-component.puml` (via `/refresh-repo-map`) once the repo is tailored; it is not part of the generated scaffold or the manifest.
55
56
 
56
- Existing scaffold targets are backed up as `<path>.bkp` before replacement. Re-running `init` skips unchanged managed files.
57
+ Existing files that collide with a scaffold target are backed up as `<path>.bkp` before replacement, and the backup is recorded as a pending reconciliation for `/setup-repo` to resolve.
57
58
 
58
59
  ## The Model
59
60
 
@@ -72,24 +73,59 @@ user task
72
73
 
73
74
  ### `bearings init`
74
75
 
75
- Scaffold the agent-friendly setup in the current repository.
76
+ State-aware entry point. With no manifest it scaffolds; with a manifest it runs an interactive update; with a corrupt manifest it enters reconstruction.
76
77
 
77
78
  | Flag | Meaning |
78
79
  |---|---|
79
80
  | `--harness <name...>` | Expose to `claude` and/or `opencode`. Defaults to detected harness dirs, or both in a fresh repo. |
80
81
  | `--copy` | Copy exposures instead of symlinking them. `verify` checks copy drift. |
81
- | `-y`, `--yes` | Accept defaults and do not prompt. |
82
+ | `-y`, `--yes` | Accept defaults and do not prompt. Fresh init only. |
83
+
84
+ **Fresh init** — scans the repo, resolves harness/exposure, aborts on unmanaged adapter collisions before writing anything, generates the scaffold, exposes `.agents/{commands,skills}/*` per harness, writes the v2 manifest, and hands off to `/setup-repo`.
85
+
86
+ **Update** — interactive only (requires a TTY; `--yes` has no effect). It refuses to downgrade the recorded bearings version and refuses to start while a prior update's `/setup-repo` handoff is still pending. Each managed file is classified against its manifest baseline:
87
+
88
+ | Situation | What happens |
89
+ |---|---|
90
+ | Content matches baseline | Kept silently |
91
+ | Template changed, file unchanged locally | Replaced |
92
+ | File changed locally **and** in the template | Conflict — you choose **Replace**, **Merge** (back up your content for `/setup-repo`), or **Skip** (decline this revision; it won't re-prompt) |
93
+ | File no longer shipped, unchanged locally | Removed |
94
+ | File no longer shipped, changed locally | You choose **Remove** or **Keep and untrack** |
95
+ | New scaffold path already occupied | Conflict, resolved the same way |
96
+
97
+ Adapter changes (harness added/removed, symlink↔copy switch) are planned alongside. The full plan is shown and confirmed before any mutation, then applied as a single transaction — the manifest is written last, and any failure restores the exact prior state. A run that changes nothing reports `already up to date`.
98
+
99
+ **Reconstruction** — when the manifest is missing fields, hash-broken, or otherwise invalid, harness and exposure config is detected from the adapters on disk, confirmed with you, and a fresh v2 manifest is rebuilt.
82
100
 
83
101
  ### `bearings verify`
84
102
 
85
- Check the manifest and harness exposures for mechanical breakage. Exit code `0` means no failures; exit code `1` means one or more failures.
103
+ Check the manifest and harness exposures for mechanical breakage. Exit code `0` means no failures; exit code `1` means one or more failures. Warnings never affect the exit code.
86
104
 
87
105
  | Code | Severity | Condition |
88
106
  |---|---|---|
89
107
  | `no-manifest` | fail | `.agents/bearings.json` missing |
108
+ | `invalid-manifest` | fail | manifest fails structural validation |
90
109
  | `missing-file` | fail | manifest entry path doesn't exist |
91
110
  | `missing-exposure` | fail | a child of `.agents/skills` or `.agents/commands` absent from a configured harness dir |
92
111
  | `broken-symlink` | fail | harness entry is a symlink whose target doesn't resolve |
93
112
  | `copy-drift` | fail | copy mode: harness file content differs from `.agents` source content |
113
+ | `setup-pending` | warn | an update finished but `/setup-repo` hasn't run yet |
94
114
  | `unfilled-placeholder` | warn | a bearings-generated file still contains `<agent:` |
95
115
  | `unreviewed-backup` | warn | manifest `backup` path still exists on disk |
116
+ | `pending-reconciliation` | warn | a recorded backup from a collision or Merge is still unresolved |
117
+
118
+ ## Development
119
+
120
+ ```sh
121
+ npm test # rebuilds dist/ via pretest, then runs the full Vitest suite
122
+ npm run build
123
+ ```
124
+
125
+ - `docs/ARCHITECTURE.md` — components, dependency direction, build shape.
126
+ - `docs/CODEBASE_MAP.md` — capability-to-source routing with `path#symbol` anchors.
127
+ - `docs/DOMAIN.md` — terminology, workflows, and domain rules.
128
+ - `docs/adr/INDEX.md` — consequential decisions.
129
+ - `docs/qa/RELEASE_QA.md` — manual pre-release tiers, staged by `node scripts/qa.ts setup`.
130
+
131
+ This repo is maintained by bearings itself; see `AGENTS.md` for the dogfooding ownership rules before editing any managed file.
@@ -7,11 +7,6 @@ function templatesDir() {
7
7
  return join(dirname(fileURLToPath(import.meta.url)), "..", "templates");
8
8
  }
9
9
  var SKILLS = [
10
- "repo-navigation",
11
- "implementing-task",
12
- "installing-dependencies",
13
- "secrets-handling",
14
- "enforcement-gates",
15
10
  "commit-convention",
16
11
  "defer-work",
17
12
  "resurface-deferred-work",
@@ -31,7 +26,7 @@ var SCAFFOLD = [
31
26
  ...SKILLS.map((skill) => ({
32
27
  template: `agents/skills/${skill}/SKILL.md`,
33
28
  target: `.agents/skills/${skill}/SKILL.md`,
34
- owner: skill === "installing-dependencies" || skill === "secrets-handling" ? "agent" : "bearings"
29
+ owner: "bearings"
35
30
  }))
36
31
  ];
37
32
 
@@ -638,7 +633,7 @@ async function runFreshInit(repoDir, flags, version) {
638
633
  async function runInit(repoDir, flags, version) {
639
634
  const state = await inspectManifest(repoDir);
640
635
  if (state.kind === "absent") return runFreshInit(repoDir, flags, version);
641
- const { runUpdate } = await import("./update-GAIUBEGX.js");
636
+ const { runUpdate } = await import("./update-5F7TZEUH.js");
642
637
  return runUpdate(repoDir, flags, version, state);
643
638
  }
644
639
 
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  runInit,
6
6
  sha256,
7
7
  validateHarnesses
8
- } from "./chunk-GUIHDRBB.js";
8
+ } from "./chunk-VRWQ3OWC.js";
9
9
 
10
10
  // src/cli.ts
11
11
  import { Command } from "commander";
@@ -10,7 +10,7 @@ import {
10
10
  sha256,
11
11
  templatesDir,
12
12
  validateHarnesses
13
- } from "./chunk-GUIHDRBB.js";
13
+ } from "./chunk-VRWQ3OWC.js";
14
14
 
15
15
  // src/semver.ts
16
16
  function parseSemver(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bearings",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Give your AI agents their bearings — scaffold an agent-friendly setup in any repository.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -47,9 +47,9 @@ When `.agents/bearings.json` is manifest v2 and has `setupPending`:
47
47
  4. Fill only the `AGENTS.md` project-purpose and primary-stack placeholders.
48
48
  Keep `AGENTS.md` a thin router — do not add a skill table, invariants
49
49
  section, or always-on rules block.
50
- 5. Tailor only the agent-owned starter skills (`installing-dependencies`,
51
- `secrets-handling`) to this project. Create a new project-specific skill
52
- only when native skill discovery has no adequate existing match.
50
+ 5. Create a project-specific skill only when native skill discovery has no
51
+ adequate existing match. Every starter skill is bearings-owned — leave
52
+ them untouched.
53
53
  6. Run the `/refresh-repo-map` workflow to initialize `docs/DOMAIN.md`,
54
54
  `docs/ARCHITECTURE.md`, `docs/CODEBASE_MAP.md`, and
55
55
  `docs/diagrams/c4-component.puml`.
@@ -69,10 +69,9 @@ When `.agents/bearings.json` is manifest v2 and has `setupPending`:
69
69
  of a Backup File is the developer's call.
70
70
  - Do not edit `.agents/bearings.json` except where this workflow requires
71
71
  it.
72
- - Do not change bearings-owned starter commands or skills; tailor only the
73
- agent-owned starter skills. The one exception: a reconciliation that records
74
- an explicit Merge decision permits applying that Backup File's changes
75
- directly to its bearings-owned target.
72
+ - Do not change bearings-owned starter commands or skills. The one exception:
73
+ a reconciliation that records an explicit Merge decision permits applying
74
+ that Backup File's changes directly to its bearings-owned target.
76
75
  - Do not add a skill registry row to `AGENTS.md` — native skill discovery
77
76
  replaces it.
78
77
  - Do not invent domain or technical constraints — every stated constraint
@@ -1,36 +0,0 @@
1
- ---
2
- name: enforcement-gates
3
- description: Use when a local hook, lint, typecheck, test, build, validation, or CI gate fails.
4
- ---
5
-
6
- # Enforcement Gates
7
-
8
- ## Purpose
9
-
10
- Diagnose failed gates from evidence, fix the underlying issue, and avoid bypassing safety checks.
11
-
12
- ## Triggers
13
-
14
- - A pre-commit, pre-push, CI, lint, typecheck, test, build, validation, or policy gate fails.
15
- - You are tempted to skip or weaken a check.
16
-
17
- ## Required Workflow
18
-
19
- 1. Capture the failing command and first relevant error -> identify the gate, not a symptom.
20
- 2. Fix the smallest underlying cause -> keep the gate intact.
21
- 3. Re-run the failed gate -> confirm it passes.
22
- 4. Run adjacent verification if the fix changes behavior -> prevent regressions.
23
-
24
- ## Rules
25
-
26
- - Do: preserve strict gate settings and cite the command/output in the report.
27
- - Do not: bypass hooks, lower thresholds, delete tests, or silence errors without a documented reason.
28
-
29
- ## Verification
30
-
31
- - Run `<agent: fill during handoff — standard gate command>` after fixing any gate failure.
32
-
33
- ## References
34
-
35
- - `<agent: fill during handoff — CI config path>` - canonical gate list.
36
- - `<agent: fill during handoff — local hook config path>` - developer gate list.
@@ -1,45 +0,0 @@
1
- ---
2
- name: implementing-task
3
- description: Use when implementing planned work from a task, issue, spec, or phase document.
4
- ---
5
-
6
- # Implementing Task
7
-
8
- ## Purpose
9
-
10
- Execute planned work without drifting from scope, skipping verification, or mixing unrelated changes.
11
-
12
- ## Triggers
13
-
14
- - You are implementing a task/spec/issue with explicit requirements.
15
- - You are changing code under a feature or phase plan.
16
-
17
- ## Required Workflow
18
-
19
- 1. Read the task source and the entire `docs/CODEBASE_MAP.md` -> identify
20
- exact scope, exclusions, and owning `path#symbol` anchors.
21
- 2. Load `docs/DOMAIN.md`, `docs/ARCHITECTURE.md`, `docs/adr/INDEX.md`, or
22
- `docs/deferred/INDEX.md` only when the task's trigger matches.
23
- 3. Write or update the smallest failing test first -> confirm the expected RED failure.
24
- 4. Implement the minimal change -> keep unrelated files untouched.
25
- 5. Run the required verification -> record command and outcome.
26
- 6. Run `/refresh-repo-map` only after this task's changes are committed and
27
- they meaningfully alter shipped behavior, structure, or source routing, or
28
- after detected staleness -> never patch the owned maps directly.
29
-
30
- ## Rules
31
-
32
- - Do: preserve exact values, paths, and commands from the task source.
33
- - Do not: pull future-phase work forward or silently expand scope.
34
- - Do not: edit `docs/DOMAIN.md`, `docs/ARCHITECTURE.md`,
35
- `docs/CODEBASE_MAP.md`, or `docs/diagrams/c4-component.puml` directly;
36
- route every change through `/refresh-repo-map`.
37
-
38
- ## Verification
39
-
40
- - Run `<agent: fill during handoff — smallest command that proves a planned task>` before reporting completion.
41
-
42
- ## References
43
-
44
- - `docs/CODEBASE_MAP.md` - current capability/concern-to-source map.
45
- - `docs/DOMAIN.md`, `docs/ARCHITECTURE.md`, `docs/adr/INDEX.md`, `docs/deferred/INDEX.md` - trigger-matched context.
@@ -1,42 +0,0 @@
1
- ---
2
- name: installing-dependencies
3
- description: Use when adding, removing, or updating dependencies, package-manager metadata, lockfiles, or workspace package links.
4
- ---
5
-
6
- # Installing Dependencies
7
-
8
- ## Purpose
9
-
10
- Keep dependency changes reproducible, scoped to the correct package, and aligned with the project's package manager.
11
-
12
- ## Triggers
13
-
14
- - Adding, removing, or upgrading an external package.
15
- - Linking an internal workspace package.
16
- - Editing package manifests or lockfiles.
17
-
18
- ## Required Workflow
19
-
20
- 1. Identify package manager and workspace shape -> `<agent: fill during handoff — package manager and workspace command rules>`.
21
- 2. Identify the owning package/app -> avoid installing at the wrong level.
22
- 3. Run the package manager command -> update manifest and lockfile together.
23
- 4. Run dependency-sensitive verification -> prove install and imports work.
24
- 5. If the change is architecture-significant (a new runtime dependency, a
25
- replaced core dependency, or a changed dependency role) -> route it to
26
- `docs/ARCHITECTURE.md` through `/refresh-repo-map` once committed; do not
27
- edit that map directly.
28
-
29
- ## Rules
30
-
31
- - Do: use `<agent: fill during handoff — approved package manager command>` for dependency changes.
32
- - Do not: edit lockfiles by hand or mix unrelated dependency upgrades.
33
-
34
- ## Verification
35
-
36
- - Run `<agent: fill during handoff — install/build/test command after dependency changes>` when dependency metadata changes.
37
-
38
- ## References
39
-
40
- - `<agent: fill during handoff — package manifest path>` - dependency owner.
41
- - `<agent: fill during handoff — lockfile path>` - resolved dependency graph.
42
- - `docs/ARCHITECTURE.md` - significant-dependency routing target via `/refresh-repo-map`.
@@ -1,53 +0,0 @@
1
- ---
2
- name: repo-navigation
3
- description: Use when exploring the repo, locating code, or deciding which docs and paths to read before making changes.
4
- ---
5
-
6
- # Repo Navigation
7
-
8
- ## Purpose
9
-
10
- Route straight to owning source using the codebase map, and load domain,
11
- architecture, decision, or deferred-work context only when the task actually
12
- needs it.
13
-
14
- ## Triggers
15
-
16
- - You need to understand where code, docs, commands, or ownership rules live.
17
- - You are about to do broad repository exploration.
18
-
19
- ## Required Workflow
20
-
21
- 1. Read the entire `docs/CODEBASE_MAP.md` before any source work -> use its
22
- `path#symbol` anchors as the routing model.
23
- 2. Load `docs/DOMAIN.md` only when the task turns on behavior, requirements,
24
- workflows, terminology, scope, or domain rules.
25
- 3. Load `docs/ARCHITECTURE.md` only when the task turns on components,
26
- dependency direction, integrations, state ownership, significant
27
- dependencies, or environment/build shape.
28
- 4. Load `docs/adr/INDEX.md` and only matching ADRs when a consequential
29
- decision constrains the task.
30
- 5. Load `docs/deferred/INDEX.md` and only matching details when planning a
31
- new capability.
32
- 6. If any loaded map is stale -> report the mismatch and continue from direct
33
- evidence.
34
-
35
- ## Rules
36
-
37
- - Do: prefer the codebase map, other durable docs, manifests, and entry
38
- points before deep file walks.
39
- - Do not: crawl archived, generated, vendored, or build-output folders unless
40
- the task explicitly needs them.
41
- - Do not: load a map whose trigger does not match the current task.
42
-
43
- ## Verification
44
-
45
- - Run `<agent: fill during handoff — smallest command that proves navigation-sensitive changes>` when exploration changes generated docs or routing metadata.
46
-
47
- ## References
48
-
49
- - `docs/CODEBASE_MAP.md` - current capability/concern-to-source map.
50
- - `docs/DOMAIN.md` - business language and workflows.
51
- - `docs/ARCHITECTURE.md` - stable technical shape and environment.
52
- - `docs/adr/INDEX.md` - consequential decision registry.
53
- - `docs/deferred/INDEX.md` - approved postponed-work registry.
@@ -1,37 +0,0 @@
1
- ---
2
- name: secrets-handling
3
- description: Use when touching credentials, tokens, keys, secret references, config containing secrets, or secret redaction paths.
4
- ---
5
-
6
- # Secrets Handling
7
-
8
- ## Purpose
9
-
10
- Prevent secrets from being committed, logged, exposed through APIs, or stored outside the approved secret store.
11
-
12
- ## Triggers
13
-
14
- - Storing, reading, rotating, deleting, or displaying credentials.
15
- - Editing config, environment files, CI secrets, tokens, keys, or redaction logic.
16
- - Adding a new integration that needs a secret.
17
-
18
- ## Required Workflow
19
-
20
- 1. Identify the secret and owner -> `<agent: fill during handoff — secret store/provider and ownership rule>`.
21
- 2. Store only references in code/config where possible -> keep raw values in the approved store.
22
- 3. Verify redaction boundaries -> responses, logs, errors, docs, and tests must not reveal secret values.
23
- 4. Rotate or revoke exposed values -> treat accidental disclosure as a security incident.
24
-
25
- ## Rules
26
-
27
- - Do: use `<agent: fill during handoff — approved secret reference pattern>` for secret lookup and storage.
28
- - Do not: commit raw secrets, print them, include them in snapshots, or expose secret references where the project forbids it.
29
-
30
- ## Verification
31
-
32
- - Run `<agent: fill during handoff — secret/config validation command>` when secret handling changes.
33
-
34
- ## References
35
-
36
- - `<agent: fill during handoff — secret management doc/path>` - approved store and redaction contract.
37
- - `<agent: fill during handoff — config/env schema path>` - allowed secret references.