@drawbridge/drawbridge-agents 0.1.6 → 0.1.8

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.
@@ -1,14 +1,22 @@
1
1
  #!/usr/bin/env node
2
- // Ensures the graphify runtime is installed (required for the family knowledge graph) and
3
- // registers its MCP server with the local assistant. Called by drawbridge-agents-sync.
4
- // Set DRAWBRIDGE_SKIP_GRAPHIFY=1 to skip in CI / headless environments.
2
+ // Ensures the graphify runtime is available for the family knowledge graph. NON-FATAL by design:
3
+ // if graphify can't be found or installed, warn and continue — `npm run sync` must never be
4
+ // blocked by it (the drift hook nudges separately, and the graph is built on demand).
5
+ // Set DRAWBRIDGE_SKIP_GRAPHIFY=1 to skip silently.
5
6
  const { execFileSync } = require('child_process')
7
+ const os = require('os')
8
+ const path = require('path')
6
9
 
7
10
  if (process.env.DRAWBRIDGE_SKIP_GRAPHIFY === '1') {
8
11
  console.log('drawbridge-agents-sync: DRAWBRIDGE_SKIP_GRAPHIFY set — skipping graphify preflight')
9
12
  process.exit(0)
10
13
  }
11
14
 
15
+ // npm runs scripts under a minimal shell (sh), so tools installed by uv/pipx into ~/.local/bin
16
+ // are often not on PATH. Add common user-bin dirs so an installed graphify is still found.
17
+ const extra = [ path.join(os.homedir(), '.local', 'bin'), '/opt/homebrew/bin' ]
18
+ process.env.PATH = [ ...extra, process.env.PATH || '' ].join(path.delimiter)
19
+
12
20
  const has = (cmd) => {
13
21
  try {
14
22
  execFileSync(cmd, [ '--version' ], { stdio: 'ignore' })
@@ -18,37 +26,30 @@ const has = (cmd) => {
18
26
  }
19
27
  }
20
28
 
21
- if (!has('graphify')) {
22
- console.log('drawbridge-agents-sync: graphify runtime not found, attempting install...')
23
- const attempts = [
24
- [ 'uv', [ 'tool', 'install', 'graphifyy' ] ],
25
- [ 'pipx', [ 'install', 'graphifyy' ] ],
26
- [ 'pip', [ 'install', '--user', 'graphifyy' ] ],
27
- [ 'pip3', [ 'install', '--user', 'graphifyy' ] ]
28
- ]
29
- for (const [ cmd, args ] of attempts) {
30
- if (!has(cmd)) continue
31
- try {
32
- execFileSync(cmd, args, { stdio: 'inherit' })
33
- break
34
- } catch (error) {
35
- // try the next installer
36
- }
37
- }
38
- if (!has('graphify')) {
39
- console.error([
40
- 'drawbridge-agents-sync: could not install the graphify runtime automatically.',
41
- 'Install it, then re-run npm run sync:',
42
- ' uv tool install graphifyy (recommended)',
43
- ' pipx install graphifyy',
44
- ' pip install --user graphifyy',
45
- 'Or set DRAWBRIDGE_SKIP_GRAPHIFY=1 to skip (CI / headless only).'
46
- ].join('\n'))
47
- process.exit(1)
29
+ if (has('graphify')) {
30
+ console.log('drawbridge-agents-sync: graphify runtime ready')
31
+ process.exit(0)
32
+ }
33
+
34
+ // Best-effort install if a Python tool installer is available; never fail if none is.
35
+ for (const [ cmd, args ] of [
36
+ [ 'uv', [ 'tool', 'install', 'graphifyy' ] ],
37
+ [ 'pipx', [ 'install', 'graphifyy' ] ],
38
+ [ 'pip', [ 'install', '--user', 'graphifyy' ] ],
39
+ [ 'pip3', [ 'install', '--user', 'graphifyy' ] ]
40
+ ]) {
41
+ if (!has(cmd)) continue
42
+ try {
43
+ execFileSync(cmd, args, { stdio: 'inherit' })
44
+ break
45
+ } catch (error) {
46
+ // try the next installer
48
47
  }
49
48
  }
50
49
 
51
- // Note: we deliberately do NOT run `graphify install` — it writes a graphify section into the
52
- // repo's CLAUDE.md and a PreToolUse hook, which would mutate a committed file and clash with the
53
- // shared CLAUDE.md. Agents use the graphify CLI directly (see conventions/graphify.md).
54
- console.log('drawbridge-agents-sync: graphify runtime ready (run `npx drawbridge-agents-graph` to build the graph)')
50
+ if (has('graphify')) {
51
+ console.log('drawbridge-agents-sync: graphify runtime installed')
52
+ } else {
53
+ console.warn('drawbridge-agents-sync: graphify not found (optional) — install with `uv tool install graphifyy` to enable the family knowledge graph. Continuing.')
54
+ }
55
+ process.exit(0)
@@ -90,9 +90,13 @@ const migrateOldDelivery = () => {
90
90
  }
91
91
  }
92
92
 
93
- // 3. Ensure the graphify runtime is present + reachable (hard-fails if it can't be).
93
+ // 3. Ensure the graphify runtime is present (best-effort, never blocks sync).
94
94
  const graphifyPreflight = () => {
95
- execFileSync('node', [ path.join(packageRoot, 'bin', 'preflight-graphify.js') ], { stdio: 'inherit' })
95
+ try {
96
+ execFileSync('node', [ path.join(packageRoot, 'bin', 'preflight-graphify.js') ], { stdio: 'inherit' })
97
+ } catch (error) {
98
+ console.warn('drawbridge-agents-sync: graphify preflight skipped (' + error.message + ')')
99
+ }
96
100
  }
97
101
 
98
102
  mirrorTemplates()
package/claude/CLAUDE.md CHANGED
@@ -16,3 +16,4 @@
16
16
  @../conventions/superpowers-docs.md
17
17
  @../conventions/git-branching.md
18
18
  @../conventions/graphify.md
19
+ @../conventions/testing.md
@@ -0,0 +1,25 @@
1
+ # Testing
2
+
3
+ Full strategy, conventions, and per-repo coverage map live in
4
+ `drawbridge-docs/testing/README.md`. The essentials:
5
+
6
+ - **Run `npm test` before shipping.** Every service and package has a
7
+ `node:test` suite (`node --test test/`). Run it with the family Node
8
+ (`nvm use`).
9
+ - **Unit tests live in the repo they test** — `test/*.test.js`, zero
10
+ dependencies, no README (knowledge is centralized in drawbridge-docs). They
11
+ version with the code and gate package publishes
12
+ (`tsup && node --test test/ && npm publish`).
13
+ - **Black-box tests live in `drawbridge-tests`** — the Playwright smoke pack,
14
+ the k6 load scenarios, and the family results ledger. No app or package repo
15
+ carries E2E or load tooling.
16
+ - **Two standing policies:** every repo keeps an export-smoke test (a dropped
17
+ export is a silent-undefined production throw — this has happened); every
18
+ fixed production incident gets a same-day regression test naming the
19
+ incident.
20
+ - **Next.js apps get pure-logic tests only** — no jsdom/component testing; UI
21
+ correctness is the smoke pack's job. Extract a pure seam into `lib/` rather
22
+ than importing a react/next module into a test.
23
+ - When a module reads env at require time, stub dummies BEFORE the require.
24
+ Node v20.9's MockTimers mishandles interleaved clears — use real timers for
25
+ timer-based logic.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawbridge/drawbridge-agents",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Shared agent-instruction content (rules, code style, conventions) for the drawbridge-* monorepo.",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
@@ -8,7 +8,8 @@
8
8
  },
9
9
  "scripts": {
10
10
  "sync": ". \"$HOME/.nvm/nvm.sh\" && nvm use && npm prune && npm install",
11
- "build": "npm publish"
11
+ "test": ". \"$HOME/.nvm/nvm.sh\" && nvm use && node --test",
12
+ "build": ". \"$HOME/.nvm/nvm.sh\" && nvm use && node --test && npm publish"
12
13
  },
13
14
  "bin": {
14
15
  "drawbridge-agents-sync": "bin/sync-claude.js",