codebyplan 1.13.46 → 1.13.48

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 (124) hide show
  1. package/dist/cli.js +33 -13
  2. package/package.json +1 -1
  3. package/templates/agents/cbp-cc-executor.md +0 -1
  4. package/templates/agents/cbp-database-agent.md +0 -1
  5. package/templates/agents/cbp-e2e-maestro.md +0 -1
  6. package/templates/agents/cbp-e2e-playwright.md +0 -1
  7. package/templates/agents/cbp-e2e-tauri.md +0 -1
  8. package/templates/agents/cbp-e2e-vscode.md +0 -1
  9. package/templates/agents/cbp-e2e-xcuitest.md +0 -1
  10. package/templates/agents/cbp-improve-claude.md +0 -1
  11. package/templates/agents/cbp-improve-round.md +0 -1
  12. package/templates/agents/cbp-map-architecture.md +0 -1
  13. package/templates/agents/cbp-mechanical-edits.md +0 -1
  14. package/templates/agents/cbp-research.md +0 -1
  15. package/templates/agents/cbp-round-executor.md +0 -1
  16. package/templates/agents/cbp-security-agent.md +0 -1
  17. package/templates/agents/cbp-task-check.md +0 -1
  18. package/templates/agents/cbp-task-planner.md +0 -1
  19. package/templates/agents/cbp-testing-qa-agent.md +0 -1
  20. package/templates/hooks/cbp-auto-test-hooks.sh +0 -1
  21. package/templates/hooks/cbp-canonical-templates-nudge.sh +0 -1
  22. package/templates/hooks/cbp-context-window-notify.sh +0 -1
  23. package/templates/hooks/cbp-e2e-spec-patterns.sh +0 -1
  24. package/templates/hooks/cbp-lint-format-on-edit.sh +0 -1
  25. package/templates/hooks/cbp-maestro-yaml-validate.sh +0 -1
  26. package/templates/hooks/cbp-mcp-caller-worktree-inject.sh +0 -1
  27. package/templates/hooks/cbp-mcp-migration-guard.sh +0 -1
  28. package/templates/hooks/cbp-mcp-round-sync.sh +0 -1
  29. package/templates/hooks/cbp-plugin-dispatch.sh +0 -1
  30. package/templates/hooks/cbp-pre-commit-quality-gate.sh +0 -1
  31. package/templates/hooks/cbp-session-start-hook.sh +0 -1
  32. package/templates/hooks/cbp-statusline.mjs +0 -1
  33. package/templates/hooks/cbp-statusline.py +0 -1
  34. package/templates/hooks/cbp-statusline.sh +0 -1
  35. package/templates/hooks/cbp-subagent-statusline.mjs +0 -1
  36. package/templates/hooks/cbp-subagent-statusline.py +0 -1
  37. package/templates/hooks/cbp-subagent-statusline.sh +0 -1
  38. package/templates/hooks/cbp-test-coverage-gate.sh +0 -1
  39. package/templates/hooks/cbp-test-hooks.sh +0 -1
  40. package/templates/hooks/validate-context-usage.sh +0 -1
  41. package/templates/hooks/validate-git-commit.sh +57 -9
  42. package/templates/hooks/validate-git-stash-deny.sh +0 -1
  43. package/templates/hooks/validate-structure-lengths.sh +0 -1
  44. package/templates/hooks/validate-structure-lib.sh +17 -1
  45. package/templates/hooks/validate-structure-patterns.sh +0 -1
  46. package/templates/hooks/validate-structure-scope.sh +43 -11
  47. package/templates/hooks/validate-structure-smoke.sh +0 -1
  48. package/templates/hooks/validate-structure-templates.sh +0 -1
  49. package/templates/hooks/validate-structure.sh +0 -1
  50. package/templates/hooks/verify-parity.sh +0 -1
  51. package/templates/rules/agent-claim-verification.md +0 -1
  52. package/templates/rules/architecture-map.md +0 -4
  53. package/templates/rules/cbp-operating-gotchas.md +0 -4
  54. package/templates/rules/context-file-loading.md +0 -1
  55. package/templates/rules/e2e-mandatory.md +0 -4
  56. package/templates/rules/parallel-waves.md +0 -1
  57. package/templates/rules/scope-vocabulary.md +14 -10
  58. package/templates/rules/supabase-branch-lifecycle.md +0 -1
  59. package/templates/rules/todo-backend.md +0 -1
  60. package/templates/skills/cbp-build-cc-agent/SKILL.md +2 -3
  61. package/templates/skills/cbp-build-cc-agent/reference/cbp-quality.md +6 -8
  62. package/templates/skills/cbp-build-cc-agent/scripts/validate-agent.sh +10 -1
  63. package/templates/skills/cbp-build-cc-claude-file/SKILL.md +0 -1
  64. package/templates/skills/cbp-build-cc-claude-file/scripts/validate-claude-file.sh +0 -1
  65. package/templates/skills/cbp-build-cc-mode/SKILL.md +0 -1
  66. package/templates/skills/cbp-build-cc-rule/SKILL.md +18 -8
  67. package/templates/skills/cbp-build-cc-rule/scripts/validate-rule.sh +4 -5
  68. package/templates/skills/cbp-build-cc-settings/SKILL.md +0 -1
  69. package/templates/skills/cbp-build-cc-settings/reference/cbp-conventions.md +0 -4
  70. package/templates/skills/cbp-build-cc-settings/scripts/validate-settings.sh +0 -1
  71. package/templates/skills/cbp-build-cc-skill/SKILL.md +0 -1
  72. package/templates/skills/cbp-build-cc-skill/reference/cbp-quality.md +6 -8
  73. package/templates/skills/cbp-build-cc-skill/scripts/validate-skill.sh +10 -2
  74. package/templates/skills/cbp-checkpoint-check/SKILL.md +0 -1
  75. package/templates/skills/cbp-checkpoint-complete/SKILL.md +0 -1
  76. package/templates/skills/cbp-checkpoint-create/SKILL.md +10 -11
  77. package/templates/skills/cbp-checkpoint-end/SKILL.md +0 -1
  78. package/templates/skills/cbp-checkpoint-plan/SKILL.md +0 -1
  79. package/templates/skills/cbp-checkpoint-plan/reference/alternative-comparison-template.md +0 -4
  80. package/templates/skills/cbp-checkpoint-plan/reference/dep-decision-rubric.md +0 -4
  81. package/templates/skills/cbp-checkpoint-plan/reference/e2e-discovery-probe.md +0 -4
  82. package/templates/skills/cbp-checkpoint-plan/reference/gap-analysis-playbook.md +0 -4
  83. package/templates/skills/cbp-checkpoint-start/SKILL.md +0 -1
  84. package/templates/skills/cbp-checkpoint-update/SKILL.md +0 -1
  85. package/templates/skills/cbp-frontend-a11y/SKILL.md +0 -1
  86. package/templates/skills/cbp-frontend-design/SKILL.md +0 -1
  87. package/templates/skills/cbp-frontend-ui/SKILL.md +0 -1
  88. package/templates/skills/cbp-frontend-ux/SKILL.md +0 -1
  89. package/templates/skills/cbp-git-branch-feat-create/SKILL.md +0 -1
  90. package/templates/skills/cbp-git-commit/SKILL.md +0 -1
  91. package/templates/skills/cbp-git-worktree-create/SKILL.md +0 -1
  92. package/templates/skills/cbp-git-worktree-remove/SKILL.md +0 -1
  93. package/templates/skills/cbp-map-architecture/SKILL.md +0 -1
  94. package/templates/skills/cbp-merge-main/SKILL.md +0 -1
  95. package/templates/skills/cbp-refresh-arch-map/SKILL.md +0 -1
  96. package/templates/skills/cbp-round-check/SKILL.md +0 -1
  97. package/templates/skills/cbp-round-complete/SKILL.md +0 -1
  98. package/templates/skills/cbp-round-end/SKILL.md +0 -1
  99. package/templates/skills/cbp-round-execute/SKILL.md +0 -1
  100. package/templates/skills/cbp-round-execute/reference/inline-fallback.md +0 -4
  101. package/templates/skills/cbp-round-input/SKILL.md +0 -1
  102. package/templates/skills/cbp-round-start/SKILL.md +0 -1
  103. package/templates/skills/cbp-round-update/SKILL.md +0 -1
  104. package/templates/skills/cbp-session-end/SKILL.md +0 -1
  105. package/templates/skills/cbp-session-start/SKILL.md +0 -1
  106. package/templates/skills/cbp-session-start/qa-regression.md +0 -1
  107. package/templates/skills/cbp-setup-e2e/SKILL.md +0 -1
  108. package/templates/skills/cbp-setup-eslint/SKILL.md +0 -1
  109. package/templates/skills/cbp-ship/SKILL.md +0 -1
  110. package/templates/skills/cbp-ship-configure/SKILL.md +0 -1
  111. package/templates/skills/cbp-ship-main/SKILL.md +0 -1
  112. package/templates/skills/cbp-supabase-branch-check/SKILL.md +0 -1
  113. package/templates/skills/cbp-supabase-branch-check/reference/dag-steps.md +0 -4
  114. package/templates/skills/cbp-supabase-migrate/SKILL.md +0 -1
  115. package/templates/skills/cbp-supabase-setup/SKILL.md +0 -1
  116. package/templates/skills/cbp-task-check/SKILL.md +0 -1
  117. package/templates/skills/cbp-task-complete/SKILL.md +0 -1
  118. package/templates/skills/cbp-task-create/SKILL.md +0 -1
  119. package/templates/skills/cbp-task-start/SKILL.md +0 -1
  120. package/templates/skills/cbp-task-testing/SKILL.md +0 -1
  121. package/templates/skills/cbp-todo/SKILL.md +0 -1
  122. package/templates/skills/cbp-todo/qa-regression.md +0 -1
  123. package/templates/skills/supabase/SKILL.md +0 -1
  124. package/templates/skills/supabase-postgres-best-practices/SKILL.md +0 -1
package/dist/cli.js CHANGED
@@ -39,7 +39,7 @@ var VERSION, PACKAGE_NAME;
39
39
  var init_version = __esm({
40
40
  "src/lib/version.ts"() {
41
41
  "use strict";
42
- VERSION = "1.13.46";
42
+ VERSION = "1.13.48";
43
43
  PACKAGE_NAME = "codebyplan";
44
44
  }
45
45
  });
@@ -35130,8 +35130,10 @@ function checkScopeMarkers(opts) {
35130
35130
  const {
35131
35131
  claudeDir,
35132
35132
  scanDirs = SCAN_DIRS,
35133
- allowlist = /* @__PURE__ */ new Set()
35133
+ allowlist = /* @__PURE__ */ new Set(),
35134
+ templatesDir
35134
35135
  } = opts;
35136
+ const twinDetectionActive = templatesDir != null && fs11.existsSync(templatesDir);
35135
35137
  const violations = [];
35136
35138
  for (const scanDir of scanDirs) {
35137
35139
  const baseDir = path12.join(claudeDir, scanDir);
@@ -35158,10 +35160,16 @@ function checkScopeMarkers(opts) {
35158
35160
  });
35159
35161
  continue;
35160
35162
  }
35161
- if (isMd) {
35162
- const scopeValue = extractFrontmatterScope(content);
35163
+ const scopeValue = isMd ? extractFrontmatterScope(content) : extractShScope(content);
35164
+ const managed = twinDetectionActive && fs11.existsSync(path12.join(templatesDir, relPath));
35165
+ if (managed) {
35163
35166
  if (scopeValue === null) {
35164
- violations.push({ type: "missing-scope", path: relPath });
35167
+ } else if (scopeValue === "org-shared") {
35168
+ violations.push({
35169
+ type: "redundant-scope",
35170
+ path: relPath,
35171
+ detail: "redundant org-shared marker \u2014 org-shared is the implicit default, remove the key"
35172
+ });
35165
35173
  } else if (!isValidScope(scopeValue)) {
35166
35174
  violations.push({
35167
35175
  type: "invalid-scope",
@@ -35170,7 +35178,6 @@ function checkScopeMarkers(opts) {
35170
35178
  });
35171
35179
  }
35172
35180
  } else {
35173
- const scopeValue = extractShScope(content);
35174
35181
  if (scopeValue === null) {
35175
35182
  violations.push({ type: "missing-scope", path: relPath });
35176
35183
  } else if (!isValidScope(scopeValue)) {
@@ -35187,14 +35194,20 @@ function checkScopeMarkers(opts) {
35187
35194
  }
35188
35195
  function runVerifyParity(opts) {
35189
35196
  const { claudeDir, templatesDir, expectedOneSided } = opts;
35190
- const violations = [];
35191
- violations.push(...checkScopeMarkers({ claudeDir }));
35197
+ const allScopeItems = [];
35198
+ const parityItems = [];
35199
+ allScopeItems.push(...checkScopeMarkers({ claudeDir, templatesDir }));
35192
35200
  if (templatesDir != null && fs11.existsSync(templatesDir)) {
35193
- violations.push(
35201
+ parityItems.push(
35194
35202
  ...checkSiblingParity({ claudeDir, templatesDir, expectedOneSided })
35195
35203
  );
35196
35204
  }
35197
- return { violations };
35205
+ const warnings = allScopeItems.filter((v) => v.type === "redundant-scope");
35206
+ const scopeViolations = allScopeItems.filter(
35207
+ (v) => v.type !== "redundant-scope"
35208
+ );
35209
+ const violations = [...scopeViolations, ...parityItems];
35210
+ return { violations, warnings };
35198
35211
  }
35199
35212
  function readdirRecursive(dir, rel = "", visited = /* @__PURE__ */ new Set()) {
35200
35213
  const realDir = fs11.realpathSync(dir);
@@ -35258,7 +35271,7 @@ var init_verify_parity = __esm({
35258
35271
  "hooks",
35259
35272
  "rules"
35260
35273
  ];
35261
- REPO_ONLY_RE = /^repo-only:[a-z0-9-]+$/;
35274
+ REPO_ONLY_RE = /^repo-only:[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;
35262
35275
  DEFAULT_EXPECTED_ONE_SIDED = /* @__PURE__ */ new Set([
35263
35276
  "hooks/cbp-mcp-migration-guard.sh",
35264
35277
  // repo-only:codebyplan — monorepo-only skill (references the in-repo
@@ -35312,12 +35325,19 @@ function verifyParity(args, deps = {}) {
35312
35325
  );
35313
35326
  return 2;
35314
35327
  }
35315
- const { violations } = result;
35328
+ const { violations, warnings } = result;
35316
35329
  if (jsonMode) {
35317
- process.stdout.write(JSON.stringify(violations, null, 2) + "\n");
35330
+ process.stdout.write(
35331
+ JSON.stringify({ violations, warnings }, null, 2) + "\n"
35332
+ );
35318
35333
  if (violations.length > 0 && !warnOnly) return 1;
35319
35334
  return 0;
35320
35335
  }
35336
+ for (const w of warnings) {
35337
+ const detail = w.detail ? `: ${w.detail}` : "";
35338
+ process.stderr.write(`verify-parity: WARN ${w.path}${detail}
35339
+ `);
35340
+ }
35321
35341
  if (violations.length === 0) {
35322
35342
  process.stdout.write("verify-parity: OK \u2014 no violations found.\n");
35323
35343
  return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebyplan",
3
- "version": "1.13.46",
3
+ "version": "1.13.48",
4
4
  "description": "CLI for CodeByPlan — AI-powered development planning and tracking",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-cc-executor
4
3
  description: Authoring executor for `.claude/` infrastructure. Applies approved changes across rules, skills, agents, context, CLAUDE.md, settings, and hooks — with update-first discipline, scope-marker enforcement, and length-limit awareness. Callable by the main conversation, `/cbp-checkpoint-end`, and `round-executor` (for in-scope `.claude/` infra deliverables).
5
4
  tools: Read, Write, Edit, Glob, Grep, Skill, Task, AskUserQuestion, Bash(npx codebyplan task create *)
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-database-agent
4
3
  description: Supabase database specialist. Handles migrations, RLS policies, type generation, and schema changes. Spawned as sub-executor by round-executor when plan includes DB work.
5
4
  tools: Read, Write, Edit, Glob, Grep, Bash, mcp__supabase__apply_migration, mcp__supabase__execute_sql, mcp__supabase__list_tables, mcp__supabase__list_migrations, mcp__supabase__get_advisors, mcp__supabase__generate_typescript_types, mcp__supabase__search_docs
@@ -4,7 +4,6 @@ description: Maestro E2E flow authoring + execution for Expo/React Native mobile
4
4
  tools: Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion, mcp__codebyplan__get_repos
5
5
  model: sonnet
6
6
  effort: xhigh
7
- scope: org-shared
8
7
  ---
9
8
 
10
9
  # Maestro E2E Agent
@@ -4,7 +4,6 @@ description: Playwright E2E test authoring + execution for web app routes. Spawn
4
4
  tools: Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion, mcp__codebyplan__get_repos
5
5
  model: sonnet
6
6
  effort: xhigh
7
- scope: org-shared
8
7
  ---
9
8
 
10
9
  # Playwright E2E Agent
@@ -4,7 +4,6 @@ description: WebDriverIO + tauri-driver E2E test authoring + execution for Tauri
4
4
  tools: Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion, mcp__codebyplan__get_repos
5
5
  model: sonnet
6
6
  effort: xhigh
7
- scope: org-shared
8
7
  ---
9
8
 
10
9
  # Tauri E2E Agent
@@ -4,7 +4,6 @@ description: VS Code extension E2E test authoring + execution using @vscode/test
4
4
  tools: Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion, mcp__codebyplan__get_repos
5
5
  model: sonnet
6
6
  effort: xhigh
7
- scope: org-shared
8
7
  ---
9
8
 
10
9
  # VS Code Extension E2E Agent
@@ -4,7 +4,6 @@ description: XCUITest native iOS E2E test authoring + execution for Expo apps ta
4
4
  tools: Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion, mcp__codebyplan__get_repos
5
5
  model: sonnet
6
6
  effort: xhigh
7
- scope: org-shared
8
7
  ---
9
8
 
10
9
  # XCUITest E2E Agent
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-improve-claude
4
3
  description: Broad analysis agent for retrospective task analysis. Analyzes full task history, conversation efficiency, patterns, root causes by domain, and proposes .claude/ infrastructure improvements.
5
4
  tools: Read, Glob, Grep, Task, AskUserQuestion
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-improve-round
4
3
  description: Code quality review agent. Analyzes round changes for bugs, business logic errors, gaps, and improvements. Spawned by /cbp-round-end.
5
4
  tools: Read, Glob, Grep, Task
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-map-architecture
4
3
  description: Read-only agent that analyzes a repository module and produces a structured architecture map following the canonical spec. Invoke when generating or refreshing a module's .claude/architecture/<module>.md map file. Returns the full map content as text for the caller to write.
5
4
  tools: Read, Glob, Grep
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-mechanical-edits
4
3
  description: Cheap mechanical-edits subagent — performs renames, moves, string substitutions, frontmatter field edits, and free-form index/manifest regeneration. Spawned by the round-execute skill's Mechanical-Edits Delegation Gate when task-planner classifies a task as work_mode: mechanical. Never authors new code logic.
5
4
  tools: Read, Write, Edit, Glob, Grep, Bash
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-research
4
3
  description: Intelligent on-demand research with discovery levels (0-3). Consults stack first, produces DISCOVERY.md for Level 2+. Callable by other agents.
5
4
  tools: Read, Glob, Grep, WebSearch, WebFetch, Write, Task
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-round-executor
4
3
  description: Execute approved plan. Receives pre-analyzed deliverables and files list. Focuses on quality implementation. Communicates with user when blocked or needs decisions.
5
4
  tools: Read, Write, Edit, Glob, Grep, Bash, TaskUpdate, AskUserQuestion, Skill, Task
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-security-agent
4
3
  description: Security review specialist. Checks for OWASP top 10 vulnerabilities, hardcoded secrets, SQL injection, XSS, CSRF, and dependency vulnerabilities.
5
4
  tools: Read, Glob, Grep, Bash
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-task-check
4
3
  description: Task verification agent. Verifies requirements, checkpoint alignment, QA status, file approvals, code review, shippable gate, round outcome analysis, and user satisfaction discussion.
5
4
  tools: Read, Glob, Grep, Bash, AskUserQuestion
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-task-planner
4
3
  description: Analyze codebase and create implementation plan. Reads context from DB. Uses Explore subagent for fast analysis. Communicates with user for clarifications.
5
4
  tools: Read, Glob, Grep, Task, TaskCreate, AskUserQuestion
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-testing-qa-agent
4
3
  description: Combined testing, QA generation, and default checklists. Runs build/lint/types/unit-tests/audit, generates auto QA items, applies default production checklists. Does NOT consume e2e screenshots or frontend-ui findings.
5
4
  tools: Read, Glob, Grep, Bash, AskUserQuestion
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # @hook: PostToolUse Edit|Write
4
3
  # Hook: PostToolUse for Edit|Write on hook files
5
4
  # Purpose: Run test-hooks.sh when a plugin hook file is modified.
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env bash
2
- # @scope: org-shared
3
2
  # @event: PreToolUse
4
3
  # @matcher: Edit|Write|MultiEdit
5
4
  # Advisory source-of-truth nudge. When editing a GATE-6-tracked .claude/ file
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Hook: UserPromptSubmit
4
3
  # Purpose: Emit a one-time notice into Claude's context when the session's total
5
4
  # context-window usage crosses CBP_CONTEXT_WARN_TOKENS (default 200000).
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env bash
2
- # @scope: org-shared
3
2
  # @event: PreToolUse
4
3
  # @matcher: Edit|Write|MultiEdit
5
4
  # Guard spec files against two patterns banned by rules/e2e-mandatory.md and
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # @hook: PostToolUse Edit|Write
4
3
  # Hook: Auto-format and auto-fix lint on edited source files
5
4
  # Purpose: Continuous Prettier + ESLint --fix after every Edit/Write.
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env bash
2
- # @scope: org-shared
3
2
  # @event: PreToolUse
4
3
  # @matcher: Edit|Write|MultiEdit
5
4
  # Validate maestro flow YAML against the installed CLI's accepted property set.
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # @hook: PreToolUse mcp__codebyplan__(update_checkpoint|complete_checkpoint|update_task|complete_task|add_round|update_round|complete_round|create_standalone_task|update_standalone_task|complete_standalone_task|add_standalone_round|update_standalone_round|complete_standalone_round|update_standalone_file_change)
4
3
  # Hook: PreToolUse for MCP write tools
5
4
  #
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # @hook: PreToolUse for MCP mutation tools
4
3
  # Hook: PreToolUse for MCP mutation tools
5
4
  # Purpose: Warn once per session if a legacy .codebyplan.json exists at repo root (post-CHK-120).
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Hook: PostToolUse mcp__codebyplan__complete_round
4
3
  # Purpose: After complete_round succeeds, delegate git-diff drift merge,
5
4
  # staging-status flip, and web-UI flag sync to the codebyplan CLI.
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Hook: universal plugin-script dispatcher
4
3
  # Purpose: Resolve a plugin-shipped hook/statusLine script path with auto-detect fallback.
5
4
  # Workaround: ${CLAUDE_PLUGIN_ROOT} is set in the plugin's own hook context but may not
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # @hook: PreToolUse Bash
4
3
  # Hook: PreToolUse for Bash (git commit commands)
5
4
  # Purpose: Block git commits that violate greenfield-lint-zero-warnings,
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Hook: SessionStart
4
3
  # Purpose: Hydrate .codebyplan/state/ via `codebyplan sync` and ensure the
5
4
  # per-worktree watch daemon is running. Hook-safe: all errors
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- // @scope: org-shared
3
2
  // @hook: NOT-A-HOOK (statusLine renderer, invoked via the cbp-statusline.sh dispatcher)
4
3
  // Claude Code Status Line — node renderer (ESM; .mjs forces ESM regardless of the
5
4
  // host repo's package.json "type", so the script is portable into any consumer).
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env python3
2
- # @scope: org-shared
3
2
  # @hook: NOT-A-HOOK (statusLine renderer, invoked via the cbp-statusline.sh dispatcher)
4
3
  # Claude Code Status Line — python renderer.
5
4
  # Byte-identical output to the bash renderer in cbp-statusline.sh and the node
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # @hook: NOT-A-HOOK (statusLine renderer, invoked by settings.json statusLine.command)
4
3
  # Claude Code Status Line — multi-runtime dispatcher + bash renderer
5
4
  # Purpose: Renders up to 6 structured lines of Claude Code status from stdin JSON.
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- // @scope: org-shared
3
2
  // @hook: NOT-A-HOOK (subagentStatusLine renderer, invoked via the cbp-subagent-statusline.sh dispatcher)
4
3
  // Claude Code Subagent Status Line — node renderer (ESM; .mjs forces ESM regardless
5
4
  // of the host repo's package.json "type"). Byte-identical output to the bash renderer
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env python3
2
- # @scope: org-shared
3
2
  # @hook: NOT-A-HOOK (subagentStatusLine renderer, invoked via the cbp-subagent-statusline.sh dispatcher)
4
3
  # Claude Code Subagent Status Line — python renderer. Byte-identical output to the
5
4
  # bash renderer in cbp-subagent-statusline.sh and the node renderer in
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Portability: bash 3.2+ (macOS default /bin/bash). UTF-8 multibyte chars in
4
3
  # user-controlled fields are byte-iterated under 3.2 (over-counts visible width
5
4
  # for non-ASCII content); acceptable safe-direction approximation — and the node
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # @hook: PreToolUse Bash
4
3
  # Hook: PreToolUse for Bash (git commit commands)
5
4
  # Purpose: Block git commits when new source files lack test companions
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # @hook: NOT-A-HOOK (test suite for plugin hooks; invoked by cbp-auto-test-hooks.sh)
4
3
  # Purpose: Test suite for plugin's shipped hooks. Invoked by cbp-auto-test-hooks.sh whenever a
5
4
  # plugin hook file is edited. Not a PreToolUse/PostToolUse/Notification hook itself —
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Hook Helper: Context file usage validation for validate-structure.sh
4
3
  # Purpose: Ensure context files are referenced by at least one agent or skill
5
4
  # Sourced by validate-structure.sh - not run directly
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # @hook: PreToolUse Bash
4
3
  # Hook: PreToolUse for Bash (git commit commands)
5
4
  # Purpose: Prevent Claude attribution in git commits
@@ -33,21 +32,70 @@ block() {
33
32
  exit 2
34
33
  }
35
34
 
36
- # Check for Claude attribution patterns
37
- # Case-insensitive check for various patterns
35
+ # ---------------------------------------------------------------------------
36
+ # Isolate the commit MESSAGE from the rest of the command.
37
+ #
38
+ # The broad "claude/anthropic" word-check below targets attribution that may
39
+ # land in the commit *message* — NOT benign mentions elsewhere in the command
40
+ # (narration echoes, a `.claude/CLAUDE.md` path argument, a piped subcommand).
41
+ # Scanning the whole command false-positives on those (e.g. an `echo` that
42
+ # says the word "claude", or `git commit .claude/CLAUDE.md -m "..."`). So we
43
+ # extract just the message text:
44
+ # (a) heredoc bodies — the `-m "$(cat <<'EOF' ... EOF)"` pattern
45
+ # (b) -m/--message args — quoted "..." or '...'
46
+ # If no message can be isolated (editor commit, `-F file`), fall back to the
47
+ # whole command so attribution protection is never silently dropped.
48
+ #
49
+ # The specific checks further down (generated-with / co-authored-by / emoji /
50
+ # --author) still scan the WHOLE command — those patterns are precise enough
51
+ # that catching them anywhere is correct, and they backstop this extraction.
52
+ # ---------------------------------------------------------------------------
53
+ extract_commit_message() {
54
+ local cmd="$1"
55
+ local out="" delim margs
38
56
 
39
- # Check for "Claude" mentions (but allow CLAUDE.md files and .claude/ folder paths)
40
- # First, remove CLAUDE.md filenames and .claude(/path|word-end) BSD-compatible word-boundary via [[:>:]]
41
- # Word-boundary allows ".claude folder" / ".claude rules" / ".claude/" all as legit folder references
42
- COMMAND_WITHOUT_FILES=$(echo "$COMMAND" \
57
+ # (a) Heredoc body. Detect the delimiter (supports <<EOF, <<'EOF', <<-EOF),
58
+ # then print the lines strictly between the opener and its closing line.
59
+ # Each pipeline ends in sed/awk (exit 0) so a no-match grep cannot trip
60
+ # `set -e` via the command substitution.
61
+ delim=$(printf '%s\n' "$cmd" \
62
+ | grep -oE "<<-?[[:space:]]*'?[A-Za-z_][A-Za-z0-9_]*'?" \
63
+ | head -n1 \
64
+ | sed -E "s/^<<-?[[:space:]]*//; s/'//g")
65
+ if [ -n "$delim" ]; then
66
+ out=$(printf '%s\n' "$cmd" | awk -v d="$delim" '
67
+ start==0 { if (index($0, "<<") && index($0, d)) { start=1 } ; next }
68
+ start==1 { s=$0; sub(/^[ \t]+/,"",s); sub(/[ \t]+$/,"",s); if (s==d) {start=2; next} print }
69
+ ')
70
+ fi
71
+
72
+ # (b) Quoted -m / --message argument values.
73
+ margs=$(printf '%s\n' "$cmd" \
74
+ | grep -oE -- "(-m|--message)[[:space:]]+(\"[^\"]*\"|'[^']*')" \
75
+ | sed -E "s/^(-m|--message)[[:space:]]+//; s/^[\"']//; s/[\"']$//")
76
+
77
+ printf '%s\n%s\n' "$out" "$margs"
78
+ }
79
+
80
+ MESSAGE=$(extract_commit_message "$COMMAND")
81
+ # Fall back to scanning the whole command when no message could be isolated.
82
+ if [ -z "$(printf '%s' "$MESSAGE" | tr -d '[:space:]')" ]; then
83
+ MESSAGE="$COMMAND"
84
+ fi
85
+
86
+ # Check for Claude attribution in the MESSAGE (case-insensitive).
87
+ # Allow legitimate CLAUDE.md filenames and .claude/ folder paths that may
88
+ # legitimately appear inside a commit message (e.g. a commit *about* them).
89
+ # BSD-compatible word-boundary via [[:>:]].
90
+ MESSAGE_WITHOUT_FILES=$(echo "$MESSAGE" \
43
91
  | sed -E 's/CLAUDE(\.[a-z]+)?\.md//gi' \
44
92
  | sed -E 's/\.claude(\/[a-zA-Z0-9_./-]*|[[:>:]])//gi' \
45
93
  | sed -E 's/\$\{CLAUDE[A-Z_]*\}//g' \
46
94
  | sed -E 's/claude-plugin[a-zA-Z0-9_./-]*//gi' \
47
95
  | sed -E 's/codebyplan-claude[a-zA-Z0-9_./-]*//gi' \
48
96
  | sed -E 's/@codebyplan\/claude[a-zA-Z0-9_./-]*//gi')
49
- if echo "$COMMAND_WITHOUT_FILES" | grep -qiE 'claude|anthropic'; then
50
- block "BLOCKED: Git commit contains Claude/Anthropic attribution. Remove any mention of Claude from the commit message. Author should only be: midevyou <midevyosauhing@gmail.com>"
97
+ if echo "$MESSAGE_WITHOUT_FILES" | grep -qiE 'claude|anthropic'; then
98
+ block "BLOCKED: Git commit message contains Claude/Anthropic attribution. Remove any mention of Claude from the commit message. Author should only be: midevyou <midevyosauhing@gmail.com>"
51
99
  fi
52
100
 
53
101
  # Check for "Generated with" patterns
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Hook: PreToolUse Bash
4
3
  # Purpose: Deny any `git stash` command. Git stash is banned per the
5
4
  # feedback_no-git-stash auto-memory entry. Alternatives:
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Hook Helper: File-length enforcement for validate-structure.sh
4
3
  # Two-tier policy: warn at recommended → stderr notice; block at hard cap (~2× warn) → exit 2
5
4
  # Sourced by validate-structure.sh — not run directly.
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Hook Helper Library: Shared primitives for validate-structure-*.sh
4
3
  # Purpose: Block/warn formatters, path-matching, content extraction,
5
4
  # frontmatter / scope-marker detection, line counting.
@@ -102,3 +101,20 @@ has_yaml_field() {
102
101
  has_scope_comment() {
103
102
  [ -f "$1" ] && head -5 "$1" 2>/dev/null | grep -q "^# @scope:"
104
103
  }
104
+
105
+ # has_template_twin <rel_path_under_claude>
106
+ # Returns 0 when the codebyplan package ships a template twin for this .claude file
107
+ # (i.e. the file is package-MANAGED — org-shared is its implicit default and a
108
+ # scope marker is NOT required). <rel_path_under_claude> is the path beneath
109
+ # .claude/ (e.g. "rules/foo.md", "skills/x/SKILL.md").
110
+ # Monorepo: $REPO_ROOT/packages/codebyplan-package/templates/<rel>
111
+ # Consumer: $REPO_ROOT/node_modules/codebyplan/templates/<rel>
112
+ # Returns non-zero when no twin is found — including when no templates dir is
113
+ # resolvable at all. Callers treat a non-zero result as "user-created", which is
114
+ # the conservative fallback: a scope marker is then required (legacy behavior).
115
+ has_template_twin() {
116
+ local rel="$1"
117
+ [ -f "$REPO_ROOT/packages/codebyplan-package/templates/$rel" ] && return 0
118
+ [ -f "$REPO_ROOT/node_modules/codebyplan/templates/$rel" ] && return 0
119
+ return 1
120
+ }
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Hook Helper: Pattern validation for validate-structure.sh
4
3
  # Purpose: Validate file paths against structure patterns
5
4
  # Sourced by validate-structure.sh - not run directly
@@ -1,31 +1,63 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Hook Helper: Scope marker validation for validate-structure.sh
4
- # Purpose: Ensure all .claude/ files have a scope marker for structural classification
3
+ # Purpose: Enforce scope markers on USER-CREATED .claude/ files only. Files the
4
+ # codebyplan package distributes (a template twin exists) are MANAGED:
5
+ # org-shared is the implicit default, so no marker is required and an
6
+ # explicit 'org-shared' marker is redundant (warned, non-blocking).
7
+ # A file with no template twin is user-created and must declare a marker.
5
8
  # Sourced by validate-structure.sh - not run directly
6
9
  #
7
- # Expects: $REL_PATH, $FILE_PATH, $EXT, warn(), match_path(),
8
- # has_yaml_frontmatter(), has_yaml_field(), has_scope_comment() (from validate-structure-lib.sh)
10
+ # Expects: $REL_PATH, $FILE_PATH, $EXT, $REPO_ROOT, warn(), match_path(),
11
+ # has_yaml_frontmatter(), has_yaml_field(), has_scope_comment(),
12
+ # has_template_twin() (from validate-structure-lib.sh)
9
13
 
10
14
  # Only check .claude/ files
11
15
  if ! match_path '^/\.claude/'; then
12
16
  return 0 2>/dev/null || true
13
17
  fi
14
18
 
19
+ # Path beneath .claude/ — used for template-twin (managed) detection.
20
+ _scope_rel="${REL_PATH#/.claude/}"
21
+
22
+ # Managed = the codebyplan package ships a template twin for this file. When no
23
+ # twin is found (or no templates dir is resolvable) the file is user-created and
24
+ # a marker is required — the conservative fallback that preserves legacy behavior.
25
+ if has_template_twin "$_scope_rel"; then
26
+ _scope_managed=1
27
+ else
28
+ _scope_managed=0
29
+ fi
30
+
31
+ _valid_scope_re='^(org-shared|project-shared|repo-only:[a-z0-9]([a-z0-9-]*[a-z0-9])?)$'
32
+
15
33
  case "$EXT" in
16
34
  md)
17
- if has_yaml_frontmatter "$FILE_PATH"; then
18
- if ! has_yaml_field "$FILE_PATH" scope; then
19
- warn "Missing scope: in frontmatter. Add 'scope: org-shared' / 'scope: project-shared' / 'scope: repo-only:<name>' for structural classification. See rules/scope-vocabulary.md."
35
+ if has_yaml_frontmatter "$FILE_PATH" && has_yaml_field "$FILE_PATH" scope 50; then
36
+ _scope_val=$(head -50 "$FILE_PATH" 2>/dev/null | grep -E '^scope:' | head -1 \
37
+ | sed -E 's/^scope:[[:space:]]*//; s/[[:space:]]*#.*$//; s/[[:space:]]*$//')
38
+ if [ "$_scope_managed" = "1" ] && [ "$_scope_val" = "org-shared" ]; then
39
+ warn "Redundant 'scope: org-shared' on a package-managed file — org-shared is the implicit default; remove the key. See rules/scope-vocabulary.md."
40
+ elif ! [[ "$_scope_val" =~ $_valid_scope_re ]]; then
41
+ warn "Invalid scope value '$_scope_val'. Use org-shared / project-shared / repo-only:<name>. See rules/scope-vocabulary.md."
20
42
  fi
21
- else
22
- warn "Missing frontmatter with scope:. Add YAML frontmatter with 'scope: org-shared' / 'scope: project-shared' / 'scope: repo-only:<name>'. See rules/scope-vocabulary.md."
43
+ elif [ "$_scope_managed" = "0" ]; then
44
+ warn "Missing scope: in frontmatter. A user-created .claude/ file must declare 'scope: project-shared' or 'scope: repo-only:<name>' (package-managed files default to org-shared). See rules/scope-vocabulary.md."
23
45
  fi
46
+ # managed + no marker → org-shared implied, no warning.
24
47
  ;;
25
48
  sh)
26
- if ! has_scope_comment "$FILE_PATH"; then
27
- warn "Missing # @scope: comment. Add '# @scope: org-shared' / '# @scope: project-shared' / '# @scope: repo-only:<name>' after shebang. See rules/scope-vocabulary.md."
49
+ if has_scope_comment "$FILE_PATH"; then
50
+ _scope_val=$(head -5 "$FILE_PATH" 2>/dev/null | grep -E '^# @scope:' | head -1 \
51
+ | sed -E 's/^# @scope:[[:space:]]*//; s/[[:space:]]*#.*$//; s/[[:space:]]*$//')
52
+ if [ "$_scope_managed" = "1" ] && [ "$_scope_val" = "org-shared" ]; then
53
+ warn "Redundant '# @scope: org-shared' on a package-managed hook — org-shared is the implicit default; remove the comment. See rules/scope-vocabulary.md."
54
+ elif ! [[ "$_scope_val" =~ $_valid_scope_re ]]; then
55
+ warn "Invalid @scope value '$_scope_val'. Use org-shared / project-shared / repo-only:<name>. See rules/scope-vocabulary.md."
56
+ fi
57
+ elif [ "$_scope_managed" = "0" ]; then
58
+ warn "Missing # @scope: comment. A user-created .claude/ hook must declare '# @scope: project-shared' or '# @scope: repo-only:<name>' (package-managed hooks default to org-shared). See rules/scope-vocabulary.md."
28
59
  fi
60
+ # managed + no marker → org-shared implied, no warning.
29
61
  ;;
30
62
  json)
31
63
  # JSON can't have frontmatter — skip
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Smoke runner for validate-structure-*.sh + validate-structure-lib.sh
4
3
  # Iterates fixtures under __test-fixtures__/validate-structure/{good,bad}/
5
4
  # Each test case maps a fixture file → simulated rel path inside .claude/
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Hook Helper: Template/context suggestion for validate-structure.sh
4
3
  # Purpose: Map file locations to applicable templates or context files
5
4
  # Sourced by validate-structure.sh - not run directly