@a-company/paradigm 3.12.0 → 3.13.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/{accept-orchestration-YKMKMWGA.js → accept-orchestration-ORQRKKGR.js} +4 -4
- package/dist/{agents-suggest-35LIQKDH.js → agents-suggest-65SER5IS.js} +1 -1
- package/dist/{aggregate-V4KPR3RW.js → aggregate-M5WMUI6B.js} +1 -1
- package/dist/{auto-6MOGYQ4G.js → auto-B22FVSQI.js} +1 -1
- package/dist/{beacon-XRXL5KZB.js → beacon-XL2ALH5O.js} +1 -1
- package/dist/{check-UZY647TB.js → check-5RKOAN7S.js} +1 -1
- package/dist/{chunk-RDPXBMHK.js → chunk-3BAMPB6I.js} +6 -6
- package/dist/{chunk-5TUAVVIG.js → chunk-6GWRQWQB.js} +1 -1
- package/dist/{chunk-F6EJKLF4.js → chunk-O5ZO5LSW.js} +1 -1
- package/dist/{chunk-UVI3OH3G.js → chunk-R2SGQ22F.js} +11 -58
- package/dist/{chunk-4PEQHWD7.js → chunk-XKAFTZOZ.js} +1 -1
- package/dist/{chunk-5N5LR2KS.js → chunk-XNUWLW73.js} +6 -6
- package/dist/{chunk-JQYGPVLQ.js → chunk-YOFP72IB.js} +1 -1
- package/dist/{chunk-CQFNTBFJ.js → chunk-Z42FOOVT.js} +3 -3
- package/dist/{chunk-CYGHL7PQ.js → chunk-ZMN3RAIT.js} +5 -5
- package/dist/{chunk-4ZO3ZOPM.js → chunk-ZRPEI35Q.js} +14 -59
- package/dist/chunk-ZXMDA7VB.js +16 -0
- package/dist/{claude-SUYNN72C.js → claude-63ISJAZK.js} +1 -1
- package/dist/{claude-cli-OF43XAO3.js → claude-cli-ABML5RHX.js} +1 -1
- package/dist/{claude-code-PW6SKD2M.js → claude-code-JRLMRPTO.js} +1 -1
- package/dist/{claude-code-teams-JLZ5IXB6.js → claude-code-teams-CAJBEFIZ.js} +1 -1
- package/dist/commands-VTFOZPUA.js +5387 -0
- package/dist/{constellation-GNK5DIMH.js → constellation-NXU6Q2HM.js} +1 -1
- package/dist/{cost-AGO5N7DD.js → cost-CTGSLSOC.js} +1 -1
- package/dist/{cost-KYXIQ62X.js → cost-XEBADYFT.js} +1 -1
- package/dist/{cursor-cli-IHJMPRCW.js → cursor-cli-QUOOF2N4.js} +1 -1
- package/dist/{cursorrules-LQFA7M62.js → cursorrules-XBWFX66V.js} +1 -1
- package/dist/{delete-3YXAJ5AA.js → delete-OINCSDQH.js} +2 -2
- package/dist/{diff-4FV7T35U.js → diff-4XJZN4OB.js} +4 -4
- package/dist/{dist-ZEMSQV74.js → dist-3RVKEJRT.js} +1 -1
- package/dist/{dist-Q6SAZI7X.js → dist-7U64HDSC.js} +1 -1
- package/dist/{dist-AG5JNIZU-XSEZ2LLK.js → dist-AG5JNIZU-HW2FWNTZ.js} +1 -1
- package/dist/dist-KY5HGDDL.js +1304 -0
- package/dist/{dist-JOHRYQUA.js → dist-PSF5CP4I.js} +1 -1
- package/dist/{dist-6SX5ZKKF.js → dist-RMAIFRTW.js} +3 -3
- package/dist/{dist-YB7T54QE.js → dist-YHDSIZQD.js} +1 -1
- package/dist/{doctor-2KM5HOK6.js → doctor-FINKMI66.js} +2 -2
- package/dist/{drift-FH2UY64B.js → drift-YGT4LJ7Q.js} +1 -1
- package/dist/{echo-VYZW3OTT.js → echo-A6HD5UP7.js} +1 -1
- package/dist/{edit-EOMPXOG5.js → edit-7FSQNAPE.js} +2 -2
- package/dist/{export-R4FJ5NOH.js → export-T7CMMJIB.js} +1 -1
- package/dist/{flow-MCKPJGRJ.js → flow-UFMPVOEM.js} +1 -1
- package/dist/{global-AXILUM5X.js → global-HHUJSBG5.js} +1 -1
- package/dist/{habits-NC2TRMRV.js → habits-KD4RLIN2.js} +3 -3
- package/dist/{history-EVO3L6SC.js → history-CETCSUCP.js} +1 -1
- package/dist/{hooks-JXYHVGIN.js → hooks-TCUHQMPF.js} +1 -1
- package/dist/index.js +138 -137
- package/dist/{lint-N4LMMEXH.js → lint-53GPXKKI.js} +1 -1
- package/dist/{list-JKBJ7ESH.js → list-Q4R7L7WJ.js} +2 -2
- package/dist/{lore-server-RQH5REZV.js → lore-server-GKZ6ESNJ.js} +1 -1
- package/dist/{manual-Y3QOXWYA.js → manual-AFJ2J2V3.js} +1 -1
- package/dist/mcp.js +4 -4
- package/dist/{orchestrate-IV54FMHD.js → orchestrate-6XGEA655.js} +4 -4
- package/dist/{portal-check-2HI4FFD6.js → portal-check-FF5EKZE5.js} +1 -1
- package/dist/{portal-compliance-KQCTAQTJ.js → portal-compliance-VU4NIFEN.js} +1 -1
- package/dist/{probe-X3J2JX62.js → probe-T77FFIAG.js} +1 -1
- package/dist/{promote-HZH5E5CO.js → promote-XO63XMAN.js} +2 -2
- package/dist/{providers-IONB4YRJ.js → providers-VIBWDN5D.js} +2 -2
- package/dist/{record-EECZ3E4I.js → record-YJ3D3462.js} +2 -2
- package/dist/{reindex-ZM6J53UP.js → reindex-4OOME3TT.js} +1 -1
- package/dist/{remember-3KJZGDUG.js → remember-IEBQHXHZ.js} +1 -1
- package/dist/{review-BF26ILZB.js → review-3OW3KVW7.js} +2 -2
- package/dist/{ripple-JIUAMBLA.js → ripple-DFMXLFWI.js} +1 -1
- package/dist/{sentinel-BGCISNIK.js → sentinel-RERNMWSE.js} +2 -2
- package/dist/sentinel-mcp.js +4181 -0
- package/dist/sentinel.js +35 -0
- package/dist/{serve-H7ZBMODT.js → serve-XLKEMQEH.js} +2 -2
- package/dist/server-CAXNYVV7.js +1616 -0
- package/dist/{server-E2CNZC4K.js → server-V3ANAXDP.js} +1 -1
- package/dist/{setup-UKJ3VGHI.js → setup-HOI52TN3.js} +2 -2
- package/dist/{setup-363IB6MO.js → setup-YNZJQLW7.js} +1 -1
- package/dist/{shift-G2ZCIR5Q.js → shift-SW3GSODO.js} +7 -7
- package/dist/{show-SAMTXEHG.js → show-CJGHREFS.js} +2 -2
- package/dist/{snapshot-KCMONZAO.js → snapshot-XHINQBZS.js} +1 -1
- package/dist/{spawn-7SDONTJN.js → spawn-JSV2HST3.js} +3 -3
- package/dist/{summary-F46FRO3Y.js → summary-NV7SBV5O.js} +1 -1
- package/dist/{switch-CC2KACXO.js → switch-WYUMVNA5.js} +1 -1
- package/dist/{sync-4CNRHUWX.js → sync-ZM4Q3R4U.js} +1 -1
- package/dist/{sync-llms-MCWB37HN.js → sync-llms-JIPP3XX4.js} +1 -1
- package/dist/{team-XUZBPIFZ.js → team-YIYA4ZLX.js} +5 -5
- package/dist/{test-DK2RWLTK.js → test-WTR5Q33E.js} +1 -1
- package/dist/{thread-RNSLADXN.js → thread-3WM7KKID.js} +1 -1
- package/dist/{timeline-TJDVVVA3.js → timeline-ELO5JTQO.js} +2 -2
- package/dist/{triage-MKKIWBSW.js → triage-GJ6GK647.js} +3 -3
- package/dist/{tutorial-L5Q3ZDHK.js → tutorial-GC6QL4US.js} +1 -1
- package/dist/{university-65YJZ2LW.js → university-KVYNACJZ.js} +2 -2
- package/dist/{upgrade-HGF4MBGV.js → upgrade-65QOQXRC.js} +1 -1
- package/dist/{validate-F3YHBCRZ.js → validate-ITC5D6QG.js} +1 -1
- package/dist/{validate-2LTHHORX.js → validate-TKKRGJKC.js} +1 -1
- package/dist/{watch-CL2PPS2K.js → watch-ERBEJUJW.js} +1 -1
- package/dist/{watch-NBPOMOEX.js → watch-X64UK7K4.js} +2 -2
- package/dist/{wisdom-LRM4FFCH.js → wisdom-L2WC7J62.js} +1 -1
- package/dist/{workspace-7CWY4IWV.js → workspace-S5Q5LVA6.js} +1 -1
- package/package.json +7 -2
- package/dist/chunk-MO4EEYFW.js +0 -38
- package/dist/server-3K3TTJH3.js +0 -10539
|
@@ -0,0 +1,1304 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// ../premise/core/dist/index.js
|
|
4
|
+
import * as fs3 from "fs";
|
|
5
|
+
import * as yaml3 from "js-yaml";
|
|
6
|
+
import { z as z2 } from "zod";
|
|
7
|
+
import * as path3 from "path";
|
|
8
|
+
|
|
9
|
+
// ../purpose/core/dist/index.js
|
|
10
|
+
import * as fs from "fs";
|
|
11
|
+
import * as yaml from "js-yaml";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import * as path from "path";
|
|
14
|
+
import { glob } from "glob";
|
|
15
|
+
var PurposeItemSchema = z.object({
|
|
16
|
+
description: z.string(),
|
|
17
|
+
endpoints: z.array(z.string()).optional(),
|
|
18
|
+
tests: z.array(z.string()).optional(),
|
|
19
|
+
rules: z.record(z.unknown()).optional(),
|
|
20
|
+
aspects: z.array(z.string()).optional(),
|
|
21
|
+
// Symbol reference arrays
|
|
22
|
+
flows: z.array(z.string()).optional(),
|
|
23
|
+
gates: z.array(z.string()).optional(),
|
|
24
|
+
signals: z.array(z.string()).optional(),
|
|
25
|
+
states: z.array(z.string()).optional(),
|
|
26
|
+
components: z.array(z.string()).optional(),
|
|
27
|
+
// Extra fields preserved
|
|
28
|
+
tags: z.array(z.string()).optional(),
|
|
29
|
+
location: z.string().optional(),
|
|
30
|
+
locations: z.array(z.string()).optional(),
|
|
31
|
+
uses: z.array(z.string()).optional(),
|
|
32
|
+
"used-by": z.array(z.string()).optional(),
|
|
33
|
+
"used-for": z.array(z.string()).optional(),
|
|
34
|
+
exports: z.array(z.string()).optional(),
|
|
35
|
+
status: z.string().optional(),
|
|
36
|
+
properties: z.record(z.unknown()).optional(),
|
|
37
|
+
handles: z.array(z.string()).optional()
|
|
38
|
+
}).passthrough();
|
|
39
|
+
var PurposeItemArraySchema = PurposeItemSchema.extend({
|
|
40
|
+
id: z.string()
|
|
41
|
+
});
|
|
42
|
+
var SignalDefinitionObjectSchema = z.object({
|
|
43
|
+
description: z.string().optional(),
|
|
44
|
+
category: z.string().optional(),
|
|
45
|
+
severity: z.enum(["info", "warn", "error"]).optional(),
|
|
46
|
+
emitters: z.array(z.string()).optional(),
|
|
47
|
+
related: z.array(z.string()).optional(),
|
|
48
|
+
data: z.record(z.unknown()).optional()
|
|
49
|
+
});
|
|
50
|
+
var SignalDefinitionSchema = z.union([
|
|
51
|
+
SignalDefinitionObjectSchema,
|
|
52
|
+
z.string().transform((desc) => ({ description: desc }))
|
|
53
|
+
]);
|
|
54
|
+
var RelationshipObjectSchema = z.object({
|
|
55
|
+
from: z.string(),
|
|
56
|
+
to: z.string(),
|
|
57
|
+
type: z.string(),
|
|
58
|
+
description: z.string().optional()
|
|
59
|
+
});
|
|
60
|
+
var RelationshipSchema = z.union([RelationshipObjectSchema, z.string()]);
|
|
61
|
+
var FlowStepObjectSchema = z.object({
|
|
62
|
+
component: z.string(),
|
|
63
|
+
action: z.string(),
|
|
64
|
+
description: z.string().optional()
|
|
65
|
+
});
|
|
66
|
+
var FlowStepSchema = z.union([FlowStepObjectSchema, z.string()]);
|
|
67
|
+
var FlowWithStepsSchema = z.object({
|
|
68
|
+
name: z.string(),
|
|
69
|
+
description: z.string().optional(),
|
|
70
|
+
steps: z.array(FlowStepSchema)
|
|
71
|
+
});
|
|
72
|
+
var FlowDefinitionSchema = z.object({
|
|
73
|
+
description: z.string().optional(),
|
|
74
|
+
gates: z.array(z.string()).optional(),
|
|
75
|
+
signals: z.array(z.string()).optional(),
|
|
76
|
+
components: z.array(z.string()).optional(),
|
|
77
|
+
steps: z.array(FlowStepSchema).optional()
|
|
78
|
+
});
|
|
79
|
+
var GateDefinitionSchema = z.object({
|
|
80
|
+
description: z.string().optional(),
|
|
81
|
+
requires: z.array(z.string()).optional(),
|
|
82
|
+
keys: z.array(z.string()).optional(),
|
|
83
|
+
signals: z.array(z.string()).optional()
|
|
84
|
+
});
|
|
85
|
+
var StateDefinitionSchema = z.object({
|
|
86
|
+
description: z.string().optional(),
|
|
87
|
+
default: z.unknown().optional(),
|
|
88
|
+
type: z.string().optional()
|
|
89
|
+
});
|
|
90
|
+
var AspectDefinitionSchema = z.object({
|
|
91
|
+
description: z.string().optional(),
|
|
92
|
+
tags: z.array(z.string()).optional(),
|
|
93
|
+
anchors: z.array(z.string()).optional(),
|
|
94
|
+
"applies-to": z.array(z.string()).optional(),
|
|
95
|
+
enforcement: z.string().optional()
|
|
96
|
+
});
|
|
97
|
+
var ReferenceSchema = z.object({
|
|
98
|
+
target: z.string(),
|
|
99
|
+
type: z.string(),
|
|
100
|
+
path: z.string()
|
|
101
|
+
});
|
|
102
|
+
var PurposeFileSchema = z.object({
|
|
103
|
+
version: z.string().optional(),
|
|
104
|
+
description: z.string().optional(),
|
|
105
|
+
apiSpec: z.string().optional(),
|
|
106
|
+
context: z.array(z.string()).optional(),
|
|
107
|
+
rules: z.record(z.unknown()).optional(),
|
|
108
|
+
// Support both array format [{ id, description }] and record format { id: { description } }
|
|
109
|
+
features: z.union([
|
|
110
|
+
z.array(PurposeItemArraySchema),
|
|
111
|
+
z.record(PurposeItemSchema)
|
|
112
|
+
]).optional(),
|
|
113
|
+
components: z.union([
|
|
114
|
+
z.array(PurposeItemArraySchema),
|
|
115
|
+
z.record(PurposeItemSchema)
|
|
116
|
+
]).optional(),
|
|
117
|
+
gates: z.record(GateDefinitionSchema).optional(),
|
|
118
|
+
states: z.record(StateDefinitionSchema).optional(),
|
|
119
|
+
signals: z.record(SignalDefinitionSchema).optional(),
|
|
120
|
+
aspects: z.record(AspectDefinitionSchema).optional(),
|
|
121
|
+
relationships: z.array(RelationshipSchema).optional(),
|
|
122
|
+
// Support both array format and record format for flows
|
|
123
|
+
flows: z.union([
|
|
124
|
+
z.array(FlowWithStepsSchema),
|
|
125
|
+
z.record(FlowDefinitionSchema)
|
|
126
|
+
]).optional(),
|
|
127
|
+
references: z.array(ReferenceSchema).optional()
|
|
128
|
+
});
|
|
129
|
+
function parsePurposeFile(filePath) {
|
|
130
|
+
const result = parsePurposeFileDetailed(filePath);
|
|
131
|
+
return { data: result.data, errors: result.errors };
|
|
132
|
+
}
|
|
133
|
+
function parsePurposeFileDetailed(filePath) {
|
|
134
|
+
const errors = [];
|
|
135
|
+
const detailedErrors = [];
|
|
136
|
+
let rawContent;
|
|
137
|
+
try {
|
|
138
|
+
rawContent = fs.readFileSync(filePath, "utf8");
|
|
139
|
+
} catch (e) {
|
|
140
|
+
const error = `Cannot read file: ${e.message}`;
|
|
141
|
+
errors.push(error);
|
|
142
|
+
detailedErrors.push({ message: error, type: "file" });
|
|
143
|
+
return { data: null, errors, detailedErrors, rawContent: void 0, isYamlValid: false };
|
|
144
|
+
}
|
|
145
|
+
const processedContent = rawContent.replace(/^([#~!$^][\w-]+):/gm, '"$1":').replace(/^(\s*-\s+)([!#][\w-]+)$/gm, '$1"$2"');
|
|
146
|
+
let data = null;
|
|
147
|
+
try {
|
|
148
|
+
data = yaml.load(processedContent);
|
|
149
|
+
} catch (e) {
|
|
150
|
+
const yamlError = e;
|
|
151
|
+
const line = yamlError.mark?.line ? yamlError.mark.line + 1 : void 0;
|
|
152
|
+
const message = `YAML syntax error: ${yamlError.reason || e.message}`;
|
|
153
|
+
errors.push(`${message}${line ? ` (line ${line})` : ""}`);
|
|
154
|
+
detailedErrors.push({
|
|
155
|
+
message,
|
|
156
|
+
line,
|
|
157
|
+
type: "yaml"
|
|
158
|
+
});
|
|
159
|
+
return { data: null, errors, detailedErrors, rawContent, isYamlValid: false };
|
|
160
|
+
}
|
|
161
|
+
if (data === null || data === void 0) {
|
|
162
|
+
return {
|
|
163
|
+
data: {},
|
|
164
|
+
errors: [],
|
|
165
|
+
detailedErrors: [],
|
|
166
|
+
rawContent,
|
|
167
|
+
isYamlValid: true
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if (typeof data === "object" && data !== null) {
|
|
171
|
+
const obj = data;
|
|
172
|
+
const prefixMap = {
|
|
173
|
+
"#": "components",
|
|
174
|
+
"$": "flows",
|
|
175
|
+
"^": "gates",
|
|
176
|
+
"!": "signals",
|
|
177
|
+
"~": "aspects"
|
|
178
|
+
};
|
|
179
|
+
for (const key of Object.keys(obj)) {
|
|
180
|
+
const prefix = key[0];
|
|
181
|
+
const target = prefixMap[prefix];
|
|
182
|
+
if (!target || key.length < 2) continue;
|
|
183
|
+
const id = key.slice(1);
|
|
184
|
+
const value = obj[key];
|
|
185
|
+
if (typeof value !== "object" || value === null) continue;
|
|
186
|
+
const dict = obj[target] || {};
|
|
187
|
+
if (!(target in obj)) obj[target] = dict;
|
|
188
|
+
if (!(id in dict)) dict[id] = value;
|
|
189
|
+
delete obj[key];
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const parseResult = PurposeFileSchema.safeParse(data);
|
|
193
|
+
if (!parseResult.success) {
|
|
194
|
+
for (const issue of parseResult.error.issues) {
|
|
195
|
+
const path22 = issue.path.join(".");
|
|
196
|
+
const message = issue.message;
|
|
197
|
+
errors.push(`Schema error at ${path22 || "/"}: ${message}`);
|
|
198
|
+
detailedErrors.push({
|
|
199
|
+
message,
|
|
200
|
+
path: path22 || "/",
|
|
201
|
+
type: "schema"
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return { data, errors, detailedErrors, rawContent, isYamlValid: true };
|
|
205
|
+
}
|
|
206
|
+
return { data: parseResult.data, errors: [], detailedErrors: [], rawContent, isYamlValid: true };
|
|
207
|
+
}
|
|
208
|
+
function normalizeItemsToEntries(items) {
|
|
209
|
+
if (!items) return [];
|
|
210
|
+
if (Array.isArray(items)) {
|
|
211
|
+
return items.map((item) => [item.id, item]);
|
|
212
|
+
} else {
|
|
213
|
+
return Object.entries(items);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
async function findPurposeFiles(rootDir) {
|
|
217
|
+
const absoluteRoot = path.resolve(rootDir);
|
|
218
|
+
const files = await glob("**/.purpose", {
|
|
219
|
+
cwd: absoluteRoot,
|
|
220
|
+
absolute: true,
|
|
221
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/.git/**"]
|
|
222
|
+
});
|
|
223
|
+
return files.sort((a, b) => {
|
|
224
|
+
const depthA = a.split(path.sep).length;
|
|
225
|
+
const depthB = b.split(path.sep).length;
|
|
226
|
+
return depthA - depthB;
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
async function getAllPurposeFiles(rootDir) {
|
|
230
|
+
const files = await findPurposeFiles(rootDir);
|
|
231
|
+
const parsed = [];
|
|
232
|
+
for (const filePath of files) {
|
|
233
|
+
const { data, errors } = parsePurposeFile(filePath);
|
|
234
|
+
if (data) {
|
|
235
|
+
parsed.push({ filePath, data });
|
|
236
|
+
if (errors.length > 0) {
|
|
237
|
+
console.warn(`Warnings parsing ${filePath}:`, errors);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return parsed;
|
|
242
|
+
}
|
|
243
|
+
function extractFeatures(parsedFiles) {
|
|
244
|
+
const features = /* @__PURE__ */ new Map();
|
|
245
|
+
for (const { filePath, data } of parsedFiles) {
|
|
246
|
+
const entries = normalizeItemsToEntries(data.features);
|
|
247
|
+
for (const [id, item] of entries) {
|
|
248
|
+
features.set(id, { item, filePath });
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return features;
|
|
252
|
+
}
|
|
253
|
+
function extractComponents(parsedFiles) {
|
|
254
|
+
const components = /* @__PURE__ */ new Map();
|
|
255
|
+
for (const { filePath, data } of parsedFiles) {
|
|
256
|
+
const entries = normalizeItemsToEntries(data.components);
|
|
257
|
+
for (const [id, item] of entries) {
|
|
258
|
+
components.set(id, { item, filePath });
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return components;
|
|
262
|
+
}
|
|
263
|
+
function extractGates(parsedFiles) {
|
|
264
|
+
const gates = /* @__PURE__ */ new Map();
|
|
265
|
+
for (const { filePath, data } of parsedFiles) {
|
|
266
|
+
if (data.gates) {
|
|
267
|
+
for (const [id, item] of Object.entries(data.gates)) {
|
|
268
|
+
gates.set(id, { item, filePath });
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return gates;
|
|
273
|
+
}
|
|
274
|
+
function extractStates(parsedFiles) {
|
|
275
|
+
const states = /* @__PURE__ */ new Map();
|
|
276
|
+
for (const { filePath, data } of parsedFiles) {
|
|
277
|
+
if (data.states) {
|
|
278
|
+
for (const [id, item] of Object.entries(data.states)) {
|
|
279
|
+
states.set(id, { item, filePath });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return states;
|
|
284
|
+
}
|
|
285
|
+
function extractFlows(parsedFiles) {
|
|
286
|
+
const flows = /* @__PURE__ */ new Map();
|
|
287
|
+
for (const { filePath, data } of parsedFiles) {
|
|
288
|
+
if (data.flows) {
|
|
289
|
+
if (Array.isArray(data.flows)) {
|
|
290
|
+
for (const flow of data.flows) {
|
|
291
|
+
flows.set(flow.name, {
|
|
292
|
+
item: {
|
|
293
|
+
id: flow.name,
|
|
294
|
+
description: flow.description,
|
|
295
|
+
steps: flow.steps
|
|
296
|
+
},
|
|
297
|
+
filePath
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
for (const [id, flowDef] of Object.entries(data.flows)) {
|
|
302
|
+
flows.set(id, {
|
|
303
|
+
item: {
|
|
304
|
+
id,
|
|
305
|
+
description: flowDef.description,
|
|
306
|
+
gates: flowDef.gates,
|
|
307
|
+
signals: flowDef.signals,
|
|
308
|
+
components: flowDef.components,
|
|
309
|
+
steps: flowDef.steps
|
|
310
|
+
},
|
|
311
|
+
filePath
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return flows;
|
|
318
|
+
}
|
|
319
|
+
function extractSignals(parsedFiles) {
|
|
320
|
+
const signals = /* @__PURE__ */ new Map();
|
|
321
|
+
for (const { filePath, data } of parsedFiles) {
|
|
322
|
+
if (data.signals) {
|
|
323
|
+
for (const [id, item] of Object.entries(data.signals)) {
|
|
324
|
+
signals.set(id, { item, filePath });
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return signals;
|
|
329
|
+
}
|
|
330
|
+
function extractAspects(parsedFiles) {
|
|
331
|
+
const aspects = /* @__PURE__ */ new Map();
|
|
332
|
+
for (const { filePath, data } of parsedFiles) {
|
|
333
|
+
if (data.aspects) {
|
|
334
|
+
for (const [id, item] of Object.entries(data.aspects)) {
|
|
335
|
+
aspects.set(id, { item, filePath });
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return aspects;
|
|
340
|
+
}
|
|
341
|
+
function extractSymbolReferences(parsedFiles) {
|
|
342
|
+
const refs = [];
|
|
343
|
+
const seen = /* @__PURE__ */ new Set();
|
|
344
|
+
for (const { filePath, data } of parsedFiles) {
|
|
345
|
+
const featureEntries = normalizeItemsToEntries(data.features);
|
|
346
|
+
for (const [id, item] of featureEntries) {
|
|
347
|
+
extractRefsFromItem(`#${id}`, item, filePath, refs, seen);
|
|
348
|
+
}
|
|
349
|
+
const componentEntries = normalizeItemsToEntries(data.components);
|
|
350
|
+
for (const [id, item] of componentEntries) {
|
|
351
|
+
extractRefsFromItem(`#${id}`, item, filePath, refs, seen);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return refs;
|
|
355
|
+
}
|
|
356
|
+
function extractRefsFromItem(sourceSymbol, item, filePath, refs, seen) {
|
|
357
|
+
if (item.flows) {
|
|
358
|
+
for (const flow of item.flows) {
|
|
359
|
+
const symbol = flow.startsWith("$") ? flow : `$${flow}`;
|
|
360
|
+
if (!seen.has(symbol)) {
|
|
361
|
+
seen.add(symbol);
|
|
362
|
+
refs.push({ symbol, type: "flow", sourceSymbol, filePath });
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (item.gates) {
|
|
367
|
+
for (const gate of item.gates) {
|
|
368
|
+
const symbol = gate.startsWith("^") ? gate : `^${gate}`;
|
|
369
|
+
if (!seen.has(symbol)) {
|
|
370
|
+
seen.add(symbol);
|
|
371
|
+
refs.push({ symbol, type: "gate", sourceSymbol, filePath });
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (item.signals) {
|
|
376
|
+
for (const signal of item.signals) {
|
|
377
|
+
const symbol = signal.startsWith("!") ? signal : `!${signal}`;
|
|
378
|
+
if (!seen.has(symbol)) {
|
|
379
|
+
seen.add(symbol);
|
|
380
|
+
refs.push({ symbol, type: "signal", sourceSymbol, filePath });
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (item.states) {
|
|
385
|
+
for (const state of item.states) {
|
|
386
|
+
const symbol = state.startsWith("#") ? state : state.startsWith("%") ? `#${state.slice(1)}` : `#${state}`;
|
|
387
|
+
if (!seen.has(symbol)) {
|
|
388
|
+
seen.add(symbol);
|
|
389
|
+
refs.push({ symbol, type: "component", sourceSymbol, filePath });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (item.components) {
|
|
394
|
+
for (const comp of item.components) {
|
|
395
|
+
const symbol = comp.startsWith("#") ? comp : `#${comp}`;
|
|
396
|
+
if (!seen.has(symbol)) {
|
|
397
|
+
seen.add(symbol);
|
|
398
|
+
refs.push({ symbol, type: "component", sourceSymbol, filePath });
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (item.aspects) {
|
|
403
|
+
for (const aspect of item.aspects) {
|
|
404
|
+
const symbol = aspect.startsWith("~") ? aspect : `~${aspect}`;
|
|
405
|
+
if (!seen.has(symbol)) {
|
|
406
|
+
seen.add(symbol);
|
|
407
|
+
refs.push({ symbol, type: "aspect", sourceSymbol, filePath });
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (item.description) {
|
|
412
|
+
const descRefs = extractSymbolsFromText(item.description);
|
|
413
|
+
for (const { symbol, type } of descRefs) {
|
|
414
|
+
if (!seen.has(symbol)) {
|
|
415
|
+
seen.add(symbol);
|
|
416
|
+
refs.push({ symbol, type, sourceSymbol, filePath });
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
var SYMBOL_BLOCKLIST = /* @__PURE__ */ new Set([
|
|
422
|
+
"$lib",
|
|
423
|
+
"$env",
|
|
424
|
+
"$app",
|
|
425
|
+
"$service-worker",
|
|
426
|
+
"$virtual",
|
|
427
|
+
"$schema",
|
|
428
|
+
"$ref",
|
|
429
|
+
"$id",
|
|
430
|
+
"$type"
|
|
431
|
+
]);
|
|
432
|
+
function extractSymbolsFromText(text) {
|
|
433
|
+
const results = [];
|
|
434
|
+
const pattern = /([$^!#~%])([a-zA-Z][a-zA-Z0-9._-]*)/g;
|
|
435
|
+
let match;
|
|
436
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
437
|
+
const prefix = match[1];
|
|
438
|
+
const id = match[2];
|
|
439
|
+
let symbol;
|
|
440
|
+
let type;
|
|
441
|
+
switch (prefix) {
|
|
442
|
+
case "#":
|
|
443
|
+
type = "component";
|
|
444
|
+
symbol = `#${id}`;
|
|
445
|
+
break;
|
|
446
|
+
case "$":
|
|
447
|
+
type = "flow";
|
|
448
|
+
symbol = `$${id}`;
|
|
449
|
+
break;
|
|
450
|
+
case "^":
|
|
451
|
+
type = "gate";
|
|
452
|
+
symbol = `^${id}`;
|
|
453
|
+
break;
|
|
454
|
+
case "!":
|
|
455
|
+
type = "signal";
|
|
456
|
+
symbol = `!${id}`;
|
|
457
|
+
break;
|
|
458
|
+
case "~":
|
|
459
|
+
type = "aspect";
|
|
460
|
+
symbol = `~${id}`;
|
|
461
|
+
break;
|
|
462
|
+
// Legacy: %state → #component
|
|
463
|
+
case "%":
|
|
464
|
+
type = "component";
|
|
465
|
+
symbol = `#${id}`;
|
|
466
|
+
break;
|
|
467
|
+
default:
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
if (SYMBOL_BLOCKLIST.has(symbol)) continue;
|
|
471
|
+
results.push({ symbol, type });
|
|
472
|
+
}
|
|
473
|
+
return results;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// ../portal/core/dist/index.js
|
|
477
|
+
import * as fs2 from "fs";
|
|
478
|
+
import * as path2 from "path";
|
|
479
|
+
import * as yaml2 from "js-yaml";
|
|
480
|
+
import { glob as glob2 } from "glob";
|
|
481
|
+
var DEFAULT_DEV_SETTINGS = {
|
|
482
|
+
visualizerPort: 42195,
|
|
483
|
+
// Marathon: 42.195km
|
|
484
|
+
watcherPort: 42196,
|
|
485
|
+
// Marathon + 1
|
|
486
|
+
autoConnect: true
|
|
487
|
+
};
|
|
488
|
+
async function parseGateConfig(configPath) {
|
|
489
|
+
const absolutePath = path2.resolve(configPath);
|
|
490
|
+
const rootDir = path2.dirname(absolutePath);
|
|
491
|
+
if (!fs2.existsSync(absolutePath)) {
|
|
492
|
+
throw new Error(`Gate config not found: ${absolutePath}`);
|
|
493
|
+
}
|
|
494
|
+
const content = fs2.readFileSync(absolutePath, "utf8");
|
|
495
|
+
const config = yaml2.load(content);
|
|
496
|
+
if (!config.version) {
|
|
497
|
+
throw new Error('Gate config missing required "version" field');
|
|
498
|
+
}
|
|
499
|
+
const gates = [];
|
|
500
|
+
const configAny = config;
|
|
501
|
+
const gatesSource = config.gates || configAny.portals;
|
|
502
|
+
if (gatesSource) {
|
|
503
|
+
for (const [id, gateDef] of Object.entries(gatesSource)) {
|
|
504
|
+
gates.push(normalizeGate(id, gateDef));
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
if (config.include) {
|
|
508
|
+
for (const pattern of config.include) {
|
|
509
|
+
const fullPattern = path2.join(rootDir, pattern);
|
|
510
|
+
const files = await glob2(fullPattern.replace(/\\/g, "/"));
|
|
511
|
+
for (const file of files) {
|
|
512
|
+
const additionalGates = await parseGateFile(file);
|
|
513
|
+
gates.push(...additionalGates);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
const flows = [];
|
|
518
|
+
if (config.flows) {
|
|
519
|
+
for (const [id, flowDef] of Object.entries(config.flows)) {
|
|
520
|
+
flows.push(normalizeFlow(id, flowDef));
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return {
|
|
524
|
+
version: config.version,
|
|
525
|
+
gates,
|
|
526
|
+
flows,
|
|
527
|
+
settings: {
|
|
528
|
+
dev: {
|
|
529
|
+
...DEFAULT_DEV_SETTINGS,
|
|
530
|
+
...config.settings?.dev
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
async function parseGateFile(filePath) {
|
|
536
|
+
const content = fs2.readFileSync(filePath, "utf8");
|
|
537
|
+
const data = yaml2.load(content);
|
|
538
|
+
if (data.id) {
|
|
539
|
+
return [normalizeGate(data.id, data)];
|
|
540
|
+
}
|
|
541
|
+
if (data.gates) {
|
|
542
|
+
const gates = [];
|
|
543
|
+
for (const [id, gateDef] of Object.entries(data.gates)) {
|
|
544
|
+
gates.push(normalizeGate(id, gateDef));
|
|
545
|
+
}
|
|
546
|
+
return gates;
|
|
547
|
+
}
|
|
548
|
+
return [];
|
|
549
|
+
}
|
|
550
|
+
function normalizeGate(id, def) {
|
|
551
|
+
const locks = [];
|
|
552
|
+
if (def.locks) {
|
|
553
|
+
for (const lockDef of def.locks) {
|
|
554
|
+
locks.push(normalizeLock(lockDef));
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
const prizes = [];
|
|
558
|
+
if (def.prizes) {
|
|
559
|
+
for (const prizeDef of def.prizes) {
|
|
560
|
+
prizes.push(normalizePrize(prizeDef));
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
return {
|
|
564
|
+
id,
|
|
565
|
+
description: def.description,
|
|
566
|
+
locks,
|
|
567
|
+
prizes,
|
|
568
|
+
position: def.position
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function normalizeLock(def) {
|
|
572
|
+
const lockDef = def;
|
|
573
|
+
const keys = [];
|
|
574
|
+
if (lockDef.keys) {
|
|
575
|
+
for (const keyDef of lockDef.keys) {
|
|
576
|
+
if (typeof keyDef === "string") {
|
|
577
|
+
keys.push({ expression: keyDef });
|
|
578
|
+
} else if (keyDef.expression) {
|
|
579
|
+
const k = keyDef;
|
|
580
|
+
keys.push({
|
|
581
|
+
expression: k.expression,
|
|
582
|
+
description: k.description
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return {
|
|
588
|
+
id: lockDef.id,
|
|
589
|
+
description: lockDef.description,
|
|
590
|
+
keys,
|
|
591
|
+
mode: lockDef.mode || "all"
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
function normalizePrize(def) {
|
|
595
|
+
const prizeDef = def;
|
|
596
|
+
return {
|
|
597
|
+
id: prizeDef.id,
|
|
598
|
+
oneTime: prizeDef.oneTime ?? false,
|
|
599
|
+
metadata: prizeDef.metadata
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
function normalizeFlow(id, def) {
|
|
603
|
+
return {
|
|
604
|
+
id,
|
|
605
|
+
description: def.description,
|
|
606
|
+
gates: def.gates || [],
|
|
607
|
+
forkable: def.forkable
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
async function findGateFiles(rootDir) {
|
|
611
|
+
const absoluteRoot = path2.resolve(rootDir);
|
|
612
|
+
const files = await glob2("**/portal.yaml", {
|
|
613
|
+
cwd: absoluteRoot,
|
|
614
|
+
absolute: true,
|
|
615
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/.git/**"]
|
|
616
|
+
});
|
|
617
|
+
return files;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// ../premise/core/dist/index.js
|
|
621
|
+
var SYMBOL_PREFIXES = {
|
|
622
|
+
component: "#",
|
|
623
|
+
flow: "$",
|
|
624
|
+
gate: "^",
|
|
625
|
+
signal: "!",
|
|
626
|
+
aspect: "~"
|
|
627
|
+
};
|
|
628
|
+
var PREFIX_TO_TYPE = {
|
|
629
|
+
"#": "component",
|
|
630
|
+
"$": "flow",
|
|
631
|
+
"^": "gate",
|
|
632
|
+
"!": "signal",
|
|
633
|
+
"~": "aspect"
|
|
634
|
+
};
|
|
635
|
+
var VALID_PREFIXES = ["#", "$", "^", "!", "~"];
|
|
636
|
+
function isValidPrefix(prefix) {
|
|
637
|
+
return VALID_PREFIXES.includes(prefix);
|
|
638
|
+
}
|
|
639
|
+
var PositionSchema = z2.object({
|
|
640
|
+
x: z2.number(),
|
|
641
|
+
y: z2.number()
|
|
642
|
+
});
|
|
643
|
+
var ViewportSchema = z2.object({
|
|
644
|
+
x: z2.number(),
|
|
645
|
+
y: z2.number(),
|
|
646
|
+
zoom: z2.number()
|
|
647
|
+
});
|
|
648
|
+
var PremiseSourceConfigSchema = z2.object({
|
|
649
|
+
path: z2.string(),
|
|
650
|
+
include: z2.array(z2.string()).optional(),
|
|
651
|
+
exclude: z2.array(z2.string()).optional()
|
|
652
|
+
});
|
|
653
|
+
var PremiseNodeSchema = z2.object({
|
|
654
|
+
id: z2.string(),
|
|
655
|
+
symbol: z2.string(),
|
|
656
|
+
type: z2.enum(["feature", "component", "flow", "state", "aspect", "gate", "signal", "idea"]),
|
|
657
|
+
content: z2.string().optional(),
|
|
658
|
+
position: PositionSchema,
|
|
659
|
+
tags: z2.array(z2.string()).optional(),
|
|
660
|
+
created: z2.string(),
|
|
661
|
+
modified: z2.string().optional()
|
|
662
|
+
});
|
|
663
|
+
var PremiseConnectionSchema = z2.object({
|
|
664
|
+
from: z2.string(),
|
|
665
|
+
to: z2.string(),
|
|
666
|
+
label: z2.string().optional(),
|
|
667
|
+
type: z2.string().optional()
|
|
668
|
+
});
|
|
669
|
+
var PremiseGroupSchema = z2.object({
|
|
670
|
+
id: z2.string(),
|
|
671
|
+
name: z2.string(),
|
|
672
|
+
nodes: z2.array(z2.string()),
|
|
673
|
+
color: z2.string().optional()
|
|
674
|
+
});
|
|
675
|
+
var PremiseLayoutSchema = z2.object({
|
|
676
|
+
viewport: ViewportSchema,
|
|
677
|
+
groups: z2.array(PremiseGroupSchema).optional()
|
|
678
|
+
});
|
|
679
|
+
var PremiseSnapshotStateSchema = z2.object({
|
|
680
|
+
nodes: z2.array(PremiseNodeSchema),
|
|
681
|
+
connections: z2.array(PremiseConnectionSchema),
|
|
682
|
+
layout: PremiseLayoutSchema
|
|
683
|
+
});
|
|
684
|
+
var PremiseSnapshotSchema = z2.object({
|
|
685
|
+
id: z2.string(),
|
|
686
|
+
name: z2.string(),
|
|
687
|
+
timestamp: z2.string(),
|
|
688
|
+
description: z2.string().optional(),
|
|
689
|
+
state: PremiseSnapshotStateSchema
|
|
690
|
+
});
|
|
691
|
+
var PremiseFileSchema = z2.object({
|
|
692
|
+
version: z2.string(),
|
|
693
|
+
metadata: z2.object({
|
|
694
|
+
name: z2.string(),
|
|
695
|
+
created: z2.string(),
|
|
696
|
+
modified: z2.string()
|
|
697
|
+
}),
|
|
698
|
+
sources: z2.object({
|
|
699
|
+
purpose: z2.array(PremiseSourceConfigSchema).optional(),
|
|
700
|
+
portal: z2.array(PremiseSourceConfigSchema).optional()
|
|
701
|
+
}),
|
|
702
|
+
nodes: z2.array(PremiseNodeSchema),
|
|
703
|
+
connections: z2.array(PremiseConnectionSchema),
|
|
704
|
+
layout: PremiseLayoutSchema,
|
|
705
|
+
snapshots: z2.array(PremiseSnapshotSchema).optional()
|
|
706
|
+
});
|
|
707
|
+
function parsePremiseFile(filePath) {
|
|
708
|
+
const errors = [];
|
|
709
|
+
let rawContent;
|
|
710
|
+
try {
|
|
711
|
+
rawContent = fs3.readFileSync(filePath, "utf8");
|
|
712
|
+
} catch (e) {
|
|
713
|
+
errors.push(`Cannot read file: ${e.message}`);
|
|
714
|
+
return { data: null, errors, rawContent: void 0 };
|
|
715
|
+
}
|
|
716
|
+
return parsePremiseContent(rawContent);
|
|
717
|
+
}
|
|
718
|
+
function parsePremiseContent(content) {
|
|
719
|
+
const errors = [];
|
|
720
|
+
let data = null;
|
|
721
|
+
try {
|
|
722
|
+
data = yaml3.load(content);
|
|
723
|
+
} catch (e) {
|
|
724
|
+
const yamlError = e;
|
|
725
|
+
const line = yamlError.mark?.line ? yamlError.mark.line + 1 : void 0;
|
|
726
|
+
errors.push(`YAML syntax error: ${yamlError.reason || e.message}${line ? ` (line ${line})` : ""}`);
|
|
727
|
+
return { data: null, errors, rawContent: content };
|
|
728
|
+
}
|
|
729
|
+
if (data === null || data === void 0) {
|
|
730
|
+
return {
|
|
731
|
+
data: createEmptyPremiseFile(),
|
|
732
|
+
errors: [],
|
|
733
|
+
rawContent: content
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
const parseResult = PremiseFileSchema.safeParse(data);
|
|
737
|
+
if (!parseResult.success) {
|
|
738
|
+
for (const issue of parseResult.error.issues) {
|
|
739
|
+
const path22 = issue.path.join(".");
|
|
740
|
+
errors.push(`Schema error at ${path22 || "/"}: ${issue.message}`);
|
|
741
|
+
}
|
|
742
|
+
return { data, errors, rawContent: content };
|
|
743
|
+
}
|
|
744
|
+
return { data: parseResult.data, errors: [], rawContent: content };
|
|
745
|
+
}
|
|
746
|
+
function createEmptyPremiseFile(name = "Untitled") {
|
|
747
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
748
|
+
return {
|
|
749
|
+
version: "1.0.0",
|
|
750
|
+
metadata: {
|
|
751
|
+
name,
|
|
752
|
+
created: now,
|
|
753
|
+
modified: now
|
|
754
|
+
},
|
|
755
|
+
sources: {
|
|
756
|
+
purpose: [{ path: "./" }],
|
|
757
|
+
portal: [{ path: "./portal.yaml" }]
|
|
758
|
+
},
|
|
759
|
+
nodes: [],
|
|
760
|
+
connections: [],
|
|
761
|
+
layout: {
|
|
762
|
+
viewport: { x: 0, y: 0, zoom: 1 }
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
function serializePremiseFile(data) {
|
|
767
|
+
data.metadata.modified = (/* @__PURE__ */ new Date()).toISOString();
|
|
768
|
+
return yaml3.dump(data, {
|
|
769
|
+
indent: 2,
|
|
770
|
+
lineWidth: -1,
|
|
771
|
+
noRefs: true,
|
|
772
|
+
sortKeys: false
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
function getDefaultPremiseContent(projectName = "My Project") {
|
|
776
|
+
return serializePremiseFile(createEmptyPremiseFile(projectName));
|
|
777
|
+
}
|
|
778
|
+
function addPremiseNode(premiseFile, node) {
|
|
779
|
+
return {
|
|
780
|
+
...premiseFile,
|
|
781
|
+
nodes: [...premiseFile.nodes, node],
|
|
782
|
+
metadata: {
|
|
783
|
+
...premiseFile.metadata,
|
|
784
|
+
modified: (/* @__PURE__ */ new Date()).toISOString()
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
function updateNodePosition(premiseFile, nodeId, position) {
|
|
789
|
+
return {
|
|
790
|
+
...premiseFile,
|
|
791
|
+
nodes: premiseFile.nodes.map(
|
|
792
|
+
(n) => n.id === nodeId ? { ...n, position, modified: (/* @__PURE__ */ new Date()).toISOString() } : n
|
|
793
|
+
),
|
|
794
|
+
metadata: {
|
|
795
|
+
...premiseFile.metadata,
|
|
796
|
+
modified: (/* @__PURE__ */ new Date()).toISOString()
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
function addConnection(premiseFile, connection) {
|
|
801
|
+
const exists = premiseFile.connections.some(
|
|
802
|
+
(c) => c.from === connection.from && c.to === connection.to
|
|
803
|
+
);
|
|
804
|
+
if (exists) return premiseFile;
|
|
805
|
+
return {
|
|
806
|
+
...premiseFile,
|
|
807
|
+
connections: [...premiseFile.connections, connection],
|
|
808
|
+
metadata: {
|
|
809
|
+
...premiseFile.metadata,
|
|
810
|
+
modified: (/* @__PURE__ */ new Date()).toISOString()
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
function createSnapshot(premiseFile, name, description) {
|
|
815
|
+
const snapshot = {
|
|
816
|
+
id: `snap-${Date.now()}`,
|
|
817
|
+
name,
|
|
818
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
819
|
+
description,
|
|
820
|
+
state: {
|
|
821
|
+
nodes: [...premiseFile.nodes],
|
|
822
|
+
connections: [...premiseFile.connections],
|
|
823
|
+
layout: { ...premiseFile.layout }
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
return {
|
|
827
|
+
...premiseFile,
|
|
828
|
+
snapshots: [...premiseFile.snapshots || [], snapshot],
|
|
829
|
+
metadata: {
|
|
830
|
+
...premiseFile.metadata,
|
|
831
|
+
modified: (/* @__PURE__ */ new Date()).toISOString()
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
async function aggregateFromPremise(premiseFile, rootDir) {
|
|
836
|
+
const symbols = [];
|
|
837
|
+
const errors = [];
|
|
838
|
+
const purposeFiles = [];
|
|
839
|
+
const portalFiles = [];
|
|
840
|
+
if (premiseFile.sources.purpose) {
|
|
841
|
+
for (const source of premiseFile.sources.purpose) {
|
|
842
|
+
const sourcePath = path3.resolve(rootDir, source.path);
|
|
843
|
+
try {
|
|
844
|
+
const parsed = await getAllPurposeFiles(sourcePath);
|
|
845
|
+
purposeFiles.push(...parsed.map((p) => p.filePath));
|
|
846
|
+
const features = extractFeatures(parsed);
|
|
847
|
+
for (const [id, { item, filePath }] of features) {
|
|
848
|
+
symbols.push(createSymbolEntry({
|
|
849
|
+
id: `purpose-feature-${id}`,
|
|
850
|
+
symbol: `#${id}`,
|
|
851
|
+
type: "component",
|
|
852
|
+
source: "purpose",
|
|
853
|
+
filePath,
|
|
854
|
+
data: item,
|
|
855
|
+
description: item.description,
|
|
856
|
+
tags: ["feature"]
|
|
857
|
+
}));
|
|
858
|
+
}
|
|
859
|
+
const components = extractComponents(parsed);
|
|
860
|
+
for (const [id, { item, filePath }] of components) {
|
|
861
|
+
symbols.push(createSymbolEntry({
|
|
862
|
+
id: `purpose-component-${id}`,
|
|
863
|
+
symbol: `#${id}`,
|
|
864
|
+
type: "component",
|
|
865
|
+
source: "purpose",
|
|
866
|
+
filePath,
|
|
867
|
+
data: item,
|
|
868
|
+
description: item.description
|
|
869
|
+
}));
|
|
870
|
+
}
|
|
871
|
+
const gates = extractGates(parsed);
|
|
872
|
+
for (const [id, { item, filePath }] of gates) {
|
|
873
|
+
symbols.push(createSymbolEntry({
|
|
874
|
+
id: `purpose-gate-${id}`,
|
|
875
|
+
symbol: `^${id}`,
|
|
876
|
+
type: "gate",
|
|
877
|
+
source: "purpose",
|
|
878
|
+
filePath,
|
|
879
|
+
data: item,
|
|
880
|
+
description: item.description
|
|
881
|
+
}));
|
|
882
|
+
}
|
|
883
|
+
const states = extractStates(parsed);
|
|
884
|
+
for (const [id, { item, filePath }] of states) {
|
|
885
|
+
symbols.push(createSymbolEntry({
|
|
886
|
+
id: `purpose-state-${id}`,
|
|
887
|
+
symbol: `#${id}`,
|
|
888
|
+
type: "component",
|
|
889
|
+
source: "purpose",
|
|
890
|
+
filePath,
|
|
891
|
+
data: item,
|
|
892
|
+
description: item.description,
|
|
893
|
+
tags: ["state"]
|
|
894
|
+
}));
|
|
895
|
+
}
|
|
896
|
+
const flows = extractFlows(parsed);
|
|
897
|
+
for (const [id, { item, filePath }] of flows) {
|
|
898
|
+
symbols.push(createSymbolEntry({
|
|
899
|
+
id: `purpose-flow-${id}`,
|
|
900
|
+
symbol: `$${id}`,
|
|
901
|
+
type: "flow",
|
|
902
|
+
source: "purpose",
|
|
903
|
+
filePath,
|
|
904
|
+
data: item,
|
|
905
|
+
description: item.description
|
|
906
|
+
}));
|
|
907
|
+
}
|
|
908
|
+
const signals = extractSignals(parsed);
|
|
909
|
+
for (const [id, { item, filePath }] of signals) {
|
|
910
|
+
symbols.push(createSymbolEntry({
|
|
911
|
+
id: `purpose-signal-${id}`,
|
|
912
|
+
symbol: `!${id}`,
|
|
913
|
+
type: "signal",
|
|
914
|
+
source: "purpose",
|
|
915
|
+
filePath,
|
|
916
|
+
data: item,
|
|
917
|
+
description: item.description
|
|
918
|
+
}));
|
|
919
|
+
}
|
|
920
|
+
const aspects = extractAspects(parsed);
|
|
921
|
+
for (const [id, { item, filePath }] of aspects) {
|
|
922
|
+
symbols.push(createSymbolEntry({
|
|
923
|
+
id: `purpose-aspect-${id}`,
|
|
924
|
+
symbol: `~${id}`,
|
|
925
|
+
type: "aspect",
|
|
926
|
+
source: "purpose",
|
|
927
|
+
filePath,
|
|
928
|
+
data: item,
|
|
929
|
+
description: item.description,
|
|
930
|
+
anchors: item.anchors?.map((a) => parseAnchorString(a)),
|
|
931
|
+
appliesTo: item["applies-to"],
|
|
932
|
+
tags: item.tags,
|
|
933
|
+
enforcement: item.enforcement
|
|
934
|
+
}));
|
|
935
|
+
}
|
|
936
|
+
const symbolRefs = extractSymbolReferences(parsed);
|
|
937
|
+
const existingSymbols = new Set(symbols.map((s) => s.symbol));
|
|
938
|
+
for (const ref of symbolRefs) {
|
|
939
|
+
if (!existingSymbols.has(ref.symbol)) {
|
|
940
|
+
existingSymbols.add(ref.symbol);
|
|
941
|
+
symbols.push(createSymbolEntry({
|
|
942
|
+
id: `purpose-ref-${ref.type}-${ref.symbol.slice(1)}`,
|
|
943
|
+
symbol: ref.symbol,
|
|
944
|
+
type: ref.type,
|
|
945
|
+
source: "purpose",
|
|
946
|
+
filePath: ref.filePath,
|
|
947
|
+
data: { referencedFrom: ref.sourceSymbol },
|
|
948
|
+
description: `Referenced from ${ref.sourceSymbol}`
|
|
949
|
+
}));
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
} catch (e) {
|
|
953
|
+
errors.push({
|
|
954
|
+
source: "purpose",
|
|
955
|
+
filePath: sourcePath,
|
|
956
|
+
message: e.message
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
if (premiseFile.sources.portal) {
|
|
962
|
+
for (const source of premiseFile.sources.portal) {
|
|
963
|
+
const sourcePath = path3.resolve(rootDir, source.path);
|
|
964
|
+
try {
|
|
965
|
+
let gateConfig;
|
|
966
|
+
if (sourcePath.endsWith(".yaml") || sourcePath.endsWith(".yml")) {
|
|
967
|
+
gateConfig = await parseGateConfig(sourcePath);
|
|
968
|
+
portalFiles.push(sourcePath);
|
|
969
|
+
} else {
|
|
970
|
+
const files = await findGateFiles(sourcePath);
|
|
971
|
+
portalFiles.push(...files);
|
|
972
|
+
if (files.length > 0) {
|
|
973
|
+
gateConfig = await parseGateConfig(files[0]);
|
|
974
|
+
for (let i = 1; i < files.length; i++) {
|
|
975
|
+
const additional = await parseGateConfig(files[i]);
|
|
976
|
+
gateConfig.gates.push(...additional.gates);
|
|
977
|
+
gateConfig.flows.push(...additional.flows);
|
|
978
|
+
}
|
|
979
|
+
} else {
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
for (const gate of gateConfig.gates) {
|
|
984
|
+
symbols.push(createGateSymbol(gate, sourcePath));
|
|
985
|
+
for (const prize of gate.prizes) {
|
|
986
|
+
symbols.push(createSymbolEntry({
|
|
987
|
+
id: `gate-signal-${gate.id}-${prize.id}`,
|
|
988
|
+
symbol: `!${prize.id}`,
|
|
989
|
+
type: "signal",
|
|
990
|
+
source: "portal",
|
|
991
|
+
filePath: sourcePath,
|
|
992
|
+
data: prize,
|
|
993
|
+
description: `Signal from gate ${gate.id}`
|
|
994
|
+
}));
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
for (const flow of gateConfig.flows) {
|
|
998
|
+
symbols.push(createFlowSymbol(flow, sourcePath));
|
|
999
|
+
}
|
|
1000
|
+
} catch (e) {
|
|
1001
|
+
errors.push({
|
|
1002
|
+
source: "portal",
|
|
1003
|
+
filePath: sourcePath,
|
|
1004
|
+
message: e.message
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
for (const node of premiseFile.nodes) {
|
|
1010
|
+
const hasIdeaTag = node.tags?.includes("idea");
|
|
1011
|
+
if (!node.content && !hasIdeaTag) {
|
|
1012
|
+
const existing = symbols.find((s) => s.symbol === node.symbol);
|
|
1013
|
+
if (existing) {
|
|
1014
|
+
existing.position = node.position;
|
|
1015
|
+
existing.tags = node.tags;
|
|
1016
|
+
continue;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
symbols.push(createSymbolEntry({
|
|
1020
|
+
id: node.id,
|
|
1021
|
+
symbol: node.symbol,
|
|
1022
|
+
type: node.type,
|
|
1023
|
+
source: "premise",
|
|
1024
|
+
filePath: ".premise",
|
|
1025
|
+
data: node,
|
|
1026
|
+
description: node.content,
|
|
1027
|
+
position: node.position,
|
|
1028
|
+
tags: node.tags,
|
|
1029
|
+
created: node.created,
|
|
1030
|
+
modified: node.modified
|
|
1031
|
+
}));
|
|
1032
|
+
}
|
|
1033
|
+
resolveReferences(symbols);
|
|
1034
|
+
return {
|
|
1035
|
+
symbols,
|
|
1036
|
+
purposeFiles,
|
|
1037
|
+
portalFiles,
|
|
1038
|
+
errors,
|
|
1039
|
+
timestamp: Date.now()
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
function createSymbolEntry(partial) {
|
|
1043
|
+
return {
|
|
1044
|
+
...partial,
|
|
1045
|
+
data: partial.data ?? null,
|
|
1046
|
+
references: partial.references ?? [],
|
|
1047
|
+
referencedBy: partial.referencedBy ?? []
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
function createGateSymbol(gate, filePath) {
|
|
1051
|
+
return createSymbolEntry({
|
|
1052
|
+
id: `gate-${gate.id}`,
|
|
1053
|
+
symbol: `^${gate.id}`,
|
|
1054
|
+
type: "gate",
|
|
1055
|
+
source: "portal",
|
|
1056
|
+
filePath,
|
|
1057
|
+
data: gate,
|
|
1058
|
+
description: gate.description,
|
|
1059
|
+
position: gate.position
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
function createFlowSymbol(flow, filePath) {
|
|
1063
|
+
return createSymbolEntry({
|
|
1064
|
+
id: `gate-flow-${flow.id}`,
|
|
1065
|
+
symbol: `$${flow.id}`,
|
|
1066
|
+
type: "flow",
|
|
1067
|
+
source: "portal",
|
|
1068
|
+
filePath,
|
|
1069
|
+
data: flow,
|
|
1070
|
+
description: flow.description
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
function parseAnchorString(raw) {
|
|
1074
|
+
const colonIndex = raw.lastIndexOf(":");
|
|
1075
|
+
if (colonIndex === -1 || colonIndex === raw.length - 1) {
|
|
1076
|
+
return { path: raw, lines: 0, raw };
|
|
1077
|
+
}
|
|
1078
|
+
const afterColon = raw.slice(colonIndex + 1);
|
|
1079
|
+
const filePath = raw.slice(0, colonIndex);
|
|
1080
|
+
if (!/^[\d,\- ]+$/.test(afterColon)) {
|
|
1081
|
+
return { path: raw, lines: 0, raw };
|
|
1082
|
+
}
|
|
1083
|
+
if (afterColon.includes("-")) {
|
|
1084
|
+
const [start, end] = afterColon.split("-").map(Number);
|
|
1085
|
+
return { path: filePath, lines: [start, end], raw };
|
|
1086
|
+
} else if (afterColon.includes(",")) {
|
|
1087
|
+
const lines = afterColon.split(",").map(Number);
|
|
1088
|
+
return { path: filePath, lines, raw };
|
|
1089
|
+
} else {
|
|
1090
|
+
return { path: filePath, lines: Number(afterColon), raw };
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
var SYMBOL_BLOCKLIST2 = /* @__PURE__ */ new Set([
|
|
1094
|
+
"$lib",
|
|
1095
|
+
"$env",
|
|
1096
|
+
"$app",
|
|
1097
|
+
"$service-worker",
|
|
1098
|
+
"$virtual",
|
|
1099
|
+
"$schema",
|
|
1100
|
+
"$ref",
|
|
1101
|
+
"$id",
|
|
1102
|
+
"$type"
|
|
1103
|
+
]);
|
|
1104
|
+
function resolveReferences(symbols) {
|
|
1105
|
+
const symbolMap = new Map(symbols.map((s) => [s.symbol, s]));
|
|
1106
|
+
for (const symbol of symbols) {
|
|
1107
|
+
const dataStr = JSON.stringify(symbol.data);
|
|
1108
|
+
const refPattern = /(?:\?[@#$%~^!]|[@#$%~^!?])[a-zA-Z][\w-]*/g;
|
|
1109
|
+
const matches = (dataStr.match(refPattern) || []).filter((m) => !SYMBOL_BLOCKLIST2.has(m));
|
|
1110
|
+
for (const match of matches) {
|
|
1111
|
+
if (match !== symbol.symbol && symbolMap.has(match)) {
|
|
1112
|
+
if (!symbol.references.includes(match)) {
|
|
1113
|
+
symbol.references.push(match);
|
|
1114
|
+
}
|
|
1115
|
+
const target = symbolMap.get(match);
|
|
1116
|
+
if (target && !target.referencedBy.includes(symbol.symbol)) {
|
|
1117
|
+
target.referencedBy.push(symbol.symbol);
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
async function aggregateFromDirectory(rootDir) {
|
|
1124
|
+
const premiseFile = {
|
|
1125
|
+
version: "1.0.0",
|
|
1126
|
+
metadata: {
|
|
1127
|
+
name: path3.basename(rootDir),
|
|
1128
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1129
|
+
modified: (/* @__PURE__ */ new Date()).toISOString()
|
|
1130
|
+
},
|
|
1131
|
+
sources: {
|
|
1132
|
+
purpose: [{ path: "./" }],
|
|
1133
|
+
portal: [{ path: "./" }]
|
|
1134
|
+
},
|
|
1135
|
+
nodes: [],
|
|
1136
|
+
connections: [],
|
|
1137
|
+
layout: {
|
|
1138
|
+
viewport: { x: 0, y: 0, zoom: 1 }
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
return aggregateFromPremise(premiseFile, rootDir);
|
|
1142
|
+
}
|
|
1143
|
+
function createSymbolIndex() {
|
|
1144
|
+
return {
|
|
1145
|
+
entries: /* @__PURE__ */ new Map(),
|
|
1146
|
+
byType: /* @__PURE__ */ new Map(),
|
|
1147
|
+
bySource: /* @__PURE__ */ new Map(),
|
|
1148
|
+
timestamp: 0
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
function buildSymbolIndex(result) {
|
|
1152
|
+
const index = createSymbolIndex();
|
|
1153
|
+
index.timestamp = result.timestamp;
|
|
1154
|
+
for (const symbol of result.symbols) {
|
|
1155
|
+
index.entries.set(symbol.id, symbol);
|
|
1156
|
+
if (!index.byType.has(symbol.type)) {
|
|
1157
|
+
index.byType.set(symbol.type, []);
|
|
1158
|
+
}
|
|
1159
|
+
index.byType.get(symbol.type).push(symbol);
|
|
1160
|
+
if (!index.bySource.has(symbol.source)) {
|
|
1161
|
+
index.bySource.set(symbol.source, []);
|
|
1162
|
+
}
|
|
1163
|
+
index.bySource.get(symbol.source).push(symbol);
|
|
1164
|
+
}
|
|
1165
|
+
return index;
|
|
1166
|
+
}
|
|
1167
|
+
function getSymbol(index, symbol) {
|
|
1168
|
+
for (const entry of index.entries.values()) {
|
|
1169
|
+
if (entry.symbol === symbol) {
|
|
1170
|
+
return entry;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
return void 0;
|
|
1174
|
+
}
|
|
1175
|
+
function getSymbolById(index, id) {
|
|
1176
|
+
return index.entries.get(id);
|
|
1177
|
+
}
|
|
1178
|
+
function getSymbolsByType(index, type) {
|
|
1179
|
+
return index.byType.get(type) || [];
|
|
1180
|
+
}
|
|
1181
|
+
function getSymbolsBySource(index, source) {
|
|
1182
|
+
return index.bySource.get(source) || [];
|
|
1183
|
+
}
|
|
1184
|
+
function searchSymbols(index, query) {
|
|
1185
|
+
const lowerQuery = query.toLowerCase();
|
|
1186
|
+
const results = [];
|
|
1187
|
+
for (const entry of index.entries.values()) {
|
|
1188
|
+
if (entry.symbol.toLowerCase().includes(lowerQuery)) {
|
|
1189
|
+
results.push(entry);
|
|
1190
|
+
continue;
|
|
1191
|
+
}
|
|
1192
|
+
if (entry.description?.toLowerCase().includes(lowerQuery)) {
|
|
1193
|
+
results.push(entry);
|
|
1194
|
+
continue;
|
|
1195
|
+
}
|
|
1196
|
+
if (entry.tags?.some((tag) => tag.toLowerCase().includes(lowerQuery))) {
|
|
1197
|
+
results.push(entry);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
return results;
|
|
1201
|
+
}
|
|
1202
|
+
function getReferencesTo(index, symbol) {
|
|
1203
|
+
const entry = getSymbol(index, symbol);
|
|
1204
|
+
if (!entry) return [];
|
|
1205
|
+
return entry.referencedBy.map((ref) => getSymbol(index, ref)).filter((e) => e !== void 0);
|
|
1206
|
+
}
|
|
1207
|
+
function getReferencesFrom(index, symbol) {
|
|
1208
|
+
const entry = getSymbol(index, symbol);
|
|
1209
|
+
if (!entry) return [];
|
|
1210
|
+
return entry.references.map((ref) => getSymbol(index, ref)).filter((e) => e !== void 0);
|
|
1211
|
+
}
|
|
1212
|
+
function getSymbolsByTag(index, tag) {
|
|
1213
|
+
const results = [];
|
|
1214
|
+
for (const entry of index.entries.values()) {
|
|
1215
|
+
if (entry.tags?.includes(tag)) {
|
|
1216
|
+
results.push(entry);
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
return results;
|
|
1220
|
+
}
|
|
1221
|
+
function getAllTags(index) {
|
|
1222
|
+
const tags = /* @__PURE__ */ new Set();
|
|
1223
|
+
for (const entry of index.entries.values()) {
|
|
1224
|
+
for (const tag of entry.tags || []) {
|
|
1225
|
+
tags.add(tag);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
return Array.from(tags).sort();
|
|
1229
|
+
}
|
|
1230
|
+
function getSymbolCounts(index) {
|
|
1231
|
+
const counts = {
|
|
1232
|
+
component: 0,
|
|
1233
|
+
flow: 0,
|
|
1234
|
+
gate: 0,
|
|
1235
|
+
signal: 0,
|
|
1236
|
+
aspect: 0
|
|
1237
|
+
};
|
|
1238
|
+
for (const [type, symbols] of index.byType) {
|
|
1239
|
+
if (type in counts) {
|
|
1240
|
+
counts[type] = symbols.length;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
return counts;
|
|
1244
|
+
}
|
|
1245
|
+
function getAllSymbols(index) {
|
|
1246
|
+
return Array.from(index.entries.values());
|
|
1247
|
+
}
|
|
1248
|
+
function parseSymbol(symbol) {
|
|
1249
|
+
if (symbol.length < 2) return null;
|
|
1250
|
+
const prefix = symbol[0];
|
|
1251
|
+
const name = symbol.slice(1);
|
|
1252
|
+
if (!isValidPrefix(prefix)) {
|
|
1253
|
+
return null;
|
|
1254
|
+
}
|
|
1255
|
+
const type = PREFIX_TO_TYPE[prefix];
|
|
1256
|
+
return { type, name };
|
|
1257
|
+
}
|
|
1258
|
+
function createSymbolString(type, name) {
|
|
1259
|
+
return `${SYMBOL_PREFIXES[type]}${name}`;
|
|
1260
|
+
}
|
|
1261
|
+
function isValidSymbol(symbol) {
|
|
1262
|
+
return parseSymbol(symbol) !== null;
|
|
1263
|
+
}
|
|
1264
|
+
function getAutocompleteSuggestions(index, partial, limit = 10) {
|
|
1265
|
+
const lowerPartial = partial.toLowerCase();
|
|
1266
|
+
const parsed = parseSymbol(partial);
|
|
1267
|
+
if (parsed) {
|
|
1268
|
+
const typeSymbols = getSymbolsByType(index, parsed.type);
|
|
1269
|
+
return typeSymbols.filter((s) => s.symbol.toLowerCase().includes(lowerPartial)).slice(0, limit);
|
|
1270
|
+
}
|
|
1271
|
+
return searchSymbols(index, partial).slice(0, limit);
|
|
1272
|
+
}
|
|
1273
|
+
export {
|
|
1274
|
+
PREFIX_TO_TYPE,
|
|
1275
|
+
SYMBOL_PREFIXES,
|
|
1276
|
+
addConnection,
|
|
1277
|
+
addPremiseNode,
|
|
1278
|
+
aggregateFromDirectory,
|
|
1279
|
+
aggregateFromPremise,
|
|
1280
|
+
buildSymbolIndex,
|
|
1281
|
+
createEmptyPremiseFile,
|
|
1282
|
+
createSnapshot,
|
|
1283
|
+
createSymbolIndex,
|
|
1284
|
+
createSymbolString,
|
|
1285
|
+
getAllSymbols,
|
|
1286
|
+
getAllTags,
|
|
1287
|
+
getAutocompleteSuggestions,
|
|
1288
|
+
getDefaultPremiseContent,
|
|
1289
|
+
getReferencesFrom,
|
|
1290
|
+
getReferencesTo,
|
|
1291
|
+
getSymbol,
|
|
1292
|
+
getSymbolById,
|
|
1293
|
+
getSymbolCounts,
|
|
1294
|
+
getSymbolsBySource,
|
|
1295
|
+
getSymbolsByTag,
|
|
1296
|
+
getSymbolsByType,
|
|
1297
|
+
isValidSymbol,
|
|
1298
|
+
parsePremiseContent,
|
|
1299
|
+
parsePremiseFile,
|
|
1300
|
+
parseSymbol,
|
|
1301
|
+
searchSymbols,
|
|
1302
|
+
serializePremiseFile,
|
|
1303
|
+
updateNodePosition
|
|
1304
|
+
};
|