@geraldmaron/construct 1.0.14 → 1.0.15

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 (259) hide show
  1. package/README.md +6 -0
  2. package/bin/construct +3 -3
  3. package/commands/build/feature.md +0 -6
  4. package/commands/build/fix.md +0 -6
  5. package/commands/design/access.md +0 -6
  6. package/commands/design/flow.md +0 -6
  7. package/commands/design/ui.md +0 -6
  8. package/commands/measure/experiment.md +0 -6
  9. package/commands/measure/metrics.md +0 -6
  10. package/commands/measure/results.md +0 -6
  11. package/commands/plan/api.md +0 -6
  12. package/commands/plan/challenge.md +0 -6
  13. package/commands/plan/decide.md +0 -6
  14. package/commands/plan/feature.md +0 -7
  15. package/commands/plan/requirements.md +0 -6
  16. package/commands/remember/context.md +0 -6
  17. package/commands/remember/handoff.md +0 -6
  18. package/commands/remember/runbook.md +0 -6
  19. package/commands/review/code.md +0 -6
  20. package/commands/review/quality.md +0 -6
  21. package/commands/review/security.md +0 -6
  22. package/commands/ship/ready.md +0 -6
  23. package/commands/ship/release.md +0 -6
  24. package/commands/ship/status.md +0 -6
  25. package/commands/understand/docs.md +0 -6
  26. package/commands/understand/research.md +0 -6
  27. package/commands/understand/this.md +0 -6
  28. package/commands/understand/why.md +0 -6
  29. package/commands/work/clean.md +0 -6
  30. package/commands/work/drive.md +0 -6
  31. package/commands/work/optimize-prompts.md +0 -6
  32. package/commands/work/parallel-review.md +0 -6
  33. package/lib/beads-client.mjs +19 -1
  34. package/lib/comment-lint.mjs +5 -1
  35. package/lib/context-state.mjs +15 -3
  36. package/lib/contracts/validate.mjs +54 -10
  37. package/lib/contracts/violation-log.mjs +154 -0
  38. package/lib/document-extract/docling-client.mjs +114 -0
  39. package/lib/document-extract/docling-sidecar.py +122 -0
  40. package/lib/document-extract/whisper-client.mjs +79 -0
  41. package/lib/document-extract.mjs +73 -8
  42. package/lib/document-ingest.mjs +26 -4
  43. package/lib/embed/daemon.mjs +6 -1
  44. package/lib/flavors/loader.mjs +1 -1
  45. package/lib/handoffs/contract.mjs +2 -2
  46. package/lib/hooks/session-start.mjs +1 -1
  47. package/lib/ingest/chunker.mjs +94 -0
  48. package/lib/ingest/pipeline.mjs +53 -0
  49. package/lib/ingest/store.mjs +82 -0
  50. package/lib/knowledge/search.mjs +12 -0
  51. package/lib/mcp/server.mjs +142 -1
  52. package/lib/mcp/tools/skills.mjs +6 -3
  53. package/lib/mcp/tools/workflow.mjs +6 -2
  54. package/lib/observation-store.mjs +14 -5
  55. package/lib/ollama-manager.mjs +32 -28
  56. package/lib/prompt-composer.js +11 -1
  57. package/lib/runtime/uv-bootstrap.mjs +129 -0
  58. package/lib/runtime/whisper-bootstrap.mjs +102 -0
  59. package/lib/server/index.mjs +22 -1
  60. package/lib/server/static/index.html +1 -1
  61. package/lib/specialists/postconditions.mjs +1 -1
  62. package/lib/sync/skill-frontmatter.mjs +113 -21
  63. package/lib/tracking-surfaces.mjs +2 -0
  64. package/lib/validators/skills.mjs +86 -54
  65. package/package.json +5 -5
  66. package/personas/construct.md +4 -7
  67. package/platforms/claude/settings.template.json +1 -1
  68. package/rules/common/beads-hygiene.md +3 -9
  69. package/rules/common/code-review.md +3 -6
  70. package/rules/common/coding-style.md +3 -6
  71. package/rules/common/comments.md +3 -7
  72. package/rules/common/commit-approval.md +3 -6
  73. package/rules/common/cx-agent-routing.md +3 -7
  74. package/rules/common/cx-skill-routing.md +3 -3
  75. package/rules/common/doc-ownership.md +3 -8
  76. package/rules/common/efficiency.md +3 -8
  77. package/rules/common/framing.md +3 -8
  78. package/rules/common/git-workflow.md +3 -5
  79. package/rules/common/no-fabrication.md +4 -12
  80. package/rules/common/patterns.md +3 -5
  81. package/rules/common/release-gates.md +3 -8
  82. package/rules/common/research.md +3 -8
  83. package/rules/common/review-before-change.md +3 -9
  84. package/rules/common/security.md +3 -6
  85. package/rules/common/skill-composition.md +3 -7
  86. package/rules/common/testing.md +3 -6
  87. package/rules/golang/coding-style.md +1 -5
  88. package/rules/golang/hooks.md +1 -5
  89. package/rules/golang/patterns.md +1 -5
  90. package/rules/golang/security.md +1 -5
  91. package/rules/golang/testing.md +1 -5
  92. package/rules/python/coding-style.md +1 -5
  93. package/rules/python/hooks.md +1 -5
  94. package/rules/python/patterns.md +1 -5
  95. package/rules/python/security.md +1 -5
  96. package/rules/python/testing.md +1 -5
  97. package/rules/swift/coding-style.md +1 -5
  98. package/rules/swift/hooks.md +1 -5
  99. package/rules/swift/patterns.md +1 -5
  100. package/rules/swift/security.md +1 -5
  101. package/rules/swift/testing.md +1 -5
  102. package/rules/typescript/coding-style.md +1 -5
  103. package/rules/typescript/hooks.md +1 -5
  104. package/rules/typescript/patterns.md +1 -5
  105. package/rules/typescript/security.md +1 -5
  106. package/rules/typescript/testing.md +1 -5
  107. package/rules/web/coding-style.md +3 -5
  108. package/rules/web/design-quality.md +3 -5
  109. package/rules/web/hooks.md +3 -5
  110. package/rules/web/patterns.md +3 -5
  111. package/rules/web/performance.md +3 -5
  112. package/rules/web/security.md +3 -5
  113. package/rules/web/testing.md +3 -5
  114. package/skills/ai/agent-dev.md +4 -5
  115. package/skills/ai/llm-security.md +4 -5
  116. package/skills/ai/ml-ops.md +4 -5
  117. package/skills/ai/orchestration-workflow.md +4 -5
  118. package/skills/ai/prompt-and-eval.md +4 -5
  119. package/skills/ai/prompt-optimizer.md +4 -6
  120. package/skills/ai/rag-system.md +4 -5
  121. package/skills/architecture/api-design.md +4 -5
  122. package/skills/architecture/caching.md +4 -5
  123. package/skills/architecture/cloud-native.md +4 -5
  124. package/skills/architecture/message-queue.md +4 -5
  125. package/skills/architecture/security-arch.md +4 -5
  126. package/skills/compliance/ai-disclosure.md +4 -5
  127. package/skills/compliance/data-privacy.md +4 -5
  128. package/skills/compliance/license-audit.md +4 -5
  129. package/skills/compliance/regulatory-review.md +4 -5
  130. package/skills/development/cpp.md +4 -5
  131. package/skills/development/go.md +4 -5
  132. package/skills/development/java.md +4 -5
  133. package/skills/development/kotlin.md +4 -5
  134. package/skills/development/mobile-crossplatform.md +4 -5
  135. package/skills/development/python.md +4 -5
  136. package/skills/development/rust.md +4 -5
  137. package/skills/development/shell.md +4 -5
  138. package/skills/development/swift.md +4 -5
  139. package/skills/development/typescript.md +4 -5
  140. package/skills/devops/ci-cd.md +4 -5
  141. package/skills/devops/containerization.md +4 -5
  142. package/skills/devops/cost-optimization.md +4 -5
  143. package/skills/devops/data-engineering.md +4 -5
  144. package/skills/devops/database.md +4 -5
  145. package/skills/devops/dependency-management.md +4 -5
  146. package/skills/devops/devsecops.md +4 -5
  147. package/skills/devops/git-workflow.md +4 -5
  148. package/skills/devops/incident-response.md +4 -5
  149. package/skills/devops/monorepo.md +4 -5
  150. package/skills/devops/observability.md +4 -5
  151. package/skills/devops/performance.md +4 -5
  152. package/skills/devops/testing.md +4 -5
  153. package/skills/docs/adr-workflow.md +4 -7
  154. package/skills/docs/backlog-proposal-workflow.md +4 -3
  155. package/skills/docs/customer-profile-workflow.md +4 -3
  156. package/skills/docs/document-ingest-workflow.md +4 -3
  157. package/skills/docs/evidence-ingest-workflow.md +4 -3
  158. package/skills/docs/init-docs.md +4 -5
  159. package/skills/docs/init-project.md +4 -5
  160. package/skills/docs/prd-workflow.md +4 -7
  161. package/skills/docs/prfaq-workflow.md +4 -3
  162. package/skills/docs/product-intelligence-review.md +4 -3
  163. package/skills/docs/product-intelligence-workflow.md +4 -6
  164. package/skills/docs/product-signal-workflow.md +4 -5
  165. package/skills/docs/research-workflow.md +4 -5
  166. package/skills/docs/runbook-workflow.md +4 -5
  167. package/skills/docs/strategy-workflow.md +4 -5
  168. package/skills/exploration/dependency-graph-reading.md +4 -7
  169. package/skills/exploration/repo-map.md +4 -5
  170. package/skills/exploration/tracer-bullet-method.md +4 -7
  171. package/skills/exploration/unknown-codebase-onboarding.md +4 -7
  172. package/skills/frameworks/django.md +4 -5
  173. package/skills/frameworks/nextjs.md +4 -5
  174. package/skills/frameworks/react.md +4 -5
  175. package/skills/frameworks/spring-boot.md +4 -5
  176. package/skills/frontend-design/accessibility.md +4 -5
  177. package/skills/frontend-design/component-patterns.md +4 -5
  178. package/skills/frontend-design/engineering.md +4 -5
  179. package/skills/frontend-design/state-management.md +4 -5
  180. package/skills/frontend-design/ui-aesthetics.md +4 -5
  181. package/skills/frontend-design/ux-principles.md +4 -5
  182. package/skills/operating/change-management.md +4 -8
  183. package/skills/operating/incident-response.md +4 -8
  184. package/skills/operating/oncall-rotation.md +4 -7
  185. package/skills/operating/orchestration-reference.md +4 -10
  186. package/skills/quality-gates/review-work.md +4 -5
  187. package/skills/quality-gates/verify-change.md +4 -5
  188. package/skills/quality-gates/verify-module.md +4 -5
  189. package/skills/quality-gates/verify-quality.md +4 -5
  190. package/skills/quality-gates/verify-security.md +4 -5
  191. package/skills/roles/architect.ai-systems.md +6 -9
  192. package/skills/roles/architect.data.md +6 -9
  193. package/skills/roles/architect.enterprise.md +6 -9
  194. package/skills/roles/architect.integration.md +6 -9
  195. package/skills/roles/architect.md +7 -14
  196. package/skills/roles/architect.platform.md +6 -9
  197. package/skills/roles/data-analyst.experiment.md +6 -9
  198. package/skills/roles/data-analyst.md +6 -9
  199. package/skills/roles/data-analyst.product-intelligence.md +7 -9
  200. package/skills/roles/data-analyst.product.md +6 -9
  201. package/skills/roles/data-analyst.telemetry.md +7 -9
  202. package/skills/roles/data-engineer.pipeline.md +6 -9
  203. package/skills/roles/data-engineer.vector-retrieval.md +7 -9
  204. package/skills/roles/data-engineer.warehouse.md +6 -9
  205. package/skills/roles/debugger.md +6 -9
  206. package/skills/roles/designer.accessibility.md +6 -9
  207. package/skills/roles/designer.md +7 -9
  208. package/skills/roles/engineer.ai.md +6 -9
  209. package/skills/roles/engineer.data.md +6 -9
  210. package/skills/roles/engineer.md +9 -9
  211. package/skills/roles/engineer.platform.md +6 -9
  212. package/skills/roles/operator.docs.md +6 -9
  213. package/skills/roles/operator.md +9 -9
  214. package/skills/roles/operator.release.md +6 -9
  215. package/skills/roles/operator.sre.md +6 -9
  216. package/skills/roles/orchestrator.md +6 -9
  217. package/skills/roles/product-manager.ai-product.md +6 -9
  218. package/skills/roles/product-manager.business-strategy.md +6 -9
  219. package/skills/roles/product-manager.enterprise.md +6 -9
  220. package/skills/roles/product-manager.growth.md +7 -9
  221. package/skills/roles/product-manager.md +7 -9
  222. package/skills/roles/product-manager.platform.md +6 -9
  223. package/skills/roles/product-manager.product.md +6 -9
  224. package/skills/roles/qa.ai-eval.md +8 -9
  225. package/skills/roles/qa.api-contract.md +7 -9
  226. package/skills/roles/qa.data-pipeline.md +7 -9
  227. package/skills/roles/qa.md +7 -9
  228. package/skills/roles/qa.test-automation.md +6 -9
  229. package/skills/roles/qa.web-ui.md +7 -9
  230. package/skills/roles/researcher.explorer.md +6 -9
  231. package/skills/roles/researcher.md +8 -9
  232. package/skills/roles/researcher.ux.md +6 -9
  233. package/skills/roles/reviewer.devil-advocate.md +6 -9
  234. package/skills/roles/reviewer.evaluator.md +6 -9
  235. package/skills/roles/reviewer.md +9 -9
  236. package/skills/roles/reviewer.trace.md +6 -9
  237. package/skills/roles/security.ai.md +7 -9
  238. package/skills/roles/security.appsec.md +6 -9
  239. package/skills/roles/security.cloud.md +6 -9
  240. package/skills/roles/security.legal-compliance.md +6 -9
  241. package/skills/roles/security.md +7 -9
  242. package/skills/roles/security.privacy.md +7 -9
  243. package/skills/roles/security.supply-chain.md +7 -9
  244. package/skills/security/blue-team.md +4 -5
  245. package/skills/security/code-audit.md +4 -5
  246. package/skills/security/pentest.md +4 -5
  247. package/skills/security/red-team.md +4 -5
  248. package/skills/security/threat-intel.md +4 -5
  249. package/skills/security/vuln-research.md +4 -5
  250. package/skills/strategy/competitive-landscape.md +4 -8
  251. package/skills/strategy/market-research-methods.md +4 -8
  252. package/skills/strategy/narrative-arc.md +4 -8
  253. package/skills/strategy/pricing-positioning.md +4 -8
  254. package/skills/utility/clean-code.md +4 -5
  255. package/specialists/policy-inventory.json +14 -0
  256. package/lib/specialist-contracts-enforce.mjs +0 -172
  257. package/rules/common/agents.md +0 -28
  258. package/rules/common/development-workflow.md +0 -32
  259. package/rules/common/performance.md +0 -55
package/README.md CHANGED
@@ -85,6 +85,12 @@ Anything dropped into `.cx/inbox/` (a bug report, a customer comment, a competit
85
85
 
86
86
  Each signal gets a primary owner and a recommended handoff chain. Inspect with `construct intake list` and `construct intake show <id>`. Generate a task graph with `construct graph from-intake <id>`. The classifier runs in the daemon and is deterministic. The agent in your editor does the actual analysis. [Intake and triage](https://geraldmaron.github.io/construct/concepts/intake-and-triage).
87
87
 
88
+ ### Document ingestion fidelity
89
+
90
+ `construct ingest <file>` extracts text from PDF, DOCX, XLSX, PPTX, HTML, plain text, email, and audio/video. High-fidelity extraction is the default and routes through a [docling](https://github.com/docling-project/docling) Python sidecar (MIT, IBM, donated to LF AI & Data) provisioned via [`uv`](https://github.com/astral-sh/uv); audio and video route through [`whisper.cpp`](https://github.com/ggml-org/whisper.cpp) (Metal-accelerated on macOS).
91
+
92
+ First run downloads `uv` and creates `.cx/runtime/docling/.venv` (~1.5 GB including PyTorch). Audio requires a system `whisper-cli` binary — `brew install whisper-cpp` on macOS. Pass `--strict` to fail on any extraction info loss; pass `--legacy-extractor` to use the pre-docling regex path. Any silent drops (image-heavy PDFs, scanned pages with low OCR yield) are surfaced as `droppedInfo` in the CLI output.
93
+
88
94
  ## Hard gates
89
95
 
90
96
  Every code mutation runs through enforcement. No secrets committed, tests green, docs current, comments lint-clean, CI passes. Gates live in three places: write-time, commit-time, CI safety net. They can only be bypassed with explicit env vars so every exception leaves an audit trail. [Gates and enforcement](https://geraldmaron.github.io/construct/concepts/gates-and-enforcement).
package/bin/construct CHANGED
@@ -917,7 +917,7 @@ async function cmdDoctor() {
917
917
  }
918
918
 
919
919
  try {
920
- const { recentViolations } = await import('../lib/specialist-contracts-enforce.mjs');
920
+ const { recentViolations } = await import('../lib/contracts/violation-log.mjs');
921
921
  const violations = recentViolations({ windowMs: 24 * 60 * 60 * 1000 });
922
922
  const label = violations.length === 0
923
923
  ? 'Contract violations (none in last 24h)'
@@ -1598,12 +1598,12 @@ async function cmdHandoffs(args) {
1598
1598
  }
1599
1599
 
1600
1600
  if (sub === 'validate') {
1601
- const { parseHandoffFile, validateHandoff } = await import('../lib/handoffs/contract.mjs');
1601
+ const { parseHandoffFile, validateHandoffFile } = await import('../lib/handoffs/contract.mjs');
1602
1602
  if (summary.state === 'empty') { info('No handoffs to validate.'); return; }
1603
1603
  let hasErrors = false;
1604
1604
  for (const f of summary.files) {
1605
1605
  const parsed = parseHandoffFile(f.path);
1606
- const { valid, errors } = validateHandoff(parsed);
1606
+ const { valid, errors } = validateHandoffFile(parsed);
1607
1607
  if (valid) {
1608
1608
  println(`✓ ${f.filename}`);
1609
1609
  } else {
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/build/feature.md (Build a feature) implement it end to end, tested and ready to ship
3
-
4
- Build a feature: implement it end to end, tested and ready to ship
5
- -->
6
1
  ---
7
2
  description: "Build a feature: implement it end to end, tested and ready to ship"
8
3
  ---
9
-
10
4
  You are Construct. Build the following: $ARGUMENTS
11
5
 
12
6
  Before writing a line:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/build/fix.md (Fix something broken) reproduce, find the root cause, apply the smallest safe change
3
-
4
- Fix something broken: reproduce, find the root cause, apply the smallest safe change
5
- -->
6
1
  ---
7
2
  description: "Fix something broken: reproduce, find the root cause, apply the smallest safe change"
8
3
  ---
9
-
10
4
  You are Construct.
11
5
 
12
6
  Debugging protocol for: $ARGUMENTS
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/design/access.md (Accessibility audit) WCAG 2.1 AA, keyboard, screen readers, contrast, motion
3
-
4
- Accessibility audit: WCAG 2.1 AA, keyboard, screen readers, contrast, motion
5
- -->
6
1
  ---
7
2
  description: "Accessibility audit: WCAG 2.1 AA, keyboard, screen readers, contrast, motion"
8
3
  ---
9
-
10
4
  You are Construct. Audit: $ARGUMENTS
11
5
 
12
6
  WCAG 2.1 AA baseline:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/design/flow.md (Map the user flow) entry to success, friction points, jobs-to-be-done
3
-
4
- Map the user flow: entry to success, friction points, jobs-to-be-done
5
- -->
6
1
  ---
7
2
  description: "Map the user flow: entry to success, friction points, jobs-to-be-done"
8
3
  ---
9
-
10
4
  You are Construct. Map the user flow for: $ARGUMENTS
11
5
 
12
6
  Produce:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/design/ui.md (Design or review UI) visual hierarchy, states, interaction model, accessibility baseline
3
-
4
- Design or review UI: visual hierarchy, states, interaction model, accessibility baseline
5
- -->
6
1
  ---
7
2
  description: "Design or review UI: visual hierarchy, states, interaction model, accessibility baseline"
8
3
  ---
9
-
10
4
  You are Construct. Design or review the UI for: $ARGUMENTS
11
5
 
12
6
  Every meaningful UI surface needs:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/measure/experiment.md (Design an experiment) hypothesis, test, evidence threshold, go/no-go decision
3
-
4
- Design an experiment: hypothesis, test, evidence threshold, go/no-go decision
5
- -->
6
1
  ---
7
2
  description: "Design an experiment: hypothesis, test, evidence threshold, go/no-go decision"
8
3
  ---
9
-
10
4
  You are Construct. Design an experiment for: $ARGUMENTS
11
5
 
12
6
  Produce:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/measure/metrics.md (Define metrics) what to measure, baselines, success thresholds, instrumentation needed
3
-
4
- Define metrics: what to measure, baselines, success thresholds, instrumentation needed
5
- -->
6
1
  ---
7
2
  description: "Define metrics: what to measure, baselines, success thresholds, instrumentation needed"
8
3
  ---
9
-
10
4
  You are Construct. Define metrics for: $ARGUMENTS
11
5
 
12
6
  For each metric:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/measure/results.md (Analyze results) interpret data, separate signal from noise, produce a recommendation
3
-
4
- Analyze results: interpret data, separate signal from noise, produce a recommendation
5
- -->
6
1
  ---
7
2
  description: "Analyze results: interpret data, separate signal from noise, produce a recommendation"
8
3
  ---
9
-
10
4
  You are Construct. Analyze: $ARGUMENTS
11
5
 
12
6
  For each finding:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/plan/api.md (Design an API) contracts, endpoints, error model, data schema
3
-
4
- Design an API: contracts, endpoints, error model, data schema
5
- -->
6
1
  ---
7
2
  description: "Design an API: contracts, endpoints, error model, data schema"
8
3
  ---
9
-
10
4
  You are Construct. Design the API for: $ARGUMENTS
11
5
 
12
6
  Produce:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/plan/challenge.md (Challenge a plan) stress-test assumptions, surface failure modes and risks
3
-
4
- Challenge a plan: stress-test assumptions, surface failure modes and risks
5
- -->
6
1
  ---
7
2
  description: "Challenge a plan: stress-test assumptions, surface failure modes and risks"
8
3
  ---
9
-
10
4
  You are Construct. Challenge the following: $ARGUMENTS
11
5
 
12
6
  Challenge in severity order:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/plan/decide.md (Record a decision) context, options considered, consequences, what it locks in
3
-
4
- Record a decision: context, options considered, consequences, what it locks in
5
- -->
6
1
  ---
7
2
  description: "Record a decision: context, options considered, consequences, what it locks in"
8
3
  ---
9
-
10
4
  You are Construct. Document the decision about: $ARGUMENTS
11
5
 
12
6
  ADR format:
@@ -1,13 +1,6 @@
1
- <!--
2
- commands/plan/feature.md: Plan a feature and turn it into a tracker-linked implementation plan
3
-
4
- Produces a structured spec using the canonical Construct plan format, saves it
5
- to .cx/plans/ as a durable planning artifact linked to the active tracker slice.
6
- -->
7
1
  ---
8
2
  description: "Plan a feature: produce a structured spec and link it to the active tracker-backed plan"
9
3
  ---
10
-
11
4
  You are Construct. Plan the following: $ARGUMENTS
12
5
 
13
6
  Use the code-backed orchestration policy for routing/escalation decisions; this prompt only defines the plan artifact shape.
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/plan/requirements.md (Define requirements) what needs to be true for this to be done
3
-
4
- Define requirements: what needs to be true for this to be done
5
- -->
6
1
  ---
7
2
  description: "Define requirements: what needs to be true for this to be done"
8
3
  ---
9
-
10
4
  You are Construct. Define requirements for: $ARGUMENTS
11
5
 
12
6
  Produce:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/remember/context.md (Save project context) update .cx/context.md so the next session picks up where this one left off
3
-
4
- Save project context: update .cx/context.md so the next session picks up where this one left off
5
- -->
6
1
  ---
7
2
  description: "Save project context: update .cx/context.md so the next session picks up where this one left off"
8
3
  ---
9
-
10
4
  You are Construct. Save context for: $ARGUMENTS
11
5
 
12
6
  Update `.cx/context.json` as canonical state and refresh `.cx/context.md` as the readable mirror:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/remember/handoff.md (Write a handoff) transfer context so the next session or person can continue without loss
3
-
4
- Write a handoff: transfer context so the next session or person can continue without loss
5
- -->
6
1
  ---
7
2
  description: "Write a handoff: transfer context so the next session or person can continue without loss"
8
3
  ---
9
-
10
4
  You are Construct. Write a handoff for: $ARGUMENTS
11
5
 
12
6
  - CURRENT STATE: what is working, in progress, blocked
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/remember/runbook.md (Write a runbook) step-by-step procedure for a recurring task or incident
3
-
4
- Write a runbook: step-by-step procedure for a recurring task or incident
5
- -->
6
1
  ---
7
2
  description: "Write a runbook: step-by-step procedure for a recurring task or incident"
8
3
  ---
9
-
10
4
  You are Construct. Write a runbook for: $ARGUMENTS
11
5
 
12
6
  Structure:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/review/code.md (Code review) correctness, regressions, security, test coverage
3
-
4
- Code review: correctness, regressions, security, test coverage
5
- -->
6
1
  ---
7
2
  description: "Code review: correctness, regressions, security, test coverage"
8
3
  ---
9
-
10
4
  You are Construct. Review: $ARGUMENTS
11
5
 
12
6
  If no target specified, review all uncommitted changes (`git diff HEAD`).
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/review/quality.md (Quality audit) complexity, naming, duplication, dead code, maintainability
3
-
4
- Quality audit: complexity, naming, duplication, dead code, maintainability
5
- -->
6
1
  ---
7
2
  description: "Quality audit: complexity, naming, duplication, dead code, maintainability"
8
3
  ---
9
-
10
4
  You are Construct. Audit quality for: $ARGUMENTS
11
5
 
12
6
  Check:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/review/security.md (Security scan) secrets, auth, injection, data exposure, dependency risk
3
-
4
- Security scan: secrets, auth, injection, data exposure, dependency risk
5
- -->
6
1
  ---
7
2
  description: "Security scan: secrets, auth, injection, data exposure, dependency risk"
8
3
  ---
9
-
10
4
  You are Construct. Scan: $ARGUMENTS
11
5
 
12
6
  If no target specified, scan all uncommitted changes.
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/ship/ready.md (Pre-release check) is this ready to ship?
3
-
4
- Pre-release check: is this ready to ship?
5
- -->
6
1
  ---
7
2
  description: "Pre-release check: is this ready to ship?"
8
3
  ---
9
-
10
4
  You are Construct. Check if the following is ready: $ARGUMENTS
11
5
 
12
6
  Check:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/ship/release.md (Release) plan rollout, changelog, rollback, and post-release verification
3
-
4
- Release: plan rollout, changelog, rollback, and post-release verification
5
- -->
6
1
  ---
7
2
  description: "Release: plan rollout, changelog, rollback, and post-release verification"
8
3
  ---
9
-
10
4
  You are Construct. Release the following: $ARGUMENTS
11
5
 
12
6
  Readiness checklist:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/ship/status.md (Status) current project state, workflow, uncommitted changes, recent activity
3
-
4
- Status: current project state, workflow, uncommitted changes, recent activity
5
- -->
6
1
  ---
7
2
  description: "Status: current project state, workflow, uncommitted changes, recent activity"
8
3
  ---
9
-
10
4
  You are Construct. Report status for: $ARGUMENTS
11
5
 
12
6
  Check and report:
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/understand/docs.md (Look up documentation) current behavior from primary sources, not training memory
3
-
4
- Look up documentation: current behavior from primary sources, not training memory
5
- -->
6
1
  ---
7
2
  description: "Look up documentation: current behavior from primary sources, not training memory"
8
3
  ---
9
-
10
4
  You are Construct. Look up: $ARGUMENTS
11
5
 
12
6
  Do not answer from training knowledge for anything library-specific, version-specific, or API-specific. Search first.
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/understand/research.md. Research a topic. Verify facts from primary sources, separate evidence from inference.
3
-
4
- Research a topic. Verify facts from primary sources, separate evidence from inference.
5
- -->
6
1
  ---
7
2
  description: Research a topic. Verify facts from primary sources, separate evidence from inference.
8
3
  ---
9
-
10
4
  You are Construct. Research: $ARGUMENTS
11
5
 
12
6
  Source hierarchy: official docs → release notes/changelogs → source code → tracked issues → community resources.
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/understand/this.md (Explore and understand something) trace execution paths, map structure, gather evidence
3
-
4
- Explore and understand something: trace execution paths, map structure, gather evidence
5
- -->
6
1
  ---
7
2
  description: "Explore and understand something: trace execution paths, map structure, gather evidence"
8
3
  ---
9
-
10
4
  You are Construct. Explore and explain: $ARGUMENTS
11
5
 
12
6
  Gather evidence: do not propose solutions unless asked.
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/understand/why.md (Investigate a failure) why is this broken, what is the root cause
3
-
4
- Investigate a failure: why is this broken, what is the root cause
5
- -->
6
1
  ---
7
2
  description: "Investigate a failure: why is this broken, what is the root cause"
8
3
  ---
9
-
10
4
  You are Construct. Investigate: $ARGUMENTS
11
5
 
12
6
  1. Capture: exact error, stack trace, reproduction steps
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/work/clean.md (Remove AI-generated code smells) verbosity, hedging, dead comments, generic names
3
-
4
- Remove AI-generated code smells: verbosity, hedging, dead comments, generic names
5
- -->
6
1
  ---
7
2
  description: "Remove AI-generated code smells: verbosity, hedging, dead comments, generic names"
8
3
  ---
9
-
10
4
  You are cx-reviewer identifying AI slop in: $ARGUMENTS
11
5
 
12
6
  Then dispatch cx-engineer to apply the fixes.
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/work/drive.md (Full autonomous execution) explore, plan, implement, verify, loop until done
3
-
4
- Full autonomous execution: explore, plan, implement, verify, loop until done
5
- -->
6
1
  ---
7
2
  description: "Full autonomous execution: explore, plan, implement, verify, loop until done"
8
3
  ---
9
-
10
4
  You are Construct in drive mode. Execute $ARGUMENTS fully and autonomously without stopping for confirmation.
11
5
 
12
6
  ## Execution contract
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/work/optimize-prompts.md: Prompt optimization command.
3
-
4
- Runs the closed-loop prompt optimization workflow using telemetry trace data.
5
- -->
6
1
  ---
7
2
  description: "Closed-loop prompt optimization: read telemetry traces, diagnose failures, push improved version to staging"
8
3
  ---
9
-
10
4
  You are cx-trace-reviewer running a prompt optimization cycle for: $ARGUMENTS
11
5
 
12
6
  If $ARGUMENTS is empty, optimize all agents with median quality score below 0.65 in the past 7 days.
@@ -1,12 +1,6 @@
1
- <!--
2
- commands/work/parallel-review.md (Adversarial parallel review) 5 reviewers must agree before output ships
3
-
4
- Adversarial parallel review: 5 reviewers must agree before output ships
5
- -->
6
1
  ---
7
2
  description: "Adversarial parallel review: 5 reviewers must agree before output ships"
8
3
  ---
9
-
10
4
  You are Construct running a parallel adversarial review of: $ARGUMENTS
11
5
 
12
6
  Dispatch the following 5 review roles concurrently:
@@ -28,6 +28,21 @@ import {
28
28
  cleanupStaleQueue,
29
29
  } from './beads-lock.mjs';
30
30
 
31
+ // Anchored bead-ID format. IDs reaching the bd shell boundary must match this;
32
+ // regex-extracted IDs from PR bodies, agent transcripts, or intake packets get
33
+ // re-validated here so a malformed value cannot reach the database. spawnSync
34
+ // uses argv-array form so shell injection isn't the failure mode — log
35
+ // corruption from a bogus ID is.
36
+
37
+ const BEAD_ID_RE = /^[a-z]+-[a-z0-9]+$/;
38
+
39
+ export function assertBeadId(id) {
40
+ if (typeof id !== 'string' || !BEAD_ID_RE.test(id)) {
41
+ throw new Error(`bd: invalid bead id ${JSON.stringify(id)} — expected prefix-suffix slug`);
42
+ }
43
+ return id;
44
+ }
45
+
31
46
  import {
32
47
  concurrentRead,
33
48
  optimisticWrite,
@@ -253,7 +268,7 @@ async function runWithLegacyLock(args, opts, cwd, commandDesc) {
253
268
  if (!lock) {
254
269
  // Failed to get lock; add to queue if allowed
255
270
  const maxQueueWaitMs = opts.maxQueueWaitSeconds * 1000;
256
- if (Date.now() - startWait + maxQueueWaitMs > maxQueueWaitMs) {
271
+ if (Date.now() - startWait > maxQueueWaitMs) {
257
272
  return {
258
273
  success: false,
259
274
  error: `Timeout waiting for lock after ${opts.timeoutSeconds}s`,
@@ -365,6 +380,7 @@ export async function listIssues(options = {}) {
365
380
  * Uses concurrent read (no locking needed).
366
381
  */
367
382
  export async function showIssue(id, options = {}) {
383
+ assertBeadId(id);
368
384
  return runBdJson(['show', id], { useOptimisticLocking: true, ...options });
369
385
  }
370
386
 
@@ -373,6 +389,7 @@ export async function showIssue(id, options = {}) {
373
389
  * Uses optimistic locking for better concurrency.
374
390
  */
375
391
  export async function claimIssue(id, options = {}) {
392
+ assertBeadId(id);
376
393
  // Use the specialized optimistic claim function
377
394
  const result = await claimBeadOptimistic(id, options);
378
395
 
@@ -388,6 +405,7 @@ export async function claimIssue(id, options = {}) {
388
405
  * Close an issue.
389
406
  */
390
407
  export async function closeIssue(id, options = {}) {
408
+ assertBeadId(id);
391
409
  return runBd(['close', id], options);
392
410
  }
393
411
 
@@ -79,11 +79,15 @@ function requiresHeader(rel) {
79
79
 
80
80
  const JS_HEADER_RE = /^(?:#![^\n]*\n)?(?:\/\/[^\n]*\n)*\/\*\*[\s\S]*?\*\//;
81
81
  const MD_HEADER_RE = /^<!--[\s\S]*?-->/;
82
+ const MD_YAML_HEADER_RE = /^---\n(?:[^\n]*\n)*?description:[\s\S]*?\n---/;
82
83
  const SH_HEADER_RE = /^#!.*\n(?:#[^\n]*\n)*/;
83
84
 
84
85
  function hasHeader(content, type) {
85
86
  if (type === 'js') return JS_HEADER_RE.test(content.trimStart());
86
- if (type === 'md') return MD_HEADER_RE.test(content.trimStart());
87
+ if (type === 'md') {
88
+ const trimmed = content.trimStart();
89
+ return MD_HEADER_RE.test(trimmed) || MD_YAML_HEADER_RE.test(trimmed);
90
+ }
87
91
  return SH_HEADER_RE.test(content.trimStart());
88
92
  }
89
93
 
@@ -1,8 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * lib/context-state.mjs — compact project/session context persistence.
4
+ *
5
+ * Writes go through writeContextState, which uses write-to-tmp + atomic
6
+ * rename so concurrent writers from different hooks (pre-compact, Stop,
7
+ * context-window-recovery, tracking-surfaces) cannot leave a half-written
8
+ * JSON or markdown file behind. POSIX rename(2) is atomic for files on
9
+ * the same filesystem; the .cx directory always lives next to the target.
4
10
  */
5
- import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
11
+ import { existsSync, readFileSync, writeFileSync, renameSync, mkdirSync } from 'node:fs';
6
12
  import { join } from 'node:path';
7
13
 
8
14
  export function contextJsonPath(rootDir) {
@@ -58,6 +64,12 @@ export function inspectContextState(rootDir) {
58
64
  };
59
65
  }
60
66
 
67
+ function atomicWrite(targetPath, content) {
68
+ const tmpPath = `${targetPath}.${process.pid}.${Date.now()}.tmp`;
69
+ writeFileSync(tmpPath, content, 'utf8');
70
+ renameSync(tmpPath, targetPath);
71
+ }
72
+
61
73
  export function writeContextState(rootDir, state, { markdown = null } = {}) {
62
74
  const cxDir = join(rootDir, '.cx');
63
75
  mkdirSync(cxDir, { recursive: true });
@@ -67,10 +79,10 @@ export function writeContextState(rootDir, state, { markdown = null } = {}) {
67
79
  savedAt: new Date().toISOString(),
68
80
  ...state,
69
81
  };
70
- writeFileSync(contextJsonPath(rootDir), `${JSON.stringify(payload, null, 2)}\n`, 'utf8');
82
+ atomicWrite(contextJsonPath(rootDir), `${JSON.stringify(payload, null, 2)}\n`);
71
83
 
72
84
  if (markdown !== null) {
73
- writeFileSync(contextMarkdownPath(rootDir), markdown.endsWith('\n') ? markdown : `${markdown}\n`, 'utf8');
85
+ atomicWrite(contextMarkdownPath(rootDir), markdown.endsWith('\n') ? markdown : `${markdown}\n`);
74
86
  }
75
87
 
76
88
  return payload;