@structor-dev/cli 0.1.0 → 0.2.1

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 (65) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +131 -21
  3. package/ROADMAP.md +38 -0
  4. package/SECURITY.md +33 -0
  5. package/bin/structor.mjs +561 -29
  6. package/contrib/self-harness/files/README.md +32 -0
  7. package/contrib/self-harness/files/ai/AGENTS.md +35 -0
  8. package/contrib/self-harness/files/ai/ARCHITECTURE.md +38 -0
  9. package/contrib/self-harness/files/ai/HUB.md +59 -0
  10. package/contrib/self-harness/files/ai/PRODUCT.md +36 -0
  11. package/contrib/self-harness/files/ai/QUALITY.md +31 -0
  12. package/contrib/self-harness/files/ai/context.md +38 -0
  13. package/contrib/self-harness/files/scripts/check-workspace.mjs +72 -0
  14. package/contrib/self-harness/harness.config.json +37 -0
  15. package/docs/CONTRIBUTOR-SETUP.md +45 -0
  16. package/docs/INIT.md +55 -2
  17. package/docs/public-launch.md +150 -0
  18. package/examples/anthropic-only/harness.config.json +26 -0
  19. package/examples/frontend-backend/harness.config.json +8 -8
  20. package/examples/generated-harness-tree.md +432 -0
  21. package/examples/openai-and-anthropic/harness.config.json +7 -7
  22. package/examples/single-repo/harness.config.json +7 -7
  23. package/harness.config.example.json +1 -1
  24. package/package.json +12 -4
  25. package/schemas/contract-manifest.schema.json +0 -1
  26. package/schemas/harness-config.schema.json +5 -2
  27. package/scripts/check-config.mjs +20 -31
  28. package/scripts/check-examples.mjs +146 -0
  29. package/scripts/check-placeholders.mjs +2 -0
  30. package/scripts/check-public-hygiene.mjs +249 -0
  31. package/scripts/check-schemas.mjs +42 -0
  32. package/scripts/check-template-files.mjs +15 -98
  33. package/scripts/generated-harness-contract.mjs +416 -0
  34. package/scripts/init-harness.mjs +227 -139
  35. package/scripts/lib.mjs +462 -12
  36. package/scripts/rendered-config.mjs +109 -0
  37. package/scripts/setup-contributor.mjs +125 -0
  38. package/scripts/smoke-template.mjs +260 -73
  39. package/template/AGENTS.md.tpl +4 -2
  40. package/template/README.md.tpl +5 -0
  41. package/template/ai/CODEX-HOOKS.md.tpl +1 -1
  42. package/template/ai/HARNESS-ENGINEERING.md.tpl +5 -2
  43. package/template/ai/HARNESS.md.tpl +4 -1
  44. package/template/ai/contracts/codex-hooks.contract.json.tpl +58 -1
  45. package/template/ai/contracts/codex-hooks.md.tpl +6 -0
  46. package/template/ai/contracts/release-flow.md.tpl +1 -1
  47. package/template/ai/templates/fixtures/issues/valid-ready.md.tpl +3 -1
  48. package/template/ai/templates/issue-template.md.tpl +3 -1
  49. package/template/ai/workspace/LOCAL-STACK.md.tpl +1 -1
  50. package/template/ai/workspace/SYSTEM-MAP.md.tpl +2 -2
  51. package/template/consumer/AGENTS.md.tpl +4 -4
  52. package/template/consumer/CLAUDE.md.tpl +4 -4
  53. package/template/scripts/bootstrap-workspace.mjs.tpl +11 -25
  54. package/template/scripts/check-claude-compatibility.mjs.tpl +62 -9
  55. package/template/scripts/check-codex-hooks.mjs.tpl +262 -20
  56. package/template/scripts/check-template-governance.mjs.tpl +2 -114
  57. package/template/scripts/check-workspace.mjs.tpl +27 -103
  58. package/template/scripts/check-worktree-bootstrap-fixtures.mjs.tpl +12 -0
  59. package/template/scripts/generate-html-views.mjs.tpl +357 -56
  60. package/template/scripts/generated-harness-contract.mjs.tpl +1 -0
  61. package/template/scripts/hooks/lib/codex-hooks-core.mjs.tpl +14 -3
  62. package/template/scripts/lib/path-safety.mjs.tpl +87 -0
  63. package/template/scripts/lib/worktree-bootstrap.mjs.tpl +16 -13
  64. package/template/scripts/validate-governance.mjs.tpl +52 -36
  65. package/schemas/task-brief.schema.json +0 -37
package/CHANGELOG.md ADDED
@@ -0,0 +1,56 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.2.0] - 2026-06-03
9
+
10
+ ### Added
11
+
12
+ - `structor doctor` diagnostics for generated workspaces and consumer pointers.
13
+ - Structor contributor bootstrap support, including the self-harness preset,
14
+ setup command, and contributor smoke checks.
15
+ - Passive generation manifests for generated harnesses.
16
+ - Public onboarding, contributor setup, example, and launch-positioning docs.
17
+
18
+ ### Changed
19
+
20
+ - `structor init` now defaults the generate-harness confirmation to yes after
21
+ previewing the planned writes.
22
+ - Generated harness templates now include stronger governance, workspace,
23
+ validation, and cockpit surfaces.
24
+
25
+ ### Fixed
26
+
27
+ - Hardened generated writes, consumer entrypoints, symlink handling, generated
28
+ JavaScript/Markdown escaping, shell-quoted worktree repair commands, and
29
+ validator provenance checks.
30
+ - Centralized config resolution, rendered template values, generated harness
31
+ contracts, and generated-path safety checks.
32
+
33
+ ## [0.1.0] - 2026-05-29
34
+
35
+ Initial experimental release of the `@structor-dev/cli` harness generator.
36
+
37
+ ### Added
38
+
39
+ - `structor init` guided, local-only, deterministic workspace setup with sibling
40
+ consumer-repo detection, config preview, and dry-run before any writes.
41
+ - `structor generate` to render a harness from an existing `harness.config.json`,
42
+ with `--dry-run`, `--force`, `--install-consumer-entrypoints`, and safe
43
+ output-path enforcement.
44
+ - Versioned harness template covering context routing (`ai/HUB.md`), contracts,
45
+ task templates, review skills, quality tracking, and decisions.
46
+ - Codex and Claude Code client surfaces gated by `models` and `clientSupport`
47
+ config, including Codex hook scaffolding and Claude project rules.
48
+ - Mechanical validators: config-shape, template-file, task-template,
49
+ contract-manifest, model-overlay, and placeholder-leak checks, plus a smoke
50
+ test that generates and bootstraps disposable workspaces.
51
+
52
+ ### Notes
53
+
54
+ - `structor doctor` is planned but not yet implemented.
55
+ - Claude hooks and Claude skills are deferred; keep those flags off until
56
+ fixture-backed validators exist.
package/README.md CHANGED
@@ -3,13 +3,45 @@
3
3
  > Experimental. Early infrastructure for harness engineering. The API,
4
4
  > generated layout, and config shape may change.
5
5
 
6
- Structor generates a repository-local AI engineering harness for your project:
7
- a versioned policy layer that gives Codex, Claude Code, and similar agents a
8
- shared, enforceable set of rules for context routing, contracts, task shape,
9
- review, and validation.
6
+ Structor is a local harness-engineering toolkit. It generates a
7
+ repository-local AI engineering harness for your project: a versioned policy
8
+ layer that gives Codex, Claude Code, and similar agents a shared, enforceable
9
+ set of rules for context routing, contracts, task shape, review, and
10
+ validation.
10
11
 
11
12
  It is a generator, not a runtime. Structor scaffolds the harness; it never runs
12
13
  agents, polls sessions, automates pull requests, or touches external services.
14
+ The open-source generator is local-only: no telemetry, no LLM calls, and no
15
+ network calls during `init` or `generate`.
16
+
17
+ Structor is for teams that want agent guidance to live next to their code,
18
+ review history, and validation commands instead of in scattered chat prompts.
19
+ It is useful when a project has multiple repos, multiple agent clients, or
20
+ repeatable review and validation expectations that should be checked
21
+ mechanically.
22
+
23
+ Structor is MIT-licensed so teams can generate, modify, and use harness
24
+ artifacts inside private or commercial repositories. Commercial policy packs,
25
+ private templates, tailored rollout support, or hosted services may be licensed
26
+ separately.
27
+
28
+ ## First Minute
29
+
30
+ - **What it is:** a local generator for repository-local AI engineering
31
+ harnesses.
32
+ - **Who it is for:** teams that want Codex, Claude Code, and similar agents to
33
+ share reviewed project policy, task shape, and validation expectations.
34
+ - **Why not just a rules file:** Structor gives the rules a repeatable
35
+ generated structure, thin client entrypoints, and validators that catch drift.
36
+ - **What it creates:** a sibling harness repo with canonical `ai/*` policy,
37
+ Codex and Claude entrypoints, contracts, task templates, review guidance, and
38
+ local validation scripts.
39
+ - **What it does not do:** run agents, coordinate sessions, open pull requests,
40
+ host services, call LLM APIs, install packages, or mutate external systems.
41
+ - **How to try it:** run `npx @structor-dev/cli init` from the workspace folder
42
+ that contains your consumer repos.
43
+ - **How validation is split:** `npm run check:ci` is the fast structural path;
44
+ `npm run validate` adds tests and smoke-tested generated-harness flows.
13
45
 
14
46
  ## Quick Start
15
47
 
@@ -23,8 +55,14 @@ During local development from a clone of this repo, use
23
55
  `node ./structor/bin/structor.mjs init` from the parent workspace instead.
24
56
 
25
57
  `init` is local-only and deterministic. It detects sibling repos, asks a few
26
- questions, previews every file it would write, and generates nothing until you
27
- confirm. No network calls, no LLM calls, no installs.
58
+ questions, writes `harness.config.json` only after confirmation, previews every
59
+ generated file with a dry run, and generates nothing until you confirm. No
60
+ network calls, no LLM calls, no telemetry, no package installs, and no remote
61
+ service mutation.
62
+
63
+ `structor init` remains the normal setup flow for users creating generated
64
+ harnesses for their own target repositories. Contributing to Structor itself is
65
+ a separate workflow.
28
66
 
29
67
  ## What You Get
30
68
 
@@ -50,6 +88,18 @@ scripts/ validation that mechanically enforces the rules above
50
88
  Optional consumer repo pointer files can route agents back to the generated
51
89
  harness from each code repo.
52
90
 
91
+ ## Why Not Just Use A Rules File?
92
+
93
+ A single `AGENTS.md`, `CLAUDE.md`, or prompt file can tell an agent what to do,
94
+ but it cannot easily keep project facts, model-specific overlays, contracts,
95
+ task templates, review guidance, and validation policy synchronized across a
96
+ workspace.
97
+
98
+ Structor keeps canonical policy in the generated harness, keeps consumer
99
+ entrypoints thin, and ships validators that check the structure. The result is
100
+ still plain files in your repository; Structor just gives those files a stable
101
+ shape and a way to detect drift.
102
+
53
103
  ## Why It Exists
54
104
 
55
105
  Most AI coding workflow tooling is a pile of prompts and rules with nothing
@@ -58,7 +108,7 @@ context architecture plus mechanical enforcement. The generated harness ships
58
108
  with validators that fail when policy drifts: overlay drift checks, contract
59
109
  manifest checks, task-shape checks, and hook guardrails.
60
110
 
61
- ## Manual Setup
111
+ ## Conservative Manual Path
62
112
 
63
113
  If you prefer the conservative manual path, create `harness.config.json` and
64
114
  run:
@@ -71,6 +121,17 @@ npx @structor-dev/cli generate --config harness.config.json --install-consumer-e
71
121
  See `docs/INIT.md` for the exact safety model, read/write behavior, and
72
122
  recovery expectations.
73
123
 
124
+ ## How Structor Differs From A Runner
125
+
126
+ Structor creates files and validation scripts. A runner executes or coordinates
127
+ agent work over time.
128
+
129
+ Structor does not start agent sessions, poll threads, assign tasks, open pull
130
+ requests, shepherd CI, auto-repair code, merge branches, or host dashboards.
131
+ Those behaviors belong in a separate runner or orchestration layer. Generated
132
+ Codex hooks are local policy guardrails only; they are not a general execution
133
+ runtime or a complete security boundary.
134
+
74
135
  ## Codex And Claude Support
75
136
 
76
137
  Structor uses a hybrid model for client support:
@@ -142,6 +203,8 @@ These boundaries are intentional in the current template:
142
203
  - Claude skills are deferred. Keep `clientSupport.claude.skills` false or omit
143
204
  it until committed `.claude/skills/*/SKILL.md` templates and validation are
144
205
  added.
206
+ - Read-only generated Harness Cockpit views under `ai/views/*` are allowed
207
+ when they are derived from canonical local files and do not execute workflows.
145
208
  - The initializer creates a repo-shaped harness folder, but it does not run
146
209
  `git init`, create remotes, install dependencies, publish branches, or modify
147
210
  external services.
@@ -150,9 +213,9 @@ These boundaries are intentional in the current template:
150
213
  The generated workspace
151
214
  bootstrap script installs workspace-level pointers and verifies consumer
152
215
  routing; it does not repair missing consumer pointers after initialization.
153
- - Runner behavior remains out of scope. Polling, PR automation, dashboards,
154
- auto-merge, repair loops, and CI shepherding belong in a separate runner or
155
- orchestration layer.
216
+ - Runner behavior remains out of scope. Polling, PR automation, live
217
+ dashboards, auto-merge, repair loops, and CI shepherding belong in a separate
218
+ runner or orchestration layer.
156
219
 
157
220
  ## Out-of-the-Box Flow
158
221
 
@@ -225,6 +288,8 @@ Rules:
225
288
  templates.
226
289
  - Create or update harness.config.json for this workspace.
227
290
  - Set output.path so the generated harness repo is a sibling of the consumer repos.
291
+ - Set consumer paths as workspace-relative sibling paths such as `./project-app`;
292
+ do not use absolute paths or `..` traversal.
228
293
  - Use concrete template-provided client-support files. Do not invent Codex or
229
294
  Claude Code surfaces from scratch.
230
295
  - If customizing Codex hook rules, keep them deterministic, local, read-only,
@@ -259,8 +324,8 @@ require human input.
259
324
 
260
325
  ## Manual Setup
261
326
 
262
- Use these commands when you want to operate the template without an
263
- agent-assisted prompt.
327
+ Use these commands from this template repo when you want to operate the
328
+ template without an agent-assisted prompt.
264
329
 
265
330
  Copy and edit the example config:
266
331
 
@@ -277,7 +342,10 @@ Set:
277
342
  - optional `clientSupport.codex.hooks`
278
343
  - optional `clientSupport.claude.rules`; keep `clientSupport.claude.hooks` and
279
344
  `clientSupport.claude.skills` false or omitted until those surfaces are added
280
- - each consumer `name`, sibling `path`, `purpose`, and validation commands
345
+ - each consumer `name`, workspace-relative sibling `path`, `purpose`, and
346
+ validation commands. Consumer paths must stay inside the workspace and cannot
347
+ use absolute paths or `..` traversal. From a template clone at
348
+ `workspace/structor`, use paths like `./project-app`, not `../project-app`.
281
349
 
282
350
  Validate the template and config shape:
283
351
 
@@ -362,14 +430,26 @@ npm run check:ci
362
430
  npm run validate
363
431
  ```
364
432
 
365
- `npm run check:ci` covers the cheap structural checks that feed both local
366
- development and CI: config examples, required template files, task template
367
- structure, contract manifest schema, placeholder hygiene, and model overlay
368
- thinness.
433
+ Validation is split into fast structural checks and the full local smoke suite.
434
+
435
+ `npm run check:ci` covers the cheap checks that feed both local development and
436
+ CI: config examples, active shipped schemas, required template files, task
437
+ template structure, contract manifest schema, placeholder hygiene,
438
+ public-release hygiene, and model overlay thinness.
439
+
440
+ The active shipped schemas are `schemas/harness-config.schema.json` and
441
+ `schemas/contract-manifest.schema.json`. Task brief validation is intentionally
442
+ Markdown/template based through `scripts/check-task-template.mjs`, not a shipped
443
+ JSON Schema contract.
444
+
445
+ Generated harness files are declared in `scripts/generated-harness-contract.mjs`.
446
+ That contract is the source of truth for render gates, trusted generated
447
+ scripts, validation check dependencies, workspace-required files, and
448
+ consumer/workspace entrypoint participation.
369
449
 
370
- The placeholder check has no hardcoded private project names. If you are
371
- extracting a harness from a private codebase, opt into leak detection with a
372
- comma-separated list:
450
+ The placeholder and public hygiene checks have no hardcoded private project
451
+ names. If you are extracting a harness from a private codebase, opt into leak
452
+ detection with a comma-separated list:
373
453
 
374
454
  ```sh
375
455
  HARNESS_FORBIDDEN_PROJECT_TERMS="Internal Product,private-api" npm run check:placeholders
@@ -395,11 +475,41 @@ For a real project config, require configured consumer repo paths to exist:
395
475
  node scripts/check-config.mjs --config harness.config.json --require-existing-consumers
396
476
  ```
397
477
 
478
+ ## Structor Contributor Model
479
+
480
+ The recommended Structor contributor path should become:
481
+
482
+ ```sh
483
+ npx @structor-dev/cli contribute structor
484
+ ```
485
+
486
+ That future contributor bootstrap creates or refreshes a contributor workspace:
487
+ a local Structor source checkout plus a sibling Structor self-harness whose
488
+ consumer repository is Structor itself. The self-harness is repo-local guidance
489
+ for working on Structor; it does not change the generic generated harness model
490
+ for other projects.
491
+
492
+ The contributor bootstrap may clone local repositories when preparing that
493
+ workspace, but v1 must not fork repositories, push branches, open pull requests,
494
+ mutate GitHub or other external services, run agents, or become a runner.
495
+
496
+ The manual contributor setup path remains the clone-first fallback:
497
+
498
+ ```sh
499
+ git clone https://github.com/nicolaycamacho/structor.git
500
+ cd structor
501
+ npm run setup:contributor
502
+ ```
503
+
398
504
  ## Non-Goals
399
505
 
400
506
  - No runner or orchestration runtime.
401
507
  - No Linear, GitHub, Claude hook, or CI automation.
402
508
  - No Codex runner automation beyond local harness hook guardrails.
403
- - No dashboards, polling loops, session control, auto-merge, or repair daemons.
509
+ - No live dashboards, polling loops, session control, auto-merge, repair
510
+ daemons, or orchestration UI.
511
+ - Read-only generated Harness Cockpit views are allowed when they summarize
512
+ canonical local files and do not execute validation, mutate state, or control
513
+ workflows.
404
514
  - No consumer implementation logic.
405
515
  - No source-project or other project-specific content in active templates.
package/ROADMAP.md ADDED
@@ -0,0 +1,38 @@
1
+ # Roadmap
2
+
3
+ Structor is a harness-engineering toolkit for generating repository-local AI
4
+ engineering harnesses. It is a local generator, not a runner or hosted product.
5
+
6
+ ## Current Open-Source Core
7
+
8
+ - Local `init` and `generate` flows for repository-local harnesses.
9
+ - Deterministic templates for Codex and Claude Code guidance.
10
+ - Conservative path, template, schema, and governance validation.
11
+ - Optional local consumer entrypoint installation.
12
+ - MIT licensing so teams can generate, modify, and use harness artifacts inside
13
+ private or commercial repositories.
14
+
15
+ ## Near-Term Launch Readiness
16
+
17
+ - Keep public documentation clear about local-only behavior and non-goals.
18
+ - Add small, deterministic public-release hygiene checks.
19
+ - Improve contributor setup for Structor itself without turning it into a
20
+ runner or workflow orchestrator.
21
+ - Keep examples and documentation focused on harness generation and validation.
22
+
23
+ ## Future Possibilities
24
+
25
+ - Commercial policy packs, private templates, tailored rollout support, or
26
+ hosted services may be licensed separately.
27
+ - Deeper consumer-repo scan and review flows may help teams draft
28
+ project-specific harness content from local evidence.
29
+ - Diagnostic tooling may help users inspect existing harness workspaces for
30
+ drift, stale pointers, and validation gaps.
31
+
32
+ ## Non-Goals
33
+
34
+ - No agent runner, polling loop, dashboard, auto-merge system, or repair daemon.
35
+ - No telemetry, LLM calls, external service mutation, or hosted workflow in the
36
+ open-source generator.
37
+ - No consumer implementation logic or deployment automation.
38
+ - No license change away from MIT in this launch slice.
package/SECURITY.md ADDED
@@ -0,0 +1,33 @@
1
+ # Security Policy
2
+
3
+ ## Reporting A Vulnerability
4
+
5
+ Please do not disclose exploit details publicly before the issue has been
6
+ reviewed.
7
+
8
+ If GitHub private vulnerability reporting is available for this repository,
9
+ please use it first. Otherwise, open a minimal public issue that says you have a
10
+ security report to share, but leave exploit details, proof-of-concept payloads,
11
+ tokens, private paths, and affected private repositories out of the issue body.
12
+
13
+ This is a solo-maintainer project. Security reports are handled on a
14
+ best-effort basis, without a formal response-time or fix-time SLA.
15
+
16
+ ## Scope
17
+
18
+ Structor is a local generator for repository-local AI engineering harnesses. It
19
+ does not run agents, host services, collect telemetry, poll sessions, automate
20
+ pull requests, or mutate external services.
21
+
22
+ Security-sensitive areas include:
23
+
24
+ - Generated script templates and render gates.
25
+ - Path validation for consumer repositories and generated harness output.
26
+ - Generated agent entrypoints, hook guardrails, and validation scripts.
27
+ - Public release hygiene that prevents accidental private-project leakage.
28
+
29
+ ## Supported Versions
30
+
31
+ Structor is experimental and early. Please report suspected vulnerabilities
32
+ against the current `main` branch unless a release-specific issue is clearly
33
+ involved.