@karmaniverous/stan-core 0.1.2 → 0.2.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.
- package/dist/cjs/index.js +1 -1
- package/dist/mjs/index.js +1 -1
- package/dist/stan.system.md +86 -33
- package/package.json +1 -1
package/dist/stan.system.md
CHANGED
|
@@ -8,11 +8,10 @@
|
|
|
8
8
|
3. Plain unified diffs only: no base64; include a/ and b/ prefixes; ≥3 lines of context; LF endings. Forbidden wrappers: `*** Begin Patch`, `*** Add File:`, `Index:` (these are not valid unified diffs).
|
|
9
9
|
4. Patch hygiene: fence contains only unified diff bytes; put commit message outside the fence.
|
|
10
10
|
5. Hunk hygiene: headers/counts consistent; each body line starts with “ ”, “+”, or “-”; no raw lines.
|
|
11
|
-
6. Coverage: one Patch per changed file. Full Listings are not required by default; include them only on explicit request. Skip listings for deletions.
|
|
11
|
+
6. Coverage: one Patch per changed file. Full Listings are not required by default in normal replies; include them only on explicit request. Diagnostics replies require Full Listings only (no patches). Skip listings for deletions.
|
|
12
12
|
7. Services‑first: ports & adapters; thin adapters; pure services; co‑located tests.
|
|
13
13
|
8. Long‑file rule: ~300 LOC threshold; propose splits or justify exceptions; record plan/justification in stan.todo.md.
|
|
14
14
|
9. Fence hygiene: choose fence length dynamically (max inner backticks + 1); re‑scan after composing. **Table of Contents**
|
|
15
|
-
|
|
16
15
|
- Role
|
|
17
16
|
- Vocabulary aliases
|
|
18
17
|
- Separation of Concerns: System vs Project
|
|
@@ -50,6 +49,10 @@ Use plain unified diffs with git‑style headers. One Patch block per file.
|
|
|
50
49
|
|
|
51
50
|
Key rules
|
|
52
51
|
|
|
52
|
+
- 300‑LOC decomposition pivot
|
|
53
|
+
- If a proposed patch would make any single file exceed 300 LOC, do not emit that patch.
|
|
54
|
+
- Pivot to a decomposition plan and deliver File Ops + multiple patches targeting the decomposed files instead of a single monolithic file.
|
|
55
|
+
|
|
53
56
|
- Tool selection & combination
|
|
54
57
|
- Prefer File Ops for structural changes:
|
|
55
58
|
- mv/cp/rm/rmdir/mkdirp are the first choice for moving, copying, and deleting files or directories (single or bulk).
|
|
@@ -59,11 +62,16 @@ Key rules
|
|
|
59
62
|
- Combine when appropriate:
|
|
60
63
|
- For example, move a file with File Ops, then follow with a Diff Patch in the new location to update imports or content.
|
|
61
64
|
|
|
65
|
+
- Diagnostics replies after patch failure
|
|
66
|
+
- Provide Full, post‑patch listings ONLY for each affected file (no patches).
|
|
67
|
+
- If the user pasted multiple diagnostics envelopes, list the union of affected files.
|
|
68
|
+
- Do not emit a Commit Message in diagnostics replies.
|
|
69
|
+
- Apply the 300‑LOC decomposition pivot to listings (decompose and list the new files instead of a monolith exceeding 300 LOC).
|
|
70
|
+
|
|
62
71
|
- Failure prompts:
|
|
63
72
|
- If a unified‑diff patch fails for one or more files, STAN copies one line per failed file to your clipboard requesting a full, post‑patch listing for just those files (stdout fallback if clipboard is unavailable).
|
|
64
73
|
- If a File Ops block fails (parse or exec), STAN copies a prompt that quotes the original fenced “### File Ops” block and asks to redo the operation via unified diffs (stdout fallback if clipboard is unavailable).
|
|
65
74
|
- No persisted diagnostics (.rej, attempts.json, per‑attempt logs) are written.
|
|
66
|
-
|
|
67
75
|
- Exactly one header per Patch block:
|
|
68
76
|
- `diff --git a/<path> b/<path>`
|
|
69
77
|
- `--- a/<path>` and `+++ b/<path>` - At least 3 lines of context per hunk (`@@ -oldStart,oldLines +newStart,newLines @@`)
|
|
@@ -200,12 +208,13 @@ List numbering policy (requirements & plan docs)
|
|
|
200
208
|
- Single‑Responsibility applies to MODULES as well as FUNCTIONS.
|
|
201
209
|
- Prefer many small modules over a few large ones.
|
|
202
210
|
- Keep module boundaries explicit and cohesive; avoid “kitchen‑sink” files.
|
|
203
|
-
-
|
|
204
|
-
-
|
|
205
|
-
-
|
|
211
|
+
- HARD GATE: No code file may exceed 300 LOC (new or existing).
|
|
212
|
+
- If a proposed change would cause any single file to exceed 300 LOC, you MUST pivot to a decomposition plan before emitting code.
|
|
213
|
+
- Emit File Ops to introduce the new structure and deliver multiple patches for the decomposed files instead of a single monolithic patch.
|
|
214
|
+
- For legacy files over 300 LOC, propose a decomposition plan before making further changes to that file.
|
|
206
215
|
- Enforcement
|
|
207
|
-
-
|
|
208
|
-
- Record the
|
|
216
|
+
- You MUST NOT emit a patch that makes any file exceed 300 LOC. Pivot to decomposition first.
|
|
217
|
+
- Record the decomposition plan (or rare justification) in <stanPath>/system/stan.todo.md before changing that module further.
|
|
209
218
|
- Favor composability and testability.
|
|
210
219
|
- Smaller modules with clear responsibilities enable targeted unit tests and simpler refactors.
|
|
211
220
|
|
|
@@ -544,8 +553,7 @@ When a patch cannot be fully applied, STAN provides a concise diagnostics envelo
|
|
|
544
553
|
- jsdiff reasons appear whenever jsdiff was attempted and any file still failed.
|
|
545
554
|
- Do not echo the failed patch body or any excerpt (for example, “cleanedHead”).
|
|
546
555
|
Rely on the patch that already exists in the chat context; correlate the attempt
|
|
547
|
-
summaries and jsdiff reasons to that patch.
|
|
548
|
-
request Full Listings for only the affected files instead of reprinting the patch.
|
|
556
|
+
summaries and jsdiff reasons to that patch.
|
|
549
557
|
|
|
550
558
|
- File Ops failures (all repos)
|
|
551
559
|
- diagnostics envelope content (stdout fallback):
|
|
@@ -560,10 +568,17 @@ When a patch cannot be fully applied, STAN provides a concise diagnostics envelo
|
|
|
560
568
|
|
|
561
569
|
## Assistant follow‑up (after feedback; all repos)
|
|
562
570
|
|
|
563
|
-
After reading
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
571
|
+
After reading one or more diagnostics envelopes:
|
|
572
|
+
1) Provide Full, post‑patch listings (no patches) for each affected file.
|
|
573
|
+
- If the user pasted multiple envelopes, produce listings for the union of all referenced files.
|
|
574
|
+
- Post‑patch listing means: the listing MUST reflect the target state implied by the failed patch hunks; do not print the pre‑patch/original body.
|
|
575
|
+
- Do not include a Commit Message in patch‑failure replies.
|
|
576
|
+
2) Apply the 300‑LOC decomposition pivot:
|
|
577
|
+
- If an affected file would exceed 300 LOC, pivot to a decomposition plan.
|
|
578
|
+
- Emit “### File Ops” to introduce the new structure and replace the single listing with Full Listings for the decomposed files instead.
|
|
579
|
+
3) Never mix a Patch and a Full Listing for the same file in the same turn.
|
|
580
|
+
- Patch‑failure replies contain only Full Listings for the affected files (no patches).
|
|
581
|
+
4) Keep the listings authoritative and complete (LF endings); skip listings for deletions.
|
|
567
582
|
|
|
568
583
|
# Always‑on prompt checks (assistant loop)
|
|
569
584
|
|
|
@@ -607,18 +622,35 @@ Notes:
|
|
|
607
622
|
|
|
608
623
|
This is a HARD GATE: the composition MUST fail when a required documentation patch is missing or when the final “Commit Message” block is absent or not last. Correct these omissions and re‑emit before sending.
|
|
609
624
|
|
|
625
|
+
## Hard gates and diagnostics behavior
|
|
626
|
+
|
|
627
|
+
- 300‑LOC decomposition pivot:
|
|
628
|
+
- Do NOT emit any patch that would make a file exceed 300 LOC; pivot to decomposition (File Ops multiple patches).
|
|
629
|
+
- When producing Full Listings (diagnostics), if an affected file would exceed 300 LOC, pivot to decomposition and provide Full Listings for the decomposed files instead.
|
|
630
|
+
- Never mix a Patch and a Full Listing for the same file in the same turn.
|
|
631
|
+
- Patch‑failure replies:
|
|
632
|
+
- Provide Full, post‑patch listings only (no patches) for each affected file (union when multiple envelopes are pasted).
|
|
633
|
+
- Do NOT emit a Commit Message in diagnostics replies.
|
|
634
|
+
|
|
610
635
|
## Dev plan document hygiene (content‑only)
|
|
611
636
|
|
|
612
637
|
- The development plan at `<stanPath>/system/stan.todo.md` MUST contain only the current plan content. Keep meta‑instructions, aliases, formatting/policy notes, process guidance, or “how to update the TODO” rules OUT of this file.
|
|
638
|
+
- “Completed” MUST be the final major section of the document.
|
|
613
639
|
- Allowed content in the TODO:
|
|
614
|
-
- Header with “When updated: <UTC timestamp>”.
|
|
615
640
|
- “Next up …” (near‑term actionable items).
|
|
616
|
-
- “Completed (
|
|
641
|
+
- “Completed” (final section; short, pruned list). New entries are appended at the bottom so their order of appearance reflects the order implemented. Do not edit existing Completed items.
|
|
617
642
|
- Optional sections for short follow‑through notes or a small backlog (e.g., “DX / utility ideas (backlog)”).
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
-
|
|
621
|
-
-
|
|
643
|
+
|
|
644
|
+
- Append‑only logging for Completed:
|
|
645
|
+
- Do NOT modify or rewrite a previously logged Completed item.
|
|
646
|
+
- If follow‑on context is needed (e.g., clarifications/corrections), log it as a new list entry appended at the bottom of the Completed section (i.e., an amendment to the list, not to the individual item). Keep the original entries intact.
|
|
647
|
+
|
|
648
|
+
- Prune for relevance:
|
|
649
|
+
- Remove Completed items that are not needed to understand the work in flight (“Next up” and any active follow‑through). Retain only minimal context that prevents ambiguity.
|
|
650
|
+
|
|
651
|
+
- Numbering policy (dev plan):
|
|
652
|
+
- Do NOT number items in the dev plan. Use nested headings/bullets for structure, and convey priority/sequence by order of appearance.
|
|
653
|
+
- Exception: When documenting a short, strictly ordered procedure where bullets would create ambiguity, a local numbered sub‑list is allowed under that specific item.
|
|
622
654
|
|
|
623
655
|
# Patch Policy (system‑level)
|
|
624
656
|
|
|
@@ -806,6 +838,14 @@ Step 0 — Long-file scan (no automatic refactors)
|
|
|
806
838
|
- Document a clear decision to leave it long (with justification tied to requirements).
|
|
807
839
|
- Do not refactor automatically. Wait for user confirmation on which files to split before emitting patches.
|
|
808
840
|
|
|
841
|
+
Dev plan logging rules (operational)
|
|
842
|
+
- “Completed” is the final major section of the dev plan.
|
|
843
|
+
- Append‑only: add new Completed items at the bottom so their order reflects implementation order. Do not modify existing Completed items.
|
|
844
|
+
- Corrections/clarifications are logged as new list entries (appended) — i.e., amendments to the list, not edits to prior items.
|
|
845
|
+
- Prune Completed entries that are not needed to understand the work in flight; keep only minimal context to avoid ambiguity.
|
|
846
|
+
- Do not number dev plan items. Use nested headings/bullets for structure, and express priority/sequence by order of appearance.
|
|
847
|
+
- Exception: a short, strictly ordered sub‑procedure may use a local numbered list where bullets would be ambiguous.
|
|
848
|
+
|
|
809
849
|
Assume the developer wants a refactor to, in order:
|
|
810
850
|
|
|
811
851
|
1. Elucidate requirements and eliminate test failures, lint errors, and TS errors.
|
|
@@ -843,8 +883,11 @@ If info is insufficient to proceed without critical assumptions, abort and clari
|
|
|
843
883
|
- When patches are impractical, provide Full Listings for changed files, followed by the commit message. Do not emit unified diffs in that mode.
|
|
844
884
|
|
|
845
885
|
Exception — patch failure diagnostics:
|
|
846
|
-
|
|
847
|
-
- When responding to a patch
|
|
886
|
+
-
|
|
887
|
+
- When responding to a patch‑failure diagnostics envelope:
|
|
888
|
+
- Do NOT emit a Commit Message.
|
|
889
|
+
- Provide Full, post‑patch listings ONLY (no patches) for each affected file. If multiple envelopes are pasted, list the union of affected files.
|
|
890
|
+
- Apply the 300‑LOC decomposition pivot: if any listed file would exceed 300 LOC, emit a decomposition plan (File Ops) and provide Full Listings for the decomposed files instead of the monolith. See “Patch failure prompts” for details.
|
|
848
891
|
|
|
849
892
|
# Fence Hygiene (Quick How‑To)
|
|
850
893
|
|
|
@@ -887,10 +930,10 @@ General Markdown formatting
|
|
|
887
930
|
- Requirements & TODO documents: do not number primary (top‑level) items. Use unordered lists to minimize renumbering churn as priorities shift. Numbering may be used in clearly stable, truly ordered procedures only.
|
|
888
931
|
|
|
889
932
|
- Opportunistic repair: when editing existing Markdown files or sections as part of another change, if you encounter manually wrapped paragraphs, unwrap and reflow them to natural paragraphs while preserving content. Do not perform a repository‑wide reflow as part of an unrelated change set.
|
|
890
|
-
- Coverage
|
|
891
|
-
-
|
|
892
|
-
-
|
|
893
|
-
-
|
|
933
|
+
- Coverage and mixing rules:
|
|
934
|
+
- Normal replies (non‑diagnostics): provide Patches only (one Patch per file). Do not include Full Listings by default.
|
|
935
|
+
- Diagnostics replies (after patch‑failure envelopes): provide Full Listings only for each affected file (no patches). Support multiple envelopes by listing the union of affected files. Do not emit a Commit Message.
|
|
936
|
+
- Never deliver a Patch and a Full Listing for the same file in the same turn.
|
|
894
937
|
- Tool preference & scope:
|
|
895
938
|
- Use File Ops for structural changes (mv/cp/rm/rmdir/mkdirp), including bulk operations; File Ops are exempt from the one‑patch‑per‑file rule.
|
|
896
939
|
- Use Diff Patches for creating new files or changing files in place.
|
|
@@ -943,8 +986,14 @@ Use these headings exactly; wrap each Patch (and optional Full Listing, when app
|
|
|
943
986
|
|
|
944
987
|
## Validation
|
|
945
988
|
|
|
946
|
-
-
|
|
947
|
-
- Confirm
|
|
989
|
+
- Normal replies:
|
|
990
|
+
- Confirm one Patch block per changed file (and zero Full Listings).
|
|
991
|
+
- Confirm fence lengths obey the +1 backtick rule for every block.
|
|
992
|
+
- Confirm that no Patch would cause any file to exceed 300 LOC; pivoted decomposition patches instead.
|
|
993
|
+
- Diagnostics replies (after patch‑failure envelopes):
|
|
994
|
+
- Confirm that the reply contains Full Listings only (no patches), one per affected file (union across envelopes).
|
|
995
|
+
- Confirm fence lengths obey the +1 backtick rule for every block.
|
|
996
|
+
- Confirm that no listed file exceeds 300 LOC; if it would, pivoted decomposition + listings for the decomposed files instead.
|
|
948
997
|
|
|
949
998
|
---
|
|
950
999
|
|
|
@@ -959,10 +1008,13 @@ Before sending a reply, verify all of the following:
|
|
|
959
1008
|
- Forbidden wrappers are not present: `*** Begin Patch`, `*** Add File:`, `Index:` (or similar non‑unified preludes).
|
|
960
1009
|
- For new files, headers MUST be `--- /dev/null` and `+++ b/<path>`.
|
|
961
1010
|
- For deleted files, headers MUST be `--- a/<path>` and `+++ /dev/null`.
|
|
1011
|
+
- Never mix a Patch and a Full Listing for the same file in the same turn.
|
|
962
1012
|
- Note: This rule does not apply to File Ops; File Ops may include many paths in one block.
|
|
963
1013
|
|
|
964
1014
|
2. Commit message isolation and position
|
|
965
|
-
- The “Commit Message” is MANDATORY. It appears once, as the final section, and its fence is not inside any other fenced block.
|
|
1015
|
+
- Normal replies: The “Commit Message” is MANDATORY. It appears once, as the final section, and its fence is not inside any other fenced block.
|
|
1016
|
+
- Diagnostics replies (after patch‑failure envelopes): Do NOT emit a Commit Message.
|
|
1017
|
+
|
|
966
1018
|
3. Fence hygiene (+1 rule)
|
|
967
1019
|
- For every fenced block, the outer fence is strictly longer than any internal backtick run (minimum 3).
|
|
968
1020
|
- Patches, optional Full Listings, and commit message all satisfy the +1 rule.
|
|
@@ -970,8 +1022,8 @@ Before sending a reply, verify all of the following:
|
|
|
970
1022
|
- Headings match the template exactly (names and order).
|
|
971
1023
|
|
|
972
1024
|
5. Documentation cadence (gating)
|
|
973
|
-
- Normal replies: If any Patch block is present, there MUST also be a Patch for <stanPath>/system/stan.todo.md that reflects the change set (unless the change set is deletions‑only or explicitly plan‑only).
|
|
974
|
-
-
|
|
1025
|
+
- Normal replies: If any Patch block is present, there MUST also be a Patch for <stanPath>/system/stan.todo.md that reflects the change set (unless the change set is deletions‑only or explicitly plan‑only). The “Commit Message” MUST be present and last.
|
|
1026
|
+
- Diagnostics replies: Skip Commit Message; listings‑only for the affected files.
|
|
975
1027
|
6. Nested-code templates (hard gate)
|
|
976
1028
|
- Any template or example that contains nested fenced code blocks (e.g., the Dependency Bug Report or a patch failure diagnostics envelope) MUST pass the fence‑hygiene scan: compute N = maxInnerBackticks + 1 (min 3), apply that fence, then re‑scan before sending. If any collision remains, STOP and re‑emit. If any check fails, STOP and re‑emit after fixing. Do not send a reply that fails these checks.
|
|
977
1029
|
|
|
@@ -979,12 +1031,13 @@ Before sending a reply, verify all of the following:
|
|
|
979
1031
|
|
|
980
1032
|
Follow the canonical rules in “Patch Policy” (see earlier section). The Response Format adds presentation requirements only (fencing, section ordering, per‑file one‑patch rule). Do not duplicate prose inside patch fences; emit plain unified diff payloads.
|
|
981
1033
|
|
|
982
|
-
Optional Full Listings
|
|
1034
|
+
Optional Full Listings — Normal replies only: when explicitly requested by the user in a non‑diagnostics turn, include Full Listings for the relevant files; otherwise omit listings by default.
|
|
1035
|
+
Diagnostics replies (after patch‑failure envelopes) MUST provide Full, post‑patch listings as described above (no patches, union across envelopes, no commit message).
|
|
1036
|
+
Skip listings for deletions.
|
|
983
1037
|
|
|
984
1038
|
## File Ops (optional pre‑ops; structural changes)
|
|
985
1039
|
|
|
986
1040
|
Use “### File Ops” to declare safe, repo‑relative file and directory operations that run before content patches. File Ops are for structure (moves/renames, creates, deletes), while unified‑diff Patches are for editing file contents.
|
|
987
|
-
|
|
988
1041
|
- Verbs:
|
|
989
1042
|
- mv <src> <dest> # move/rename a file or directory (recursive), no overwrite
|
|
990
1043
|
- cp <src> <dest> # copy a file or directory (recursive), no overwrite; creates parents for <dest>
|
package/package.json
CHANGED