fix(core,cli): harden install engine and argument parsing
- Reject unknown flags with exit 2 and never write on --dry-run, even in a TTY - Treat files already matching the new content as up to date after an interrupted update - Remove unmodified orphan files from older versions, keep and report modified ones and shared paths - Degrade malformed manifests instead of blocking installs; readIfExists only maps ENOENT/ENOTDIR to null - Block downgrades from older CLIs (semver), honor uninstall --scope, dedupe targets, fix next-step output and table width - Deeper package verification, LF normalization for .mjs, MIT LICENSE
This commit is contained in:
parent
97f2c241e4
commit
eecd3f03ff
29 changed files with 867 additions and 124 deletions
18
AGENTS.md
18
AGENTS.md
|
|
@ -24,7 +24,7 @@ Key packaging fact: when the CLI builds, `@designpaca/core` is bundled into the
|
|||
## Commands
|
||||
|
||||
```bash
|
||||
pnpm install # pnpm 10.x, Node >= 20.11
|
||||
pnpm install # pnpm 10.x; dev/CI need Node >= 22.6 (see Node versions below)
|
||||
pnpm build # skill bundle + CLI build (packages only)
|
||||
pnpm typecheck # tsc --noEmit in packages
|
||||
pnpm test # node:test across all packages
|
||||
|
|
@ -69,17 +69,29 @@ node tools/visual.mjs --update-baseline # refresh visual baselines, then commi
|
|||
10. **Never soften the step-0 interview gate.** v0.11.0 (`45ba92e`) rewrote "almost always ask" into "ask only when it would change the result", with an empty commit body and no changelog line. Combined with harness autonomy pressure (Claude Code auto mode, Codex "bias to action"), the skill stopped asking users. `build/ci/lint-skill.mjs` now fails if the `## 인터뷰 게이트` section, the "명시적으로 의존한다" sentence, or the `harness.md`/`brief-interview.md` links disappear, or if a "~때만 묻는다" condition returns. Any change to when the skill asks must be stated in its changeset and re-checked with `build/eval/interview/` on Claude Code and Codex.
|
||||
11. **Keep tool names harness-neutral in the skill body.** Every target adapter copies `SKILL.md` verbatim, so a Claude-only tool name (e.g. `AskUserQuestion`) reaches Codex, Cursor, Gemini, and others unchanged. Put per-harness tool names, limits, and fallbacks in `references/harness.md`, not in the body.
|
||||
|
||||
### Node versions
|
||||
|
||||
- Installed CLI runtime: `engines.node >= 20.11` (`packages/cli/package.json`). Do not use anything newer in shipped `dist` code.
|
||||
- Development and CI: Node >= 22.6, because tests run `node --test --experimental-strip-types`. `build/ci/verify-node.sh` enforces this on the runner (`MIN_MAJOR=22`, `MIN_MINOR=6`).
|
||||
|
||||
### Scratch and eval
|
||||
|
||||
- `outputs/` is gitignored scratch space; never rely on anything there being committed.
|
||||
- `build/eval/interview/` runs agent sessions in a temp directory outside the repo (`os.tmpdir()/dp-eval-*`) and refuses to start if an ancestor holds `AGENTS.md`/`CLAUDE.md`/`.git`, so repo instructions cannot contaminate a run. Per-run records are kept inside the repo.
|
||||
|
||||
## Architecture & data flow
|
||||
|
||||
### Install pipeline (core)
|
||||
|
||||
- `targets/*.ts` — one adapter per destination tool (claude-code, codex, cursor, zcode, agents, antigravity, gemini-cli, windsurf, copilot, agents-md). Each implements `detect()` (any trace on system → preselected in TUI) and `plan()` which returns a pure `InstallPlan` (list of file actions, **no disk writes**).
|
||||
- Two adapter shapes: `skillDirActions()` copies the whole skill directory (Claude Code, Codex — SKILL.md used verbatim), `referenceActions()`/injection split the body from references (Cursor, AGENTS.md). For the latter, `rewriteRefPaths()` rewrites `references/...` links to the actual install location — without this the body points at nonexistent paths.
|
||||
- One shape: every adapter builds its file list with `skillDirActions()` (whole skill directory; `SKILL.md` verbatim). The `agents-md` adapter additionally injects a pointer block into `AGENTS.md` and runs `rewriteRefPaths()` over the `SKILL.md` copy it unpacks to a separate directory — without that, `references/...` links point at nonexistent paths. There is no body/reference split any more.
|
||||
- `installer.ts` — `planInstall()` → `applyPlan()`. Safety semantics (do not break these):
|
||||
- User-modified files (drift detected via stored sha256) are **skipped** unless `--force`; force still backs up to `.orig`.
|
||||
- Skipped files stay in the manifest with their **original install-time hash** — using the current hash would make drift vanish and a later update silently overwrite user edits.
|
||||
- Marker-injected files (`AGENTS.md` etc.) hash only the content inside `<!-- designpaca:start/end -->` blocks; the rest of the user's document is untouchable.
|
||||
- `manifest.ts` — install records in `~/.designpaca/manifest.json`. Uninstall only removes recorded files; corrupted manifest degrades to empty rather than blocking installs.
|
||||
- Orphans (files a previous install recorded but the new plan no longer contains): unmodified ones are deleted (`ApplyResult.removedStale`); modified ones, marker-injected docs and out-of-bounds paths are kept and stay in the manifest with their original hash (`keptStale`). On uninstall, a path another record also owns is kept (`RemoveResult.sharedKept`, e.g. `agents` + `antigravity` in project scope). The CLI reports all three.
|
||||
- `readIfExists()` returns `null` only for `ENOENT`/`ENOTDIR` and throws on anything else (permissions, locks) — treating an unreadable user document as absent would overwrite it without a backup. `readOrNull()` swallows every error and is only for disposable files such as the update-check cache.
|
||||
- `manifest.ts` — install records in `~/.designpaca/manifest.json`. Uninstall only removes recorded files; a manifest that fails to parse or has the wrong shape (schema, record fields) degrades to empty rather than blocking installs, and `writeManifest` keeps the original as `.corrupt-*` before overwriting. Degradation applies only to those two cases; I/O errors still throw.
|
||||
- AGENTS.md adapter deliberately injects **a pointer only**, not the skill body — AGENTS.md loads unconditionally in every session and Codex truncates around 32 KiB. If you change this adapter, keep that reasoning in mind.
|
||||
|
||||
### CLI (packages/cli)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue