@karmaniverous/stan-core 0.4.5 → 0.4.7
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/README.md +1 -1
- package/dist/cjs/classifier-ClvtQeTy.js +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/mjs/classifier-Bqzr65UC.js +1 -0
- package/dist/mjs/index.js +1 -1
- package/dist/stan.system.md +50 -7
- package/dist/types/index.d.ts +5 -5
- package/package.json +2 -2
- package/dist/cjs/classifier-D1njCQ3L.js +0 -1
- package/dist/mjs/classifier-DeYwffC_.js +0 -1
package/dist/stan.system.md
CHANGED
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
1. Integrity-first intake: enumerate archive.tar and verify bytes read match header sizes; stop and report on mismatch.
|
|
7
7
|
2. Dev plan first: keep stan.todo.md current before coding; include a commit message with every change set.
|
|
8
|
-
3. Plain unified diffs only:
|
|
8
|
+
3. Plain unified diffs only: include a/ and b/ prefixes; ≥3 lines of context; LF endings.
|
|
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
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
|
+
|
|
15
16
|
- Role
|
|
16
17
|
- Vocabulary aliases
|
|
17
18
|
- Separation of Concerns: System vs Project
|
|
@@ -80,7 +81,6 @@ Key rules
|
|
|
80
81
|
- Create/delete:
|
|
81
82
|
- New file: `--- /dev/null` and `+++ b/<path>`
|
|
82
83
|
- Delete: `--- a/<path>` and `+++ /dev/null`
|
|
83
|
-
- Forbidden wrappers (not valid diffs): `*** Begin Patch`, `*** Add File:`, `Index:` or mbox/email prelude lines. Do not use them.
|
|
84
84
|
|
|
85
85
|
Canonical examples
|
|
86
86
|
|
|
@@ -660,7 +660,6 @@ This is a HARD GATE: the composition MUST fail when a required documentation pat
|
|
|
660
660
|
- Patches must be plain unified diffs.
|
|
661
661
|
- Prefer diffs with a/ b/ prefixes and stable strip levels; include sufficient context.
|
|
662
662
|
- Normalize to UTF‑8 + LF. Avoid BOM and zero‑width characters.
|
|
663
|
-
- Forbidden wrappers: do not emit `*** Begin Patch`, `*** Add File:`, `Index:` or other non‑unified preambles; they are not accepted by `git apply` or `stan patch`.
|
|
664
663
|
- Tool preference & scope
|
|
665
664
|
- File Ops are the preferred method for moving, copying, and deleting files or directories (single or bulk).
|
|
666
665
|
- Diff Patches are the preferred method for creating files or changing them in place.
|
|
@@ -947,6 +946,51 @@ Notes
|
|
|
947
946
|
- Reserved denials remain in effect (e.g., do not place content under `/<stanPath>/diff/**`, `/<stanPath>/patch/**`, or archive outputs in `/<stanPath>/output/**`).
|
|
948
947
|
- The facet‑aware editing guard still applies: do not propose edits under an inactive facet this run; enable the facet first and emit patches next turn.
|
|
949
948
|
|
|
949
|
+
# STAN assistant guide — creation & upkeep policy
|
|
950
|
+
|
|
951
|
+
This repository SHOULD include a “STAN assistant guide” document at
|
|
952
|
+
`guides/stan-assistant-guide.md`, unless the project prompt explicitly declares
|
|
953
|
+
a different single, stable path for the guide (in which case, that declared path
|
|
954
|
+
is authoritative).
|
|
955
|
+
|
|
956
|
+
The assistant guide exists to let STAN assistants use and integrate the library
|
|
957
|
+
effectively without consulting external type definition files or other project
|
|
958
|
+
documentation.
|
|
959
|
+
|
|
960
|
+
Policy
|
|
961
|
+
|
|
962
|
+
- Creation (required):
|
|
963
|
+
- If the assistant guide is missing, create it as part of the first change set
|
|
964
|
+
where you would otherwise rely on it (e.g., when adding/altering public APIs,
|
|
965
|
+
adapters, configuration, or key workflows).
|
|
966
|
+
- Prefer creating it in the same turn as the first relevant code changes so it
|
|
967
|
+
cannot drift from reality.
|
|
968
|
+
- Maintenance (required):
|
|
969
|
+
- Treat the guide as a maintained artifact, not a one-off doc.
|
|
970
|
+
- Whenever a change set materially affects how an assistant should use the
|
|
971
|
+
library (public exports, configuration shape/semantics, runtime invariants,
|
|
972
|
+
query contracts, paging tokens, projection behavior, adapter
|
|
973
|
+
responsibilities, or common pitfalls), update the guide in the same change
|
|
974
|
+
set.
|
|
975
|
+
- When deprecating/renaming APIs or changing semantics, update the guide and
|
|
976
|
+
include migration guidance (old → new), but keep it concise.
|
|
977
|
+
- Intent (what the guide must enable):
|
|
978
|
+
- Provide a self-contained description of the “mental model” (runtime behavior
|
|
979
|
+
and invariants) and the minimum working patterns (how to configure, how to
|
|
980
|
+
call core entrypoints, how to integrate a provider/adapter).
|
|
981
|
+
- Include only the information required to use the library correctly; omit
|
|
982
|
+
narrative or historical context.
|
|
983
|
+
- Constraints (how to keep it effective and reusable):
|
|
984
|
+
- Keep it compact: “as short as possible, but as long as necessary.”
|
|
985
|
+
- Make it self-contained: do not require readers to import or open `.d.ts`
|
|
986
|
+
files, TypeDoc pages, or other repo docs to understand core contracts.
|
|
987
|
+
- Avoid duplicating durable requirements or the dev plan:
|
|
988
|
+
- Requirements belong in `stan.requirements.md`.
|
|
989
|
+
- Work tracking belongs in `stan.todo.md`.
|
|
990
|
+
- The assistant guide should focus on usage contracts and integration.
|
|
991
|
+
- Define any acronyms locally on first use within the guide (especially if
|
|
992
|
+
used outside generic type parameters).
|
|
993
|
+
|
|
950
994
|
# Default Task (when files are provided with no extra prompt)
|
|
951
995
|
|
|
952
996
|
Primary objective — Plan-first
|
|
@@ -1151,7 +1195,6 @@ Before sending a reply, verify all of the following:
|
|
|
1151
1195
|
- There is exactly one Patch block per changed file.
|
|
1152
1196
|
- Each Patch block MUST contain exactly one `diff --git a/<path> b/<path>` header.
|
|
1153
1197
|
- No Patch block contains more than one `diff --git a/<path> b/<path>`.
|
|
1154
|
-
- Forbidden wrappers are not present: `*** Begin Patch`, `*** Add File:`, `Index:` (or similar non‑unified preludes).
|
|
1155
1198
|
- For new files, headers MUST be `--- /dev/null` and `+++ b/<path>`.
|
|
1156
1199
|
- For deleted files, headers MUST be `--- a/<path>` and `+++ /dev/null`.
|
|
1157
1200
|
- Never mix a Patch and a Full Listing for the same file in the same turn.
|
|
@@ -1184,11 +1227,10 @@ Before sending a reply, verify all of the following:
|
|
|
1184
1227
|
|
|
1185
1228
|
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.
|
|
1186
1229
|
|
|
1187
|
-
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.
|
|
1188
|
-
Diagnostics replies (after patch‑failure envelopes) MUST provide Full, post‑patch listings as described above (no patches, union across envelopes, no commit message).
|
|
1189
|
-
Skip listings for deletions.
|
|
1230
|
+
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. Diagnostics replies (after patch‑failure envelopes) MUST provide Full, post‑patch listings as described above (no patches, union across envelopes, no commit message). Skip listings for deletions.
|
|
1190
1231
|
|
|
1191
1232
|
Dev plan Completed enforcement (pre‑send)
|
|
1233
|
+
|
|
1192
1234
|
- If `<stanPath>/system/stan.todo.md` is patched in this turn, enforce late‑append semantics for the “Completed” section:
|
|
1193
1235
|
- “Completed” MUST remain the final major section of the document.
|
|
1194
1236
|
- Only append new lines at the end of “Completed”. Do NOT modify existing lines above the final append point (no edits, no insertions, no re‑ordering).
|
|
@@ -1199,6 +1241,7 @@ Dev plan Completed enforcement (pre‑send)
|
|
|
1199
1241
|
## File Ops (optional pre‑ops; structural changes)
|
|
1200
1242
|
|
|
1201
1243
|
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.
|
|
1244
|
+
|
|
1202
1245
|
- Verbs:
|
|
1203
1246
|
- mv <src> <dest> # move/rename a file or directory (recursive), no overwrite
|
|
1204
1247
|
- cp <src> <dest> # copy a file or directory (recursive), no overwrite; creates parents for <dest>
|
package/dist/types/index.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ type CreateArchiveOptions = {
|
|
|
48
48
|
* });
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
-
declare
|
|
51
|
+
declare function createArchive(cwd: string, stanPath: string, options?: CreateArchiveOptions): Promise<string>;
|
|
52
52
|
|
|
53
53
|
/** Public default STAN path for consumers and internal use. */
|
|
54
54
|
declare const DEFAULT_STAN_PATH = ".stan";
|
|
@@ -137,13 +137,13 @@ type SnapshotUpdateMode = 'never' | 'createIfMissing' | 'replace';
|
|
|
137
137
|
* ```
|
|
138
138
|
* @returns Absolute path to the `.archive.snapshot.json` file.
|
|
139
139
|
*/
|
|
140
|
-
declare
|
|
140
|
+
declare function writeArchiveSnapshot({ cwd, stanPath, includes, excludes, anchors, }: {
|
|
141
141
|
cwd: string;
|
|
142
142
|
stanPath: string;
|
|
143
143
|
includes?: string[];
|
|
144
144
|
excludes?: string[];
|
|
145
145
|
anchors?: string[];
|
|
146
|
-
})
|
|
146
|
+
}): Promise<string>;
|
|
147
147
|
/**
|
|
148
148
|
* Create a diff tar at <stanPath>/output/<baseName>.diff.tar.
|
|
149
149
|
* - If snapshot exists: include only changed files.
|
|
@@ -177,7 +177,7 @@ declare const writeArchiveSnapshot: ({ cwd, stanPath, includes, excludes, anchor
|
|
|
177
177
|
* });
|
|
178
178
|
* ```
|
|
179
179
|
*/
|
|
180
|
-
declare
|
|
180
|
+
declare function createArchiveDiff({ cwd, stanPath, baseName, includes, excludes, updateSnapshot, includeOutputDirInDiff, anchors, onArchiveWarnings, }: {
|
|
181
181
|
cwd: string;
|
|
182
182
|
stanPath: string;
|
|
183
183
|
baseName: string;
|
|
@@ -187,7 +187,7 @@ declare const createArchiveDiff: ({ cwd, stanPath, baseName, includes, excludes,
|
|
|
187
187
|
includeOutputDirInDiff?: boolean;
|
|
188
188
|
anchors?: string[];
|
|
189
189
|
onArchiveWarnings?: (text: string) => void;
|
|
190
|
-
})
|
|
190
|
+
}): Promise<{
|
|
191
191
|
diffPath: string;
|
|
192
192
|
}>;
|
|
193
193
|
|
package/package.json
CHANGED
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
]
|
|
131
131
|
},
|
|
132
132
|
"npm": {
|
|
133
|
-
"publish":
|
|
133
|
+
"publish": false
|
|
134
134
|
}
|
|
135
135
|
},
|
|
136
136
|
"repository": {
|
|
@@ -152,5 +152,5 @@
|
|
|
152
152
|
},
|
|
153
153
|
"type": "module",
|
|
154
154
|
"types": "dist/index.d.ts",
|
|
155
|
-
"version": "0.4.
|
|
155
|
+
"version": "0.4.7"
|
|
156
156
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var t=require("node:fs/promises"),e=require("node:path");const n=1048576;exports.classifyForArchive=async(r,s)=>{const i=[],a=[],o=[];await Promise.all(s.map(async s=>{const c=s.replace(/\\/g,"/");const l=e.resolve(r,s);let h=0;try{h=(await t.stat(l)).size}catch{return}let u,p=!1;try{p=await(async e=>{try{const n=await t.open(e,"r");try{const t=Buffer.allocUnsafe(8192),{bytesRead:e}=await n.read(t,0,t.length,0);for(let n=0;n<e;n+=1)if(0===t[n])return!0;return!1}finally{await n.close().catch(()=>{})}}catch{return!1}})(l)}catch{p=!1}if(p)return void a.push({path:c,size:h});i.push(c);try{if(h<=n||h<5*n){u=(t=>{const e=t.replace(/\r\n/g,"\n");return 0===e.length?0:e.split("\n").length})(await t.readFile(l,"utf8"))}}catch{}(h>n||"number"==typeof u&&u>3e3)&&o.push({path:c,size:h,loc:u})}));const c=[];if(a.length>0){c.push(`Binary files excluded from archive (${a.length.toString()}):`);for(const t of a)c.push(` - ${t.path} (${t.size.toString()} bytes)`);c.push("")}if(o.length>0){c.push(`Large text files (included; consider excludes if unwanted) (${o.length.toString()}):`);for(const t of o){const e=[` - ${t.path}`,`(${t.size.toString()} bytes)`];"number"==typeof t.loc&&e.push(`${t.loc.toString()} LOC`),c.push(e.join(" "))}c.push(""),c.push(`Thresholds: size > ${n.toString()} bytes or LOC > ${3e3.toString()}`)}0===c.length&&c.push("No archive warnings.");const l=c.join("\n")+(c.length?"\n":"");return{textFiles:i,excludedBinaries:a,largeText:o,warningsBody:l}};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{stat as t,readFile as e,open as n}from"node:fs/promises";import{resolve as r}from"node:path";const s=1048576,o=async(o,i)=>{const a=[],c=[],h=[];await Promise.all(i.map(async i=>{const l=i.replace(/\\/g,"/");const u=r(o,i);let p=0;try{p=(await t(u)).size}catch{return}let f,g=!1;try{g=await(async t=>{try{const e=await n(t,"r");try{const t=Buffer.allocUnsafe(8192),{bytesRead:n}=await e.read(t,0,t.length,0);for(let e=0;e<n;e+=1)if(0===t[e])return!0;return!1}finally{await e.close().catch(()=>{})}}catch{return!1}})(u)}catch{g=!1}if(g)return void c.push({path:l,size:p});a.push(l);try{if(p<=s||p<5*s){f=(t=>{const e=t.replace(/\r\n/g,"\n");return 0===e.length?0:e.split("\n").length})(await e(u,"utf8"))}}catch{}(p>s||"number"==typeof f&&f>3e3)&&h.push({path:l,size:p,loc:f})}));const l=[];if(c.length>0){l.push(`Binary files excluded from archive (${c.length.toString()}):`);for(const t of c)l.push(` - ${t.path} (${t.size.toString()} bytes)`);l.push("")}if(h.length>0){l.push(`Large text files (included; consider excludes if unwanted) (${h.length.toString()}):`);for(const t of h){const e=[` - ${t.path}`,`(${t.size.toString()} bytes)`];"number"==typeof t.loc&&e.push(`${t.loc.toString()} LOC`),l.push(e.join(" "))}l.push(""),l.push(`Thresholds: size > ${s.toString()} bytes or LOC > ${3e3.toString()}`)}0===l.length&&l.push("No archive warnings.");const u=l.join("\n")+(l.length?"\n":"");return{textFiles:a,excludedBinaries:c,largeText:h,warningsBody:u}};export{o as classifyForArchive};
|