@thebassclef/lite 0.1.3 → 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 (293) hide show
  1. package/dist/cli.cjs +216 -137
  2. package/dist/cli.js +218 -139
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/lite/.bassclef-source.json +10 -0
  7. package/dist/lite/.claude/settings.json +212 -0
  8. package/dist/lite/CLAUDE.md +41 -0
  9. package/dist/lite/gitignore +58 -0
  10. package/dist/lite/standards/bassclef-wiring-manifest.json +497 -0
  11. package/dist/lite/whereami.md +24 -0
  12. package/package.json +8 -2
  13. package/substrate/.bassclef/lite-manifest.json +0 -2701
  14. package/substrate/.claude/agents/architect.md +0 -70
  15. package/substrate/.claude/agents/builder.md +0 -114
  16. package/substrate/.claude/agents/designer.md +0 -156
  17. package/substrate/.claude/agents/reviewer.md +0 -88
  18. package/substrate/.claude/hooks/artifact-ingestion-gate.sh +0 -357
  19. package/substrate/.claude/hooks/assert-verify-steering.sh +0 -77
  20. package/substrate/.claude/hooks/bassclef-source-config-validate.sh +0 -215
  21. package/substrate/.claude/hooks/bassclef-sync.sh +0 -634
  22. package/substrate/.claude/hooks/compound-noun-scrub.sh +0 -292
  23. package/substrate/.claude/hooks/kiss-expansion-inject.sh +0 -69
  24. package/substrate/.claude/hooks/longrun-prep-compounding-axis-check.sh +0 -492
  25. package/substrate/.claude/hooks/longrun-prep-compounding-sequence-check.sh +0 -492
  26. package/substrate/.claude/hooks/plain-english-steering.sh +0 -156
  27. package/substrate/.claude/hooks/post-skill-friction-check.sh +0 -177
  28. package/substrate/.claude/hooks/post-skill-telemetry.sh +0 -62
  29. package/substrate/.claude/hooks/pre-build-gate.sh +0 -511
  30. package/substrate/.claude/hooks/pre-commit-gate.sh +0 -451
  31. package/substrate/.claude/hooks/session-end.sh +0 -433
  32. package/substrate/.claude/hooks/session-reflection.sh +0 -303
  33. package/substrate/.claude/hooks/skill-body-grade-gate.sh +0 -219
  34. package/substrate/.claude/hooks/skill-body-intent-drift.sh +0 -107
  35. package/substrate/.claude/hooks/skill-step-list-check.sh +0 -171
  36. package/substrate/.claude/hooks/state-validate.sh +0 -271
  37. package/substrate/.claude/hooks/substrate-clarity-gate.sh +0 -1110
  38. package/substrate/.claude/hooks/temperance-gate.sh +0 -147
  39. package/substrate/.claude/hooks/testing-tier-enforce.sh +0 -233
  40. package/substrate/.claude/hooks/turn-prose-grade-measure.sh +0 -219
  41. package/substrate/.claude/hooks/turn-prose-kiss-check.sh +0 -463
  42. package/substrate/.claude/hooks/vocabulary-migration-check.sh +0 -171
  43. package/substrate/.claude/hooks/whereami-utc-gate.sh +0 -142
  44. package/substrate/.claude/luminaries/alan-cooper.md +0 -170
  45. package/substrate/.claude/luminaries/alistair-cockburn.md +0 -140
  46. package/substrate/.claude/luminaries/amazon-pr-faq.md +0 -34
  47. package/substrate/.claude/luminaries/ash-maurya.md +0 -121
  48. package/substrate/.claude/luminaries/bill-buxton.md +0 -210
  49. package/substrate/.claude/luminaries/charles-sanders-peirce.md +0 -150
  50. package/substrate/.claude/luminaries/david-ogilvy.md +0 -192
  51. package/substrate/.claude/luminaries/don-norman.md +0 -173
  52. package/substrate/.claude/luminaries/edward-tufte.md +0 -179
  53. package/substrate/.claude/luminaries/eric-evans.md +0 -160
  54. package/substrate/.claude/luminaries/frederick-brooks.md +0 -50
  55. package/substrate/.claude/luminaries/gang-of-four.md +0 -157
  56. package/substrate/.claude/luminaries/glenford-myers.md +0 -230
  57. package/substrate/.claude/luminaries/hunt-thomas.md +0 -115
  58. package/substrate/.claude/luminaries/hyrum-wright.md +0 -94
  59. package/substrate/.claude/luminaries/jason-fried-dhh.md +0 -46
  60. package/substrate/.claude/luminaries/jesse-james-garrett.md +0 -154
  61. package/substrate/.claude/luminaries/john-ousterhout.md +0 -94
  62. package/substrate/.claude/luminaries/karl-popper.md +0 -132
  63. package/substrate/.claude/luminaries/kent-beck.md +0 -168
  64. package/substrate/.claude/luminaries/linus-torvalds.md +0 -218
  65. package/substrate/.claude/luminaries/martin-fowler.md +0 -164
  66. package/substrate/.claude/luminaries/michael-feathers.md +0 -125
  67. package/substrate/.claude/luminaries/michael-nygard.md +0 -118
  68. package/substrate/.claude/luminaries/robert-c-martin.md +0 -164
  69. package/substrate/.claude/luminaries/saltzer-schroeder.md +0 -194
  70. package/substrate/.claude/luminaries/sophia-prater.md +0 -193
  71. package/substrate/.claude/luminaries/stephen-toulmin.md +0 -131
  72. package/substrate/.claude/luminaries/tony-hoare.md +0 -170
  73. package/substrate/.claude/luminaries/vaughn-vernon.md +0 -50
  74. package/substrate/.claude/luminaries/w-edwards-deming.md +0 -158
  75. package/substrate/.claude/rules/accessor-library-discipline.md +0 -138
  76. package/substrate/.claude/rules/adr-discipline.md +0 -120
  77. package/substrate/.claude/rules/api-conventions.md +0 -125
  78. package/substrate/.claude/rules/artifact-ingestion.md +0 -179
  79. package/substrate/.claude/rules/assert-only-after-verify.md +0 -137
  80. package/substrate/.claude/rules/blocked-items.md +0 -146
  81. package/substrate/.claude/rules/bootstrap-pair-discipline.md +0 -141
  82. package/substrate/.claude/rules/branching.md +0 -28
  83. package/substrate/.claude/rules/cold-adopter-harness-discipline.md +0 -129
  84. package/substrate/.claude/rules/commit-conventions.md +0 -22
  85. package/substrate/.claude/rules/compounding-axis-fresh-analysis.md +0 -188
  86. package/substrate/.claude/rules/compounding-sequence-fresh-analysis.md +0 -188
  87. package/substrate/.claude/rules/context-engineering.md +0 -202
  88. package/substrate/.claude/rules/context-management.md +0 -85
  89. package/substrate/.claude/rules/defensive-bash.md +0 -68
  90. package/substrate/.claude/rules/deferred-actions.md +0 -233
  91. package/substrate/.claude/rules/destructive-operations.md +0 -69
  92. package/substrate/.claude/rules/diagnosis.md +0 -38
  93. package/substrate/.claude/rules/github-issue-flash-tweet.md +0 -156
  94. package/substrate/.claude/rules/guardrails.md +0 -73
  95. package/substrate/.claude/rules/hook-wire-on-author.md +0 -103
  96. package/substrate/.claude/rules/identifier-leak-prevention.md +0 -104
  97. package/substrate/.claude/rules/iteration-bet-brief-completeness.md +0 -54
  98. package/substrate/.claude/rules/lite-manifest-schema-change-discipline.md +0 -98
  99. package/substrate/.claude/rules/longrun-prep-plan-doc-compression.md +0 -89
  100. package/substrate/.claude/rules/loop-discipline.md +0 -81
  101. package/substrate/.claude/rules/manual-prod-approval.md +0 -100
  102. package/substrate/.claude/rules/marker-enrichment-discipline.md +0 -99
  103. package/substrate/.claude/rules/mobile-ephemeral-session.md +0 -109
  104. package/substrate/.claude/rules/new-dependency-check.md +0 -51
  105. package/substrate/.claude/rules/oo-ad-entry-point.md +0 -117
  106. package/substrate/.claude/rules/operator-facing-prose.md +0 -196
  107. package/substrate/.claude/rules/option-label-discipline.md +0 -108
  108. package/substrate/.claude/rules/pattern-annotation.md +0 -100
  109. package/substrate/.claude/rules/plain-english-discipline.md +0 -156
  110. package/substrate/.claude/rules/plan-enumeration-needs-value-props.md +0 -211
  111. package/substrate/.claude/rules/pr-body-shape.md +0 -317
  112. package/substrate/.claude/rules/pr-strategy.md +0 -167
  113. package/substrate/.claude/rules/pr-title-shape.md +0 -161
  114. package/substrate/.claude/rules/prototype-workflow.md +0 -65
  115. package/substrate/.claude/rules/reserved-skill-names.md +0 -123
  116. package/substrate/.claude/rules/schema-management.md +0 -49
  117. package/substrate/.claude/rules/sdlc-gates.md +0 -149
  118. package/substrate/.claude/rules/security.md +0 -37
  119. package/substrate/.claude/rules/session-artifacts.md +0 -236
  120. package/substrate/.claude/rules/skill-composition-declarations.md +0 -124
  121. package/substrate/.claude/rules/skill-description-clarity.md +0 -247
  122. package/substrate/.claude/rules/skill-procedure-step-list.md +0 -137
  123. package/substrate/.claude/rules/state-schema-validation.md +0 -162
  124. package/substrate/.claude/rules/stuck-signal-diagnostic.md +0 -140
  125. package/substrate/.claude/rules/substrate-config-schema.md +0 -98
  126. package/substrate/.claude/rules/test-list-discipline.md +0 -175
  127. package/substrate/.claude/rules/test-sufficiency.md +0 -210
  128. package/substrate/.claude/rules/testing-tier-config.md +0 -145
  129. package/substrate/.claude/rules/testing.md +0 -38
  130. package/substrate/.claude/rules/turn-estimate-grounding.md +0 -134
  131. package/substrate/.claude/rules/visual-hierarchy.md +0 -437
  132. package/substrate/.claude/rules/we-dont-break-adopters.md +0 -126
  133. package/substrate/.claude/rules/whereami-load-bearing.md +0 -202
  134. package/substrate/.claude/rules/writing-craft-discipline.md +0 -92
  135. package/substrate/.claude/rules/wu-sequencing-compounds.md +0 -145
  136. package/substrate/.claude/skills/build/SKILL.md +0 -640
  137. package/substrate/.claude/skills/chronicle/SKILL.md +0 -55
  138. package/substrate/.claude/skills/clean-artifacts/SKILL.md +0 -249
  139. package/substrate/.claude/skills/decompose/SKILL.md +0 -280
  140. package/substrate/.claude/skills/diagnose/SKILL.md +0 -297
  141. package/substrate/.claude/skills/feynman/SKILL.md +0 -90
  142. package/substrate/.claude/skills/howdoi/SKILL.md +0 -105
  143. package/substrate/.claude/skills/ia-model/SKILL.md +0 -108
  144. package/substrate/.claude/skills/interaction-design/SKILL.md +0 -112
  145. package/substrate/.claude/skills/interpret-input/SKILL.md +0 -180
  146. package/substrate/.claude/skills/journal/SKILL.md +0 -209
  147. package/substrate/.claude/skills/kiss/SKILL.md +0 -449
  148. package/substrate/.claude/skills/launch/SKILL.md +0 -915
  149. package/substrate/.claude/skills/lean-canvas/SKILL.md +0 -332
  150. package/substrate/.claude/skills/longrun/SKILL.md +0 -463
  151. package/substrate/.claude/skills/luminary/SKILL.md +0 -481
  152. package/substrate/.claude/skills/ogilvy-writing-audit/SKILL.md +0 -177
  153. package/substrate/.claude/skills/onboard-repo/SKILL.md +0 -1624
  154. package/substrate/.claude/skills/pattern-review/SKILL.md +0 -99
  155. package/substrate/.claude/skills/personas/SKILL.md +0 -207
  156. package/substrate/.claude/skills/promote/SKILL.md +0 -283
  157. package/substrate/.claude/skills/requirement/SKILL.md +0 -98
  158. package/substrate/.claude/skills/retro/SKILL.md +0 -117
  159. package/substrate/.claude/skills/riff/SKILL.md +0 -114
  160. package/substrate/.claude/skills/roadmap-reconcile/SKILL.md +0 -163
  161. package/substrate/.claude/skills/session-end/SKILL.md +0 -309
  162. package/substrate/.claude/skills/session-log/SKILL.md +0 -299
  163. package/substrate/.claude/skills/skills/SKILL.md +0 -228
  164. package/substrate/.claude/skills/spec/SKILL.md +0 -105
  165. package/substrate/.claude/skills/sprint/SKILL.md +0 -392
  166. package/substrate/.claude/skills/stage/SKILL.md +0 -384
  167. package/substrate/.claude/skills/state-a-problem/SKILL.md +0 -185
  168. package/substrate/.claude/skills/temperance/SKILL.md +0 -108
  169. package/substrate/.claude/skills/use-case/SKILL.md +0 -417
  170. package/substrate/.claude/skills/user-stories/SKILL.md +0 -268
  171. package/substrate/.claude/skills/value-prop/SKILL.md +0 -251
  172. package/substrate/.claude/skills/verify/SKILL.md +0 -160
  173. package/substrate/.claude/skills/visual-review/SKILL.md +0 -503
  174. package/substrate/.claude/skills/whats-the-plan/SKILL.md +0 -202
  175. package/substrate/.claude/skills/whereami/SKILL.md +0 -307
  176. package/substrate/AGENTS.md +0 -79
  177. package/substrate/CLAUDE-lite.md +0 -85
  178. package/substrate/CODE_OF_CONDUCT.md +0 -28
  179. package/substrate/CONTRIBUTING.md +0 -177
  180. package/substrate/README.md +0 -173
  181. package/substrate/SECURITY.md +0 -19
  182. package/substrate/architecture/decisions/ADR-029-release-pipeline.md +0 -79
  183. package/substrate/architecture/decisions/ADR-031-non-breaking-changes-adopter-discipline.md +0 -139
  184. package/substrate/architecture/decisions/ADR-032-adopter-sync-dispatcher-architecture.md +0 -192
  185. package/substrate/architecture/decisions/ADR-039-release-tagging-scheme.md +0 -145
  186. package/substrate/architecture/decisions/ADR-040-planning-skill-vocabulary-and-lite-profile.md +0 -155
  187. package/substrate/architecture/decisions/ADR-044-unified-skill-body-template.md +0 -162
  188. package/substrate/lib/clean-artifacts-sweep.sh +0 -112
  189. package/substrate/lib/code-comment-discipline.sh +0 -144
  190. package/substrate/lib/composer-preflight.sh +0 -459
  191. package/substrate/lib/hook-inject.sh +0 -255
  192. package/substrate/lib/luminary-pick.sh +0 -96
  193. package/substrate/lib/output-discipline.sh +0 -143
  194. package/substrate/lib/prose-scan-boundary.sh +0 -171
  195. package/substrate/lib/rewrite-check.sh +0 -214
  196. package/substrate/lib/state.sh +0 -1372
  197. package/substrate/lib/telemetry.sh +0 -205
  198. package/substrate/lib/tier-check.sh +0 -187
  199. package/substrate/lib/tier-dependency-audit.sh +0 -1088
  200. package/substrate/presence/install/bassclef-hook-connect.sh +0 -178
  201. package/substrate/presence/install/bassclef-sync.dispatcher.template.sh +0 -841
  202. package/substrate/presence/install/bassclef-sync.template.sh +0 -2076
  203. package/substrate/presence/install/schedule-auto-save.cron.sh +0 -88
  204. package/substrate/presence/install/schedule-auto-save.taskscheduler.md +0 -122
  205. package/substrate/scripts/aggregate-telemetry.sh +0 -217
  206. package/substrate/scripts/analyze-tier-dependencies.sh +0 -239
  207. package/substrate/scripts/generate-lite-manifest.sh +0 -505
  208. package/substrate/scripts/generate-tier-manifest.sh +0 -28
  209. package/substrate/scripts/intent-drift-check.sh +0 -456
  210. package/substrate/scripts/lite-manifest-drift-check.sh +0 -146
  211. package/substrate/scripts/render-lite-manifest-doc.sh +0 -150
  212. package/substrate/standards/adr-template.md +0 -86
  213. package/substrate/standards/api-conventions/nextjs.md +0 -84
  214. package/substrate/standards/artifact-composition.md +0 -209
  215. package/substrate/standards/bash-hook-safety.md +0 -246
  216. package/substrate/standards/bassclef-configs-schema.md +0 -232
  217. package/substrate/standards/bassclef-evolution.md +0 -143
  218. package/substrate/standards/bassclef-internal-jargon.md +0 -244
  219. package/substrate/standards/bassclef-managed-sentinel.md +0 -96
  220. package/substrate/standards/bassclef-source-config.md +0 -228
  221. package/substrate/standards/branch-stacking.md +0 -408
  222. package/substrate/standards/code-safety-principles.md +0 -176
  223. package/substrate/standards/composer-prerequisites.md +0 -155
  224. package/substrate/standards/deferred-actions-schema.md +0 -204
  225. package/substrate/standards/dependency-discipline/cargo.md +0 -39
  226. package/substrate/standards/dependency-discipline/gem.md +0 -43
  227. package/substrate/standards/dependency-discipline/go-mod.md +0 -41
  228. package/substrate/standards/dependency-discipline/npm.md +0 -42
  229. package/substrate/standards/dependency-discipline/pip.md +0 -42
  230. package/substrate/standards/deployment-topology/ec2-tailscale.md +0 -225
  231. package/substrate/standards/deployment-topology.md +0 -69
  232. package/substrate/standards/docs-sync-allowlist.md +0 -76
  233. package/substrate/standards/domain-and-dns.md +0 -145
  234. package/substrate/standards/frontend-stack.md +0 -67
  235. package/substrate/standards/frontmatter-schema.md +0 -154
  236. package/substrate/standards/graceful-exit.md +0 -227
  237. package/substrate/standards/hook-idempotency.md +0 -102
  238. package/substrate/standards/hook-injection-discipline.md +0 -202
  239. package/substrate/standards/hook-install-class.md +0 -215
  240. package/substrate/standards/input-handler-interface.md +0 -152
  241. package/substrate/standards/lite-manifest-schema-changes.md +0 -135
  242. package/substrate/standards/luminary-matching.md +0 -105
  243. package/substrate/standards/luminary-problem-patterns.md +0 -481
  244. package/substrate/standards/migration-discipline/active-record.md +0 -50
  245. package/substrate/standards/migration-discipline/alembic.md +0 -43
  246. package/substrate/standards/migration-discipline/gorm.md +0 -50
  247. package/substrate/standards/migration-discipline/prisma.md +0 -53
  248. package/substrate/standards/migration-discipline/sqlalchemy.md +0 -51
  249. package/substrate/standards/mobile-ephemeral-session.md +0 -167
  250. package/substrate/standards/model-routing-discipline.md +0 -160
  251. package/substrate/standards/ogilvy-writing-rules.md +0 -225
  252. package/substrate/standards/opener-discipline.md +0 -96
  253. package/substrate/standards/operator-facing-prose-discipline.md +0 -201
  254. package/substrate/standards/persona-schema.md +0 -229
  255. package/substrate/standards/pluggable-luminaries.md +0 -323
  256. package/substrate/standards/pr-body-discipline.md +0 -115
  257. package/substrate/standards/preview-state-schema.md +0 -189
  258. package/substrate/standards/project-directory-layout.md +0 -276
  259. package/substrate/standards/release-tagging.md +0 -137
  260. package/substrate/standards/reserved-skill-names.md +0 -120
  261. package/substrate/standards/scannable-multi-option-output.md +0 -261
  262. package/substrate/standards/sdlc-compliance.md +0 -286
  263. package/substrate/standards/sdlc-gates/typescript.md +0 -57
  264. package/substrate/standards/secrets-lifecycle.md +0 -210
  265. package/substrate/standards/security-scanner-adapter.md +0 -145
  266. package/substrate/standards/session-board.md +0 -256
  267. package/substrate/standards/skill-output-discipline.md +0 -90
  268. package/substrate/standards/state-spine-contract.md +0 -255
  269. package/substrate/standards/state-spine.md +0 -511
  270. package/substrate/standards/steering-hints/kiss-words.md +0 -11
  271. package/substrate/standards/substrate-config-schema.md +0 -267
  272. package/substrate/standards/tech-stack-config.md +0 -109
  273. package/substrate/standards/tier-dependency-analysis.md +0 -167
  274. package/substrate/standards/tier-runtime-deps/lite.md +0 -57
  275. package/substrate/standards/tier-tag-schema.md +0 -155
  276. package/substrate/standards/two-layer-config.md +0 -99
  277. package/substrate/standards/use-case-format.md +0 -292
  278. package/substrate/standards/user-story-invest.md +0 -268
  279. package/substrate/standards/velocity-and-appetite.md +0 -229
  280. package/substrate/standards/voice-input-pattern.md +0 -119
  281. package/substrate/standards/whereami-schema.md +0 -301
  282. package/substrate/standards/worktree-management.md +0 -211
  283. package/substrate/standards/writing-guide.md +0 -213
  284. package/substrate/templates/chronicle-template.md +0 -75
  285. package/substrate/templates/deferred-action-template.md +0 -45
  286. package/substrate/templates/memory-proposal-template.md +0 -77
  287. package/substrate/templates/persona-template.md +0 -200
  288. package/substrate/templates/pr-faq.md +0 -45
  289. package/substrate/templates/secret-rotation-template.md +0 -162
  290. package/substrate/templates/spec-template.md +0 -131
  291. package/substrate/templates/use-case-template.md +0 -194
  292. package/substrate/templates/user-story-template.md +0 -107
  293. package/substrate/templates/whereami-template.md +0 -101
package/dist/cli.cjs CHANGED
@@ -27,7 +27,6 @@ const node_path = require("node:path");
27
27
  const node_os = require("node:os");
28
28
  const node_crypto = require("node:crypto");
29
29
  const node_url = require("node:url");
30
- const node_module = require("node:module");
31
30
  const promises = require("node:readline/promises");
32
31
  const node_process = require("node:process");
33
32
  var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
@@ -243,22 +242,6 @@ function hashContent(content) {
243
242
  normalized = normalized.replace(/\r\n/g, "\n");
244
243
  return node_crypto.createHash("sha256").update(normalized, "utf8").digest("hex");
245
244
  }
246
- const SETTINGS_TEMPLATE_VERSION = "0.0.1";
247
- function settingsJsonTemplate(pkgVersion) {
248
- const value = {
249
- $bassclef: {
250
- template: "settings.json",
251
- template_version: SETTINGS_TEMPLATE_VERSION,
252
- generated_by: "@thebassclef/core",
253
- generated_by_version: pkgVersion
254
- },
255
- permissions: {
256
- additionalDirectories: []
257
- },
258
- hooks: {}
259
- };
260
- return JSON.stringify(value, null, 2) + "\n";
261
- }
262
245
  const SUBSTRATE_CONFIG_TEMPLATE_VERSION = "0.0.1";
263
246
  function substrateConfigMdTemplate(pkgVersion) {
264
247
  return [
@@ -409,129 +392,215 @@ async function computeConfigHashes(targetDir, paths) {
409
392
  }
410
393
  return out;
411
394
  }
412
- const SUBSTRATE_ROOT = "substrate";
413
- const CONFIG_FILES = [
414
- ".claude/settings.json",
415
- "substrate.config.md",
416
- "substrate.secrets.md"
417
- ];
418
- const CURRENT_ENTRY_COUNT = 149;
395
+ const EXPECTED_WIRING_SCHEMA_MAJOR = 2;
396
+ const WIRING_MANIFEST_RELATIVE = "standards/bassclef-wiring-manifest.json";
397
+ class CopyFailure extends Error {
398
+ constructor(kind, message) {
399
+ super(message);
400
+ this.kind = kind;
401
+ this.name = "CopyFailure";
402
+ }
403
+ }
419
404
  function copySubstrate(targetDir, options = {}) {
420
405
  const bundleRoot = resolveBundleRoot(options.bundleRoot);
421
- const manifest = loadBundledManifest(bundleRoot);
406
+ const manifest = readWiringManifest(bundleRoot);
422
407
  const result = {
423
408
  copied: [],
424
409
  refused: [],
425
410
  errored: [],
426
- erroredMessages: []
411
+ erroredMessages: [],
412
+ hookCount: 0,
413
+ wiringVersion: manifest.version
427
414
  };
428
415
  if (options.dryRun) result.wouldCopy = [];
429
- const groups = groupByTopDirectory(manifest.entries);
430
- for (const [directory, entries] of groups) {
416
+ const files = walkDistTree(bundleRoot);
417
+ const groups = groupByTopDirectory(files);
418
+ for (const [directory, groupFiles] of groups) {
431
419
  let completedInGroup = 0;
432
- for (const entry of entries) {
433
- const outcome = copyOne(entry, bundleRoot, targetDir, options, result);
420
+ for (const relPath of groupFiles) {
421
+ const outcome = copyOne(relPath, bundleRoot, targetDir, options, result);
434
422
  if (outcome !== "skipped") completedInGroup += 1;
435
423
  }
436
424
  if (options.onProgress) options.onProgress(directory, completedInGroup);
437
425
  }
426
+ result.hookCount = readHookCount(
427
+ options.dryRun ? node_path.join(bundleRoot, ".claude/settings.json") : node_path.join(targetDir, ".claude/settings.json")
428
+ );
438
429
  return result;
439
430
  }
440
- function copyOne(entry, bundleRoot, targetDir, options, result) {
441
- const sourcePath = node_path.join(bundleRoot, entry.path);
442
- const targetPath = node_path.join(targetDir, entry.path);
431
+ function readWiringManifest(bundleRoot) {
432
+ const manifestPath = node_path.join(bundleRoot, WIRING_MANIFEST_RELATIVE);
433
+ if (!fileExists(manifestPath)) {
434
+ throw new CopyFailure(
435
+ "ManifestMissing",
436
+ `Wiring manifest missing at ${manifestPath}. Cli built for schema_version ${EXPECTED_WIRING_SCHEMA_MAJOR}.x. Run \`npm install @thebassclef/lite@latest\` to fix.`
437
+ );
438
+ }
439
+ let manifest;
440
+ let raw;
441
+ try {
442
+ raw = node_fs.readFileSync(manifestPath, "utf8");
443
+ } catch (e) {
444
+ const err = e;
445
+ throw new CopyFailure(
446
+ "ManifestMissing",
447
+ `Wiring manifest at ${manifestPath} unreadable (${err.code ?? "unknown"}). Reinstall @thebassclef/lite to restore the bundle.`
448
+ );
449
+ }
450
+ try {
451
+ manifest = JSON.parse(raw);
452
+ } catch (e) {
453
+ const err = e;
454
+ throw new CopyFailure(
455
+ "SchemaIncompatible",
456
+ `Wiring manifest at ${manifestPath} is not valid JSON: ${err.message}. Reinstall @thebassclef/lite to restore the bundle.`
457
+ );
458
+ }
459
+ if (typeof manifest.version !== "string" || manifest.version.length === 0) {
460
+ throw new CopyFailure(
461
+ "SchemaIncompatible",
462
+ `Wiring manifest at ${manifestPath} missing 'version' field. Cli requires schema_version ${EXPECTED_WIRING_SCHEMA_MAJOR}.x. Reinstall @thebassclef/lite to fix.`
463
+ );
464
+ }
465
+ const major = parseInt(manifest.version.split(".")[0] ?? "0", 10);
466
+ if (major !== EXPECTED_WIRING_SCHEMA_MAJOR) {
467
+ throw new CopyFailure(
468
+ "SchemaIncompatible",
469
+ `Wiring manifest at ${manifestPath} has version ${manifest.version}. Cli built for schema_version ${EXPECTED_WIRING_SCHEMA_MAJOR}.x. Upgrade cli OR downgrade @thebassclef/lite to a compatible version.`
470
+ );
471
+ }
472
+ return { version: manifest.version };
473
+ }
474
+ function walkDistTree(bundleRoot) {
475
+ if (!dirExists(bundleRoot)) {
476
+ throw new CopyFailure(
477
+ "BundleMissing",
478
+ `Bundled substrate missing at ${bundleRoot}. Reinstall @thebassclef/lite to restore the bundle.`
479
+ );
480
+ }
481
+ const results = [];
482
+ function walk(dir) {
483
+ for (const name of node_fs.readdirSync(dir)) {
484
+ const full = node_path.join(dir, name);
485
+ const st = node_fs.statSync(full);
486
+ if (st.isDirectory()) walk(full);
487
+ else results.push(node_path.relative(bundleRoot, full));
488
+ }
489
+ }
490
+ walk(bundleRoot);
491
+ results.sort();
492
+ return results;
493
+ }
494
+ const GITIGNORE_BUNDLE_NAME = "gitignore";
495
+ const GITIGNORE_ADOPTER_NAME = ".gitignore";
496
+ function mapAdopterPath(relPath) {
497
+ if (relPath === GITIGNORE_BUNDLE_NAME) return GITIGNORE_ADOPTER_NAME;
498
+ return relPath;
499
+ }
500
+ function copyOne(relPath, bundleRoot, targetDir, options, result) {
501
+ const sourcePath = node_path.join(bundleRoot, relPath);
502
+ const adopterRelPath = mapAdopterPath(relPath);
503
+ const targetPath = node_path.join(targetDir, adopterRelPath);
443
504
  let content;
444
505
  try {
445
506
  content = node_fs.readFileSync(sourcePath, "utf8");
446
507
  } catch (e) {
447
508
  const err = e;
448
- const message = `${entry.path} — cannot read bundled source (${err.code ?? "unknown"}). Reinstall @thebassclef/core to restore the bundle.`;
449
- result.errored.push(entry.path);
450
- result.erroredMessages?.push(message);
451
- return "errored";
452
- }
453
- const declaredHash = stripHashPrefix(entry.content_hash);
454
- const actualHash = sha256Hex(content);
455
- if (declaredHash !== actualHash) {
456
- const message = `${entry.path} — bundled content hash does not match the manifest. Reinstall @thebassclef/core to repair the bundle, then rerun bassclef init --force.`;
457
- result.errored.push(entry.path);
509
+ const message = `${relPath} — cannot read bundled source (${err.code ?? "unknown"}). Reinstall @thebassclef/lite to restore the bundle.`;
510
+ result.errored.push(adopterRelPath);
458
511
  result.erroredMessages?.push(message);
459
512
  return "errored";
460
513
  }
514
+ const outputContent = options.transform ? options.transform(adopterRelPath, content) : content;
461
515
  if (options.dryRun) {
462
- result.wouldCopy?.push(entry.path);
516
+ result.wouldCopy?.push(adopterRelPath);
463
517
  return "wouldCopy";
464
518
  }
465
519
  try {
466
520
  mkdirSafely(node_path.dirname(targetPath));
467
- writeSafely(targetPath, content, { force: options.force ?? false });
468
- result.copied.push(entry.path);
521
+ writeSafely(targetPath, outputContent, { force: options.force ?? false });
522
+ result.copied.push(adopterRelPath);
469
523
  return "copied";
470
524
  } catch (e) {
471
525
  if (e instanceof WriteError) {
472
526
  if (e.kind === "AlreadyExists") {
473
- result.refused.push(entry.path);
527
+ result.refused.push(adopterRelPath);
474
528
  return "refused";
475
529
  }
476
530
  if (e.kind === "SymlinkRefused") {
477
- result.refused.push(entry.path);
531
+ result.refused.push(adopterRelPath);
478
532
  return "refused";
479
533
  }
480
- const message = `${entry.path} — write failed (${e.kind}): ${e.message}. Check the target directory exists and is writable, then rerun.`;
481
- result.errored.push(entry.path);
534
+ const message = `${adopterRelPath} — write failed (${e.kind}): ${e.message}. Check the target directory exists and is writable, then rerun.`;
535
+ result.errored.push(adopterRelPath);
482
536
  result.erroredMessages?.push(message);
483
537
  return "errored";
484
538
  }
485
539
  throw e;
486
540
  }
487
541
  }
488
- function loadBundledManifest(bundleRoot) {
489
- const manifestPath = node_path.join(bundleRoot, ".bassclef", "lite-manifest.json");
490
- const raw = node_fs.readFileSync(manifestPath, "utf8");
491
- const parsed = JSON.parse(raw);
492
- if (!Array.isArray(parsed.entries)) {
493
- throw new Error(
494
- `bundled manifest at ${manifestPath} has no entries[] array. Reinstall @thebassclef/core to restore the bundle.`
495
- );
496
- }
497
- return parsed;
498
- }
499
542
  function resolveBundleRoot(explicit) {
500
543
  if (explicit && explicit.length > 0) return node_path.resolve(explicit);
501
544
  const thisFile = node_url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("cli.cjs", document.baseURI).href);
502
545
  let dir = node_path.dirname(thisFile);
503
546
  for (let i = 0; i < 5; i += 1) {
504
- try {
505
- node_fs.readFileSync(node_path.join(dir, "package.json"), "utf8");
506
- return node_path.join(dir, SUBSTRATE_ROOT);
507
- } catch {
508
- const parent = node_path.dirname(dir);
509
- if (parent === dir) break;
510
- dir = parent;
547
+ if (fileExists(node_path.join(dir, "package.json"))) {
548
+ return node_path.join(dir, "dist", "lite");
511
549
  }
550
+ const parent = node_path.dirname(dir);
551
+ if (parent === dir) break;
552
+ dir = parent;
512
553
  }
513
- const require$1 = node_module.createRequire(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("cli.cjs", document.baseURI).href);
514
- const pkgJsonPath = require$1.resolve("@thebassclef/core/package.json");
515
- const pkgRoot = node_path.dirname(pkgJsonPath);
516
- return node_path.join(pkgRoot, SUBSTRATE_ROOT);
554
+ throw new CopyFailure(
555
+ "BundleMissing",
556
+ `Cannot resolve bundled substrate root — package.json unreachable from ${thisFile}. Reinstall @thebassclef/lite.`
557
+ );
517
558
  }
518
- function groupByTopDirectory(entries) {
559
+ function groupByTopDirectory(files) {
519
560
  const groups = /* @__PURE__ */ new Map();
520
- for (const entry of entries) {
521
- const parts = entry.path.split("/");
561
+ for (const p of files) {
562
+ const parts = p.split("/");
522
563
  const top = parts.length >= 2 ? parts.slice(0, 2).join("/") : parts[0] ?? "";
523
564
  if (!groups.has(top)) groups.set(top, []);
524
- groups.get(top).push(entry);
565
+ groups.get(top).push(p);
525
566
  }
526
567
  return groups;
527
568
  }
528
- function stripHashPrefix(value) {
529
- const prefix = "sha256:";
530
- return value.startsWith(prefix) ? value.slice(prefix.length) : value;
569
+ function readHookCount(settingsPath) {
570
+ try {
571
+ const parsed = JSON.parse(node_fs.readFileSync(settingsPath, "utf8"));
572
+ let count = 0;
573
+ for (const matcherBlocks of Object.values(parsed.hooks ?? {})) {
574
+ for (const block of matcherBlocks) {
575
+ count += (block.hooks ?? []).length;
576
+ }
577
+ }
578
+ return count;
579
+ } catch {
580
+ return 0;
581
+ }
531
582
  }
532
- function sha256Hex(content) {
533
- return node_crypto.createHash("sha256").update(content).digest("hex");
583
+ function fileExists(p) {
584
+ try {
585
+ return node_fs.statSync(p).isFile();
586
+ } catch {
587
+ return false;
588
+ }
534
589
  }
590
+ function dirExists(p) {
591
+ try {
592
+ return node_fs.statSync(p).isDirectory();
593
+ } catch {
594
+ return false;
595
+ }
596
+ }
597
+ const RESOLVED_TIER = "lite";
598
+ const PLACEHOLDER_FILES = /* @__PURE__ */ new Set([
599
+ "CLAUDE.md",
600
+ "docs/whereami.md",
601
+ "whereami.md",
602
+ ".bassclef-source.json"
603
+ ]);
535
604
  function runInit(argv) {
536
605
  let args;
537
606
  try {
@@ -577,14 +646,6 @@ function runInit(argv) {
577
646
  }
578
647
  }
579
648
  const plans = [
580
- {
581
- label: "settings.json",
582
- relativePath: ".claude/settings.json",
583
- fullPath: node_path.join(targetDir, ".claude", "settings.json"),
584
- content: settingsJsonTemplate(index.version),
585
- templateName: "settings.json",
586
- templateVersion: SETTINGS_TEMPLATE_VERSION
587
- },
588
649
  {
589
650
  label: "substrate.config.md",
590
651
  relativePath: "substrate.config.md",
@@ -596,30 +657,28 @@ function runInit(argv) {
596
657
  ];
597
658
  if (args.dryRun) {
598
659
  runDryRun$1(plans);
599
- dispatchSubstrateCopy(targetDir, args.force, args.verbose, true);
600
- return 0;
601
- }
602
- const exitCode = runReal$1(plans, args.force, args.verbose, targetDir);
603
- if (exitCode === 0) {
604
- dispatchSubstrateCopy(targetDir, args.force, args.verbose, false);
660
+ return dispatchSubstrateCopy(targetDir, args.force, args.verbose, true);
605
661
  }
606
- return exitCode;
662
+ return runReal$1(plans, args.force, args.verbose, targetDir);
607
663
  }
608
664
  function dispatchSubstrateCopy(targetDir, force, verbose, dryRun) {
665
+ const substitute = makePlaceholderTransform(targetDir);
609
666
  let result;
610
667
  try {
611
- result = copySubstrate(targetDir, { force, dryRun });
668
+ result = copySubstrate(targetDir, {
669
+ force,
670
+ dryRun,
671
+ transform: substitute
672
+ });
612
673
  } catch (e) {
613
- const err = e;
614
- process.stderr.write(
615
- `bassclef init: substrate copy failed — ${err.message}
616
- cause: the installed @thebassclef/core package is missing the bundled substrate manifest.
617
- fix: reinstall with \`npm install -g @thebassclef/core@latest --force\`.
618
- If the reinstall does not help, file an issue at
619
- https://github.com/sunj-labs/bassclef-cli/issues with your package version.
620
- `
621
- );
622
- process.exit(2);
674
+ if (e instanceof CopyFailure) {
675
+ process.stderr.write(`bassclef init: ${e.message}
676
+ `);
677
+ if (e.kind === "ManifestMissing") return 4;
678
+ if (e.kind === "SchemaIncompatible") return 5;
679
+ return 2;
680
+ }
681
+ throw e;
623
682
  }
624
683
  if (dryRun) {
625
684
  const wouldCopy = result.wouldCopy ?? [];
@@ -634,10 +693,14 @@ function dispatchSubstrateCopy(targetDir, force, verbose, dryRun) {
634
693
  `
635
694
  );
636
695
  }
637
- return;
696
+ process.stdout.write(
697
+ `bassclef init: ${result.hookCount} hooks armed (${RESOLVED_TIER} tier).
698
+ `
699
+ );
700
+ return 0;
638
701
  }
639
702
  if (result.copied.length === 0 && result.refused.length === 0 && result.errored.length === 0) {
640
- return;
703
+ return 0;
641
704
  }
642
705
  const groupCounts = /* @__PURE__ */ new Map();
643
706
  for (const path of result.copied) {
@@ -655,9 +718,13 @@ function dispatchSubstrateCopy(targetDir, force, verbose, dryRun) {
655
718
  if (result.errored.length > 0) parts.push(`${result.errored.length} error(s)`);
656
719
  process.stdout.write(`bassclef init: ${parts.join(", ")}.
657
720
  `);
658
- const grandTotal = 2 + result.copied.length;
721
+ const grandTotal = 1 + result.copied.length;
722
+ process.stdout.write(
723
+ `bassclef init: ${grandTotal} files total (1 config + ${result.copied.length} substrate).
724
+ `
725
+ );
659
726
  process.stdout.write(
660
- `bassclef init: ${grandTotal} files total (2 config + ${result.copied.length} substrate).
727
+ `bassclef init: ${result.hookCount} hooks armed (${RESOLVED_TIER} tier).
661
728
  `
662
729
  );
663
730
  if (verbose && result.erroredMessages) {
@@ -666,6 +733,15 @@ function dispatchSubstrateCopy(targetDir, force, verbose, dryRun) {
666
733
  `);
667
734
  }
668
735
  }
736
+ return result.errored.length > 0 ? 2 : 0;
737
+ }
738
+ function makePlaceholderTransform(targetDir) {
739
+ const repoName = node_path.basename(targetDir);
740
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
741
+ return (relPath, content) => {
742
+ if (!PLACEHOLDER_FILES.has(relPath)) return content;
743
+ return content.replace(/\[REPO_NAME\]/g, repoName).replace(/\[ISO_TIMESTAMP\]/g, timestamp).replace(/\[TIER\]/g, RESOLVED_TIER).replace(/\[Repo name\]/g, repoName).replace(/<tier>/g, RESOLVED_TIER);
744
+ };
669
745
  }
670
746
  function runDryRun$1(plans) {
671
747
  for (const p of plans) {
@@ -749,8 +825,8 @@ function runReal$1(plans, force, verbose, targetDir) {
749
825
  process.stderr.write(`bassclef init: ${tag}: ${r.message ?? "write failed"}: ${r.plan.fullPath}
750
826
  `);
751
827
  }
752
- writeManifest(targetDir, results);
753
828
  if (anyError) {
829
+ writeManifest(targetDir, results);
754
830
  const parts = [];
755
831
  if (created > 0) parts.push(`${created} created`);
756
832
  if (unchanged > 0) parts.push(`${unchanged} unchanged`);
@@ -761,28 +837,26 @@ function runReal$1(plans, force, verbose, targetDir) {
761
837
  `);
762
838
  return 2;
763
839
  }
764
- if (created === 0 && unchanged === plans.length) {
765
- process.stdout.write("bassclef init: already initialized. No changes.\n");
766
- return 0;
767
- }
768
840
  if (anyRefused && created > 0) {
769
841
  process.stdout.write(
770
842
  `bassclef init: ${created} config files created, ${unchanged} unchanged. Pass --force to overwrite.
771
843
  `
772
844
  );
845
+ } else if (created === 0 && unchanged === plans.length) {
846
+ process.stdout.write("bassclef init: already initialized. No changes.\n");
847
+ } else {
848
+ process.stdout.write(`bassclef init: ${created} config files created, ${unchanged} unchanged.
849
+ `);
850
+ }
851
+ const walkerExit = dispatchSubstrateCopy(targetDir, force, verbose, false);
852
+ writeManifest(targetDir, results);
853
+ if (walkerExit === 0) {
773
854
  process.stdout.write(
774
855
  `bassclef init: your substrate lives under .claude/. Add .claude/ to .gitignore if you have not.
775
856
  `
776
857
  );
777
- return 0;
778
858
  }
779
- process.stdout.write(`bassclef init: ${created} config files created, ${unchanged} unchanged.
780
- `);
781
- process.stdout.write(
782
- `bassclef init: your substrate lives under .claude/. Add .claude/ to .gitignore if you have not.
783
- `
784
- );
785
- return 0;
859
+ return walkerExit;
786
860
  }
787
861
  function shouldRefuseRoot(currentUid, allowRoot) {
788
862
  if (currentUid === void 0) return false;
@@ -830,17 +904,22 @@ function usage$2() {
830
904
  " --allow-any-dir Allow --dir outside your home directory. Default: refuse.",
831
905
  " --verbose Print per-file result.",
832
906
  "",
907
+ "Exit codes:",
908
+ " 0 — success",
909
+ " 1 — refused by policy (existing file; running as root; outside HOME)",
910
+ " 2 — safety check failed at write (symlink; parent not writable)",
911
+ " 3 — invalid args",
912
+ " 4 — wiring manifest missing from bundled substrate (reinstall @thebassclef/lite)",
913
+ " 5 — wiring manifest schema major version incompatible with this cli",
914
+ "",
833
915
  "Files written under <target>:",
834
- " .claude/settings.json Claude Code settings (minimal, opt-in blocks)",
835
916
  " substrate.config.md Bassclef project manifest",
836
917
  " .bassclef/init.manifest.json Record of what init wrote (used by sync)",
837
918
  "",
838
- " Plus the bundled substrate tree (~280 files):",
839
- " .claude/{agents,hooks,luminaries,rules,skills}/",
840
- " standards/, templates/, scripts/, lib/, presence/install/",
841
- " architecture/decisions/",
842
- " AGENTS.md, CLAUDE-lite.md, README.md, CONTRIBUTING.md,",
843
- " SECURITY.md, CODE_OF_CONDUCT.md",
919
+ " Plus the bundled substrate tree from dist/lite/:",
920
+ " .claude/settings.json Claude Code settings (verbatim from bundle)",
921
+ " CLAUDE.md, whereami.md, .bassclef-source.json, .gitignore",
922
+ " Templates with placeholders substituted",
844
923
  "",
845
924
  " Run with --dry-run first to preview the full file list before",
846
925
  " writing anything to disk.",
@@ -922,12 +1001,6 @@ function parseSyncArgs(argv) {
922
1001
  return out;
923
1002
  }
924
1003
  const TEMPLATES = [
925
- {
926
- templateName: "settings.json",
927
- currentVersion: SETTINGS_TEMPLATE_VERSION,
928
- render: settingsJsonTemplate,
929
- hasMarker: (c) => c.includes('"$bassclef"')
930
- },
931
1004
  {
932
1005
  templateName: "substrate.config.md",
933
1006
  currentVersion: SUBSTRATE_CONFIG_TEMPLATE_VERSION,
@@ -1379,6 +1452,12 @@ async function confirm(question, opts = {}) {
1379
1452
  rl.close();
1380
1453
  }
1381
1454
  }
1455
+ const CONFIG_FILES = [
1456
+ ".claude/settings.json",
1457
+ "substrate.config.md",
1458
+ "substrate.secrets.md"
1459
+ ];
1460
+ const CURRENT_ENTRY_COUNT = 149;
1382
1461
  async function detectAdopterState(targetDir) {
1383
1462
  let manifest;
1384
1463
  try {