@spexcode/spec-core 0.6.2 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/anchors.d.ts +94 -0
  2. package/dist/anchors.js +730 -0
  3. package/dist/git.d.ts +166 -0
  4. package/dist/git.js +2736 -0
  5. package/dist/graph-delta.d.ts +44 -0
  6. package/dist/graph-delta.js +72 -0
  7. package/dist/graph.d.ts +34 -0
  8. package/dist/graph.js +237 -0
  9. package/dist/graphDelta.d.ts +3 -0
  10. package/dist/graphDelta.js +13 -0
  11. package/dist/harness-identity.d.ts +31 -0
  12. package/dist/harness-identity.js +20 -0
  13. package/dist/identity-presets.d.ts +152 -0
  14. package/dist/identity-presets.js +132 -0
  15. package/dist/index.d.ts +45 -0
  16. package/dist/index.js +19 -0
  17. package/dist/layout.d.ts +183 -0
  18. package/dist/layout.js +548 -0
  19. package/dist/process-identity.d.ts +37 -0
  20. package/dist/process-identity.js +214 -0
  21. package/dist/project-identity.d.ts +12 -0
  22. package/dist/project-identity.js +71 -0
  23. package/dist/project-store.d.ts +3 -0
  24. package/dist/project-store.js +14 -0
  25. package/dist/resilience.d.ts +2 -0
  26. package/dist/resilience.js +40 -0
  27. package/dist/review/index.d.ts +3 -0
  28. package/{src → dist}/review/index.js +3 -3
  29. package/dist/review/reviewFilters.d.ts +77 -0
  30. package/dist/review/reviewFilters.js +308 -0
  31. package/dist/review/reviewQuery.d.ts +66 -0
  32. package/dist/review/reviewQuery.js +180 -0
  33. package/dist/review/session.d.ts +4 -0
  34. package/dist/review/session.js +8 -0
  35. package/dist/reviewSnapshot.d.ts +15 -0
  36. package/dist/reviewSnapshot.js +12 -0
  37. package/dist/root-lru.d.ts +4 -0
  38. package/{src/root-lru.ts → dist/root-lru.js} +26 -30
  39. package/dist/specs.d.ts +117 -0
  40. package/dist/specs.js +489 -0
  41. package/package.json +23 -8
  42. package/src/anchors.ts +0 -728
  43. package/src/git.ts +0 -2556
  44. package/src/graph.ts +0 -251
  45. package/src/harness-identity.ts +0 -26
  46. package/src/identity-presets.d.ts +0 -13
  47. package/src/identity-presets.js +0 -138
  48. package/src/index.ts +0 -20
  49. package/src/layout.ts +0 -637
  50. package/src/process-identity.ts +0 -207
  51. package/src/project-identity.ts +0 -73
  52. package/src/project-store.ts +0 -17
  53. package/src/resilience.ts +0 -41
  54. package/src/review/reviewFilters.js +0 -324
  55. package/src/review/reviewQuery.js +0 -174
  56. package/src/review/session.js +0 -13
  57. package/src/reviewSnapshot.ts +0 -28
  58. package/src/specs.ts +0 -498
@@ -12,7 +12,6 @@
12
12
  // This existed twice, verbatim in logic and even in name — `touchRoot` in git.ts (index/drift) and again in
13
13
  // spec-eval's scenariofresh.ts (scenario chains), whose comment said it was "mirroring historyIndex/driftIndex
14
14
  // in git.ts". Both authors knew; neither had anywhere to put it. Now they do.
15
-
16
15
  // slot bound for one cache family. Every caller names its own env knob and default so operators can tune the
17
16
  // families independently, but nobody gets to invent a different FLOOR or a bare literal — a cache whose bound
18
17
  // is a magic number cannot be tuned in the field at all (scenariofresh's was a hardcoded 16).
@@ -20,35 +19,32 @@
20
19
  // NaN for a mistyped value, and `size > NaN` is always false: one typo in an env var silently turned the
21
20
  // bound OFF and let the cache grow without limit. A bound that fails open is worse than no bound, because
22
21
  // nothing reports it. Anything that does not parse to a positive number falls back to the caller's default.
23
- export const rootSlots = (env: string | undefined, fallback: number): number => {
24
- const asked = Number(env)
25
- return Math.max(4, Number.isFinite(asked) && asked > 0 ? asked : fallback)
26
- }
27
-
22
+ export const rootSlots = (env, fallback) => {
23
+ const asked = Number(env);
24
+ return Math.max(4, Number.isFinite(asked) && asked > 0 ? asked : fallback);
25
+ };
28
26
  // Record that `root` now wants `key`, evicting what no root wants any more and keeping `roots` within `slots`.
29
27
  // `cache` is the caller's own keyed store; this owns only the ROOT→key bookkeeping and the eviction decision.
30
- export function touchRoot(
31
- roots: Map<string, string>,
32
- cache: Map<string, unknown> & { delete(key: string): boolean },
33
- root: string,
34
- key: string,
35
- slots: number,
36
- ): void {
37
- const previous = roots.get(root)
38
- if (previous !== key) {
39
- roots.set(root, key)
40
- // the old key survives only while some OTHER root still names it — immutable entries are shared, so
41
- // dropping one root's view must not throw away a sibling checkout's warm work.
42
- if (previous && ![...roots.values()].includes(previous)) cache.delete(previous)
43
- } else {
44
- roots.delete(root)
45
- roots.set(root, key) // recency bump: reinsertion is what makes the eviction loop below pick the oldest
46
- }
47
- while (roots.size > slots) {
48
- const oldest = roots.keys().next().value as string | undefined
49
- if (oldest === undefined) break
50
- const oldKey = roots.get(oldest)
51
- roots.delete(oldest)
52
- if (oldKey && ![...roots.values()].includes(oldKey)) cache.delete(oldKey)
53
- }
28
+ export function touchRoot(roots, cache, root, key, slots) {
29
+ const previous = roots.get(root);
30
+ if (previous !== key) {
31
+ roots.set(root, key);
32
+ // the old key survives only while some OTHER root still names it — immutable entries are shared, so
33
+ // dropping one root's view must not throw away a sibling checkout's warm work.
34
+ if (previous && ![...roots.values()].includes(previous))
35
+ cache.delete(previous);
36
+ }
37
+ else {
38
+ roots.delete(root);
39
+ roots.set(root, key); // recency bump: reinsertion is what makes the eviction loop below pick the oldest
40
+ }
41
+ while (roots.size > slots) {
42
+ const oldest = roots.keys().next().value;
43
+ if (oldest === undefined)
44
+ break;
45
+ const oldKey = roots.get(oldest);
46
+ roots.delete(oldest);
47
+ if (oldKey && ![...roots.values()].includes(oldKey))
48
+ cache.delete(oldKey);
49
+ }
54
50
  }
@@ -0,0 +1,117 @@
1
+ import { type HistoryIndex, type DriftIndex } from './git.js';
2
+ type FmValue = string | string[];
3
+ export declare function parseFrontmatter(src: string): {
4
+ fm: Record<string, FmValue>;
5
+ body: string;
6
+ };
7
+ export type SpecParts = {
8
+ rawSource: string;
9
+ expandedSpec: string;
10
+ };
11
+ declare function parseParts(body: string): SpecParts | null;
12
+ export type DerivedStatus = 'pending' | 'active' | 'merged' | 'drift';
13
+ export declare function deriveStatus(d: {
14
+ version: number;
15
+ drift: number;
16
+ hasOverlay?: boolean;
17
+ hasCode?: boolean;
18
+ fmStatus?: string;
19
+ }): DerivedStatus;
20
+ export declare function mintIds(segs: string[][]): string[];
21
+ export type SpecTreeSnapshot = {
22
+ tip: string;
23
+ files: ReadonlyMap<string, string>;
24
+ };
25
+ export declare function specOwners(file: string): {
26
+ id: string;
27
+ desc: string;
28
+ scoped: boolean;
29
+ }[];
30
+ export declare function specRelated(file: string): {
31
+ id: string;
32
+ desc: string;
33
+ }[];
34
+ export type SpecLite = {
35
+ id: string;
36
+ title: string;
37
+ path: string;
38
+ desc: string;
39
+ body: string;
40
+ };
41
+ export declare function loadSpecsLite(): SpecLite[];
42
+ export declare function specContent(id: string): {
43
+ body: string;
44
+ parts: ReturnType<typeof parseParts>;
45
+ } | null;
46
+ export type LoadSpecsOptions = {
47
+ tip?: string;
48
+ history?: HistoryIndex | null;
49
+ drift?: DriftIndex | null;
50
+ snapshot?: SpecTreeSnapshot;
51
+ };
52
+ export declare function loadSpecs(root?: string, options?: LoadSpecsOptions): Promise<{
53
+ id: string;
54
+ parent: string | null;
55
+ path: string;
56
+ title: string;
57
+ status: DerivedStatus;
58
+ fmStatus: string | null;
59
+ session: string | null;
60
+ hue: number;
61
+ desc: string;
62
+ code: string[];
63
+ codeEntries: import("./anchors.js").RelationEntry[];
64
+ codeScoped: import("./anchors.js").RelationEntry[];
65
+ related: string[];
66
+ relatedEntries: import("./anchors.js").RelationEntry[];
67
+ relatedScoped: import("./anchors.js").RelationEntry[];
68
+ relationProblems: string[];
69
+ version: number;
70
+ reason: string;
71
+ lastEdited: string | null;
72
+ drift: number;
73
+ driftFiles: {
74
+ file: string;
75
+ behind: number;
76
+ }[];
77
+ relatedDriftFiles: {
78
+ file: string;
79
+ behind: number;
80
+ }[];
81
+ body: string;
82
+ parts: SpecParts | null;
83
+ }[]>;
84
+ export declare function specHistory(id: string): Promise<{
85
+ additions: number;
86
+ deletions: number;
87
+ files: number;
88
+ hash: string;
89
+ date: string;
90
+ reason: string;
91
+ session: string | null;
92
+ }[]>;
93
+ export declare function specDiffAt(id: string, hash: string): Promise<{
94
+ hash: string;
95
+ patch: string;
96
+ } | null>;
97
+ export type ConfigPreset = {
98
+ name: string;
99
+ title: string;
100
+ desc: string;
101
+ kind: string;
102
+ dir: string;
103
+ files: string[];
104
+ body: string;
105
+ events: string[];
106
+ order: number;
107
+ block: boolean;
108
+ tools: string[];
109
+ };
110
+ export declare const PLUGIN_INSTANCE_ROOT = ".plugins";
111
+ export declare function loadConfig(): ConfigPreset[];
112
+ export declare function loadSystemConfig(): ConfigPreset[];
113
+ export declare function loadHookConfig(): ConfigPreset[];
114
+ export declare function loadSkillConfig(): ConfigPreset[];
115
+ export declare function loadAgentConfig(): ConfigPreset[];
116
+ export declare function loadReviewConfig(): ConfigPreset[];
117
+ export {};