@sassywares/skills 0.13.2 → 0.15.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 (43) hide show
  1. package/README.md +28 -14
  2. package/package.json +1 -2
  3. package/skills/sassy-compound/SKILL.md +1 -1
  4. package/skills/sassy-compound/references/concepts.md +2 -2
  5. package/skills/sassy-debug/SKILL.md +1 -1
  6. package/skills/sassy-docs/SKILL.md +56 -0
  7. package/skills/sassy-docs/references/handbook.md +17 -0
  8. package/skills/sassy-docs/references/review.md +57 -0
  9. package/skills/sassy-goal/SKILL.md +5 -0
  10. package/skills/sassy-goal/references/check.md +1 -1
  11. package/skills/sassy-goal/references/close.md +6 -5
  12. package/skills/sassy-goal/references/goal-format.md +13 -2
  13. package/skills/sassy-goal/references/next.md +2 -2
  14. package/skills/sassy-goal/references/write.md +9 -5
  15. package/skills/sassy-handoff/references/write.md +1 -1
  16. package/skills/sassy-lfg/SKILL.md +2 -2
  17. package/skills/sassy-plan/SKILL.md +24 -17
  18. package/skills/sassy-plan/references/interview.md +5 -3
  19. package/skills/sassy-plan/references/plan-format.md +22 -2
  20. package/skills/sassy-setup/SKILL.md +19 -11
  21. package/skills/sassy-setup/assets/agents-md.md +71 -0
  22. package/skills/sassy-setup/assets/roster +2 -1
  23. package/skills/sassy-setup/assets/sassywares-readme.md +6 -6
  24. package/skills/sassy-setup/references/anchors.md +122 -0
  25. package/skills/sassy-setup/references/check.md +14 -2
  26. package/skills/sassy-setup/references/config.md +13 -8
  27. package/skills/sassy-setup/references/harness.md +3 -2
  28. package/skills/sassy-setup/references/init.md +9 -4
  29. package/skills/sassy-setup/references/workspace.md +23 -0
  30. package/skills/sassy-setup/scripts/detect.sh +281 -30
  31. package/skills/sassy-ship/SKILL.md +26 -10
  32. package/skills/sassy-ship/references/brief.md +20 -0
  33. package/skills/sassy-ship/references/plan.md +20 -0
  34. package/skills/sassy-ship/references/slice.md +21 -0
  35. package/skills/sassy-strategy/SKILL.md +66 -0
  36. package/skills/sassy-strategy/references/check.md +81 -0
  37. package/skills/sassy-strategy/references/strategy-format.md +84 -0
  38. package/skills/sassy-strategy/references/write.md +180 -0
  39. package/skills/sassy-validate/SKILL.md +1 -1
  40. package/skills/sassy-work/SKILL.md +1 -1
  41. package/CONCEPTS.md +0 -173
  42. package/skills/sassy-handbook/SKILL.md +0 -52
  43. /package/skills/{sassy-handbook → sassy-docs}/references/handbook-format.md +0 -0
@@ -51,9 +51,10 @@ artifacts:
51
51
  plans: docs/plans
52
52
  solutions: docs/solutions
53
53
  handbooks: docs/handbooks
54
- concepts: CONCEPTS.md
54
+ concepts: docs/concepts.md
55
+ strategy: docs/strategy.md
55
56
  knowledge:
56
- read: [docs/solutions, CONCEPTS.md]
57
+ read: [docs/solutions, docs/concepts.md]
57
58
  write: true
58
59
  git:
59
60
  repo: origin # <remote name> | workspace | none
@@ -101,9 +102,10 @@ dogfood:
101
102
  |-----|---------|---------|
102
103
  | `artifacts.plans` | `docs/plans` | Where `sassy-plan` writes plans, and where `sassy-goal` keeps goal folders (`<type>-<slug>/goal.md` plus slice plans) |
103
104
  | `artifacts.solutions` | `docs/solutions` | Where `sassy-compound` writes learnings |
104
- | `artifacts.handbooks` | `docs/handbooks` | Where `sassy-handbook` writes handbooks |
105
- | `artifacts.concepts` | `CONCEPTS.md` | The glossary file compound maintains |
106
- | `knowledge.read` | `[docs/solutions, CONCEPTS.md]` | Paths scouted for prior learnings |
105
+ | `artifacts.handbooks` | `docs/handbooks` | Where `sassy-docs` writes handbooks, and one of the document sets its review walks |
106
+ | `artifacts.concepts` | `docs/concepts.md` | The glossary file compound maintains. When the config is silent and a root `CONCEPTS.md` exists, that root file is the glossary |
107
+ | `artifacts.strategy` | `docs/strategy.md` | The strategy file `sassy-strategy` writes and revises — where direction is decided. Absent is not drift: the file appears on the first write |
108
+ | `knowledge.read` | `[docs/solutions, docs/concepts.md]` | Paths scouted for prior learnings |
107
109
  | `knowledge.write` | `true` | `false` = this project takes no learnings |
108
110
  | `git.repo` | `origin` | Remote name, or a reserved value (below) |
109
111
  | `git.base_map` | probed `"*"` | Head branch → the base it targets. `"*"` is required |
@@ -180,7 +182,7 @@ without asking, so the version line is how staleness surfaces.
180
182
  | Step | remote | `workspace` | `none` |
181
183
  |------|--------|-------------|--------|
182
184
  | plan, cycle, work, review, validate | normal | normal | normal |
183
- | compound, handbook | normal | normal, at the root | normal |
185
+ | compound, docs | normal | normal, at the root | normal |
184
186
  | commit | `git commit` | no `git commit`; run the snapshot | refused, one line |
185
187
  | PR, ship's PR step, babysit | normal | per affected repo (below) | refused, one line |
186
188
  | snapshot | not used | the commit mechanism | not used |
@@ -571,7 +573,8 @@ report layout, the verdict classes, and the lint are in
571
573
  ## Validation rules
572
574
 
573
575
  - `artifacts.*` values are repo-relative directories (or one file for
574
- `concepts`), must resolve inside the project, and must not be the root itself.
576
+ `concepts` and `strategy`), must resolve inside the project, and must not be
577
+ the root itself.
575
578
  - `git.repo` is `workspace`, `none`, or one existing remote name.
576
579
  - `git.remote` is required when `git.repo: workspace`; forbidden otherwise.
577
580
  `git.mirror_branch` and `repos` are workspace-only too.
@@ -626,4 +629,6 @@ note, never as drift; [`check.md`](check.md) has the outcomes. The merge that
626
629
  closes it is `detect.sh --root <path> --sync --write`: it keeps every leaf the
627
630
  check accepts, value and same-line trailing comment byte for byte, and takes the
628
631
  rest from the template, so a comment carries the project's confirmation forward
629
- and a malformed value is replaced.
632
+ and a malformed value is replaced. The same command also creates, appends, or
633
+ replaces the `AGENTS.md` routing block; `--no-agents` scopes it to this config,
634
+ and `--agents` to the block alone.
@@ -12,10 +12,10 @@ A missing sibling means the suite is incomplete: stop and point at `sassy-setup`
12
12
 
13
13
  ## Dispatching an agent
14
14
 
15
- "Dispatch a `worker`" (or `scout`, `reviewer`, `simplifier`, `validator`) means: start that [sassy-agents](https://github.com/sassywares/sassy-agents) subagent by name through the harness's own mechanism — the `subagent` tool in pi, the Agent tool with that agent type in Claude Code. "In parallel" means several dispatches in one turn.
15
+ "Dispatch a `worker`" (or `scout`, `reviewer`, `simplifier`, `validator`) means: start that [sassy-agents](https://github.com/sassywares/sassy-agents) subagent by name through the harness's own mechanism — the `subagent` tool in pi, the Agent tool with that agent type in Claude Code, `delegate_task` in Hermes Agent with `~/.hermes/agents/<name>.md`'s body, frontmatter stripped, as the child's context. "In parallel" means several dispatches in one turn.
16
16
 
17
17
  - **Agent not installed** — stop and point at `sassy-setup`, which installs the roster for the running harness. Never substitute a generic agent silently.
18
- - **Cannot dispatch** — you are yourself a subagent and the harness does not let subagents dispatch (Claude Code), or the harness has no subagents at all. Do that step inline with the same brief and constraints, and say in your result that it ran inline. Never skip it.
18
+ - **Cannot dispatch** — you are yourself a subagent and the harness does not let subagents dispatch (Claude Code; in Hermes Agent a child cannot call `delegate_task`), or the harness has no subagents at all. Do that step inline with the same brief and constraints, and say in your result that it ran inline. Never skip it.
19
19
 
20
20
  ## Commands the user types
21
21
 
@@ -25,6 +25,7 @@ Skills tell the user what to run next. Write the command for the harness you are
25
25
  |---|---|---|
26
26
  | pi | `/skill:<name> <args>` | `/reload` |
27
27
  | Claude Code | `/<name> <args>` | restart the session |
28
+ | Hermes Agent | `/sassy-plan <args>` | a new session for the `/` menu; a skill is read from disk on every load, so a changed file takes effect immediately |
28
29
 
29
30
  For any other harness, give the skill name and its arguments and let the user invoke it their way.
30
31
 
@@ -19,6 +19,7 @@ Never re-ask what the tree already said.
19
19
  - **`workspace`** — the snapshot mirror: create a **private** GitHub repo, or connect an existing one? Creating it needs explicit approval and a named slug first.
20
20
  - **`none`** — confirm the intent: this folder is deliberately outside git, so commit, PR, and babysit refuse here.
21
21
  - **Artifacts** — offer the detected paths as the default; take overrides.
22
+ - **Strategy** — offer to run the strategy interview in this same run, the way the dogfood bullet offers `mode:discover`. Say what the file is for: the one document that says what the product is for, who it is for, and what it refuses, read where direction is decided and written only by `sassy-strategy`. Yes means dispatch `sassy-strategy` now, in its own run; no means hand over `/sassy-strategy` and say the project is wired either way. **Never author a word of the interview yourself** — the model, the questions, the six sections, and the `draft`→`active` read-back are `sassy-strategy`'s alone. See the `sassy-setup` skill's [`anchors.md`](anchors.md) for where the file lives and why an absent one is not a failure.
22
23
  - **Knowledge** — `knowledge.read` defaults to the solutions dir plus the concepts file. Ask whether there are extra folders to read (a hand-written `notes/learnings/`, a `docs/adr/`).
23
24
  - **Base map** — detection proposes `"*"` from the probed remote default. Ask where ordinary work branches from, and whether the default branch itself releases to another branch (a `staging: main` rung). Never write `main` as a guess. In `workspace` mode, show the `repos` map and get a yes on every row — a probed base is only the remote's default.
24
25
  - **`commit.branch`** — default `new`: the run cuts a branch before the first change and never commits on a base branch. Offer `current` for a repo that genuinely wants work committed where it stands, and say plainly that `current` lets a run commit onto its base branch and push it, with no PR (`pr.*` and `hooks.pr` are ignored; `hooks.push` runs), and that a later `sassy-ship` run in `mode:auto` will then push to that base with no gate.
@@ -50,21 +51,23 @@ Both install the same way: report the scope if the pieces are present, otherwise
50
51
  **Do not wire updates.** How and when the suite is refreshed is the user's or the project's decision, not setup's: no `skills:*` scripts, no `postinstall` edit. Mention the update command for the chosen scope and stop there. Note for yourself that `npx skills check` is an alias of `update` — it is not a validator, and running it here would silently move the pin.
51
52
 
52
53
  - **Write `.sassywares/README.md`** from `assets/sassywares-readme.md` when absent. Never overwrite it — it may carry project notes.
54
+ - **Write the routing block into `AGENTS.md`.** It is the shipped `assets/agents-md.md`, written through `detect.sh --sync --write`, which renders the block's five `{{artifacts.*}}` placeholders — `strategy`, `concepts`, `plans`, `solutions`, `handbooks` — from the config step 4 wrote, never from the defaults the asset happens to carry. The file's own state picks the shape: no `AGENTS.md` means the whole template, and an `AGENTS.md` that already exists means the marked block alone — `<!-- sassywares:skills v1 -->` … — appended after its last line. The anchors are named whether or not they exist yet: the strategy route always appears, with `sassy-strategy` named as the command that writes one, because a route to a file that is not there yet is better than an agent that never learns the file exists. It is idempotent: an identical block is left alone and reported as already current. **Any difference is a diff and a question** — an older marker version, a hand-edited row, a block that no longer matches the config — run the sync without `--write` to see the action, show the diff, and write only on a yes; a no leaves every byte as it was, and any config fix then goes through `detect.sh --sync --write --no-agents`, which leaves the block untouched until the user asks for it. Only the bytes between the markers are ever written: the file's own lines are never rewritten, and `CLAUDE.md` and any per-harness agent file are never touched. In `workspace` topology the block goes to the root always and to a nested repo only where one already exists — read `references/workspace.md`; in `none` it lands at the root and is committed by nothing, by design.
53
55
  - **Agents.** The skills dispatch five subagents by name — `scout`, `worker`, `reviewer`, `simplifier`, `validator` — from [`sassy-agents`](https://github.com/sassywares/sassy-agents), which keeps one folder per harness. Use the row for the harness you are running in:
54
56
 
55
57
  | Harness | sassy-agents folder | User scope | Project scope |
56
58
  |---|---|---|---|
57
59
  | pi | `pi/` | `~/.pi/agent/agents/` | `.pi/agents/` |
58
60
  | Claude Code | `claude/` | `~/.claude/agents/` | `.claude/agents/` |
61
+ | Hermes Agent | `hermes/` | `~/.hermes/agents/` | — (user scope only) |
59
62
 
60
- A harness with no row has no folder in sassy-agents: say so, skip the agents, and name it in the report. Never translate another harness's folder by hand.
63
+ A harness with no row has no folder in sassy-agents: say so, skip the agents, and name it in the report. Never translate another harness's folder by hand. Hermes Agent has no project-scope agent directory, so its row has none: install user scope, or set `HERMES_AGENTS_DIR` when the roster lives somewhere else.
61
64
 
62
- **Installed** means all five `<name>.md` files exist in the user scope or the project scope.
65
+ **Installed** means all five `<name>.md` files exist in the user scope or the project scope — user scope alone where the harness has no project scope.
63
66
 
64
67
  - **User scope** — every project on this machine, updated by `git pull`. Reuse the user's sassy-agents checkout if they have one; otherwise ask where to clone it (`git clone https://github.com/sassywares/sassy-agents.git <dir>`). Then run `<dir>/scripts/install.sh <folder>`, which symlinks the folder into the user scope and never overwrites a differing file.
65
- - **Project scope** — only this project, pinned with it. Shallow-clone into its own `mktemp -d` under `/tmp/sassywares/scratch/` (two runs share that folder now, per `references/harness.md`), copy `<folder>/*.md` into the project scope directory, delete the clone. Never overwrite an existing agent file that differs: show it and ask. The copies join step 8's commit list.
68
+ - **Project scope** — only this project, pinned with it. Shallow-clone into its own `mktemp -d` under `/tmp/sassywares/scratch/` (two runs share that folder now, per `references/harness.md`), copy `<folder>/*.md` into the project scope directory, delete the clone. Never overwrite an existing agent file that differs: show it and ask. The copies join step 8's commit list. A harness with no project scope (Hermes Agent) gets no project install: user scope or nothing, said plainly in the report.
66
69
 
67
- - **Tell the user to `/reload`** (or restart the harness). The skills and agents are invisible to the harness until it rescans.
70
+ - **Tell the user the harness's reload step** — `/reload` in pi, a new session in Claude Code and Hermes Agent. A harness that has not rescanned does not see new or changed skills and agents.
68
71
 
69
72
  ## 6. Install the git tooling
70
73
 
@@ -98,7 +101,9 @@ Then return to `SKILL.md` for steps 7–9.
98
101
  | Approval to create a remote | Creating the mirror repo needs an explicit yes and a named slug first. |
99
102
  | Comments are part of the file | Every key keeps its description and allowed values. A stripped config is an incomplete config. |
100
103
  | Hooks are named, not written | Setup records hook skill names. Creating those skills is the project's work. |
104
+ | The block is never a rewrite | `AGENTS.md` gets the marked block and nothing else. An existing file's own lines are never touched, a differing block is shown as a diff and asked about, and `CLAUDE.md` is never written. |
101
105
  | Dogfood is a pointer | The block names a recipe, a reports path, a timeout, and whether Auto rows are allowed — four keys. Never a command and never a tool: a copied command duplicates the manifest and cannot express step order. |
106
+ | The strategy is offered, never authored | Setup names `sassy-strategy` and offers the interview. Every question, section, and status flip belongs to that skill's own run: a setup run that drafts a line has written an anchor nobody grilled. |
102
107
  | The recipe is the project's | Setup scaffolds the skeleton and stops. Authoring or "fixing" a procedure is `sassy-dogfood mode:discover`'s job, and a run may never edit the recipe to make its own failure pass. |
103
108
  | Worktrees need `new` | `worktrees.enabled: true` with `commit.branch: current` is refused, not written: nothing cuts a branch there, so the switch could never fire. |
104
109
  | Stubs are inert | The interview writes labelled comments in the scaffolding slots, never executable code: an untouched pair behaves exactly like the git-only baseline. |
@@ -38,6 +38,29 @@ lives under one directory:
38
38
  - Do **not** run the snapshot during setup. It clones and pushes; that is the
39
39
  user's call. Offer `--dry-run` and run it only if they ask.
40
40
 
41
+ ## The routing block
42
+
43
+ A workspace has one config, so it has one set of `artifacts.*` paths and one routing
44
+ block, and both belong to the root that holds `.sassywares/`. Render it from the
45
+ shipped `assets/agents-md.md` exactly as `references/init.md` step 5 says — resolved
46
+ paths, anchors named with the absent note, idempotent, a difference shown as a diff
47
+ and asked about. Where it goes is the one place a workspace differs:
48
+
49
+ - **The workspace root, always.** The root's `AGENTS.md` gets the block — the whole
50
+ template when there is none, the marked block appended when there is.
51
+ - **A nested repo, only when that repo already keeps an `AGENTS.md`.** The agent
52
+ working inside a repo reads that repo's file, not the root's, so a repo that has
53
+ one gets the same block appended. **Never invent an `AGENTS.md` in a repo that
54
+ never kept one**: a file created only to hold a block is a second document the
55
+ project maintains and the next reader has to explain, and a repo with none was
56
+ never an agent's entry point here.
57
+ - **The report names both lists** — the files written or appended, and the nested
58
+ repos skipped because they have no `AGENTS.md`. A skipped repo is not a gap.
59
+ - **Nothing is committed.** The root is not a repo, so the root block rides the next
60
+ `snapshot` with the rest of the glue. A nested repo's `AGENTS.md` is that repo's
61
+ own file: setup leaves it uncommitted, says so in the report, and never sweeps it
62
+ into a sync.
63
+
41
64
  ## Script aliases (optional)
42
65
 
43
66
  The scripts are executable and tracked, so the whole contract is the path itself:
@@ -14,9 +14,11 @@
14
14
  # detect.sh [--root DIR] --worktree-script MODE
15
15
  # print the absolute path of the create or
16
16
  # remove script a run executes
17
- # detect.sh [--root DIR] --sync [--write]
17
+ # detect.sh [--root DIR] --sync [--write] [--agents|--no-agents]
18
18
  # merge the existing config onto the template
19
19
  # and print it (or write it with --write)
20
+ # --agents syncs only the AGENTS.md block,
21
+ # --no-agents only the config
20
22
  #
21
23
  # --policy takes infer|current|new: the skill-level token. infer (the default)
22
24
  # defers to commit.branch in the config, and new is the fallback when the config
@@ -37,6 +39,10 @@
37
39
  # proposal. A malformed value is not accepted, so it comes from the proposal,
38
40
  # exactly as --check judges it. A dry run prints the merged file and writes
39
41
  # nothing.
42
+ # --sync owns two files: the config merge and the AGENTS.md routing block.
43
+ # --agents scopes it to the block, --no-agents to the config, so a run that
44
+ # declined one of the two diffs can fix the other with the same command. With
45
+ # neither flag it does both, exactly as before.
40
46
  set -euo pipefail
41
47
 
42
48
  ROOT_ARG=""
@@ -49,6 +55,8 @@ CHECK=0
49
55
  BRANCH=0
50
56
  SYNC=0
51
57
  SINGLE=0
58
+ AGENTS_ONLY=0
59
+ NO_AGENTS=0
52
60
 
53
61
  while (( $# )); do
54
62
  case "$1" in
@@ -68,6 +76,8 @@ while (( $# )); do
68
76
  --check) CHECK=1 ;;
69
77
  --sync) SYNC=1 ;;
70
78
  --write) SINGLE=1 ;;
79
+ --agents) AGENTS_ONLY=1 ;;
80
+ --no-agents) NO_AGENTS=1 ;;
71
81
  -h|--help) sed -n '2,/^set -euo pipefail/p' "${BASH_SOURCE[0]}" | sed '$d' | sed 's|^# \{0,1\}||'; exit 0 ;;
72
82
  *) echo "unknown argument: $1" >&2; exit 2 ;;
73
83
  esac
@@ -86,6 +96,12 @@ START="${ROOT_ARG:-$PWD}"
86
96
  # --write is read by --sync. Alone it would print the proposal and drop itself.
87
97
  (( ! SINGLE )) || (( SYNC )) \
88
98
  || { echo "--write is read with --sync; run them together" >&2; exit 2; }
99
+ # --agents and --no-agents name opposite halves of --sync: together they
100
+ # contradict, and alone they would print the proposal and drop themselves.
101
+ (( ! AGENTS_ONLY || ! NO_AGENTS )) \
102
+ || { echo "--agents and --no-agents are separate scopes; pick one" >&2; exit 2; }
103
+ (( ! AGENTS_ONLY && ! NO_AGENTS )) || (( SYNC )) \
104
+ || { echo "--agents and --no-agents are read with --sync; run them together" >&2; exit 2; }
89
105
  # --goal resolves hooks inside --check. Anywhere else the flag would print the
90
106
  # proposal and drop itself silently.
91
107
  (( CHECK )) || [[ -z "$GOAL_ARG" ]] || { echo "--goal is read with --check; run them together" >&2; exit 2; }
@@ -433,6 +449,13 @@ pick_artifact() {
433
449
  if path_exists "$candidate"; then printf '%s' "$candidate"; else printf '%s' "$fallback"; fi
434
450
  }
435
451
 
452
+ # The glossary moved under docs/. Prefer the new home, and fall back to a legacy
453
+ # root file only when that file already exists — an existing config is never
454
+ # migrated, and a project with neither file gets the new default.
455
+ pick_concepts() {
456
+ pick_artifact docs/concepts.md "$(pick_artifact CONCEPTS.md docs/concepts.md)"
457
+ }
458
+
436
459
  # wt_script_reason VALUE — succeeds with the reason when a `worktrees.create|remove`
437
460
  # value has the wrong shape, fails when it is usable. One path, relative to the
438
461
  # project, no arguments: the script is the lifecycle, so a command line here would
@@ -490,7 +513,195 @@ fi
490
513
  PLANS="$(pick_artifact docs/plans docs/plans)"
491
514
  SOLUTIONS="$(pick_artifact docs/solutions docs/solutions)"
492
515
  HANDBOOKS="$(pick_artifact docs/handbooks docs/handbooks)"
493
- CONCEPTS="$(pick_artifact CONCEPTS.md CONCEPTS.md)"
516
+ CONCEPTS="$(pick_concepts)"
517
+ STRATEGY="$(pick_artifact docs/strategy.md docs/strategy.md)"
518
+
519
+ # --- AGENTS.md routing block ----------------------------------------------
520
+ # One shipped file, assets/agents-md.md, used two ways: the whole file when the
521
+ # project has none, and the marked block appended to an existing one. The
522
+ # version lives in the markers, so a later shipped version can replace an older
523
+ # block by exact marker match. Placeholders are rendered from the resolved
524
+ # artifacts.* paths, never hardcoded here.
525
+ AGENTS_ASSET="$SKILL_DIR/assets/agents-md.md"
526
+ # The marker grammar in one place, valid as grep ERE, sed BRE, and awk ERE.
527
+ AGENTS_OPEN_RE='^<!-- sassywares:skills v[0-9][0-9]* -->$'
528
+ AGENTS_CLOSE_RE='^<!-- /sassywares:skills v[0-9][0-9]* -->$'
529
+
530
+ agents_md_open_no() { grep -n -E "$AGENTS_OPEN_RE" "$1" 2>/dev/null | head -n 1 | cut -d: -f1; }
531
+ agents_md_close_no() { grep -n -E "$AGENTS_CLOSE_RE" "$1" 2>/dev/null | head -n 1 | cut -d: -f1; }
532
+ agents_md_version() { sed -n 's/^<!-- sassywares:skills v\([0-9][0-9]*\) -->$/\1/p' "$1" 2>/dev/null | head -n 1; }
533
+ agents_md_shipped_version() { agents_md_version "$AGENTS_ASSET"; }
534
+ agents_md_close_version() { sed -n 's/^<!-- \/sassywares:skills v\([0-9][0-9]*\) -->$/\1/p' "$1" 2>/dev/null | head -n 1; }
535
+
536
+ # agents_md_artifact KEY DEFAULT — the configured path, else the default this
537
+ # detector already resolved. Relative to the project root, like every artifact.
538
+ agents_md_artifact() {
539
+ local v
540
+ v="$(block_value artifacts "$1" 2>/dev/null || true)"
541
+ [[ -n "$v" ]] || v="$2"
542
+ printf '%s' "${v#./}"
543
+ }
544
+
545
+ # The shipped block, rendered, on stdout.
546
+ agents_md_render() {
547
+ local strategy concepts plans solutions handbooks
548
+ strategy="$(agents_md_artifact strategy "$STRATEGY")"
549
+ concepts="$(agents_md_artifact concepts "$CONCEPTS")"
550
+ plans="$(agents_md_artifact plans "$PLANS")"
551
+ solutions="$(agents_md_artifact solutions "$SOLUTIONS")"
552
+ handbooks="$(agents_md_artifact handbooks "$HANDBOOKS")"
553
+ # Values go through the environment, not -v: awk's -v interprets escape
554
+ # sequences, so a configured path with a backslash would lose it.
555
+ SASSY_AGENTS_STRATEGY="$strategy" SASSY_AGENTS_CONCEPTS="$concepts" \
556
+ SASSY_AGENTS_PLANS="$plans" SASSY_AGENTS_SOLUTIONS="$solutions" \
557
+ SASSY_AGENTS_HANDBOOKS="$handbooks" \
558
+ awk -v openre="$AGENTS_OPEN_RE" -v closere="$AGENTS_CLOSE_RE" '
559
+ # Splice a value literally: no regex replacement, so an & or a backslash in
560
+ # a configured path survives. Scanning resumes past the inserted value, so a
561
+ # value that itself contains the placeholder cannot loop.
562
+ function put(line, ph, val, i, from) {
563
+ from = 1
564
+ while ((i = index(substr(line, from), ph)) > 0) {
565
+ i = from + i - 1
566
+ line = substr(line, 1, i-1) val substr(line, i+length(ph))
567
+ from = i + length(val)
568
+ }
569
+ return line
570
+ }
571
+ BEGIN {
572
+ strategy = ENVIRON["SASSY_AGENTS_STRATEGY"]
573
+ concepts = ENVIRON["SASSY_AGENTS_CONCEPTS"]
574
+ plans = ENVIRON["SASSY_AGENTS_PLANS"]
575
+ solutions = ENVIRON["SASSY_AGENTS_SOLUTIONS"]
576
+ handbooks = ENVIRON["SASSY_AGENTS_HANDBOOKS"]
577
+ }
578
+ $0 ~ openre { f = 1 }
579
+ f {
580
+ line = $0
581
+ line = put(line, "{{artifacts.strategy}}", strategy)
582
+ line = put(line, "{{artifacts.concepts}}", concepts)
583
+ line = put(line, "{{artifacts.plans}}", plans)
584
+ line = put(line, "{{artifacts.solutions}}", solutions)
585
+ line = put(line, "{{artifacts.handbooks}}", handbooks)
586
+ print line
587
+ }
588
+ f && $0 ~ closere { exit }' "$AGENTS_ASSET"
589
+ }
590
+
591
+ # agents_md_block FILE — the block exactly as it sits in FILE, on stdout.
592
+ agents_md_block() {
593
+ awk -v openre="$AGENTS_OPEN_RE" -v closere="$AGENTS_CLOSE_RE" '
594
+ $0 ~ openre { f = 1 }
595
+ f { print }
596
+ f && $0 ~ closere { exit }' "$1"
597
+ }
598
+
599
+ # agents_md_plan — what --sync --write would do to AGENTS.md:
600
+ # create | append | replace | current | newer | unterminated | mismatch | unreadable
601
+ agents_md_plan() {
602
+ local target="$ROOT/AGENTS.md" open_no close_no v cv shipped
603
+ shipped="$(agents_md_shipped_version)"
604
+ [[ -n "$shipped" ]] || { printf 'unreadable'; return; }
605
+ [[ -f "$target" ]] || { printf 'create'; return; }
606
+ open_no="$(agents_md_open_no "$target")"
607
+ [[ -n "$open_no" ]] || { printf 'append'; return; }
608
+ close_no="$(agents_md_close_no "$target")"
609
+ if [[ -z "$close_no" ]] || (( close_no < open_no )); then printf 'unterminated'; return; fi
610
+ v="$(agents_md_version "$target")"
611
+ cv="$(agents_md_close_version "$target")"
612
+ [[ -n "$v" && "$v" == "$cv" ]] || { printf 'mismatch'; return; }
613
+ if (( 10#$v < 10#$shipped )); then printf 'replace'; return; fi
614
+ if (( 10#$v > 10#$shipped )); then printf 'newer'; return; fi
615
+ if diff -q <(agents_md_block "$target") <(agents_md_render) >/dev/null 2>&1; then
616
+ printf 'current'
617
+ else
618
+ printf 'replace'
619
+ fi
620
+ }
621
+
622
+ # agents_md_write ACTION RENDERED — the block is the only region touched. The
623
+ # file is replaced through a temp in the project root, so a failure never leaves
624
+ # a half-written AGENTS.md.
625
+ agents_md_write() {
626
+ local action="$1" rendered="$2" target="$ROOT/AGENTS.md" tmp mode rendered_file
627
+ case "$target" in "$ROOT"/*) ;; *) echo "sync: refusing to write outside the project root: $target" >&2; return 1 ;; esac
628
+ tmp="$(mktemp "$ROOT/.AGENTS.md.XXXXXX")" || return 1
629
+ case "$action" in
630
+ create)
631
+ printf '%s\n' "$rendered" > "$tmp"
632
+ ;;
633
+ append)
634
+ cat "$target" > "$tmp"
635
+ # Every byte the file already carried is kept; only a separator is added.
636
+ if [[ -n "$(tail -c 1 "$target")" ]]; then printf '\n' >> "$tmp"; fi
637
+ printf '\n%s\n' "$rendered" >> "$tmp"
638
+ ;;
639
+ replace)
640
+ # The rendered block is passed as a file, not -v: awk's -v would try to
641
+ # interpret the block's newlines and backslashes as escapes.
642
+ rendered_file="$(mktemp "${TMPDIR:-/tmp}/sassy-agents-block.XXXXXX")" || { rm -f "$tmp"; return 1; }
643
+ printf '%s\n' "$rendered" > "$rendered_file"
644
+ if ! awk -v openre="$AGENTS_OPEN_RE" -v closere="$AGENTS_CLOSE_RE" -v replf="$rendered_file" '
645
+ FILENAME == replf { a[++n] = $0; next }
646
+ $0 ~ openre { for (i = 1; i <= n; i++) print a[i]; skip = 1; next }
647
+ skip && $0 ~ closere { skip = 0; next }
648
+ !skip { print }
649
+ ' "$rendered_file" "$target" > "$tmp"; then
650
+ rm -f "$tmp" "$rendered_file"; return 1
651
+ fi
652
+ rm -f "$rendered_file"
653
+ ;;
654
+ *) rm -f "$tmp"; return 1 ;;
655
+ esac
656
+ if [[ -f "$target" ]]; then
657
+ mode="$(stat -f '%Lp' "$target" 2>/dev/null || stat -c '%a' "$target" 2>/dev/null || true)"
658
+ [[ -z "$mode" ]] || chmod "$mode" "$tmp" 2>/dev/null || true
659
+ fi
660
+ mv "$tmp" "$target"
661
+ }
662
+
663
+ # agents_md_sync DRY — create, append, or replace the block; a second run is a
664
+ # no-op that says so. DRY 1 only reports what a write would do.
665
+ agents_md_sync() {
666
+ local dry="$1" action shipped v
667
+ action="$(agents_md_plan)"
668
+ shipped="$(agents_md_shipped_version)"
669
+ case "$action" in
670
+ create|append|replace)
671
+ if (( dry )); then
672
+ case "$action" in
673
+ create) echo "sync: AGENTS.md would be created with routing block v${shipped} — nothing written; rerun with --sync --write" >&2 ;;
674
+ append) echo "sync: AGENTS.md would get routing block v${shipped} appended — nothing written; rerun with --sync --write" >&2 ;;
675
+ replace) echo "sync: AGENTS.md routing block would be replaced with v${shipped} — nothing written; rerun with --sync --write" >&2 ;;
676
+ esac
677
+ return 0
678
+ fi
679
+ agents_md_write "$action" "$(agents_md_render)" || { echo "sync: could not write AGENTS.md" >&2; return 1; }
680
+ case "$action" in
681
+ create) echo "sync: wrote AGENTS.md (routing block v${shipped} created)" >&2 ;;
682
+ append) echo "sync: wrote AGENTS.md (routing block v${shipped} appended)" >&2 ;;
683
+ replace) echo "sync: wrote AGENTS.md (routing block replaced with v${shipped})" >&2 ;;
684
+ esac
685
+ ;;
686
+ current)
687
+ echo "sync: AGENTS.md is already current" >&2
688
+ ;;
689
+ newer)
690
+ v="$(agents_md_version "$ROOT/AGENTS.md")"
691
+ echo "sync: AGENTS.md routing block is v${v}, newer than this skill ships (v${shipped}) — left alone" >&2
692
+ ;;
693
+ unterminated)
694
+ echo "sync: AGENTS.md has an opening sassywares:skills marker with no matching closing marker — fix it by hand, nothing written" >&2
695
+ ;;
696
+ mismatch)
697
+ echo "sync: AGENTS.md routing block markers disagree on the version — fix it by hand, nothing written" >&2
698
+ ;;
699
+ *)
700
+ echo "sync: no routing-block asset found — AGENTS.md untouched" >&2
701
+ ;;
702
+ esac
703
+ return 0
704
+ }
494
705
 
495
706
  MIRROR_REMOTE=""
496
707
  MIRROR_BRANCH="main"
@@ -529,10 +740,12 @@ leaf_ok() { # PATH VALUE — PATH joined with US, value comment- and quote-strip
529
740
  local path="$1" v="$2" key kind rest pat point entry name
530
741
  key="${path//$US/.}"
531
742
  case "$key" in
532
- artifacts.plans|artifacts.solutions|artifacts.handbooks|artifacts.concepts)
743
+ artifacts.plans|artifacts.solutions|artifacts.handbooks|artifacts.concepts|artifacts.strategy)
533
744
  case "$v" in ""|/*|~*|.|./) return 1 ;; esac
534
745
  escapes_root "$v" && return 1
535
- [[ "$key" == "artifacts.concepts" && "$v" == */ ]] && return 1
746
+ case "$key" in
747
+ artifacts.concepts|artifacts.strategy) [[ "$v" == */ ]] && return 1 ;;
748
+ esac
536
749
  return 0 ;;
537
750
  knowledge.read)
538
751
  case "$v" in \[*\]) ;; *) return 1 ;; esac
@@ -855,8 +1068,9 @@ artifacts:
855
1068
  EOF
856
1069
  kv plans "$PLANS" 34 '# sassy-plan writes plans here'
857
1070
  kv solutions "$SOLUTIONS" 34 '# sassy-compound writes learnings here'
858
- kv handbooks "$HANDBOOKS" 34 '# sassy-handbook writes handovers here'
1071
+ kv handbooks "$HANDBOOKS" 34 '# sassy-docs writes handbooks here'
859
1072
  kv concepts "$CONCEPTS" 34 '# the glossary sassy-compound maintains (a file)'
1073
+ kv strategy "$STRATEGY" 34 '# the direction sassy-strategy writes (a file)'
860
1074
  cat <<EOF
861
1075
 
862
1076
  # --- Knowledge ------------------------------------------------------------
@@ -1102,7 +1316,7 @@ if (( CHECK )); then
1102
1316
  [[ -n "$kpath" ]] || continue
1103
1317
  key="${kpath//$US/.}"
1104
1318
  case "$key" in
1105
- artifacts.plans|artifacts.solutions|artifacts.handbooks|artifacts.concepts) ;;
1319
+ artifacts.plans|artifacts.solutions|artifacts.handbooks|artifacts.concepts|artifacts.strategy) ;;
1106
1320
  knowledge.read|knowledge.write) ;;
1107
1321
  git.repo|git.remote|git.mirror_branch) ;;
1108
1322
  git.default_branch) ;; # has its own message below
@@ -1375,7 +1589,7 @@ if (( CHECK )); then
1375
1589
  # artifacts is the one block that fails closed everywhere it is read, so a
1376
1590
  # bad value here is drift, not a note: a typo must not write docs outside the
1377
1591
  # project. Existence is not drift — the directory is created on first write.
1378
- for key in plans solutions handbooks concepts; do
1592
+ for key in plans solutions handbooks concepts strategy; do
1379
1593
  val="$(block_value artifacts "$key" || true)"
1380
1594
  [[ -n "$val" ]] || continue
1381
1595
  case "$val" in
@@ -1384,8 +1598,8 @@ if (( CHECK )); then
1384
1598
  *)
1385
1599
  if escapes_root "$val"; then
1386
1600
  bad "artifacts.$key '$val' walks outside the project"
1387
- elif [[ "$key" == "concepts" && "$val" == */ ]]; then
1388
- bad "artifacts.concepts '$val' is a directory — concepts is one file"
1601
+ elif [[ "$val" == */ ]] && [[ "$key" == concepts || "$key" == strategy ]]; then
1602
+ bad "artifacts.$key '$val' is a directory — $key is one file (default docs/$key.md)"
1389
1603
  elif path_exists "$val"; then
1390
1604
  note " artifacts.$key: $val (exists)"
1391
1605
  else
@@ -1399,7 +1613,7 @@ if (( CHECK )); then
1399
1613
  # broken value has to be visible here: nothing else will ever complain.
1400
1614
  while IFS= read -r kline; do
1401
1615
  [[ -n "$kline" ]] || continue
1402
- bad "knowledge.read must be an inline list — write read: [docs/solutions, CONCEPTS.md]"
1616
+ bad "knowledge.read must be an inline list — write read: [docs/solutions, docs/concepts.md]"
1403
1617
  done < <(sed -n '/^knowledge:/,/^[a-z]/p' "$CONFIG" | grep -E '^[[:space:]]*-[[:space:]]' || true)
1404
1618
  readv="$(yflat "knowledge${US}read" || true)"
1405
1619
  while IFS= read -r kpath; do
@@ -1673,6 +1887,34 @@ if (( CHECK )); then
1673
1887
  fi
1674
1888
  fi
1675
1889
 
1890
+ # The routing block: AGENTS.md is what an agent reads before any skill is
1891
+ # invoked. A missing or stale block is a note, never drift — the config is
1892
+ # complete without it, and --sync --write is the updater.
1893
+ shipped_agents="$(agents_md_shipped_version)"
1894
+ case "$(agents_md_plan)" in
1895
+ create)
1896
+ note " agents-md: AGENTS.md is missing — --sync --write would create it with routing block v${shipped_agents}" ;;
1897
+ append)
1898
+ note " agents-md: AGENTS.md has no routing block — --sync --write would append v${shipped_agents}" ;;
1899
+ replace)
1900
+ agents_v="$(agents_md_version "$ROOT/AGENTS.md")"
1901
+ if [[ "$agents_v" == "$shipped_agents" ]]; then
1902
+ note " agents-md: routing block v${agents_v} differs from this skill's copy — --sync --write replaces it in place"
1903
+ else
1904
+ note " agents-md: routing block is v${agents_v}, this skill ships v${shipped_agents} — --sync --write replaces it in place"
1905
+ fi ;;
1906
+ current)
1907
+ note " agents-md: routing block v${shipped_agents}" ;;
1908
+ newer)
1909
+ note " agents-md: routing block is v$(agents_md_version "$ROOT/AGENTS.md"), newer than this skill ships (v${shipped_agents}) — left alone" ;;
1910
+ unterminated)
1911
+ note " agents-md: AGENTS.md has an opening sassywares:skills marker with no matching closing marker — fix it by hand" ;;
1912
+ mismatch)
1913
+ note " agents-md: AGENTS.md routing block markers disagree on the version — fix it by hand" ;;
1914
+ *)
1915
+ note " agents-md: routing-block asset not found — AGENTS.md unchecked" ;;
1916
+ esac
1917
+
1676
1918
  if (( drift )); then exit 1; fi
1677
1919
  note " config matches the tree"
1678
1920
  exit 0
@@ -1882,27 +2124,36 @@ fi
1882
2124
  # says so.
1883
2125
  if (( SYNC )); then
1884
2126
  [[ -n "$CONFIG" ]] || { echo "no .sassywares/config.yaml found — run sassy-setup" >&2; exit 1; }
1885
- merged="$(merged_config)"
1886
- current="$(cat "$CONFIG")"
1887
- if [[ "$merged" == "$current" ]]; then
1888
- (( SINGLE )) || printf '%s\n' "$merged"
1889
- echo "sync: $CONFIG is already current" >&2
1890
- exit 0
1891
- fi
1892
- before="$(mktemp "${TMPDIR:-/tmp}/sassy-sync-before.XXXXXX")"
1893
- after="$(mktemp "${TMPDIR:-/tmp}/sassy-sync-after.XXXXXX")"
1894
- printf '%s\n' "$current" > "$before"
1895
- printf '%s\n' "$merged" > "$after"
1896
- changed="$(diff -u "$before" "$after" 2>/dev/null | awk '/^\+[^+]|^-[^-]/{n++} END{print n+0}' || true)"
1897
- rm -f "$before" "$after"
1898
- if (( SINGLE )); then
1899
- printf '%s\n' "$merged" > "$CONFIG"
1900
- echo "sync: wrote $CONFIG ($changed line(s) changed)" >&2
1901
- else
1902
- printf '%s\n' "$merged"
1903
- echo "sync: $CONFIG would change ($changed line(s)) — nothing written; rerun with --sync --write" >&2
2127
+ # --agents scopes the run to AGENTS.md: the config merge is skipped, not printed.
2128
+ if (( ! AGENTS_ONLY )); then
2129
+ merged="$(merged_config)"
2130
+ current="$(cat "$CONFIG")"
2131
+ if [[ "$merged" == "$current" ]]; then
2132
+ (( SINGLE )) || printf '%s\n' "$merged"
2133
+ echo "sync: $CONFIG is already current" >&2
2134
+ else
2135
+ before="$(mktemp "${TMPDIR:-/tmp}/sassy-sync-before.XXXXXX")"
2136
+ after="$(mktemp "${TMPDIR:-/tmp}/sassy-sync-after.XXXXXX")"
2137
+ printf '%s\n' "$current" > "$before"
2138
+ printf '%s\n' "$merged" > "$after"
2139
+ changed="$(diff -u "$before" "$after" 2>/dev/null | awk '/^\+[^+]|^-[^-]/{n++} END{print n+0}' || true)"
2140
+ rm -f "$before" "$after"
2141
+ if (( SINGLE )); then
2142
+ printf '%s\n' "$merged" > "$CONFIG"
2143
+ echo "sync: wrote $CONFIG ($changed line(s) changed)" >&2
2144
+ else
2145
+ printf '%s\n' "$merged"
2146
+ echo "sync: $CONFIG would change ($changed line(s)) — nothing written; rerun with --sync --write" >&2
2147
+ fi
2148
+ fi
1904
2149
  fi
1905
- exit 0
2150
+ # AGENTS.md is the second thing --sync owns. Its block is independent of the
2151
+ # config merge, so a run whose config is already current still refreshes it,
2152
+ # and an untouched project is a no-op that says so.
2153
+ if (( NO_AGENTS )); then
2154
+ echo "sync: AGENTS.md untouched (--no-agents)" >&2
2155
+ elif (( SINGLE )); then agents_md_sync 0; else agents_md_sync 1; fi
2156
+ exit $?
1906
2157
  fi
1907
2158
 
1908
2159
  emit_proposal