@sassywares/skills 0.13.0 → 0.13.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.
package/CONCEPTS.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  The repo's `skills/` directory is the only copy of the skills. Consumers install from it with `npx skills add sassywares/sassy-skills` — per project, which vendors the files and pins content hashes in `skills-lock.json`, or globally with `-g`, into `~/.agents/skills/`. See README.md's Installation section.
6
6
 
7
+ ## Consumer project
8
+
9
+ A project that installs the suite per project, so it vendors its own copy in `.agents/skills/` and pins it in `skills-lock.json`. It does not get the maintainer's `~/.agents/skills` link, so a push to this repo reaches it only through the `sassy-skills-sync` hook, which mirrors exactly the suite's roster, repins those skills, commits, and pushes to the branch recorded in `.sassywares/consumers`. Its setup is never auto-updated: the sync reports that it is out of date, and which project.
10
+
7
11
  ## Skill
8
12
 
9
13
  A directory containing `SKILL.md`, discovered by a harness from a project skills directory, a user skills directory, or an installed package. Skills are explicit workflows, not always-on instructions. The model may invoke any of them, and the user can invoke one directly through their harness (the `sassy-setup` skill's `references/harness.md` lists each harness's command).
package/README.md CHANGED
@@ -131,7 +131,7 @@ Each does one job and takes `mode:manual` (default: ask which to fix), `mode:aut
131
131
  | Skill | What it does |
132
132
  |---|---|
133
133
  | **`sassy-skill`** | Creates, retunes, or restructures Agent Skills. |
134
- | **`sassy-setup`** | Detects the project topology and writes `.sassywares/config.yaml`; installs the suite and the sassy-agents subagents, globally or per project, when missing; installs the snapshot tooling for a multi-repo workspace; commits the files it wrote. `mode:check` verifies an existing setup, including a project install's pin. |
134
+ | **`sassy-setup`** | Detects the project topology and writes `.sassywares/config.yaml`; installs the suite and the sassy-agents subagents, globally or per project, when missing; installs the snapshot tooling for a multi-repo workspace; commits the files it wrote. `mode:check` verifies an existing setup, including a project install's pin, and reports a config that has fallen behind the shipped template with the `--sync --write` merge that closes it. |
135
135
 
136
136
  ## Project config
137
137
 
@@ -499,4 +499,4 @@ pi install npm:@sassywares/skills
499
499
 
500
500
  ## Repository maintenance
501
501
 
502
- Work here lands on `main` through `sassy-ship` (`commit.branch: current`). After the approved push, the project's `hooks.push` `after_push` step runs the release: on `main`, when files consumers receive changed, it bumps the patch version and tags it, and the tag publishes `@sassywares/skills` to npm. [`AGENTS.md`](AGENTS.md) is the full guide: layout, adding a skill, testing, and releasing.
502
+ Work here lands on `main` through `sassy-ship` (`commit.branch: current`). After the approved push, the project's `hooks.push` `after_push` steps run in order: the release, which on `main`, when files consumers receive changed, bumps the patch version and tags it, and the tag publishes `@sassywares/skills` to npm; a self-check that syncs this repo's own config template; and a consumer sync that refreshes the projects listed in `.sassywares/consumers` — projects that vendor the suite themselves, committing and pushing to each one's recorded branch (the engine is `.agents/skills/sassy-skills-sync/scripts/sync`, with `scripts/lock.mjs` repinning the vendored skills). A consumer's setup is never rewritten: an out-of-date one is reported and nothing else. [`AGENTS.md`](AGENTS.md) is the full guide: layout, adding a skill, testing, and releasing.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sassywares/skills",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "Lean, explicit-invocation Agent Skills for shipping fast: plan, work, review, validate, ship.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -35,7 +35,12 @@ A check run never edits the config and never rewrites the tree. Its only possibl
35
35
 
36
36
  ## Steps 7–9 — shared by both modes
37
37
 
38
- 7. **Verify.** Run `scripts/detect.sh --root <path> --check`. It validates the config against the tree — topology and remotes, `base_map` shape and cycles, `repos` against each nested repo, hooks, artifacts paths, `knowledge`, `pr.*` booleans, `commit.branch`, the `worktrees` block, the removed legacy keys `up`, `down`, and `hooks.worktree` (a named error each), the `dogfood` block, any unknown key, and in `workspace` mode the installed snapshot's version — plus, for a project-scope install, the pin: every suite-skill folder in `.agents/skills` (a name in the suite's roster, `assets/roster` in sassy-setup, not any `sassy-` prefix) hashed against `skills-lock.json`, the lock's coverage both ways, and whether git carries the lock. A user-scope install has no pin here; the check notes the scope it found. Report every `drift:` line verbatim, or that the config matches the tree. Drift blocks step 8.
38
+ 7. **Verify.** Run `scripts/detect.sh --root <path> --check`. It validates the config against the tree — topology and remotes, `base_map` shape and cycles, `repos` against each nested repo, hooks, artifacts paths, `knowledge`, `pr.*` booleans, `commit.branch`, the `worktrees` block, the removed legacy keys `up`, `down`, and `hooks.worktree` (a named error each), the `dogfood` block, any unknown key, and in `workspace` mode the installed snapshot's version — plus, for a project-scope install, the pin: every suite-skill folder in `.agents/skills` (a name in the suite's roster, `assets/roster` in sassy-setup, not any `sassy-` prefix) hashed against `skills-lock.json`, the lock's coverage both ways, and whether git carries the lock. A user-scope install has no pin here; the check notes the scope it found. Report every `drift:` line verbatim, or that the config matches the tree. A
39
+ passing check can still print a `template:` note: the config matches the tree
40
+ but is behind the shipped template — blocks, comment layers, or examples it
41
+ lacks. Report it as a note, not drift, and name `--sync --write` as its fix: it
42
+ merges the template onto the file and keeps every value the check accepts,
43
+ comment and all. Drift blocks step 8.
39
44
 
40
45
  The `worktrees` half checks what a run would read: the switch, that the tooling is installed with the shipped bytes, that no checkout sits inside the working tree, and that none holds a branch `base_map` names as a base.
41
46
 
@@ -72,7 +77,7 @@ A check run never edits the config and never rewrites the tree. Its only possibl
72
77
  | Run output and sessions never ship | `.sassywares/.gitignore` holds `/session/` and `/dogfood/reports/`. Never remove a line, never add anything from either path to the commit, and never write a credential anywhere else. |
73
78
  | No secrets in setup's writes | Env var names only, in the config and in the skeleton. A credential never lands in a file setup commits. |
74
79
  | Version is reported | Setup names the snapshot and `workspace-git` versions it installed; `--check` flags an installed copy older than the skill's. |
75
- | Repair is `init` | `check` reports drift and never rewrites; closing it is `mode:init`, where every change is shown and approved first. |
80
+ | Repair is `init` | `check` reports drift and never rewrites; closing it is `mode:init`, where every change is shown and approved first. Template drift is the one stated exception: the check names `--sync --write`, and only the operator runs it. |
76
81
 
77
82
  ## What setup is not
78
83
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Read the shared sections in `SKILL.md` first, including steps 7–9. This file is only what a check run does differently: it enters at step 7 and never runs steps 1–6.
4
4
 
5
- 1. **Enter at step 7.** No detection, no questions, no config write: a folder that is already wired is verified, never rebuilt from detection. Run `scripts/detect.sh --root <path> --check` exactly as step 7 says, and report every `drift:` line verbatim, or that the config matches the tree.
5
+ 1. **Enter at step 7.** No detection, no questions, no config write: a folder that is already wired is verified, never rebuilt from detection. Run `scripts/detect.sh --root <path> --check` exactly as step 7 says, and report every `drift:` line verbatim, or that the config matches the tree — plus any `template:` note, which is not drift (see below).
6
6
  2. **Report the scope you found.** Check the skills and the agents exactly as step 5's **Installed** rules say, and report the scope each was found in or what is missing. **Check installs nothing** — a missing suite or roster is reported with the fix, and it does not block step 8.
7
7
  3. **Commit only dirty setup-owned files.** Step 8 applies only when something setup already owns is uncommitted — an edited config, a scaffold nobody committed, a pin that drifted — and only when step 7 is clean. Nothing dirty, nothing to commit.
8
8
  4. **Report as step 9 says,** then name what closes each finding: the drift line, the missing scope, and the mode that fixes it.
@@ -11,9 +11,30 @@ A check run never edits the config, never installs a skill or an agent, never re
11
11
 
12
12
  | Rule | Requirement |
13
13
  |------|-------------|
14
- | Check reports, init repairs | Every finding is reported with `mode:init` as its fix. Nothing is corrected in place, approved or not. |
14
+ | Check reports, init repairs | Every finding is reported with `mode:init` as its fix, except the template note, whose fix is the explicit `--sync --write` merge. Nothing is corrected in place, approved or not. |
15
15
  | No detection | A check compares the file to the tree; it never re-derives the config from the tree and calls the difference drift. |
16
16
 
17
+ ## What the template note means
18
+
19
+ A config can match the tree and still be behind the shipped template: a block, a
20
+ key, a comment layer, or a commented example that a later version added is
21
+ missing, so the next reader gets a thinner file than [`config.md`](config.md)
22
+ documents. `--check` prints it as a note — `template: --sync --write would add
23
+ worktrees, dogfood and refresh the comments (values the check accepts stay)` —
24
+ and still exits 0. It is never drift: every value the file declares is valid.
25
+
26
+ The fix is `bash scripts/detect.sh --root <path> --sync --write`, which merges
27
+ the template onto the file. It keeps the line of every leaf the check accepts —
28
+ value and same-line trailing comment, byte for byte — so a project's
29
+ `"*": main # confirmed: …` stays exactly as written, and takes every block,
30
+ key, comment, and example the file lacks from the proposal. A malformed value is
31
+ not accepted, so it is replaced, the same judgement the check makes. Without
32
+ `--write` it is a dry run that prints the merged file and writes nothing; a
33
+ second run reports `already current` and touches nothing.
34
+
35
+ Report the note and the command; run the sync only when the user asks, the same
36
+ as every other repair.
37
+
17
38
  ## What a worktree finding means
18
39
 
19
40
  `worktrees.create` and `worktrees.remove` are the project's own files, so a check
@@ -614,3 +614,11 @@ the lock is reported. Both lock eras count: the definition named by the lock's
614
614
  or half-installed suite is drift even when the config itself matches the tree. A
615
615
  user-scope install (`~/.agents/skills/`) has no pin to verify; the check notes
616
616
  it, and a suite found in neither scope is noted, not drift.
617
+
618
+ A config that passes every rule can still be behind this template — a missing
619
+ block, key, comment layer, or example — and the check says so in a `template:`
620
+ note, never as drift; [`check.md`](check.md) has the outcomes. The merge that
621
+ closes it is `detect.sh --root <path> --sync --write`: it keeps every leaf the
622
+ check accepts, value and same-line trailing comment byte for byte, and takes the
623
+ rest from the template, so a comment carries the project's confirmation forward
624
+ and a malformed value is replaced.
@@ -14,6 +14,9 @@
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]
18
+ # merge the existing config onto the template
19
+ # and print it (or write it with --write)
17
20
  #
18
21
  # --policy takes infer|current|new: the skill-level token. infer (the default)
19
22
  # defers to commit.branch in the config, and new is the fallback when the config
@@ -27,6 +30,13 @@
27
30
  # built-in .sassywares/worktree/<mode>. A declared path that is gone warns on
28
31
  # stderr and falls back; an absent key falls back silently. It never writes and
29
32
  # never creates a directory, so it answers even before setup has installed one.
33
+ # --sync is the one mode that writes. It starts from the same proposal the
34
+ # default mode prints, then keeps every line the current file declares and
35
+ # --check accepts — value and same-line trailing comment, byte for byte — and
36
+ # takes every block, key, comment layer, and example the file lacks from the
37
+ # proposal. A malformed value is not accepted, so it comes from the proposal,
38
+ # exactly as --check judges it. A dry run prints the merged file and writes
39
+ # nothing.
30
40
  set -euo pipefail
31
41
 
32
42
  ROOT_ARG=""
@@ -37,6 +47,8 @@ NAME_ARG=""
37
47
  WT_SCRIPT=""
38
48
  CHECK=0
39
49
  BRANCH=0
50
+ SYNC=0
51
+ SINGLE=0
40
52
 
41
53
  while (( $# )); do
42
54
  case "$1" in
@@ -54,6 +66,8 @@ while (( $# )); do
54
66
  --worktree-script=*) WT_SCRIPT="${1#*=}" ;;
55
67
  --branch) BRANCH=1 ;;
56
68
  --check) CHECK=1 ;;
69
+ --sync) SYNC=1 ;;
70
+ --write) SINGLE=1 ;;
57
71
  -h|--help) sed -n '2,/^set -euo pipefail/p' "${BASH_SOURCE[0]}" | sed '$d' | sed 's|^# \{0,1\}||'; exit 0 ;;
58
72
  *) echo "unknown argument: $1" >&2; exit 2 ;;
59
73
  esac
@@ -65,6 +79,13 @@ START="${ROOT_ARG:-$PWD}"
65
79
  # --branch prints a decision; --check validates a config. One at a time, or the
66
80
  # second is silently ignored.
67
81
  (( BRANCH && CHECK )) && { echo "--branch and --check are separate modes; run them one at a time" >&2; exit 2; }
82
+ # --sync computes the proposal too, so the default print, --check, and --branch
83
+ # would each silently drop it.
84
+ (( ! SYNC )) || (( ! CHECK && ! BRANCH )) \
85
+ || { echo "--sync is a mode of its own; run it apart from --check and --branch" >&2; exit 2; }
86
+ # --write is read by --sync. Alone it would print the proposal and drop itself.
87
+ (( ! SINGLE )) || (( SYNC )) \
88
+ || { echo "--write is read with --sync; run them together" >&2; exit 2; }
68
89
  # --goal resolves hooks inside --check. Anywhere else the flag would print the
69
90
  # proposal and drop itself silently.
70
91
  (( CHECK )) || [[ -z "$GOAL_ARG" ]] || { echo "--goal is read with --check; run them together" >&2; exit 2; }
@@ -73,8 +94,8 @@ START="${ROOT_ARG:-$PWD}"
73
94
  (( CHECK || BRANCH )) || [[ -z "$HEAD_ARG" ]] || { echo "--head is read with --check or --branch; run them together" >&2; exit 2; }
74
95
  # --worktree-script prints one path and returns before either mode, so without
75
96
  # this guard `--check --worktree-script create` would silently skip the check.
76
- [[ -z "$WT_SCRIPT" ]] || (( ! CHECK && ! BRANCH )) \
77
- || { echo "--worktree-script is a mode of its own; run it apart from --check and --branch" >&2; exit 2; }
97
+ [[ -z "$WT_SCRIPT" ]] || (( ! CHECK && ! BRANCH && ! SYNC )) \
98
+ || { echo "--worktree-script is a mode of its own; run it apart from --check, --branch, and --sync" >&2; exit 2; }
78
99
  # Absolute, or the walk-up loop below re-reads "." forever.
79
100
  START="$(cd "$START" && pwd -P)"
80
101
 
@@ -480,8 +501,10 @@ case "$TOPOLOGY" in
480
501
  repo)
481
502
  REPO_NAME="$(remote_name "$ROOT")"
482
503
  REPO_NAME="${REPO_NAME:-origin}"
483
- # A check run reads the base from the config; probing costs a network call.
484
- (( CHECK )) || DEFAULT_BRANCH="$(detect_base "$ROOT")"
504
+ # A check or sync run reads the base from the config; probing costs a
505
+ # network call. A sync keeps the file's base when it has a valid one and
506
+ # leaves the placeholder when it does not, for a human to confirm.
507
+ (( CHECK || SYNC )) || DEFAULT_BRANCH="$(detect_base "$ROOT")"
485
508
  ;;
486
509
  workspace)
487
510
  MIRROR_REMOTE="$(config_value remote 2>/dev/null || true)"
@@ -490,6 +513,529 @@ case "$TOPOLOGY" in
490
513
  ;;
491
514
  esac
492
515
 
516
+ # --- Template merge -------------------------------------------------------
517
+ # --sync starts from the proposal the default mode prints (emit_proposal) and
518
+ # merges the existing file onto it: a leaf the file declares and this check
519
+ # accepts keeps its line — value and same-line trailing comment — exactly as
520
+ # written, and every block, key, comment layer, and example the file lacks comes
521
+ # from the proposal. A value --check reports as drift is not accepted, so it is
522
+ # replaced by the proposal's, the same judgement --check makes.
523
+ #
524
+ # "Value --check accepts" is one predicate, leaf_ok, over the schema in
525
+ # references/config.md. It deliberately validates only the value, never its
526
+ # context: a `worktrees.enabled: true` with no tooling installed is a valid value
527
+ # in a wrong state, so the sync keeps it and the check keeps reporting it.
528
+ leaf_ok() { # PATH VALUE — PATH joined with US, value comment- and quote-stripped
529
+ local path="$1" v="$2" key kind rest pat point entry name
530
+ key="${path//$US/.}"
531
+ case "$key" in
532
+ artifacts.plans|artifacts.solutions|artifacts.handbooks|artifacts.concepts)
533
+ case "$v" in ""|/*|~*|.|./) return 1 ;; esac
534
+ escapes_root "$v" && return 1
535
+ [[ "$key" == "artifacts.concepts" && "$v" == */ ]] && return 1
536
+ return 0 ;;
537
+ knowledge.read)
538
+ case "$v" in \[*\]) ;; *) return 1 ;; esac
539
+ while IFS= read -r entry; do
540
+ [[ -n "$entry" ]] || continue
541
+ case "$entry" in /*|~*) return 1 ;; esac
542
+ escapes_root "$entry" && return 1
543
+ done < <(list_items "$v")
544
+ return 0 ;;
545
+ knowledge.write|pr.babysit|pr.merge|pr.delete_branch|dogfood.enabled|worktrees.enabled)
546
+ [[ "$v" == "true" || "$v" == "false" ]] ;;
547
+ git.repo)
548
+ if [[ "$TOPOLOGY" == "repo" ]]; then
549
+ case "$v" in ""|workspace|none) return 1 ;; esac
550
+ git -C "$ROOT" remote 2>/dev/null | grep -qx "$v"
551
+ else
552
+ [[ "$v" == "workspace" || "$v" == "none" ]]
553
+ fi ;;
554
+ git.remote|git.mirror_branch)
555
+ [[ "$TOPOLOGY" != "repo" && -n "$v" ]] ;;
556
+ git.base_map.*)
557
+ pat="${key#git.base_map.}"
558
+ case "$pat" in
559
+ *"*") [[ "$pat" == "*" || ( -n "${pat%\*}" && "${pat%\*}" != *"*" ) ]] || return 1 ;;
560
+ esac
561
+ return 0 ;;
562
+ repos.*)
563
+ [[ "$TOPOLOGY" != "repo" ]] ;;
564
+ commit.branch)
565
+ [[ "$v" == "current" || "$v" == "new" ]] ;;
566
+ dogfood.timeout)
567
+ [[ "$v" =~ ^[1-9][0-9]*$ ]] ;;
568
+ dogfood.recipe|dogfood.reports)
569
+ case "$v" in ""|/*|~*|.|./) return 1 ;; esac
570
+ escapes_root "$v" && return 1
571
+ return 0 ;;
572
+ worktrees.dir)
573
+ [[ -n "$v" ]] ;;
574
+ worktrees.create|worktrees.remove)
575
+ ! wt_script_reason "$v" >/dev/null ;;
576
+ hooks.*)
577
+ kind="${key#hooks.}"; kind="${kind%%.*}"
578
+ case "$kind" in pr|push|goal) ;; *) return 1 ;; esac
579
+ rest="${key#hooks.}"; rest="${rest#*.}"
580
+ point="${rest##*.}"
581
+ pat="${rest%.*}"
582
+ case " $(hook_points "$kind") " in *" $point "*) ;; *) return 1 ;; esac
583
+ case "$pat" in
584
+ *"*") [[ "$pat" == "*" || ( -n "${pat%\*}" && "${pat%\*}" != *"*" ) ]] || return 1 ;;
585
+ esac
586
+ while IFS= read -r entry; do
587
+ [[ -n "$entry" ]] || continue
588
+ name="${entry%% *}"
589
+ is_suite_skill "$name" && return 1
590
+ hook_skill_path "$name" >/dev/null 2>&1 || return 1
591
+ done < <(list_items "$v")
592
+ return 0 ;;
593
+ *)
594
+ return 1 ;;
595
+ esac
596
+ }
597
+
598
+ # One parser, two readers: the flat path stack is the same shape yaml_flat
599
+ # builds, so a line can be matched to the current file and to the proposal.
600
+ LEAF_AWK='function trim(s) { sub(/^[ \t]+/, "", s); sub(/[ \t]+$/, "", s); return s }
601
+ function ind(s, m) { m = match(s, /^ */); return m ? RLENGTH : 0 }
602
+ {
603
+ raw = $0
604
+ body0 = trim(raw)
605
+ if (body0 == "" || substr(body0, 1, 1) == "#") next
606
+ line = raw; sub(/#.*$/, "", line)
607
+ d = ind(line); body = trim(line)
608
+ if (body ~ /:$/) {
609
+ k = body; sub(/:$/, "", k); gsub(/"/, "", k)
610
+ while (sp > 0 && sd[sp] >= d) sp--
611
+ sd[++sp] = d; sk[sp] = k
612
+ next
613
+ }
614
+ k = body; sub(/:.*/, "", k); gsub(/"/, "", k)
615
+ while (sp > 0 && sd[sp] >= d) sp--
616
+ p = ""
617
+ for (i = 1; i <= sp; i++) p = p (p == "" ? "" : us) sk[i]
618
+ print p (p == "" ? "" : us) k "\t" raw
619
+ }'
620
+
621
+ # The merge. Records are `kind <TAB> depth <TAB> path <TAB> raw`; a commented
622
+ # example is a record too, with the depth its `#` markers would have if removed
623
+ # (the hash characters themselves add no depth, the spaces after them do), so
624
+ # `# push:` under `hooks:` is known to be the posited `hooks.push` block. When the
625
+ # file declares a valid leaf under such an example, the example is replaced by
626
+ # the file's own active block, verbatim — the one case where a commented example
627
+ # in the proposal is not an example for this project.
628
+ MERGE_AWK='function trim(s) { sub(/^[ \t]+/, "", s); sub(/[ \t]+$/, "", s); return s }
629
+ function ind(s, m) { m = match(s, /^ */); return m ? RLENGTH : 0 }
630
+ function joinall( p, i) { p = ""; for (i = 1; i <= sp; i++) p = p (p == "" ? "" : us) sk[i]; return p }
631
+ function dopop(d) { while (sp > 0 && sd[sp] >= d) sp-- }
632
+ function outf(r, p) { o++; oraw[o] = r; okind[o] = ""; opath[o] = p }
633
+ function outfk(r, d, p) { o++; oraw[o] = r; okind[o] = "key"; odepth[o] = d; opath[o] = p }
634
+ function outfl(r, d, p) { o++; oraw[o] = r; okind[o] = "leaf"; odepth[o] = d; opath[o] = p }
635
+ function under_accepted(P, a) {
636
+ for (a = 1; a <= na; a++) if (index(aorder[a], P us) == 1) return 1
637
+ return 0
638
+ }
639
+ function emit_acc(P, d) { o++; oraw[o] = acc[P]; okind[o] = "leaf"; odepth[o] = d; opath[o] = P; emitted[P] = 1 }
640
+ function emit_block(P, i, j, e, a) {
641
+ b0 = 0
642
+ for (i = 1; i <= cn; i++) if (ckind[i] == "key" && cpath[i] == P) { b0 = i; break }
643
+ if (b0 == 0) { warn[++nw] = P; return }
644
+ e = b0
645
+ for (j = b0 + 1; j <= cn; j++) {
646
+ if (ckind[j] == "blank") continue
647
+ if (cdepth[j] > cdepth[b0]) { e = j; continue }
648
+ break
649
+ }
650
+ for (j = b0; j <= e; j++) {
651
+ if (ckind[j] == "key") outfk(crawl[j], cdepth[j], cpath[j])
652
+ else if (ckind[j] == "leaf") outfl(crawl[j], cdepth[j], cpath[j])
653
+ else outf(crawl[j])
654
+ }
655
+ for (a = 1; a <= na; a++) if (index(aorder[a], P us) == 1) emitted[aorder[a]] = 1
656
+ emitted[P] = 1
657
+ }
658
+ BEGIN { cn = 0; pn = 0; na = 0; sp = 0; o = 0; nw = 0 }
659
+ FILENAME == accf {
660
+ if ($2 != "") { acc[$1] = $2; aorder[++na] = $1 }
661
+ next
662
+ }
663
+ FILENAME == curf {
664
+ raw = $0
665
+ body0 = trim(raw)
666
+ if (body0 == "") { ckind[++cn] = "blank"; crawl[cn] = raw; next }
667
+ if (substr(body0, 1, 1) == "#") { ckind[++cn] = "comment"; crawl[cn] = raw; next }
668
+ line = raw; sub(/#.*$/, "", line)
669
+ d = ind(line); body = trim(line)
670
+ if (body ~ /:$/) {
671
+ k = body; sub(/:$/, "", k); gsub(/"/, "", k)
672
+ dopop(d); sd[++sp] = d; sk[sp] = k
673
+ ckind[++cn] = "key"; cdepth[cn] = d; cpath[cn] = joinall(); crawl[cn] = raw
674
+ } else {
675
+ k = body; sub(/:.*/, "", k); gsub(/"/, "", k)
676
+ dopop(d); p = joinall()
677
+ ckind[++cn] = "leaf"; cdepth[cn] = d; cpath[cn] = p (p == "" ? "" : us) k; crawl[cn] = raw
678
+ }
679
+ next
680
+ }
681
+ FILENAME == propf {
682
+ raw = $0
683
+ body0 = trim(raw)
684
+ if (body0 == "") { pkind[++pn] = "blank"; pdepth[pn] = 0; ppath[pn] = ""; praw[pn] = raw; next }
685
+ if (substr(body0, 1, 1) == "#") {
686
+ rest = body0
687
+ while (substr(rest, 1, 1) == "#") rest = substr(rest, 2)
688
+ m = match(rest, /^ */); spc = m ? RLENGTH : 0
689
+ rest = substr(rest, spc + 1)
690
+ # A commented example sits at its `#` column, and its content starts two
691
+ # columns later ("# "); the spaces after the marker encode the depth of a
692
+ # child, so subtracting the marker leaves the line the example stands for.
693
+ ed = ind(raw) + (spc > 0 ? spc - 1 : 0)
694
+ if (rest ~ /^[^ \t:]+:/) {
695
+ k = rest; sub(/:.*/, "", k); gsub(/"/, "", k)
696
+ v = rest; sub(/^[^:]*:/, "", v); sub(/#.*/, "", v); v = trim(v)
697
+ dopop(ed)
698
+ if (v == "") {
699
+ sd[++sp] = ed; sk[sp] = k
700
+ pkind[++pn] = "example_key"; pdepth[pn] = ed; ppath[pn] = joinall(); praw[pn] = raw
701
+ } else {
702
+ p = joinall()
703
+ pkind[++pn] = "example_leaf"; pdepth[pn] = ed
704
+ ppath[pn] = p (p == "" ? "" : us) k; praw[pn] = raw
705
+ }
706
+ } else {
707
+ pkind[++pn] = "comment"; pdepth[pn] = 0; ppath[pn] = ""; praw[pn] = raw
708
+ }
709
+ next
710
+ }
711
+ line = raw; sub(/#.*$/, "", line)
712
+ d = ind(line); body = trim(line)
713
+ if (body ~ /:$/) {
714
+ k = body; sub(/:$/, "", k); gsub(/"/, "", k)
715
+ dopop(d); sd[++sp] = d; sk[sp] = k
716
+ pkind[++pn] = "key"; pdepth[pn] = d; ppath[pn] = joinall(); praw[pn] = raw
717
+ } else {
718
+ k = body; sub(/:.*/, "", k); gsub(/"/, "", k)
719
+ dopop(d); p = joinall()
720
+ pkind[++pn] = "leaf"; pdepth[pn] = d
721
+ ppath[pn] = p (p == "" ? "" : us) k; praw[pn] = raw
722
+ }
723
+ next
724
+ }
725
+ END {
726
+ i = 1
727
+ while (i <= pn) {
728
+ if (pkind[i] == "blank" || pkind[i] == "comment") { outf(praw[i]); i++; continue }
729
+ if (pkind[i] == "example_key") {
730
+ j = i + 1
731
+ while (j <= pn && (pkind[j] == "example_key" || pkind[j] == "example_leaf") && pdepth[j] > pdepth[i]) j++
732
+ if (under_accepted(ppath[i])) {
733
+ emit_block(ppath[i])
734
+ } else {
735
+ for (m = i; m < j; m++) outf(praw[m])
736
+ }
737
+ i = j; continue
738
+ }
739
+ if (pkind[i] == "example_leaf") {
740
+ if (ppath[i] in acc) emit_acc(ppath[i], pdepth[i]); else outf(praw[i])
741
+ i++; continue
742
+ }
743
+ if (pkind[i] == "leaf") {
744
+ if (ppath[i] in acc) emit_acc(ppath[i], pdepth[i]); else outfl(praw[i], pdepth[i], ppath[i])
745
+ i++; continue
746
+ }
747
+ outfk(praw[i], pdepth[i], ppath[i])
748
+ i++
749
+ }
750
+ # An accepted leaf the proposal has no slot for — an extra base_map rung, a
751
+ # hand-written head — is inserted under its own block, after the last line
752
+ # of that block. Dropping it would be the one thing the sync must never do:
753
+ # change a value the check accepts.
754
+ for (a = 1; a <= na; a++) {
755
+ P = aorder[a]
756
+ if (P in emitted) continue
757
+ par = P; sub(us "[^" us "]*$", "", par)
758
+ if (par == P) { warn[++nw] = P; continue }
759
+ b0 = 0; bd = -1
760
+ for (m = 1; m <= o; m++) if (okind[m] == "key" && opath[m] == par) { b0 = m; bd = odepth[m] }
761
+ if (b0 == 0) { warn[++nw] = P; continue }
762
+ last = b0
763
+ for (m = b0 + 1; m <= o; m++) {
764
+ if (okind[m] == "blank") continue
765
+ if (odepth[m] <= bd) break
766
+ last = m
767
+ }
768
+ insn[last]++
769
+ insraw[last, insn[last]] = acc[P]
770
+ }
771
+ for (m = 1; m <= o; m++) {
772
+ print oraw[m]
773
+ for (q = 1; q <= insn[m]; q++) print insraw[m, q]
774
+ }
775
+ for (m = 1; m <= nw; m++) print "sync: no slot for " warn[m] > "/dev/stderr"
776
+ }'
777
+
778
+ leaf_lines() { # FILE -> `path<TAB>raw line` for every active leaf
779
+ awk -v us="$US" "$LEAF_AWK" "$1"
780
+ }
781
+
782
+ accepted_table() { # -> `path<TAB>raw line` for every leaf --check accepts today
783
+ local path raw value
784
+ leaf_lines "$CONFIG" | while IFS=$'\t' read -r path raw; do
785
+ [[ -n "$path" ]] || continue
786
+ value="$(printf '%s' "$raw" \
787
+ | sed -E 's/^[[:space:]]*[^:]*:[[:space:]]*//; s/[[:space:]]+#.*$//; s/[[:space:]]+$//')"
788
+ value="${value#\"}"; value="${value%\"}"
789
+ if leaf_ok "$path" "$value"; then printf '%s\t%s\n' "$path" "$raw"; fi
790
+ done
791
+ }
792
+
793
+ merged_config() { # the current file merged onto the proposal, on stdout
794
+ local prop acc
795
+ prop="$(mktemp "${TMPDIR:-/tmp}/sassy-sync-proposal.XXXXXX")"
796
+ acc="$(mktemp "${TMPDIR:-/tmp}/sassy-sync-accepted.XXXXXX")"
797
+ emit_proposal > "$prop"
798
+ accepted_table > "$acc"
799
+ awk -F'\t' -v us="$US" -v accf="$acc" -v curf="$CONFIG" -v propf="$prop" \
800
+ "$MERGE_AWK" "$acc" "$CONFIG" "$prop"
801
+ rm -f "$prop" "$acc"
802
+ }
803
+
804
+ sync_phrase() { # MERGED -> what --sync --write would do, for the check's note
805
+ local merged="$1" cur_paths merged_paths acc_paths added="" replaced="" p raw out
806
+ cur_paths="$(leaf_lines "$CONFIG" | cut -f1)"
807
+ merged_paths="$(printf '%s\n' "$merged" | leaf_lines /dev/stdin | cut -f1)"
808
+ acc_paths="$(accepted_table | cut -f1)"
809
+ added="$(comm -13 <(printf '%s\n' "$cur_paths" | sort -u) <(printf '%s\n' "$merged_paths" | sort -u) 2>/dev/null \
810
+ | cut -d"$US" -f1 | sort -u | grep -v '^$' | paste -sd, - | sed 's/,/, /g' || true)"
811
+ while IFS=$'\t' read -r p raw; do
812
+ [[ -n "$p" ]] || continue
813
+ grep -qxF "$p" <<< "$acc_paths" && continue
814
+ grep -qxF "$p" <<< "$merged_paths" || continue
815
+ replaced="${replaced:+$replaced, }${p//$US/.}"
816
+ done < <(leaf_lines "$CONFIG")
817
+ if [[ -z "$added" && -z "$replaced" ]]; then printf 'refresh the comments'; return; fi
818
+ out=""
819
+ [[ -n "$added" ]] && out="add $added"
820
+ [[ -n "$replaced" ]] && out="${out:+$out; }replace $replaced (not valid today)"
821
+ printf '%s and refresh the comments' "$out"
822
+ }
823
+
824
+ # --- Emit a proposal -------------------------------------------------------
825
+ # One function, two callers: the default mode prints it, and --sync/--check
826
+ # merge onto it. Everything it reads (PLANS, REPO_NAME, TOPOLOGY, DEFAULT_BRANCH,
827
+ # MIRROR_*) is computed above, before either caller runs.
828
+ emit_proposal() {
829
+ # Every key carries its meaning and its allowed values. The file is the
830
+ # documentation a teammate reads, so the comments are part of the output, not
831
+ # decoration to be stripped.
832
+
833
+ # kv KEY VALUE WIDTH COMMENT [INDENT] — prints "key: value" padded so comments
834
+ # align. WIDTH 0 means no padding.
835
+ kv() {
836
+ local indent="${5:- }" line
837
+ line="$indent$1: $2"
838
+ if [[ -n "${4:-}" && "${3:-0}" != "0" ]]; then
839
+ printf '%-*s%s\n' "$3" "$line" "$4"
840
+ elif [[ -n "${4:-}" ]]; then
841
+ printf '%s %s\n' "$line" "$4"
842
+ else
843
+ printf '%s\n' "$line"
844
+ fi
845
+ }
846
+
847
+ cat <<EOF
848
+ # Sassy Skills project config — written by sassy-setup.
849
+ # Every key is optional: delete a line to fall back to the documented default.
850
+ # Guide: https://github.com/sassywares/sassy-skills/blob/main/skills/sassy-setup/references/config.md
851
+
852
+ # --- Artifacts ------------------------------------------------------------
853
+ # Where sassy writes its documents. Paths are relative to this file's folder.
854
+ artifacts:
855
+ EOF
856
+ kv plans "$PLANS" 34 '# sassy-plan writes plans here'
857
+ kv solutions "$SOLUTIONS" 34 '# sassy-compound writes learnings here'
858
+ kv handbooks "$HANDBOOKS" 34 '# sassy-handbook writes handovers here'
859
+ kv concepts "$CONCEPTS" 34 '# the glossary sassy-compound maintains (a file)'
860
+ cat <<EOF
861
+
862
+ # --- Knowledge ------------------------------------------------------------
863
+ # read: folders and files searched for prior learnings before planning or
864
+ # debugging. Any paths; one that does not exist is skipped, not fatal.
865
+ # write: true | false — false means this project takes no learnings.
866
+ knowledge:
867
+ EOF
868
+ kv read "[$SOLUTIONS, $CONCEPTS]" 0
869
+ kv write true 34 '# true | false'
870
+
871
+ case "$TOPOLOGY" in
872
+ repo)
873
+ cat <<EOF
874
+
875
+ # --- Git ------------------------------------------------------------------
876
+ # repo: a remote name (this folder is the repo) | workspace (repos live below,
877
+ # this folder is not a repo) | none (no git anywhere here).
878
+ # base_map: the base for a HEAD branch, so a PR targets the right rung.
879
+ # "*" is ordinary work; add a rung for a branch that releases elsewhere.
880
+ git:
881
+ EOF
882
+ kv repo "$REPO_NAME" 0
883
+ printf ' base_map:\n'
884
+ if [[ -n "$DEFAULT_BRANCH" ]]; then
885
+ printf ' "*": %s # probed — confirm this is where ordinary work branches from\n' "$DEFAULT_BRANCH"
886
+ else
887
+ printf ' "*": %s # base for ordinary work; never guessed\n' "<confirm by hand>"
888
+ fi
889
+ printf ' # staging: main # uncomment when a branch releases somewhere else\n'
890
+ printf ' # release/*: main # a family of heads, longest prefix wins\n'
891
+ cat <<'EOF'
892
+ # remote: owner/backup # workspace only: the snapshot mirror
893
+ # mirror_branch: main # workspace only: the mirror's branch
894
+
895
+ # workspace only: each nested repo folder -> the base its PRs target
896
+ # repos:
897
+ # fe: dev
898
+ EOF
899
+ ;;
900
+ workspace)
901
+ cat <<EOF
902
+
903
+ # --- Git ------------------------------------------------------------------
904
+ # repo: workspace means repos live below and this folder is not a repo.
905
+ # remote: the snapshot mirror (GitHub owner/name or URL), required here.
906
+ # mirror_branch: the branch the mirror pushes to. Not a PR base — nested repos
907
+ # carry their own, and a workspace has no branches of its own.
908
+ git:
909
+ EOF
910
+ kv repo workspace 0
911
+ kv remote "${MIRROR_REMOTE:-<set the snapshot mirror, owner/name or URL>}" 0
912
+ kv mirror_branch "$MIRROR_BRANCH" 0
913
+ cat <<'EOF'
914
+
915
+ # --- Repos ----------------------------------------------------------------
916
+ # Every nested repo -> the base its PRs target. A touched repo missing here is
917
+ # a question, never a default.
918
+ repos:
919
+ EOF
920
+ any=0
921
+ while IFS= read -r name; do
922
+ [[ -n "$name" ]] || continue
923
+ base="$(detect_base "$ROOT/$name")"
924
+ if [[ -n "$base" ]]; then
925
+ kv "$name" "$base" 34 '# probed — confirm the PR base'
926
+ else
927
+ kv "$name" "<confirm>" 34 '# base unknown; confirm by hand'
928
+ fi
929
+ any=1
930
+ done < <(nested_repos)
931
+ (( any )) || printf ' # no nested repos found\n'
932
+ ;;
933
+ *)
934
+ cat <<EOF
935
+
936
+ # --- Git ------------------------------------------------------------------
937
+ # repo: none means this folder is deliberately outside git: commit, PR, and
938
+ # babysit refuse here, and work still leaves its changes on disk.
939
+ git:
940
+ EOF
941
+ kv repo none 0
942
+ ;;
943
+ esac
944
+
945
+ cat <<'EOF'
946
+
947
+ # --- Commit ---------------------------------------------------------------
948
+ # current: commit on the checked-out branch, even on a base branch, then push
949
+ # it to its upstream. No PR: pr.* and hooks.pr are ignored; hooks.push runs.
950
+ # new: never commit on a base branch — sassy-work, sassy-lfg, and sassy-debug
951
+ # cut a branch at the start of the run and stay on it.
952
+ commit:
953
+ EOF
954
+ kv branch new 34 '# current | new'
955
+ cat <<'EOF'
956
+
957
+ # --- Pull requests --------------------------------------------------------
958
+ pr:
959
+ EOF
960
+ kv babysit true 24 '# true | false — babysit the PR this run opened'
961
+ kv merge false 24 '# true = merge every babysat PR here'
962
+ kv delete_branch false 24 '# true | false — delete the head branch once merged'
963
+ cat <<'EOF'
964
+
965
+ # --- Hooks ----------------------------------------------------------------
966
+ # Project steps injected into the PR pipeline, after a push under
967
+ # commit.branch: current, across a worktree's life, or around a goal. Keyed by
968
+ # the branch — the branch the PR comes from, never the one it targets — or by the
969
+ # goal slug for hooks.goal. `"*"` is the default; a name overrides per point, and
970
+ # `release/*` matches a family. Each entry is `<skill> <args…>`, resolved at
971
+ # .agents/skills/<name>/SKILL.md; args are passed to the skill verbatim. Declared
972
+ # order, one worker each, missing skill fails closed.
973
+ hooks:
974
+ pr:
975
+ "*":
976
+ EOF
977
+ kv before_create '[]' 30 '# after the commit, before the PR opens' ' '
978
+ kv after_create '[]' 30 '# the PR was just created' ' '
979
+ kv before_merge '[]' 30 '# this run is about to merge' ' '
980
+ kv after_merge '[]' 30 '# this run observed the merge' ' '
981
+ cat <<'EOF'
982
+ # staging: # per-point override for one head branch
983
+ # before_create: []
984
+ # release/*: # a family of heads
985
+ # after_merge: [notify mode:auto]
986
+ goal: # keyed by the goal slug (the folder under artifacts.plans)
987
+ "*":
988
+ EOF
989
+ kv before_slice '[]' 30 '# sassy-goal mode:next: after the previous slice merges' ' '
990
+ kv after_close '[]' 30 '# sassy-goal mode:close: after the status is persisted' ' '
991
+ cat <<'EOF'
992
+ # migration-v2: # one goal, by slug
993
+ # before_slice: [db-migrate mode:auto]
994
+ # push: # commit.branch: current only; keyed by the pushed branch
995
+ # "*":
996
+ # after_push: []
997
+ EOF
998
+ cat <<'EOF'
999
+
1000
+ # --- Worktrees ------------------------------------------------------------
1001
+ # Parallel work in one repo: a checkout per branch, each with its own derived
1002
+ # namespace, so two runs never fight over one working tree. enabled: true lets a
1003
+ # run offer one instead of working here — the run asks, and stays here unless the
1004
+ # answer is yes. It needs commit.branch: new, because `current` never cuts a
1005
+ # branch. The built-in scripts in .sassywares/worktree/ own the git mechanics;
1006
+ # create: and remove: name this project's own scripts, which wrap them for
1007
+ # whatever a checkout needs and are what a run executes. Nothing else reads
1008
+ # these values.
1009
+ #
1010
+ # Repo topology only: a workspace root has no repo to cut a checkout from, and a
1011
+ # `none` folder has no git at all. A checkout is addressed by the project's own
1012
+ # stack, not by the suite: a port is the project's business, and this block
1013
+ # carries no range.
1014
+ worktrees:
1015
+ EOF
1016
+ kv enabled false 34 '# true = a run may offer its own checkout'
1017
+ kv dir '~/.sassywares/worktrees' 34 '# parent of the per-repo folder; ~ is allowed'
1018
+ cat <<'EOF'
1019
+ # create: scripts/worktrees/create # this project's own; runs before and after git
1020
+ # remove: scripts/worktrees/remove # this project's own; stop, then dispose
1021
+ EOF
1022
+ cat <<'EOF'
1023
+
1024
+ # --- Dogfood --------------------------------------------------------------
1025
+ # Agent QA: a stored procedure that proves a change works in the running
1026
+ # product. This block only points at it — commands live in the recipe, because
1027
+ # a copy here would duplicate the manifest and could not express step order.
1028
+ # The recipe ends each section in a `Prove it:` step whose exit code is the
1029
+ # verdict. enabled: true lets a plan write Mode: Auto QA rows, but only for a
1030
+ # section that actually has one.
1031
+ dogfood:
1032
+ EOF
1033
+ kv enabled false 42 '# true = plan writes Auto QA rows; false = all Manual'
1034
+ kv recipe .sassywares/dogfood/recipe.md 42 '# the procedure; sassy-dogfood writes it'
1035
+ kv reports .sassywares/dogfood/reports 42 '# run output; must stay gitignored'
1036
+ kv timeout 900 42 '# seconds for the whole procedure'
1037
+ }
1038
+
493
1039
  if (( CHECK )); then
494
1040
  drift=0
495
1041
  note() { printf '%s\n' "$*"; }
@@ -1115,6 +1661,18 @@ if (( CHECK )); then
1115
1661
  fi
1116
1662
  fi
1117
1663
 
1664
+ # A config can match the tree and still be behind the template: whole blocks,
1665
+ # comment layers, and examples a later version added are missing, so the next
1666
+ # reader gets a thinner file than the one sassy-setup documents. It is a note,
1667
+ # never drift — every value the file declares is valid — and the sync only adds
1668
+ # what is missing, so this is the one passing check worth reading.
1669
+ template=""
1670
+ if template="$(merged_config)"; then
1671
+ if [[ "$template" != "$(cat "$CONFIG")" ]]; then
1672
+ note " template: --sync --write would $(sync_phrase "$template") (values the check accepts stay) — run: bash ${BASH_SOURCE[0]} --root $ROOT --sync --write"
1673
+ fi
1674
+ fi
1675
+
1118
1676
  if (( drift )); then exit 1; fi
1119
1677
  note " config matches the tree"
1120
1678
  exit 0
@@ -1316,212 +1874,36 @@ if (( BRANCH )); then
1316
1874
  exit 0
1317
1875
  fi
1318
1876
 
1319
- # --- Emit a proposal -------------------------------------------------------
1320
- # Every key carries its meaning and its allowed values. The file is the
1321
- # documentation a teammate reads, so the comments are part of the output, not
1322
- # decoration to be stripped.
1323
-
1324
- # kv KEY VALUE WIDTH COMMENT [INDENT] — prints "key: value" padded so comments
1325
- # align. WIDTH 0 means no padding.
1326
- kv() {
1327
- local indent="${5:- }" line
1328
- line="$indent$1: $2"
1329
- if [[ -n "${4:-}" && "${3:-0}" != "0" ]]; then
1330
- printf '%-*s%s\n' "$3" "$line" "$4"
1331
- elif [[ -n "${4:-}" ]]; then
1332
- printf '%s %s\n' "$line" "$4"
1877
+ # --- Template sync ---------------------------------------------------------
1878
+ # The one mode that writes. It computes the same proposal the default mode
1879
+ # prints, merges the current file onto it (see --sync at the top), and either
1880
+ # prints the result (dry run, the default) or writes it with --write. The file is
1881
+ # left untouched when the merge is identical, so a second run is a no-op that
1882
+ # says so.
1883
+ if (( SYNC )); then
1884
+ [[ -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
1333
1901
  else
1334
- printf '%s\n' "$line"
1902
+ printf '%s\n' "$merged"
1903
+ echo "sync: $CONFIG would change ($changed line(s)) — nothing written; rerun with --sync --write" >&2
1335
1904
  fi
1336
- }
1337
-
1338
- cat <<EOF
1339
- # Sassy Skills project config — written by sassy-setup.
1340
- # Every key is optional: delete a line to fall back to the documented default.
1341
- # Guide: https://github.com/sassywares/sassy-skills/blob/main/skills/sassy-setup/references/config.md
1342
-
1343
- # --- Artifacts ------------------------------------------------------------
1344
- # Where sassy writes its documents. Paths are relative to this file's folder.
1345
- artifacts:
1346
- EOF
1347
- kv plans "$PLANS" 34 '# sassy-plan writes plans here'
1348
- kv solutions "$SOLUTIONS" 34 '# sassy-compound writes learnings here'
1349
- kv handbooks "$HANDBOOKS" 34 '# sassy-handbook writes handovers here'
1350
- kv concepts "$CONCEPTS" 34 '# the glossary sassy-compound maintains (a file)'
1351
- cat <<EOF
1352
-
1353
- # --- Knowledge ------------------------------------------------------------
1354
- # read: folders and files searched for prior learnings before planning or
1355
- # debugging. Any paths; one that does not exist is skipped, not fatal.
1356
- # write: true | false — false means this project takes no learnings.
1357
- knowledge:
1358
- EOF
1359
- kv read "[$SOLUTIONS, $CONCEPTS]" 0
1360
- kv write true 34 '# true | false'
1361
-
1362
- case "$TOPOLOGY" in
1363
- repo)
1364
- cat <<EOF
1365
-
1366
- # --- Git ------------------------------------------------------------------
1367
- # repo: a remote name (this folder is the repo) | workspace (repos live below,
1368
- # this folder is not a repo) | none (no git anywhere here).
1369
- # base_map: the base for a HEAD branch, so a PR targets the right rung.
1370
- # "*" is ordinary work; add a rung for a branch that releases elsewhere.
1371
- git:
1372
- EOF
1373
- kv repo "$REPO_NAME" 0
1374
- printf ' base_map:\n'
1375
- if [[ -n "$DEFAULT_BRANCH" ]]; then
1376
- printf ' "*": %s # probed — confirm this is where ordinary work branches from\n' "$DEFAULT_BRANCH"
1377
- else
1378
- printf ' "*": %s # base for ordinary work; never guessed\n' "<confirm by hand>"
1379
- fi
1380
- printf ' # staging: main # uncomment when a branch releases somewhere else\n'
1381
- printf ' # release/*: main # a family of heads, longest prefix wins\n'
1382
- cat <<'EOF'
1383
- # remote: owner/backup # workspace only: the snapshot mirror
1384
- # mirror_branch: main # workspace only: the mirror's branch
1385
-
1386
- # workspace only: each nested repo folder -> the base its PRs target
1387
- # repos:
1388
- # fe: dev
1389
- EOF
1390
- ;;
1391
- workspace)
1392
- cat <<EOF
1393
-
1394
- # --- Git ------------------------------------------------------------------
1395
- # repo: workspace means repos live below and this folder is not a repo.
1396
- # remote: the snapshot mirror (GitHub owner/name or URL), required here.
1397
- # mirror_branch: the branch the mirror pushes to. Not a PR base — nested repos
1398
- # carry their own, and a workspace has no branches of its own.
1399
- git:
1400
- EOF
1401
- kv repo workspace 0
1402
- kv remote "${MIRROR_REMOTE:-<set the snapshot mirror, owner/name or URL>}" 0
1403
- kv mirror_branch "$MIRROR_BRANCH" 0
1404
- cat <<'EOF'
1405
-
1406
- # --- Repos ----------------------------------------------------------------
1407
- # Every nested repo -> the base its PRs target. A touched repo missing here is
1408
- # a question, never a default.
1409
- repos:
1410
- EOF
1411
- any=0
1412
- while IFS= read -r name; do
1413
- [[ -n "$name" ]] || continue
1414
- base="$(detect_base "$ROOT/$name")"
1415
- if [[ -n "$base" ]]; then
1416
- kv "$name" "$base" 34 '# probed — confirm the PR base'
1417
- else
1418
- kv "$name" "<confirm>" 34 '# base unknown; confirm by hand'
1419
- fi
1420
- any=1
1421
- done < <(nested_repos)
1422
- (( any )) || printf ' # no nested repos found\n'
1423
- ;;
1424
- *)
1425
- cat <<EOF
1426
-
1427
- # --- Git ------------------------------------------------------------------
1428
- # repo: none means this folder is deliberately outside git: commit, PR, and
1429
- # babysit refuse here, and work still leaves its changes on disk.
1430
- git:
1431
- EOF
1432
- kv repo none 0
1433
- ;;
1434
- esac
1435
-
1436
- cat <<'EOF'
1437
-
1438
- # --- Commit ---------------------------------------------------------------
1439
- # current: commit on the checked-out branch, even on a base branch, then push
1440
- # it to its upstream. No PR: pr.* and hooks.pr are ignored; hooks.push runs.
1441
- # new: never commit on a base branch — sassy-work, sassy-lfg, and sassy-debug
1442
- # cut a branch at the start of the run and stay on it.
1443
- commit:
1444
- EOF
1445
- kv branch new 34 '# current | new'
1446
- cat <<'EOF'
1447
-
1448
- # --- Pull requests --------------------------------------------------------
1449
- pr:
1450
- EOF
1451
- kv babysit true 24 '# true | false — babysit the PR this run opened'
1452
- kv merge false 24 '# true = merge every babysat PR here'
1453
- kv delete_branch false 24 '# true | false — delete the head branch once merged'
1454
- cat <<'EOF'
1455
-
1456
- # --- Hooks ----------------------------------------------------------------
1457
- # Project steps injected into the PR pipeline, after a push under
1458
- # commit.branch: current, across a worktree's life, or around a goal. Keyed by
1459
- # the branch — the branch the PR comes from, never the one it targets — or by the
1460
- # goal slug for hooks.goal. `"*"` is the default; a name overrides per point, and
1461
- # `release/*` matches a family. Each entry is `<skill> <args…>`, resolved at
1462
- # .agents/skills/<name>/SKILL.md; args are passed to the skill verbatim. Declared
1463
- # order, one worker each, missing skill fails closed.
1464
- hooks:
1465
- pr:
1466
- "*":
1467
- EOF
1468
- kv before_create '[]' 30 '# after the commit, before the PR opens' ' '
1469
- kv after_create '[]' 30 '# the PR was just created' ' '
1470
- kv before_merge '[]' 30 '# this run is about to merge' ' '
1471
- kv after_merge '[]' 30 '# this run observed the merge' ' '
1472
- cat <<'EOF'
1473
- # staging: # per-point override for one head branch
1474
- # before_create: []
1475
- # release/*: # a family of heads
1476
- # after_merge: [notify mode:auto]
1477
- goal: # keyed by the goal slug (the folder under artifacts.plans)
1478
- "*":
1479
- EOF
1480
- kv before_slice '[]' 30 '# sassy-goal mode:next: after the previous slice merges' ' '
1481
- kv after_close '[]' 30 '# sassy-goal mode:close: after the status is persisted' ' '
1482
- cat <<'EOF'
1483
- # migration-v2: # one goal, by slug
1484
- # before_slice: [db-migrate mode:auto]
1485
- # push: # commit.branch: current only; keyed by the pushed branch
1486
- # "*":
1487
- # after_push: []
1488
- EOF
1489
- cat <<'EOF'
1905
+ exit 0
1906
+ fi
1490
1907
 
1491
- # --- Worktrees ------------------------------------------------------------
1492
- # Parallel work in one repo: a checkout per branch, each with its own derived
1493
- # namespace, so two runs never fight over one working tree. enabled: true lets a
1494
- # run offer one instead of working here — the run asks, and stays here unless the
1495
- # answer is yes. It needs commit.branch: new, because `current` never cuts a
1496
- # branch. The built-in scripts in .sassywares/worktree/ own the git mechanics;
1497
- # create: and remove: name this project's own scripts, which wrap them for
1498
- # whatever a checkout needs and are what a run executes. Nothing else reads
1499
- # these values.
1500
- #
1501
- # Repo topology only: a workspace root has no repo to cut a checkout from, and a
1502
- # `none` folder has no git at all. A checkout is addressed by the project's own
1503
- # stack, not by the suite: a port is the project's business, and this block
1504
- # carries no range.
1505
- worktrees:
1506
- EOF
1507
- kv enabled false 34 '# true = a run may offer its own checkout'
1508
- kv dir '~/.sassywares/worktrees' 34 '# parent of the per-repo folder; ~ is allowed'
1509
- cat <<'EOF'
1510
- # create: scripts/worktrees/create # this project's own; runs before and after git
1511
- # remove: scripts/worktrees/remove # this project's own; stop, then dispose
1512
- EOF
1513
- cat <<'EOF'
1908
+ emit_proposal
1514
1909
 
1515
- # --- Dogfood --------------------------------------------------------------
1516
- # Agent QA: a stored procedure that proves a change works in the running
1517
- # product. This block only points at it — commands live in the recipe, because
1518
- # a copy here would duplicate the manifest and could not express step order.
1519
- # The recipe ends each section in a `Prove it:` step whose exit code is the
1520
- # verdict. enabled: true lets a plan write Mode: Auto QA rows, but only for a
1521
- # section that actually has one.
1522
- dogfood:
1523
- EOF
1524
- kv enabled false 42 '# true = plan writes Auto QA rows; false = all Manual'
1525
- kv recipe .sassywares/dogfood/recipe.md 42 '# the procedure; sassy-dogfood writes it'
1526
- kv reports .sassywares/dogfood/reports 42 '# run output; must stay gitignored'
1527
- kv timeout 900 42 '# seconds for the whole procedure'