Skip to content

Commit a40e312

Browse files
authored
Merge branch 'next' into wf/f20-feedback-skill-b16
2 parents f1986f5 + ae032e7 commit a40e312

87 files changed

Lines changed: 13619 additions & 253 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.ai/skills/hack-repo-verify/SKILL.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ needs source mapping and implementation regression evidence; use
146146

147147
Do not overlap stateful runs against one checkout, daemon, port range or runtime.
148148
Record owned resources before a live run, use bounded fixtures and verify cleanup.
149+
A harness outside `privateCliEnv` and `buildCliEnv` sets
150+
`HACK_DAEMON_AUTOSTART_DISABLE=1` for every CLI run: `doctor --fix`,
151+
`doctor --migrate-env-config` and `global up` start a daemon that outlives the run,
152+
even with `HACK_NO_INTERACTIVE=1`. `gateway enable` and `gateway setup` start one
153+
regardless of it.
149154
Never hand-edit managed internal state or prune unowned resources to repair a test.
150155
Report exact command, source/executable, host/container context, result, skips/cache
151156
and remaining gate. Do not upgrade a mocked/unit result into live runtime evidence.

‎.husky/pre-commit‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ if [ -z "$STAGED_FILES" ]; then
77
exit 0
88
fi
99

10+
# Call the pinned Biome binary directly with the flags `ultracite fix` used. Paths travel
11+
# NUL-delimited through xargs straight into argv, so names with brackets, spaces or quotes
12+
# (for example Next.js `site/app/docs/[[...slug]]/page.tsx`) reach Biome unchanged. Ultracite 7
13+
# shell-quoted each path and then ran Biome through a shell, which left literal quotes in the
14+
# path (HACK-1665). Nested configs such as `site/biome.jsonc` still apply per file.
15+
BIOME="$(git rev-parse --show-toplevel)/node_modules/.bin/biome"
16+
if [ ! -x "$BIOME" ]; then
17+
echo "pre-commit: Biome is not installed at $BIOME. Run: bun install --frozen-lockfile" >&2
18+
exit 1
19+
fi
20+
1021
# Stash unstaged tracked changes so we format the staged snapshot of each file.
1122
# Note: if unstaged changes touch the same lines formatting changes, stash pop may conflict. In that
1223
# case we abort the commit and leave the stash for manual resolution.
@@ -17,7 +28,8 @@ if ! git diff --quiet; then
1728
fi
1829

1930
# Format only staged files (avoid rewriting unrelated files).
20-
git diff --cached --name-only --diff-filter=ACMR -z | xargs -0 bun x ultracite fix
31+
git diff --cached --name-only --diff-filter=ACMR -z |
32+
xargs -0 "$BIOME" check --write --no-errors-on-unmatched --
2133

2234
# Restage in case the formatter changed them.
2335
git diff --cached --name-only --diff-filter=ACMR -z | xargs -0 git add --

‎docs/env.md‎

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ A `null` result means no modern env configuration exists; it does not inspect or
231231
resolve legacy `.env` or secret-store values. Callers retain responsibility for
232232
their existing legacy fallback. Selected managed-env layer reads distinguish a
233233
missing path from a failed read or a dangling symlink. Only regular files
234-
(including readable symlinks to regular files) are read; invalid or unreadable
235-
layers throw a value-free error without YAML excerpts or a nested cause. Project configuration
234+
(including readable symlinks to regular files inside the real project root) are read;
235+
invalid or unreadable layers throw a value-free error without YAML excerpts or a nested cause. Project configuration
236236
selection keeps its existing semantics. Metadata inspection never writes key
237237
files or materializes `.env`.
238238

@@ -592,6 +592,15 @@ input and without writing anything:
592592
`.hack/hack.env.<overlay>.local.yaml`) instead of the shared repo env file — use it for
593593
per-checkout values you don't want to commit.
594594

595+
In a project with `.hack/hack.env.json` and no env layers yet, `hack env set --local` refuses and
596+
writes nothing for a plaintext value, because that project's migration copies `.hack/.env` values to
597+
tracked layers. Use `hack env add` with the same flags, which migrates first and then writes the
598+
machine-local layer. That migration still copies values already in `.hack/.env`, and a `plain_env`
599+
value exported in your shell, to tracked layers.
600+
With `--secret`, the value goes to the secret backend, and a key the contract declares as `keychain`
601+
reaches a tracked layer as ciphertext when the project migrates. Without `hack.env.json`, `--local`
602+
still writes `.hack/.env`.
603+
595604
Repeating `hack env add` or `hack env set` with the value already stored is a no-op: when
596605
the existing secret decrypts to the same value under the current key, its ciphertext is
597606
kept, so once Hack has written the file it stays byte-identical and Git shows no change.
@@ -609,9 +618,23 @@ new layer, so `.hack/.gitignore` ignores `.hack.env*.tmp`, and you can delete it
609618
does not remove it on the next write, because another write may still be using it. The
610619
rename has these effects:
611620

612-
- a symlinked env file keeps its link; the new contents land at the file the link points
613-
to, and the staging file is created next to that file
614-
- a symlink whose target does not exist is replaced by a regular file
621+
- a symlinked YAML env layer is allowed only when its fully resolved path stays inside
622+
the project's real root. Relative links and link chains are resolved at each hop; a
623+
root behind a symlink works too. An allowed link keeps its link, the write lands at
624+
its target, and the staging file is created next to that target
625+
- outside targets (including dangling outside links), sibling-prefix escapes and link
626+
loops are refused with a closed, value-free error before reading values from stdin
627+
or writing decrypted or hydrated output. This applies to the base, tracked overlays
628+
and local layers, including init scaffold writes; mutation discovery checks all named
629+
YAML layers, including case-variant names on case-insensitive filesystems.
630+
`hack doctor --fix` reports an error for a `.hack` linked outside the project
631+
and leaves the link and outside files in place
632+
- an in-project symlink whose target does not exist keeps the existing behavior: the
633+
link is replaced by a regular file. Strict planning and hydrate reads still refuse
634+
dangling links
635+
- the writer rechecks both the layer and its resolved destination before staging and
636+
commit. These path checks narrow concurrent-swap races; they are not an atomic
637+
filesystem fence against a directory changed after the last check
615638
- a hard link is broken: the env file gets a new inode, and any other name for the old
616639
file keeps the previous contents
617640
- the directory must be writable, even when the env file itself is writable; if it is
@@ -1023,6 +1046,17 @@ That migrates the repo into:
10231046
- `.hack/hack.env.<overlay>.yaml`
10241047
- `.hack.secret.key` when needed
10251048

1049+
Doctor offers legacy dotenv files for cleanup only when every parsed entry was
1050+
delivered to an env layer. Files containing undeclared or undelivered entries stay
1051+
on disk; the cleanup report lists their key names and omits their values. This
1052+
also applies to untracked overlays such as `.env.bak` and `.env.example`.
1053+
Migration refuses a legacy `.env.default` overlay before writing env layers,
1054+
because it would overwrite the base `hack.env.default.yaml` layer. Rename that
1055+
legacy overlay and update its project references before retrying.
1056+
If a legacy dotenv file cannot be read, migration refuses cleanup and leaves
1057+
legacy artifacts in place. Env layers may already have been written; check read
1058+
access and preserve the remaining entries before cleaning up manually.
1059+
10261060
`hack doctor` also warns when a repo still depends on the old format.
10271061
For modern env repos, `hack doctor` also warns when materialized compatibility output in
10281062
`.hack/.env` or `.hack/.env.state.json` is stale and points to `hack env materialize`.

‎docs/security/env-secrets-threat-model.md‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,21 @@ These gaps are known and not closed on `next`. Each one needs its own change.
155155
published now (HACK-1318); until `hack config adopt --recover --rollback` releases
156156
its journaled switch, it also keeps the file. Other generated files under `.hack/.internal/` and `.hack/.branch/` are
157157
written with the process umask; the scan shows they hold no values today.
158-
5. **YAML env file writes.** `writeProjectEnvConfigFile` in
159-
`src/lib/project-env-config.ts` also uses `writeTextFileIfChanged`, so
160-
`.hack/hack.env.*.yaml` writes follow a symlink at the file. These files hold
161-
ciphertext and non-secret plaintext, but a hostile repository could redirect the
162-
write.
158+
5. **YAML env layer TOCTOU (narrowed, HACK-1685).** Base and overlay YAML layers,
159+
including local layers and init scaffold writes, may follow links only when the whole chain resolves inside
160+
`realpath(projectRoot)`. Component-aware resolution handles relative targets,
161+
chains, symlinked roots and missing targets; segment-aware containment refuses
162+
sibling-prefix escapes. Outside targets, dangling outside links, loops and failed
163+
inspections produce closed, value-free errors. Mutation discovery and commands
164+
check before value stdin, and readers check before decryption or hydration output.
165+
`writeProjectEnvConfigFile` uses `writeTextFileAtomicIfChanged` in
166+
`src/lib/fs.ts`: allowed links keep their link and writes rename over their real
167+
target. The writer rechecks the original layer and captured destination before
168+
staging and commit, including after a concurrent link swap. These checks are
169+
path-based, not descriptor-relative `openat`/`renameat`: an ancestor directory
170+
swapped after the last check can still redirect an operation. This residual race
171+
remains open; ordinary outside-link redirection is refused. In-project dangling
172+
links retain set/unset's prior replacement behavior; strict reads refuse them.
163173
6. **`encrypted_file` key file reads.** Key writes now use the
164174
`src/lib/private-file.ts` helpers: explicit provisioning replaces the key
165175
atomically, and first-use generation publishes it exclusively. `readEncryptedFileKey`

‎docs/versions/v5/agent-handoff.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Give an agent the right context
22

3-
[Agent setup on the v5 branch (unreleased PR531)](guides/agent-setup-v5-branch.md) documents the newer opt-in model at its exact source revision. The runtime docs remain pinned to next.5. Use the same actual selected documentation host for that guide; do not infer that a public PR is a deployed release.
3+
[Agent setup in next.6](guides/agent-setup-v5-branch.md) documents the shipped opt-in model at source `44aaf5156426dfcbb1c8a189b8e20531e5b95613`. Use the actual selected documentation host; source publication does not establish site deployment.
44

55
Read this version's [LLM index](/v5/llms.txt) or [full corpus](/v5/llms-full.txt). They contain only the
66
selected version's allowlisted public docs. Use these canonical URLs when the
@@ -23,7 +23,7 @@ arguments. Verify the application's own health, not just CLI exit status.
2323
```
2424

2525
[Agent integrations](../integrations.md) describes this version's optional client
26-
setup, with a factual next.5 compatibility boundary. Choose the selected CLI and
27-
reviewed skills explicitly; do not treat the shipped bundle as already hook-free. A plugin on your laptop does not install tools in a cloud agent.
26+
setup, with a historical next.5 compatibility boundary. The next.6 plugin manifests select skills only. Choose the selected CLI and
27+
reviewed skills explicitly. A plugin on your laptop does not install tools in a cloud agent.
2828
Agents with shell access can use the CLI directly; MCP is a separate interface,
2929
not a prerequisite for ordinary project use.

‎docs/versions/v5/cli.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Historical remote guides are excluded from the supported documentation.
134134
apply documented defaults or fail fast with `E_INTERACTIVE_REQUIRED`.
135135
- `NO_COLOR` (or `HACK_NO_COLOR`) disables colored/decorated output.
136136

137-
Agent context is explicitly selected through the [versioned docs and optional interfaces](integrations.md). No guidance freshness or instruction-writing workflow is part of this onboarding. [Historical compatibility](reference/agent-compatibility.md) records the released next.5 interfaces omitted from this editorial selection.
137+
Agent context is explicitly selected through the [versioned docs and optional interfaces](integrations.md). No guidance freshness or instruction-writing workflow is part of this onboarding. [Historical compatibility](reference/agent-compatibility.md) records next.5 history and the shipped next.6 retirement. See [release contracts](reference/next6-contracts.md) for new read-only task/target and env hydrate inputs.
138138

139139
## First-run path
140140

‎docs/versions/v5/core.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Native project basics
22

3-
This v5 corpus describes the published next.5 native candidate. Complete [Install](install.md) and [Native preparation](guides/native-candidate.md), select that candidate's explicit launcher, then follow [Getting started](getting-started.md).
3+
This v5 corpus describes the published next.6 native candidate. Complete [Install](install.md) and [Native preparation](guides/native-candidate.md), select that candidate's explicit launcher, then follow [Getting started](getting-started.md).
44

55
For the stable Compose workflow, select v4 in the documentation version selector. Detached startup, pretty/following logs and Compose lifecycle JSON examples are not the native startup path.
66

‎docs/versions/v5/getting-started.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Getting started
22

33
Complete [Install](install.md) and [Native preparation](../guides/native-candidate.md)
4-
first. This version documents the published next.5 native candidate. For Compose,
5-
choose v4 in Docs version; this launcher's backend cannot be overridden to Compose.
4+
first. This version documents the published next.6 native candidate. For Compose,
5+
choose v4 in Docs version; native execution is the default. Explicit Compose selection is described in [Install](install.md).
6+
7+
This guide uses the native path. Cross-version upgrade/rollback, initialized data,
8+
native application and client acceptance remain open; the fresh-install check
9+
does not qualify those paths.
610

711
## Prepare one project
812

‎docs/versions/v5/guides/agent-first-setup.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A useful task description names the project, execution host, selected version an
88

99
The pinned CLI's `agent onboard` command prints a project onboarding prompt. It does not install skills or client instructions. Review that prompt before handing it to your agent; the request defines the work to perform. It is separate from the historical primer hooks.
1010

11-
For clients supporting explicitly selected skills, the shipped hack-init skill asks for that CLI prompt. Review the actual skill first: the overall next.5 bundle still contains retiring maintenance guidance. [Choose an agent interface](../integrations.md) explains the exact shipped contents and the forthcoming hook-free direction.
11+
For clients supporting explicitly selected skills, the shipped hack-init skill asks for that CLI prompt. Review the actual skill first: next.6 ships opt-in skills without automatic guidance injection. [Choose an agent interface](../integrations.md) explains the exact shipped contents and the shipped opt-in model.
1212

1313
## Keep policy with its owner
1414

0 commit comments

Comments
 (0)