@structor-dev/cli 0.1.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 (119) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +405 -0
  3. package/bin/structor.mjs +576 -0
  4. package/docs/INIT.md +109 -0
  5. package/docs/adr/0001-default-generated-repo-name.md +9 -0
  6. package/docs/issues/0001-structor-doctor.md +39 -0
  7. package/examples/frontend-backend/harness.config.json +35 -0
  8. package/examples/openai-and-anthropic/harness.config.json +28 -0
  9. package/examples/single-repo/harness.config.json +26 -0
  10. package/harness.config.example.json +38 -0
  11. package/package.json +58 -0
  12. package/schemas/contract-manifest.schema.json +18 -0
  13. package/schemas/harness-config.schema.json +85 -0
  14. package/schemas/task-brief.schema.json +37 -0
  15. package/scripts/check-config.mjs +76 -0
  16. package/scripts/check-contract-manifests.mjs +85 -0
  17. package/scripts/check-model-overlays.mjs +30 -0
  18. package/scripts/check-placeholders.mjs +48 -0
  19. package/scripts/check-task-template.mjs +53 -0
  20. package/scripts/check-template-files.mjs +110 -0
  21. package/scripts/init-harness.mjs +270 -0
  22. package/scripts/lib.mjs +190 -0
  23. package/scripts/smoke-template.mjs +309 -0
  24. package/scripts/validate-governance.mjs +3 -0
  25. package/scripts/validate-template.mjs +16 -0
  26. package/template/.claude/CLAUDE.md.tpl +12 -0
  27. package/template/.claude/rules/harness-client-surfaces.md.tpl +20 -0
  28. package/template/.claude/settings.json.tpl +10 -0
  29. package/template/.codex/hooks.json.tpl +77 -0
  30. package/template/AGENTS.md.tpl +22 -0
  31. package/template/CLAUDE.md.tpl +16 -0
  32. package/template/README.md.tpl +109 -0
  33. package/template/ai/AGENT-GARBAGE-COLLECTION.md.tpl +18 -0
  34. package/template/ai/AGENTS.md.tpl +36 -0
  35. package/template/ai/ARCHITECTURE.md.tpl +35 -0
  36. package/template/ai/CODEX-HOOKS.md.tpl +23 -0
  37. package/template/ai/DECISIONS.md.tpl +22 -0
  38. package/template/ai/DESIGN.md.tpl +22 -0
  39. package/template/ai/HARNESS-ENGINEERING.md.tpl +107 -0
  40. package/template/ai/HARNESS.md.tpl +53 -0
  41. package/template/ai/HUB.md.tpl +53 -0
  42. package/template/ai/PRODUCT-SUMMARY.md.tpl +28 -0
  43. package/template/ai/PRODUCT.md.tpl +32 -0
  44. package/template/ai/QUALITY.md.tpl +37 -0
  45. package/template/ai/READINESS.md.tpl +39 -0
  46. package/template/ai/RUNNER-READINESS.md.tpl +14 -0
  47. package/template/ai/RUNNER-SAFETY.md.tpl +21 -0
  48. package/template/ai/VERSIONING.md.tpl +16 -0
  49. package/template/ai/WORKFLOW.md.tpl +42 -0
  50. package/template/ai/context.md.tpl +17 -0
  51. package/template/ai/contracts/README.md.tpl +23 -0
  52. package/template/ai/contracts/api-boundary.contract.json.tpl +11 -0
  53. package/template/ai/contracts/api-boundary.md.tpl +17 -0
  54. package/template/ai/contracts/app-legibility.contract.json.tpl +11 -0
  55. package/template/ai/contracts/app-legibility.md.tpl +24 -0
  56. package/template/ai/contracts/codex-hooks.contract.json.tpl +15 -0
  57. package/template/ai/contracts/codex-hooks.md.tpl +18 -0
  58. package/template/ai/contracts/github-safety.contract.json.tpl +11 -0
  59. package/template/ai/contracts/github-safety.md.tpl +15 -0
  60. package/template/ai/contracts/release-flow.contract.json.tpl +12 -0
  61. package/template/ai/contracts/release-flow.md.tpl +15 -0
  62. package/template/ai/contracts/repo-boundaries.contract.json.tpl +12 -0
  63. package/template/ai/contracts/repo-boundaries.md.tpl +18 -0
  64. package/template/ai/contracts/security-boundary.contract.json.tpl +11 -0
  65. package/template/ai/contracts/security-boundary.md.tpl +19 -0
  66. package/template/ai/knowledge-manifest.json.tpl +149 -0
  67. package/template/ai/model-overlays/anthropic/CLAUDE.md.tpl +14 -0
  68. package/template/ai/model-overlays/openai/AGENTS.md.tpl +13 -0
  69. package/template/ai/plans/README.md.tpl +10 -0
  70. package/template/ai/plans/tech-debt.md.tpl +7 -0
  71. package/template/ai/skills/README.md.tpl +15 -0
  72. package/template/ai/skills/review-architecture.md.tpl +41 -0
  73. package/template/ai/skills/review-contract-drift.md.tpl +41 -0
  74. package/template/ai/skills/review-governance-drift.md.tpl +42 -0
  75. package/template/ai/skills/review-security.md.tpl +40 -0
  76. package/template/ai/specs/README.md.tpl +14 -0
  77. package/template/ai/templates/README.md.tpl +13 -0
  78. package/template/ai/templates/fixtures/issues/invalid-placeholder.md.tpl +20 -0
  79. package/template/ai/templates/fixtures/issues/invalid-protected-surface.md.tpl +21 -0
  80. package/template/ai/templates/fixtures/issues/valid-ready.md.tpl +105 -0
  81. package/template/ai/templates/issue-template.md.tpl +107 -0
  82. package/template/ai/templates/task-brief-template.md.tpl +185 -0
  83. package/template/ai/workspace/LOCAL-STACK.md.tpl +21 -0
  84. package/template/ai/workspace/REPOS.md.tpl +19 -0
  85. package/template/ai/workspace/SESSION-BOOTSTRAP.md.tpl +27 -0
  86. package/template/ai/workspace/SYSTEM-MAP.md.tpl +19 -0
  87. package/template/ai/workspace/TEST-STRATEGY.md.tpl +22 -0
  88. package/template/consumer/.claude/CLAUDE.md.tpl +14 -0
  89. package/template/consumer/AGENTS.md.tpl +23 -0
  90. package/template/consumer/CLAUDE.md.tpl +15 -0
  91. package/template/scripts/bootstrap-codex-worktree.mjs.tpl +52 -0
  92. package/template/scripts/bootstrap-workspace.mjs.tpl +100 -0
  93. package/template/scripts/check-claude-compatibility.mjs.tpl +120 -0
  94. package/template/scripts/check-codex-hooks.mjs.tpl +190 -0
  95. package/template/scripts/check-contract-manifests.mjs.tpl +81 -0
  96. package/template/scripts/check-garbage-collection.mjs.tpl +25 -0
  97. package/template/scripts/check-html-views.mjs.tpl +60 -0
  98. package/template/scripts/check-issue-template.mjs.tpl +167 -0
  99. package/template/scripts/check-knowledge-manifest.mjs.tpl +82 -0
  100. package/template/scripts/check-overlay-drift.mjs.tpl +49 -0
  101. package/template/scripts/check-plans.mjs.tpl +70 -0
  102. package/template/scripts/check-readiness.mjs.tpl +130 -0
  103. package/template/scripts/check-review-skills.mjs.tpl +48 -0
  104. package/template/scripts/check-task-template.mjs.tpl +63 -0
  105. package/template/scripts/check-template-governance.mjs.tpl +161 -0
  106. package/template/scripts/check-workspace.mjs.tpl +212 -0
  107. package/template/scripts/check-worktree-bootstrap-fixtures.mjs.tpl +122 -0
  108. package/template/scripts/check-worktrees.mjs.tpl +69 -0
  109. package/template/scripts/fixtures/worktrees/README.md.tpl +4 -0
  110. package/template/scripts/generate-html-views.mjs.tpl +189 -0
  111. package/template/scripts/hooks/codex-hook.mjs.tpl +21 -0
  112. package/template/scripts/hooks/lib/codex-hooks-core.mjs.tpl +114 -0
  113. package/template/scripts/lib/worktree-bootstrap.mjs.tpl +388 -0
  114. package/template/scripts/validate-governance.mjs.tpl +78 -0
  115. package/template/workspace/.claude/CLAUDE.md.tpl +9 -0
  116. package/template/workspace/.claude/rules/harness-client-surfaces.md.tpl +15 -0
  117. package/template/workspace/.claude/settings.json.tpl +10 -0
  118. package/template/workspace/AGENTS.md.tpl +17 -0
  119. package/template/workspace/CLAUDE.md.tpl +18 -0
@@ -0,0 +1,105 @@
1
+ ---
2
+ id: HARNESS-FIXTURE-001
3
+ status: Ready for Agent
4
+ risk: medium
5
+ autonomy: pr_ready
6
+ model_policy: standard
7
+ repos:
8
+ - {{HARNESS_REPO_NAME}}
9
+ allowed_paths:
10
+ - ai/HARNESS.md
11
+ forbidden_paths:
12
+ - workspace/**
13
+ requires_human_approval: false
14
+ ---
15
+
16
+ # Valid Ready Fixture
17
+
18
+ ## Summary
19
+
20
+ Update harness guidance without touching protected surfaces.
21
+
22
+ ## Context
23
+
24
+ This fixture proves that a concrete issue brief can pass validation.
25
+
26
+ ## Goals
27
+
28
+ - Keep the fixture mechanically valid.
29
+
30
+ ## Non-Goals
31
+
32
+ - Do not change consumer repos.
33
+
34
+ ## Scope
35
+
36
+ ### In Scope
37
+
38
+ - `ai/HARNESS.md`
39
+
40
+ ### Out of Scope
41
+
42
+ - `workspace/**`
43
+
44
+ ## Path Contract
45
+
46
+ ### Allowed Paths
47
+
48
+ - `ai/HARNESS.md`
49
+
50
+ ### Forbidden Paths
51
+
52
+ - `workspace/**`
53
+
54
+ ## Requirements
55
+
56
+ - Preserve harness-only scope.
57
+
58
+ ## Bootstrap Requirements
59
+
60
+ - Read `ai/HUB.md`.
61
+
62
+ ## Proposed Approach
63
+
64
+ - Make a narrow documentation update.
65
+
66
+ ## Agent Execution Protocol
67
+
68
+ - Stay inside allowed paths.
69
+
70
+ ## Success Criteria
71
+
72
+ - Governance validation passes.
73
+
74
+ ## Validation
75
+
76
+ - `node scripts/validate-governance.mjs`
77
+
78
+ ## Validation Evidence Required
79
+
80
+ - Report command outcomes.
81
+
82
+ ## Risk and Autonomy
83
+
84
+ Protected surfaces require current human approval. `auto_merge` is future-facing
85
+ metadata and does not imply current execution by this repo.
86
+
87
+ ## Review Routing
88
+
89
+ - Use `ai/skills/review-governance-drift.md`.
90
+
91
+ ## Dependencies
92
+
93
+ - None.
94
+
95
+ ## Rollback / Recovery
96
+
97
+ - Revert the documentation change.
98
+
99
+ ## Open Questions
100
+
101
+ - None.
102
+
103
+ ## Notes for the Agent
104
+
105
+ No protected surface is in scope.
@@ -0,0 +1,107 @@
1
+ ---
2
+ id: <ISSUE-ID>
3
+ status: Backlog
4
+ risk: medium
5
+ autonomy: pr_ready
6
+ model_policy: standard
7
+ repos:
8
+ - {{HARNESS_REPO_NAME}}
9
+ allowed_paths:
10
+ - <path-or-glob>
11
+ forbidden_paths:
12
+ - <path-or-glob>
13
+ requires_human_approval: false
14
+ ---
15
+
16
+ # <Issue Title>
17
+
18
+ ## Summary
19
+
20
+ Describe the work in one short paragraph.
21
+
22
+ ## Context
23
+
24
+ Explain why the change is needed and what existing behavior matters.
25
+
26
+ ## Goals
27
+
28
+ - Describe the intended outcomes.
29
+
30
+ ## Non-Goals
31
+
32
+ - Describe what must remain out of scope.
33
+
34
+ ## Scope
35
+
36
+ ### In Scope
37
+
38
+ - List allowed surfaces.
39
+
40
+ ### Out of Scope
41
+
42
+ - List forbidden surfaces.
43
+
44
+ ## Path Contract
45
+
46
+ ### Allowed Paths
47
+
48
+ - `<path-or-glob>`
49
+
50
+ ### Forbidden Paths
51
+
52
+ - `<path-or-glob>`
53
+
54
+ ## Requirements
55
+
56
+ - State concrete functional and technical requirements.
57
+
58
+ ## Bootstrap Requirements
59
+
60
+ - State what the agent must read or check before editing.
61
+
62
+ ## Proposed Approach
63
+
64
+ - Describe the implementation sequence.
65
+
66
+ ## Agent Execution Protocol
67
+
68
+ - Keep changes scoped to allowed paths.
69
+ - Stop and ask before protected surfaces or remote mutations.
70
+
71
+ ## Success Criteria
72
+
73
+ - State the observable finish line.
74
+
75
+ ## Validation
76
+
77
+ - `node scripts/validate-governance.mjs`
78
+
79
+ ## Validation Evidence Required
80
+
81
+ - List commands and outcomes in the final report.
82
+
83
+ ## Risk and Autonomy
84
+
85
+ Protected surfaces require current human approval. `auto_merge` is future-facing
86
+ metadata and does not imply current execution by this repo.
87
+
88
+ ## Review Routing
89
+
90
+ - Route review to the relevant harness docs and skills.
91
+
92
+ ## Dependencies
93
+
94
+ - List dependencies or say none.
95
+
96
+ ## Rollback / Recovery
97
+
98
+ - Describe how to revert the change safely.
99
+
100
+ ## Open Questions
101
+
102
+ - List unresolved questions or say none.
103
+
104
+ ## Notes for the Agent
105
+
106
+ Keep Markdown, JSON, and YAML sources canonical. Generated views are review
107
+ artifacts.
@@ -0,0 +1,185 @@
1
+ ---
2
+ id: TASK-ID
3
+ status: backlog
4
+ risk: medium
5
+ autonomy: pr_ready
6
+ model_policy: standard
7
+ model: runtime-selected
8
+ repos: []
9
+ allowed_paths: []
10
+ forbidden_paths: []
11
+ requires_human_approval: false
12
+ ---
13
+
14
+ # Title
15
+
16
+ ## Summary
17
+
18
+ What needs to change and why.
19
+
20
+ ## Context
21
+
22
+ Relevant harness docs, contracts, and repo state.
23
+
24
+ ## Goals
25
+
26
+ - Goal 1
27
+
28
+ ## Non-Goals
29
+
30
+ - Non-goal 1
31
+
32
+ ## Scope
33
+
34
+ ### In Scope
35
+
36
+ - In scope item
37
+
38
+ ### Out of Scope
39
+
40
+ - Out of scope item
41
+
42
+ ### Repos Affected
43
+
44
+ - Repo name
45
+
46
+ ## Path Contract
47
+
48
+ ### Allowed Paths
49
+
50
+ - Path the agent may edit
51
+
52
+ ### Forbidden Paths
53
+
54
+ - Path the agent must not touch
55
+
56
+ ### Protected Contracts
57
+
58
+ - Existing public APIs, CLI commands, validation commands, and generated
59
+ artifact shapes must remain backward compatible unless explicitly stated.
60
+
61
+ ## Requirements
62
+
63
+ ### Functional Requirements
64
+
65
+ - Functional requirement
66
+
67
+ ### Technical Requirements
68
+
69
+ - Technical requirement
70
+
71
+ ### UX / Content Requirements
72
+
73
+ - UX or content requirement, if applicable
74
+
75
+ ### Data / API Requirements
76
+
77
+ - Data or API requirement, if applicable
78
+
79
+ ## Bootstrap Requirements
80
+
81
+ Before implementation, the agent must:
82
+
83
+ - Read the relevant repo entrypoint and routed harness docs.
84
+ - Identify canonical repo names and ownership boundaries.
85
+ - Identify validation commands and safe dry-run checks.
86
+ - Report missing, stale, or contradictory harness files before editing.
87
+
88
+ Expected evidence:
89
+
90
+ - Context files read.
91
+ - Bootstrap or path-contract check output, if available.
92
+ - Any mismatch or ambiguity found.
93
+
94
+ ## Proposed Approach
95
+
96
+ - Preferred solution
97
+ - Alternatives considered
98
+ - Key trade-offs
99
+
100
+ ## Agent Execution Protocol
101
+
102
+ Before changing files, the agent must state:
103
+
104
+ - Files expected to change.
105
+ - Contracts expected to remain unchanged.
106
+ - Validation commands it will run.
107
+ - Risks or ambiguities found.
108
+
109
+ The agent must not proceed if the plan conflicts with the Path Contract, risk
110
+ and autonomy, or Open Questions sections.
111
+
112
+ ## Success Criteria
113
+
114
+ - Observable end state
115
+ - Acceptance criteria
116
+ - Definition of done
117
+
118
+ ## Validation
119
+
120
+ - Command or check 1
121
+
122
+ ## Validation Evidence Required
123
+
124
+ - Commands run
125
+ - Exit codes
126
+ - Relevant output excerpts
127
+ - Failures or skipped checks with reasons
128
+ - Files changed
129
+ - Manual checks performed
130
+ - Known residual risks
131
+
132
+ ## Risk and Autonomy
133
+
134
+ - Risk: `low` / `medium` / `high`
135
+ - Autonomy: `report_only` / `pr_ready` / `auto_merge`
136
+ - Model policy: `cheap` / `standard` / `reasoning` / `frontier` /
137
+ `review_only`
138
+ - Model: keep `runtime-selected` unless the task owner explicitly requires a
139
+ provider-specific model. Choose the active runtime's current appropriate
140
+ model: cheaper models for low-risk mechanical work, stronger reasoning
141
+ models for cross-file implementation, and frontier models for high-risk,
142
+ architecturally heavy, or cross-repo work.
143
+ - Human approvals required
144
+ - Protected surfaces touched, if any
145
+ - Rollout or rollback notes
146
+ - `auto_merge` is future-facing metadata only unless a separate runner is
147
+ explicitly authorized.
148
+
149
+ ## Review Routing
150
+
151
+ Required reviewers:
152
+
153
+ - Architecture reviewer: yes/no
154
+ - Security reviewer: yes/no
155
+ - UX/content reviewer: yes/no
156
+ - Cross-repo consistency reviewer: yes/no
157
+
158
+ Reviewer focus:
159
+
160
+ - What reviewers should inspect.
161
+ - What reviewers can ignore.
162
+
163
+ ## Dependencies
164
+
165
+ - Upstream dependencies
166
+ - Downstream dependencies
167
+ - External blockers
168
+
169
+ ## Rollback / Recovery
170
+
171
+ How to recover if validation fails.
172
+
173
+ ## Open Questions
174
+
175
+ - None yet.
176
+
177
+ ## Notes for the Agent
178
+
179
+ - Ask for clarification before changing files if anything is ambiguous and the
180
+ brief does not authorize a safe default.
181
+ - Keep the change as small as possible.
182
+ - Prefer existing patterns, contracts, commands, and repo conventions.
183
+ - Do not widen scope to nearby cleanup.
184
+ - Do not make speculative architecture changes.
185
+ - Do not silently skip validation.
@@ -0,0 +1,21 @@
1
+ # Local Stack
2
+
3
+ This document records stable local assumptions for `{{PROJECT_NAME}}`.
4
+
5
+ ## Harness
6
+
7
+ - Primary validation: `node scripts/validate-governance.mjs`
8
+ - Workspace layout check: `node scripts/check-workspace.mjs`
9
+ - Workspace bootstrap: `node scripts/bootstrap-workspace.mjs`
10
+
11
+ ## Consumers
12
+
13
+ Consumer validation commands are configured in `harness.config.json` and owned
14
+ by the consumer repos.
15
+
16
+ {{CONSUMER_REPOS_LIST}}
17
+
18
+ ## Rule
19
+
20
+ Do not require external services, production data, or remote mutations for
21
+ harness validation.
@@ -0,0 +1,19 @@
1
+ # Workspace Repos
2
+
3
+ This workspace uses `{{HARNESS_REPO_NAME}}` as the harness repo.
4
+
5
+ ## Harness
6
+
7
+ - `{{HARNESS_REPO_NAME}}`: policy, routing, contracts, review templates, generated views, and validation scripts.
8
+
9
+ ## Consumers
10
+
11
+ {{CONSUMER_REPOS_LIST}}
12
+
13
+ Consumer repos own product implementation, runtime behavior, app dependencies,
14
+ and product-specific validation.
15
+
16
+ ## Boundary
17
+
18
+ The harness may describe repo ownership and expected checks. It must not become
19
+ the implementation source of truth for consumer applications.
@@ -0,0 +1,27 @@
1
+ # Session Bootstrap
2
+
3
+ Before editing, confirm the current checkout and task boundary.
4
+
5
+ Use `ai/workspace/REPOS.md` when the repo owner or workspace role is unclear.
6
+
7
+ ## Checks
8
+
9
+ 1. Run `git status --short --branch`.
10
+ 2. Confirm the target repo owns the files being edited.
11
+ 3. Read `ai/context.md` and route through `ai/HUB.md`.
12
+ 4. Check whether the task touches protected surfaces.
13
+ 5. Choose validation from `ai/workspace/TEST-STRATEGY.md`.
14
+
15
+ ## Worktrees
16
+
17
+ For Codex worktrees or copied consumer checkouts, run:
18
+
19
+ ```bash
20
+ node scripts/check-worktrees.mjs --include-canonical
21
+ ```
22
+
23
+ If a consumer checkout has stale harness pointers, repair it with:
24
+
25
+ ```bash
26
+ node scripts/bootstrap-codex-worktree.mjs <checkout-path>
27
+ ```
@@ -0,0 +1,19 @@
1
+ # System Map
2
+
3
+ `{{PROJECT_NAME}}` is organized around a separate harness repo and one or more
4
+ consumer repos.
5
+
6
+ ## Relationship
7
+
8
+ - Harness repo: `{{HARNESS_REPO_NAME}}`
9
+ - Consumer repos: {{CONSUMER_REPO_NAMES_JSON}}
10
+
11
+ The harness defines shared engineering policy and review expectations. Consumer
12
+ repos define application architecture, runtime commands, data models, and
13
+ deployment behavior.
14
+
15
+ ## Routing
16
+
17
+ Start from `ai/HUB.md`, then load only the docs that match the task. Use
18
+ `ai/workspace/REPOS.md` for repo ownership and `ai/workspace/TEST-STRATEGY.md`
19
+ for validation ownership.
@@ -0,0 +1,22 @@
1
+ # Test Strategy
2
+
3
+ ## Harness-Owned Checks
4
+
5
+ - `node scripts/check-template-governance.mjs`
6
+ - `node scripts/check-task-template.mjs`
7
+ - `node scripts/check-knowledge-manifest.mjs`
8
+ - `node scripts/check-plans.mjs`
9
+ - `node scripts/check-review-skills.mjs`
10
+ - `node scripts/check-contract-manifests.mjs`
11
+ - `node scripts/check-html-views.mjs`
12
+ - `node scripts/validate-governance.mjs`
13
+
14
+ ## Consumer-Owned Checks
15
+
16
+ Consumer repos own app-specific install, lint, test, build, browser, database,
17
+ and service checks.
18
+
19
+ ## Evidence
20
+
21
+ Report exactly which commands ran, from which repo, and whether each passed,
22
+ failed, or was skipped with a reason.
@@ -0,0 +1,14 @@
1
+ # {{CONSUMER_NAME}} Claude Project Memory
2
+
3
+ Use this file with the root `../CLAUDE.md` entrypoint when Claude Code starts
4
+ inside this repository or a worktree.
5
+
6
+ @../CLAUDE.md
7
+
8
+ Read the harness first through the root Claude guide.
9
+
10
+ The {{PROJECT_NAME}} engineering harness is the policy source of truth. If this
11
+ repo is checked out as a worktree, also look for workspace-level guidance in
12
+ the parent folders before relying only on local files.
13
+
14
+ Keep this pointer short.
@@ -0,0 +1,23 @@
1
+ # {{CONSUMER_NAME}} Agent Guide
2
+
3
+ This consumer repository is governed by the {{PROJECT_NAME}} engineering
4
+ harness.
5
+
6
+ ## Harness
7
+
8
+ Read the harness first:
9
+
10
+ 1. `{{HARNESS_RELATIVE_PATH}}/AGENTS.md`
11
+ 2. `{{HARNESS_RELATIVE_PATH}}/ai/AGENTS.md`
12
+ 3. `{{HARNESS_RELATIVE_PATH}}/ai/HUB.md`
13
+ 4. `{{HARNESS_RELATIVE_PATH}}/ai/context.md`
14
+
15
+ ## Local Purpose
16
+
17
+ {{CONSUMER_PURPOSE}}
18
+
19
+ ## Local Validation
20
+
21
+ {{CONSUMER_VALIDATION_LIST}}
22
+
23
+ Keep this file short. Canonical policy belongs in the harness.
@@ -0,0 +1,15 @@
1
+ # {{CONSUMER_NAME}} Claude Guide
2
+
3
+ This consumer repository is governed by the {{PROJECT_NAME}} engineering
4
+ harness.
5
+
6
+ Read:
7
+
8
+ 1. `{{HARNESS_RELATIVE_PATH}}/CLAUDE.md`
9
+ 2. `{{HARNESS_RELATIVE_PATH}}/ai/AGENTS.md`
10
+ 3. `{{HARNESS_RELATIVE_PATH}}/ai/HUB.md`
11
+ 4. `{{HARNESS_RELATIVE_PATH}}/ai/context.md`
12
+
13
+ Local purpose: {{CONSUMER_PURPOSE}}
14
+
15
+ Keep this file short. Canonical policy belongs in the harness.
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import {
6
+ buildRepairPlan,
7
+ formatInspection,
8
+ gitMetadataForPath,
9
+ inspectCheckout,
10
+ writeRepairPlan,
11
+ } from "./lib/worktree-bootstrap.mjs";
12
+
13
+ const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
14
+ const args = process.argv.slice(2);
15
+ const dryRun = args.includes("--dry-run");
16
+ const targetArg = args.find((arg) => !arg.startsWith("--"));
17
+
18
+ if (!targetArg) {
19
+ console.error("Usage: node scripts/bootstrap-codex-worktree.mjs <worktree-path> [--dry-run]");
20
+ process.exit(1);
21
+ }
22
+
23
+ const targetPath = path.resolve(targetArg);
24
+ const metadata = await gitMetadataForPath(targetPath);
25
+ if (!metadata.gitRoot) {
26
+ console.error(`Refusing to repair ${targetPath}: target is not inside a git checkout.`);
27
+ process.exit(1);
28
+ }
29
+
30
+ const inspection = await inspectCheckout({ targetPath: metadata.gitRoot, harnessRoot: repoRoot });
31
+ console.log(formatInspection(inspection, { harnessRoot: repoRoot }));
32
+
33
+ if (inspection.valid) {
34
+ console.log("Worktree bootstrap is already valid.");
35
+ process.exit(0);
36
+ }
37
+
38
+ const repairPlan = buildRepairPlan({ inspection, harnessRoot: repoRoot });
39
+ if (!repairPlan.repairable) {
40
+ console.error(`Refusing to repair ${inspection.targetPath}: ${repairPlan.reason}`);
41
+ process.exit(1);
42
+ }
43
+
44
+ console.log("Files to write:");
45
+ for (const write of repairPlan.writes) console.log(`- ${write.targetPath}`);
46
+
47
+ if (dryRun) {
48
+ console.log("Dry run complete. No files were written.");
49
+ } else {
50
+ await writeRepairPlan(repairPlan);
51
+ console.log("Worktree bootstrap repair complete.");
52
+ }