@karmaniverous/stan-core 0.8.4 → 0.9.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/README.md +0 -10
- package/dist/mjs/index.js +1 -1
- package/dist/stan.system.md +63 -35
- package/dist/types/index.d.ts +2 -30
- package/package.json +1 -1
package/dist/stan.system.md
CHANGED
|
@@ -133,7 +133,7 @@ If this file (`stan.system.md`) is present in the uploaded code base, its conten
|
|
|
133
133
|
- Development plan (`<stanPath>/system/stan.todo.md`): short‑lived, actionable plan that explains how to get from the current state to the desired state.
|
|
134
134
|
- Keep the full file under 300 lines by pruning oldest Completed entries as needed (delete whole oldest entries; do not rewrite retained entries).
|
|
135
135
|
- When a completed item establishes a durable policy, promote that policy to the project prompt.
|
|
136
|
-
- System prompt (this file) is the repo‑agnostic baseline. In downstream repos, propose durable behavior changes in `<stanPath>/system/stan.project.md`. STAN‑repo‑specific authoring/assembly
|
|
136
|
+
- System prompt (this file) is the repo‑agnostic baseline. In downstream repos, propose durable behavior changes in `<stanPath>/system/stan.project.md`. STAN‑repo‑specific authoring/assembly policies belong in that repository’s project prompt.
|
|
137
137
|
|
|
138
138
|
List numbering policy (requirements & plan docs)
|
|
139
139
|
- Do not number primary (top‑level) items in requirements (`stan.project.md`) or plan (`stan.todo.md`) documents. Use unordered lists instead. This avoids unnecessary renumbering churn when priorities change or items are re‑ordered.
|
|
@@ -142,6 +142,9 @@ List numbering policy (requirements & plan docs)
|
|
|
142
142
|
# Operating Model
|
|
143
143
|
|
|
144
144
|
- All interactions occur in chat. You cannot modify local files or run external commands. Developers will copy/paste your output back into their repo as needed.
|
|
145
|
+
- Patch ingestion constraint (important for enforcement):
|
|
146
|
+
- In the default CLI workflow, patch tooling may receive only the patch payload a human user chooses to copy (not the full assistant reply).
|
|
147
|
+
- Do not rely on any “whole-reply validator” for enforcement; enforce cross-patch requirements via the system prompt and human gating.
|
|
145
148
|
- Requirements‑first simplification:
|
|
146
149
|
- When tools in the repository impose constraints that would require brittle or complex workarounds to meet requirements exactly, propose targeted requirement adjustments that achieve a similar outcome with far simpler code. Seek agreement before authoring new code.
|
|
147
150
|
- When asked requirements‑level questions, respond with analysis first (scope, impact, risks, migration); only propose code once the requirement is settled.
|
|
@@ -159,8 +162,14 @@ Discussion Protocol ("Discuss before implementing")
|
|
|
159
162
|
- When the user provides new context (archives, scripts) and instructs to "discuss before implementing" (or similar):
|
|
160
163
|
1. Ingest the new information.
|
|
161
164
|
2. Engage in a **design-level discussion** (requirements analysis, approach options, trade-offs).
|
|
162
|
-
3.
|
|
163
|
-
|
|
165
|
+
3. If dependency graph mode is active and a selection plan is required, you MAY emit patches limited to:
|
|
166
|
+
- `<stanPath>/context/dependency.state.json` (WHAT to select next),
|
|
167
|
+
- `<stanPath>/system/stan.scratch.md` (WHY it was selected),
|
|
168
|
+
- `<stanPath>/system/stan.todo.md`,
|
|
169
|
+
- and a `## Commit Message`.
|
|
170
|
+
You MUST NOT emit implementation code patches or File Ops in this mode.
|
|
171
|
+
4. Otherwise, **STOP.** Do not emit patches or File Ops in the current turn.
|
|
172
|
+
5. Wait until the discussion has reached an **actionable conclusion** and the user explicitly confirms to proceed.
|
|
164
173
|
|
|
165
174
|
# Design‑first lifecycle (always prefer design before code)
|
|
166
175
|
|
|
@@ -368,6 +377,11 @@ diff --git a/src/example.ts b/src/example.ts
|
|
|
368
377
|
- Do not proceed with analysis or patching until the user explicitly confirms the new documents are correct.
|
|
369
378
|
- If the user confirms, proceed and treat the new signature as active for subsequent turns. If not, wait for the correct artifacts.
|
|
370
379
|
|
|
380
|
+
6. No web search for in-repo source code when archives are available.
|
|
381
|
+
- Web search is permitted only for third-party dependency research (Open-Source First) or time-sensitive external facts.
|
|
382
|
+
- External browsing (GitHub, npm docs) is non-authoritative unless the commit/tag is confirmed to match the attached archive.
|
|
383
|
+
- Do not use web search to “locate” repo modules that should be present in the provided artifacts.
|
|
384
|
+
|
|
371
385
|
# Documentation formatting policy (HARD RULE)
|
|
372
386
|
|
|
373
387
|
- NEVER manually hard-wrap narrative Markdown or plain text content anywhere in the repository.
|
|
@@ -581,9 +595,11 @@ Content guidelines (keep it small and high-signal)
|
|
|
581
595
|
When context is tight or replies risk truncation:
|
|
582
596
|
|
|
583
597
|
1) Stop before partial output. Do not emit incomplete patches or listings.
|
|
584
|
-
2)
|
|
598
|
+
2) Dependency graph mode guard:
|
|
599
|
+
- If dependency graph mode is active and you cannot safely emit a complete, useful `dependency.state.json` update (or the explicit `dependency.state.json: no change` signal) plus required companion patches, request a new thread.
|
|
600
|
+
3) Prefer scratch-based continuity:
|
|
585
601
|
- If you can still safely emit patches, update `<stanPath>/system/stan.scratch.md` to reflect the current state and intended next step, then stop.
|
|
586
|
-
|
|
602
|
+
4) If you cannot safely emit patches (including scratch), stop cleanly:
|
|
587
603
|
- Do not attempt to emit partial diffs or long listings.
|
|
588
604
|
- Ask the user to start a new thread and paste the tail of the current discussion alongside the most recent archives.
|
|
589
605
|
|
|
@@ -921,67 +937,79 @@ When dependency graph mode is enabled (via the CLI “context mode”), STAN use
|
|
|
921
937
|
|
|
922
938
|
Dependency artifacts (workspace; gitignored):
|
|
923
939
|
|
|
924
|
-
- Graph (assistant-facing):
|
|
925
|
-
- Selection state (assistant-authored):
|
|
940
|
+
- Graph (assistant-facing): `<stanPath>/context/dependency.meta.json`
|
|
941
|
+
- Selection state (assistant-authored; v2): `<stanPath>/context/dependency.state.json`
|
|
942
|
+
- Host-private integrity map (MUST NOT be archived): `<stanPath>/context/dependency.map.json`
|
|
926
943
|
- Staged external files (engine-staged for archiving):
|
|
927
|
-
- NPM/package deps:
|
|
928
|
-
- Absolute/outside-root deps:
|
|
944
|
+
- NPM/package deps: `<stanPath>/context/npm/<pkgName>/<pkgVersion>/<pathInPackage>`
|
|
945
|
+
- Absolute/outside-root deps: `<stanPath>/context/abs/<sha256(sourceAbs)>/<basename>`
|
|
929
946
|
|
|
930
|
-
Archive outputs (under
|
|
947
|
+
Archive outputs (under `<stanPath>/output/`):
|
|
931
948
|
|
|
932
|
-
-
|
|
933
|
-
-
|
|
934
|
-
-
|
|
935
|
-
- Contains system files + dependency meta;
|
|
949
|
+
- `<stanPath>/output/archive.tar` (full)
|
|
950
|
+
- `<stanPath>/output/archive.diff.tar` (diff)
|
|
951
|
+
- `<stanPath>/output/archive.meta.tar` (meta; only when context mode enabled)
|
|
952
|
+
- Contains system files + dependency meta; omits dependency state always (clean slate for selections).
|
|
953
|
+
- Excludes staged payloads by omission.
|
|
954
|
+
- Never includes `dependency.map.json` (host-private; reserved denial).
|
|
936
955
|
|
|
937
956
|
## Read-only staged imports (baseline rule)
|
|
938
957
|
|
|
939
|
-
Never create, patch, or delete any file under
|
|
958
|
+
Never create, patch, or delete any file under `<stanPath>/imports/**`.
|
|
940
959
|
|
|
941
|
-
Imported content under
|
|
960
|
+
Imported content under `<stanPath>/imports/**` is read-only context staged by tooling. If a document exists both as an explicit import and as dependency-staged context, prefer selecting the explicit `<stanPath>/imports/**` copy in dependency state to avoid archive bloat.
|
|
942
961
|
|
|
943
962
|
## When the assistant must act
|
|
944
963
|
|
|
945
964
|
Treat dependency graph mode as active if `dependency.meta.json` is present in the current archive **OR** has been observed previously in this thread (thread-sticky). Only treat it as inactive if a *full* archive explicitly shows it deleted.
|
|
946
965
|
|
|
947
|
-
When dependency graph mode is active
|
|
966
|
+
When dependency graph mode is active and you emit any Patch blocks in a turn, you MUST do exactly one of:
|
|
967
|
+
|
|
968
|
+
- Patch `<stanPath>/context/dependency.state.json` with a real change (no no-op patches), or
|
|
969
|
+
- Make no dependency state change and include the exact line `dependency.state.json: no change` under `## Input Data Changes`.
|
|
970
|
+
|
|
971
|
+
No-op state patches are forbidden: do not emit a Patch for `dependency.state.json` unless the file contents change.
|
|
948
972
|
|
|
949
|
-
|
|
973
|
+
When you change dependency selection, also update `<stanPath>/system/stan.scratch.md` to capture WHY the selection changed.
|
|
974
|
+
|
|
975
|
+
## State file schema (v2)
|
|
950
976
|
|
|
951
977
|
Concepts:
|
|
952
978
|
|
|
953
|
-
- `nodeId`: a repo-relative POSIX path.
|
|
979
|
+
- `nodeId`: a repo-relative POSIX path (the archive address).
|
|
954
980
|
- Repo-local nodes: e.g., `src/index.ts`, `packages/app/src/a.ts`
|
|
955
|
-
- Staged external nodes: e.g.,
|
|
956
|
-
- `depth`: recursion depth (hops) along outgoing edges.
|
|
957
|
-
|
|
958
|
-
-
|
|
981
|
+
- Staged external nodes: e.g., `<stanPath>/context/npm/zod/4.3.5/index.d.ts`
|
|
982
|
+
- `depth`: recursion depth (hops) along outgoing edges (`0` means seed only; no traversal).
|
|
983
|
+
- `kindMask`: which edge kinds to traverse (bitmask).
|
|
984
|
+
- runtime = `1`
|
|
985
|
+
- type = `2`
|
|
986
|
+
- dynamic = `4`
|
|
987
|
+
- all = `7`
|
|
959
988
|
|
|
960
989
|
Types:
|
|
961
990
|
|
|
962
991
|
~~~~ts
|
|
963
|
-
type
|
|
964
|
-
|
|
965
|
-
type DependencyStateEntry =
|
|
992
|
+
type DependencyStateEntryV2 =
|
|
966
993
|
| string
|
|
967
994
|
| [string, number]
|
|
968
|
-
| [string, number,
|
|
995
|
+
| [string, number, number];
|
|
969
996
|
|
|
970
|
-
type
|
|
971
|
-
|
|
972
|
-
|
|
997
|
+
type DependencyStateFileV2 = {
|
|
998
|
+
v: 2;
|
|
999
|
+
i: DependencyStateEntryV2[];
|
|
1000
|
+
x?: DependencyStateEntryV2[]; // excludes win
|
|
973
1001
|
};
|
|
974
1002
|
~~~~
|
|
975
1003
|
|
|
976
1004
|
Defaults:
|
|
977
1005
|
|
|
978
1006
|
- If `depth` is omitted, it defaults to `0`.
|
|
979
|
-
- If `
|
|
1007
|
+
- If `kindMask` is omitted, it defaults to `7` (runtime + type + dynamic).
|
|
980
1008
|
- Excludes win over includes.
|
|
981
1009
|
|
|
982
1010
|
Semantics:
|
|
983
1011
|
|
|
984
|
-
- Selection expands from each included entry by traversing outgoing edges up to the specified depth, restricted to
|
|
1012
|
+
- Selection expands from each included entry by traversing outgoing edges up to the specified depth, restricted to `kindMask`.
|
|
985
1013
|
- Exclude entries subtract from the final include set using the same traversal semantics (excludes win).
|
|
986
1014
|
|
|
987
1015
|
## Expansion precedence (dependency mode)
|
|
@@ -993,19 +1021,19 @@ Dependency expansion is intended to expand the archive beyond the baseline selec
|
|
|
993
1021
|
|
|
994
1022
|
## Meta archive behavior (thread opener)
|
|
995
1023
|
|
|
996
|
-
When context mode is enabled, tooling produces
|
|
1024
|
+
When context mode is enabled, tooling produces `<stanPath>/output/archive.meta.tar` in addition to the full and diff archives.
|
|
997
1025
|
|
|
998
1026
|
The meta archive is intended for the start of a thread:
|
|
999
1027
|
|
|
1000
1028
|
- It contains system docs + dependency meta.
|
|
1001
|
-
- It
|
|
1029
|
+
- It omits dependency state always (clean slate for selections).
|
|
1002
1030
|
- It excludes staged dependency payloads by omission.
|
|
1003
1031
|
- The assistant should produce an initial `dependency.state.json` based on the prompt and then rely on full/diff archives for subsequent turns.
|
|
1004
1032
|
|
|
1005
1033
|
## Assistant guidance (anti-bloat)
|
|
1006
1034
|
|
|
1007
1035
|
- Prefer shallow recursion and explicit exclusions over deep, unconstrained traversal. Increase depth deliberately when required.
|
|
1008
|
-
- Prefer
|
|
1036
|
+
- Prefer `<stanPath>/imports/**` paths when they satisfy the need; avoid selecting redundant `<stanPath>/context/**` nodes unless the imported copy is incomplete or mismatched.
|
|
1009
1037
|
|
|
1010
1038
|
## Editing Safety (CRITICAL)
|
|
1011
1039
|
|
package/dist/types/index.d.ts
CHANGED
|
@@ -305,34 +305,6 @@ declare function createArchiveDiff({ cwd, stanPath, baseName, includes, excludes
|
|
|
305
305
|
diffPath: string;
|
|
306
306
|
}>;
|
|
307
307
|
|
|
308
|
-
/**
|
|
309
|
-
* Types for response validation (blocks, options, results); used by parser and
|
|
310
|
-
* validator logic.
|
|
311
|
-
* @module
|
|
312
|
-
*/
|
|
313
|
-
type BlockKind = 'patch' | 'full' | 'commit';
|
|
314
|
-
type Block = {
|
|
315
|
-
kind: BlockKind;
|
|
316
|
-
/** Repo-relative target path for patch/listing blocks; undefined for commit. */
|
|
317
|
-
path?: string;
|
|
318
|
-
/** Start index (character offset) in the source for ordering checks. */
|
|
319
|
-
start: number;
|
|
320
|
-
/** Block body (content between its heading and the next heading). */
|
|
321
|
-
body: string;
|
|
322
|
-
};
|
|
323
|
-
type ValidationResult = {
|
|
324
|
-
ok: boolean;
|
|
325
|
-
errors: string[];
|
|
326
|
-
warnings: string[];
|
|
327
|
-
};
|
|
328
|
-
type ValidateResponseOptions = {
|
|
329
|
-
dependencyMode?: boolean;
|
|
330
|
-
stanPath?: string;
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
declare const validateResponseMessage: (text: string, options?: ValidateResponseOptions) => ValidationResult;
|
|
334
|
-
declare const validateOrThrow: (text: string) => void;
|
|
335
|
-
|
|
336
308
|
/**
|
|
337
309
|
* Detect and clean a patch payload from clipboard/file/argument.
|
|
338
310
|
* - Unwraps chat fences and BEGIN/END PATCH banners when they wrap the entire payload.
|
|
@@ -969,5 +941,5 @@ declare const assembleSystemMonolith: (cwd: string, stanPath: string) => Promise
|
|
|
969
941
|
|
|
970
942
|
declare const CORE_VERSION: string;
|
|
971
943
|
|
|
972
|
-
export { CORE_VERSION, DEFAULT_OPEN_COMMAND, DEFAULT_STAN_PATH, applyPatchPipeline, applyWithJsDiff, assembleSystemMonolith, buildDependencyMeta, computeContextAllowlistPlan, computeSelectedNodeIds, createArchive, createArchiveDiff, createArchiveDiffWithDependencyContext, createArchiveWithDependencyContext, createContextArchiveDiffWithDependencyContext, createContextArchiveWithDependencyContext, createMetaArchive, dependencyMapFileSchema, dependencyMapNodeSchema, dependencyMetaFileSchema, dependencyMetaNodeSchema, dependencyStateEntrySchema, dependencyStateFileSchema, detectAndCleanPatch, ensureOutputDir, executeFileOps, expandEntry, findConfigPathSync, getPackagedSystemPromptPath, loadConfig, loadConfigSync, makeGlobMatcher, parseDependencyStateFile, parseFileOpsBlock, prepareDependencyContext, prepareImports, resolveStanPath, resolveStanPathSync, stageDependencyContext, stagePreparedDependencyContext, summarizeContextAllowlistBudget, validateDependencySelection, validateDependencySelectionOrThrow,
|
|
973
|
-
export type { ApplyResult, AssembleResult, AttemptCapture,
|
|
944
|
+
export { CORE_VERSION, DEFAULT_OPEN_COMMAND, DEFAULT_STAN_PATH, applyPatchPipeline, applyWithJsDiff, assembleSystemMonolith, buildDependencyMeta, computeContextAllowlistPlan, computeSelectedNodeIds, createArchive, createArchiveDiff, createArchiveDiffWithDependencyContext, createArchiveWithDependencyContext, createContextArchiveDiffWithDependencyContext, createContextArchiveWithDependencyContext, createMetaArchive, dependencyMapFileSchema, dependencyMapNodeSchema, dependencyMetaFileSchema, dependencyMetaNodeSchema, dependencyStateEntrySchema, dependencyStateFileSchema, detectAndCleanPatch, ensureOutputDir, executeFileOps, expandEntry, findConfigPathSync, getPackagedSystemPromptPath, loadConfig, loadConfigSync, makeGlobMatcher, parseDependencyStateFile, parseFileOpsBlock, prepareDependencyContext, prepareImports, resolveStanPath, resolveStanPathSync, stageDependencyContext, stagePreparedDependencyContext, summarizeContextAllowlistBudget, validateDependencySelection, validateDependencySelectionOrThrow, writeArchiveSnapshot, writeDependencyMapFile, writeDependencyMetaFile };
|
|
945
|
+
export type { ApplyResult, AssembleResult, AttemptCapture, BudgetEntry, BudgetSource, BuildDependencyMetaArgs, BuildDependencyMetaResult, ContextAllowlistBudget, ContextAllowlistPlan, ContextConfig, ContextModeSelection, CreateArchiveDiffWithDependencyContextResult, CreateArchiveFromFilesOptions, CreateArchiveOptions, CreateArchiveWithDependencyContextResult, CreateContextArchiveDiffResult, CreateContextArchiveOptions, CreateContextArchiveResult, DependencyContextInputs, DependencyMapFile, DependencyMapNode, DependencyMetaFile, DependencyMetaNode, DependencyStateEntry, DependencyStateFile, DependencyValidationMismatch, FileOp, FileOpsPlan, ImportsMap, JsDiffOutcome, NodeSource, NormalizedDependencyStateEntry, OpResult, PipelineOutcome, PrepareDependencyContextResult, SelectionReport, SelectionReportCounts, SnapshotUpdateMode, StageDependencyContextArgs, StageDependencyContextResult, StagePreparedDependencyContextResult, StagedEntry, ValidateDependencySelectionResult };
|
package/package.json
CHANGED