|
1 | 1 | # scripts |
2 | 2 |
|
3 | | -Repo-local helpers for agent-kit. Binary tools ship with `nils-cli` and are on PATH after `brew install nils-cli`; any legacy repo-local |
4 | | -wrappers under `commands/` should not be required for normal use. |
| 3 | +Repo-local helper scripts used by local development and CI in `agent-kit`. |
| 4 | +Use these entrypoints to keep local checks aligned with CI behavior. |
5 | 5 |
|
6 | | -## Structure |
| 6 | +## Quick start |
7 | 7 |
|
8 | | -```text |
9 | | -commands/ Legacy repo-local wrappers (not required when using `nils-cli`). |
10 | | -scripts/ |
11 | | -├── build/ Tooling to generate bundled commands. |
12 | | -├── ci/ CI/local audit helpers. |
13 | | -│ ├── markdownlint-audit.sh Markdown lint audit (`markdownlint-cli2`). |
14 | | -│ └── third-party-artifacts-audit.sh Third-party artifact freshness audit. |
15 | | -├── chrome-devtools-mcp.sh Launcher for the chrome-devtools MCP server. |
16 | | -├── env.zsh Environment defaults shared by repo scripts. |
17 | | -├── fix-typeset-empty-string-quotes.zsh Normalizes `local/typeset foo=\"\"` to `foo=''`. |
18 | | -├── fix-zsh-typeset-initializers.zsh Adds initializers to bare zsh `typeset/local` declarations. |
19 | | -├── fix-shell-style.zsh Runs shell style fixers (check/write). |
20 | | -├── generate-third-party-artifacts.sh Generates THIRD_PARTY_LICENSES.md + THIRD_PARTY_NOTICES.md. |
21 | | -├── lint.sh Runs shell + python lint/syntax checks. |
22 | | -├── project-resolve Deterministic project path resolver (bundled). |
23 | | -├── semgrep-scan.sh Runs Semgrep with local rules + curated Registry packs. |
24 | | -├── test.sh Dev test runner (repo-only). |
25 | | -├── check.sh Runs selected checks (lint/markdown/third-party/contracts/skills-layout/plans/env-bools/semgrep/tests). |
26 | | -└── audit-env-bools.zsh Audits boolean env var conventions (zsh). |
27 | | -``` |
28 | | - |
29 | | -## Bundling wrappers |
30 | | - |
31 | | -Use `build/bundle-wrapper.zsh` to inline a wrapper (and its `source` files) into a single executable script. This is helpful when you want a |
32 | | -portable, repo-local command without external dependencies on wrapper paths. |
33 | | - |
34 | | -Example (copy mode: project-resolve): |
35 | | - |
36 | | -```zsh |
37 | | -zsh -f $AGENT_HOME/scripts/build/bundle-wrapper.zsh \ |
38 | | - --input "$HOME/.agents/scripts/project-resolve" \ |
39 | | - --output scripts/project-resolve |
40 | | -``` |
41 | | - |
42 | | -Notes: |
43 | | - |
44 | | -- Only simple `source` lines and the `typeset -a sources=(...)` / `typeset -a exec_sources=(...)` patterns are supported. |
45 | | -- The bundler writes a shebang + minimal env exports into the output file. |
46 | | -- If the wrapper relies on side effects (PATH, cache dirs, etc.), you may need to expand the bundler to inline those sections too. |
47 | | - |
48 | | -## Validation |
49 | | - |
50 | | -### Agent-docs bootstrap helper |
51 | | - |
52 | | -Use the `agent-doc-init` skill entrypoint for safe baseline initialization in new repositories: |
53 | | - |
54 | | -```bash |
55 | | -$AGENT_HOME/skills/tools/agent-doc-init/scripts/agent_doc_init.sh --dry-run --project-path "$PROJECT_PATH" |
56 | | -$AGENT_HOME/skills/tools/agent-doc-init/scripts/agent_doc_init.sh --apply --project-path "$PROJECT_PATH" |
57 | | -``` |
| 8 | +- Full local gate (recommended before commit): |
| 9 | + - `scripts/check-pre-commit.sh` |
| 10 | +- Canonical single-command gate: |
| 11 | + - `scripts/check.sh --all` |
| 12 | +- Targeted runs: |
| 13 | + - `scripts/check.sh --docs` |
| 14 | + - `scripts/check.sh --entrypoint-ownership` |
| 15 | + - `scripts/check.sh --tests -- -m script_smoke` |
58 | 16 |
|
59 | | -Validate after apply: |
| 17 | +## Directory layout |
60 | 18 |
|
61 | | -```bash |
62 | | -agent-docs baseline --check --target all --strict --project-path "$PROJECT_PATH" --format text |
| 19 | +```text |
| 20 | +scripts/ |
| 21 | +├── build/ |
| 22 | +│ ├── README.md |
| 23 | +│ └── bundle-wrapper.zsh |
| 24 | +├── ci/ |
| 25 | +│ ├── docs-freshness-audit.sh |
| 26 | +│ ├── markdownlint-audit.sh |
| 27 | +│ ├── stale-skill-scripts-audit.sh |
| 28 | +│ └── third-party-artifacts-audit.sh |
| 29 | +├── e2e/ |
| 30 | +│ ├── run_agent_docs_subagent_trials.py |
| 31 | +│ └── summarize_agent_docs_trials.py |
| 32 | +├── check-pre-commit.sh |
| 33 | +├── check.sh |
| 34 | +├── check_plan_issue_worktree_cleanup.sh |
| 35 | +├── chrome-devtools-mcp.sh |
| 36 | +├── clean-untracked.sh |
| 37 | +├── env.zsh |
| 38 | +├── fix-shell-style.zsh |
| 39 | +├── fix-typeset-empty-string-quotes.zsh |
| 40 | +├── fix-zsh-typeset-initializers.zsh |
| 41 | +├── generate-third-party-artifacts.sh |
| 42 | +├── install-homebrew-nils-cli.sh |
| 43 | +├── lint.sh |
| 44 | +├── project-resolve |
| 45 | +├── semgrep-scan.sh |
| 46 | +└── test.sh |
63 | 47 | ``` |
64 | 48 |
|
65 | | -### Skill contract lint |
66 | | - |
67 | | -`$AGENT_HOME/skills/tools/skill-management/skill-governance/scripts/validate_skill_contracts.sh` enforces a minimal skill contract format |
68 | | -across `skills/**/SKILL.md`. |
69 | | - |
70 | | -Requirements (inside `## Contract`, in order): |
71 | | - |
72 | | -- `Prereqs:` |
73 | | -- `Inputs:` |
74 | | -- `Outputs:` |
75 | | -- `Exit codes:` |
76 | | -- `Failure modes:` |
77 | | - |
78 | | -Usage: |
79 | | - |
80 | | -- Validate all tracked skills: `$AGENT_HOME/skills/tools/skill-management/skill-governance/scripts/validate_skill_contracts.sh` |
81 | | -- Validate a specific file: |
82 | | - `$AGENT_HOME/skills/tools/skill-management/skill-governance/scripts/validate_skill_contracts.sh --file skills/<path>/SKILL.md` |
83 | | - |
84 | | -Exit codes: |
85 | | - |
86 | | -- `0`: all validated files are compliant |
87 | | -- non-zero: validation/usage errors (prints `error:` lines to stderr) |
88 | | - |
89 | | -### Skill layout audit |
90 | | - |
91 | | -`$AGENT_HOME/skills/tools/skill-management/skill-governance/scripts/audit-skill-layout.sh` enforces a consistent tracked skill directory |
92 | | -layout: |
93 | | - |
94 | | -- `SKILL.md` at the skill root |
95 | | -- Required: `tests/` |
96 | | -- Optional: `scripts/`, `references/`, `assets/` |
97 | | -- No other tracked top-level entries |
98 | | -- Markdown files with `TEMPLATE` in the filename must live under `references/` or `assets/templates/` within the skill |
99 | | - |
100 | | -### Lint + syntax checks |
101 | | - |
102 | | -`$AGENT_HOME/scripts/lint.sh` runs: |
103 | | - |
104 | | -- Shell: `shellcheck` (bash) + `bash -n` + `zsh -n` (shebang-based) |
105 | | -- Python: `ruff` + `mypy` + `pyright` |
| 49 | +## Script index |
| 50 | + |
| 51 | +### Core validation entrypoints |
| 52 | + |
| 53 | +- `scripts/check-pre-commit.sh` |
| 54 | + - Pre-commit wrapper: |
| 55 | + - `scripts/check.sh --all` |
| 56 | + - `bash scripts/ci/stale-skill-scripts-audit.sh --check` |
| 57 | + - `scripts/check.sh --entrypoint-ownership` |
| 58 | +- `scripts/check.sh` |
| 59 | + - Main validation router for lint, docs audits, Semgrep, and pytest. |
| 60 | +- `scripts/lint.sh` |
| 61 | + - Shell + Python lint/type/syntax checks. |
| 62 | +- `scripts/test.sh` |
| 63 | + - Pytest runner (uses `.venv` python when available). |
| 64 | +- `scripts/semgrep-scan.sh` |
| 65 | + - Semgrep scan with local rules and curated profiles. |
| 66 | + |
| 67 | +### CI and docs/artifact audits |
| 68 | + |
| 69 | +- `scripts/ci/markdownlint-audit.sh` |
| 70 | + - Markdown lint wrapper (`markdownlint-cli2`). |
| 71 | +- `scripts/ci/third-party-artifacts-audit.sh` |
| 72 | + - Verifies required third-party artifacts and drift. |
| 73 | +- `scripts/ci/docs-freshness-audit.sh` |
| 74 | + - Verifies required docs commands/paths are still accurate. |
| 75 | +- `scripts/ci/stale-skill-scripts-audit.sh` |
| 76 | + - Classifies skill scripts as `ACTIVE` / `TRANSITIONAL` / `REMOVABLE`. |
| 77 | +- `scripts/generate-third-party-artifacts.sh` |
| 78 | + - Generates `THIRD_PARTY_LICENSES.md` and `THIRD_PARTY_NOTICES.md`. |
| 79 | + |
| 80 | +### Shell maintenance utilities |
| 81 | + |
| 82 | +- `scripts/fix-shell-style.zsh` |
| 83 | + - Runs shell style auto-fixers/checkers. |
| 84 | +- `scripts/fix-typeset-empty-string-quotes.zsh` |
| 85 | + - Normalizes `typeset/local foo=""` to `foo=''`. |
| 86 | +- `scripts/fix-zsh-typeset-initializers.zsh` |
| 87 | + - Adds missing initializers for zsh `typeset/local` declarations. |
| 88 | +- `scripts/audit-env-bools.zsh` |
| 89 | + - Audits boolean env var naming conventions. |
| 90 | + |
| 91 | +### Workflow-specific utilities |
| 92 | + |
| 93 | +- `scripts/check_plan_issue_worktree_cleanup.sh` |
| 94 | + - Checks leftover `plan-issue-delivery` worktree directories. |
| 95 | +- `scripts/chrome-devtools-mcp.sh` |
| 96 | + - Launcher for chrome-devtools MCP server with repo env handling. |
| 97 | +- `scripts/project-resolve` |
| 98 | + - Bundled deterministic project path resolver. |
| 99 | + |
| 100 | +### Environment/bootstrap helpers |
| 101 | + |
| 102 | +- `scripts/install-homebrew-nils-cli.sh` |
| 103 | + - CI bootstrap helper to install Homebrew + `nils-cli`. |
| 104 | +- `scripts/clean-untracked.sh` |
| 105 | + - Safe-by-default git clean wrapper (`--dry-run` default, `--apply` to delete). |
| 106 | +- `scripts/env.zsh` |
| 107 | + - Shared environment defaults used by repo scripts. |
| 108 | + |
| 109 | +### E2E trial helpers |
| 110 | + |
| 111 | +- `scripts/e2e/run_agent_docs_subagent_trials.py` |
| 112 | + - Runs configured agent-docs trial scenarios and captures structured results. |
| 113 | +- `scripts/e2e/summarize_agent_docs_trials.py` |
| 114 | + - Converts trial JSON results into a markdown summary. |
106 | 115 |
|
107 | | -Usage: |
108 | | - |
109 | | -- Lint everything: `$AGENT_HOME/scripts/lint.sh` |
110 | | -- Shell only: `$AGENT_HOME/scripts/lint.sh --shell` |
111 | | -- Python only: `$AGENT_HOME/scripts/lint.sh --python` |
112 | | - |
113 | | -### Markdown lint checks |
114 | | - |
115 | | -`$AGENT_HOME/scripts/ci/markdownlint-audit.sh` runs `markdownlint-cli2` against all tracked Markdown files. |
116 | | - |
117 | | -Usage: |
118 | | - |
119 | | -- Strict mode (recommended): `$AGENT_HOME/scripts/ci/markdownlint-audit.sh --strict` |
120 | | - |
121 | | -### Third-party artifact checks |
122 | | - |
123 | | -`$AGENT_HOME/scripts/generate-third-party-artifacts.sh` generates deterministic `THIRD_PARTY_LICENSES.md` and `THIRD_PARTY_NOTICES.md`. |
124 | | - |
125 | | -Usage: |
126 | | - |
127 | | -- Write/update artifacts: `$AGENT_HOME/scripts/generate-third-party-artifacts.sh --write` |
128 | | -- Check for drift: `$AGENT_HOME/scripts/generate-third-party-artifacts.sh --check` |
129 | | - |
130 | | -`$AGENT_HOME/scripts/ci/third-party-artifacts-audit.sh` verifies required third-party artifacts and fails on drift in strict mode. |
131 | | - |
132 | | -Usage: |
133 | | - |
134 | | -- Strict mode (recommended): `$AGENT_HOME/scripts/ci/third-party-artifacts-audit.sh --strict` |
135 | | - |
136 | | -## Semgrep |
137 | | - |
138 | | -Use `semgrep-scan.sh` to run `.semgrep.yaml` plus curated Semgrep Registry packs. |
139 | | - |
140 | | -Examples: |
141 | | - |
142 | | -- Default (scripting profile): `$AGENT_HOME/scripts/semgrep-scan.sh` |
143 | | -- Shell scripts only: `$AGENT_HOME/scripts/semgrep-scan.sh --profile shell` |
144 | | - |
145 | | -## Plans |
146 | | - |
147 | | -Plan tooling helps keep implementation plans concrete (executable + verifiable) and easy to split into parallel subagent tasks. Install with |
148 | | -`brew install nils-cli` to get `plan-tooling`, `api-*`, and `semantic-commit` on PATH. |
149 | | - |
150 | | -### Plan lint |
151 | | - |
152 | | -`plan-tooling validate` enforces a minimal Plan Format v1 across `docs/plans/*-plan.md`: |
153 | | - |
154 | | -- Sprints: `## Sprint N: <name>` |
155 | | -- Tasks: `### Task N.M: <name>` |
156 | | -- Required per-task fields: |
157 | | - - `Location` (non-empty list) |
158 | | - - `Description` |
159 | | - - `Dependencies` (`none` or list of `Task N.M`) |
160 | | - - `Acceptance criteria` (non-empty list) |
161 | | - - `Validation` (non-empty list) |
162 | | - |
163 | | -Usage: |
164 | | - |
165 | | -- Lint all tracked plans: `plan-tooling validate` |
166 | | -- Lint a specific plan: `plan-tooling validate --file docs/plans/<name>-plan.md` |
167 | | - |
168 | | -### Plan scaffolding |
169 | | - |
170 | | -`plan-tooling scaffold` creates a new `docs/plans/*-plan.md` file from the shared template: |
171 | | - |
172 | | -- `plan-tooling scaffold --slug <kebab-case> --title "<task name>"` |
173 | | - |
174 | | -### Plan JSON export |
175 | | - |
176 | | -`plan-tooling to-json` parses a plan into JSON for tooling to consume: |
177 | | - |
178 | | -- `plan-tooling to-json --file docs/plans/<name>-plan.md | python3 -m json.tool` |
179 | | - |
180 | | -### Parallel batches |
| 116 | +## Bundling wrappers |
181 | 117 |
|
182 | | -`plan-tooling batches` computes dependency layers (parallel batches) for a sprint: |
| 118 | +Use `scripts/build/bundle-wrapper.zsh` to inline a wrapper plus sourced files into a single executable. |
| 119 | +Details and examples live in: |
183 | 120 |
|
184 | | -- `plan-tooling batches --file docs/plans/<name>-plan.md --sprint 1 --format text` |
| 121 | +- `scripts/build/README.md` |
0 commit comments