@m4ike1/ion-cue 0.1.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 +92 -0
- package/dist/dispatcher.d.ts +31 -0
- package/dist/dispatcher.d.ts.map +1 -0
- package/dist/dispatcher.js +230 -0
- package/dist/dispatcher.js.map +1 -0
- package/dist/harness-bridge.d.ts +13 -0
- package/dist/harness-bridge.d.ts.map +1 -0
- package/dist/harness-bridge.js +29 -0
- package/dist/harness-bridge.js.map +1 -0
- package/dist/harness-router.d.ts +12 -0
- package/dist/harness-router.d.ts.map +1 -0
- package/dist/harness-router.js +189 -0
- package/dist/harness-router.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/injector.d.ts +23 -0
- package/dist/injector.d.ts.map +1 -0
- package/dist/injector.js +62 -0
- package/dist/injector.js.map +1 -0
- package/dist/marks.d.ts +26 -0
- package/dist/marks.d.ts.map +1 -0
- package/dist/marks.js +59 -0
- package/dist/marks.js.map +1 -0
- package/dist/messages.d.ts +23 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +2 -0
- package/dist/messages.js.map +1 -0
- package/dist/registry.d.ts +94 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +582 -0
- package/dist/registry.js.map +1 -0
- package/dist/resolver.d.ts +15 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +50 -0
- package/dist/resolver.js.map +1 -0
- package/dist/scanner.d.ts +32 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +252 -0
- package/dist/scanner.js.map +1 -0
- package/dist/scope.d.ts +25 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +180 -0
- package/dist/scope.js.map +1 -0
- package/dist/secret-store.d.ts +16 -0
- package/dist/secret-store.d.ts.map +1 -0
- package/dist/secret-store.js +89 -0
- package/dist/secret-store.js.map +1 -0
- package/dist/stream-events.d.ts +26 -0
- package/dist/stream-events.d.ts.map +1 -0
- package/dist/stream-events.js +2 -0
- package/dist/stream-events.js.map +1 -0
- package/dist/toml.d.ts +3 -0
- package/dist/toml.d.ts.map +1 -0
- package/dist/toml.js +117 -0
- package/dist/toml.js.map +1 -0
- package/dist/types.d.ts +182 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +5 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +61 -0
- package/dist/validation.js.map +1 -0
- package/package.json +23 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
export class HarnessRouter {
|
|
2
|
+
handlers = new Map();
|
|
3
|
+
register(name, handler) {
|
|
4
|
+
this.handlers.set(name, handler);
|
|
5
|
+
}
|
|
6
|
+
async route(directive, element, session) {
|
|
7
|
+
const handlerName = element.handler;
|
|
8
|
+
if (!handlerName) {
|
|
9
|
+
return { action: "error", error: `Element ${element.name} has no handler` };
|
|
10
|
+
}
|
|
11
|
+
const handler = this.handlers.get(handlerName);
|
|
12
|
+
if (!handler) {
|
|
13
|
+
return { action: "error", error: `Unknown handler: ${handlerName}` };
|
|
14
|
+
}
|
|
15
|
+
const args = this.extractArgs(directive);
|
|
16
|
+
const ctx = {
|
|
17
|
+
element,
|
|
18
|
+
directive,
|
|
19
|
+
session,
|
|
20
|
+
args,
|
|
21
|
+
};
|
|
22
|
+
try {
|
|
23
|
+
return await handler(ctx);
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
return { action: "error", error: String(e) };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async routeColonTier(message, session) {
|
|
30
|
+
const results = [];
|
|
31
|
+
const commands = this.parseColonCommands(message);
|
|
32
|
+
for (const cmd of commands) {
|
|
33
|
+
// For now, we need to resolve the element from the command name.
|
|
34
|
+
// This will be integrated with the registry later.
|
|
35
|
+
// For simplicity, we assume the command name maps to a handler name "harness::<cmd>".
|
|
36
|
+
const handlerName = `harness::${cmd.command}`;
|
|
37
|
+
const handler = this.handlers.get(handlerName);
|
|
38
|
+
if (!handler) {
|
|
39
|
+
results.push({ action: "error", error: `Unknown handler: ${handlerName}` });
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
// We need a dummy element and directive for context.
|
|
43
|
+
// This will be properly implemented when integrated with dispatcher.
|
|
44
|
+
const dummyElement = {
|
|
45
|
+
name: cmd.command,
|
|
46
|
+
description: "",
|
|
47
|
+
version: "",
|
|
48
|
+
class: "harness",
|
|
49
|
+
handler: handlerName,
|
|
50
|
+
tags: {},
|
|
51
|
+
uses: [],
|
|
52
|
+
bodyPath: "",
|
|
53
|
+
tomlPath: "",
|
|
54
|
+
};
|
|
55
|
+
const dummyDirective = {
|
|
56
|
+
raw: cmd.raw,
|
|
57
|
+
element: cmd.command,
|
|
58
|
+
tags: [],
|
|
59
|
+
scope: null,
|
|
60
|
+
line: 0,
|
|
61
|
+
col: 0,
|
|
62
|
+
};
|
|
63
|
+
const ctx = {
|
|
64
|
+
element: dummyElement,
|
|
65
|
+
directive: dummyDirective,
|
|
66
|
+
session,
|
|
67
|
+
args: cmd.arg ? { arg: cmd.arg } : {},
|
|
68
|
+
};
|
|
69
|
+
try {
|
|
70
|
+
const result = await handler(ctx);
|
|
71
|
+
results.push(result);
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
results.push({ action: "error", error: String(e) });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return results;
|
|
78
|
+
}
|
|
79
|
+
generateToolSchema(element) {
|
|
80
|
+
if (element.class !== "harness" || !element.handler) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const inputSchema = {
|
|
84
|
+
type: "object",
|
|
85
|
+
properties: {},
|
|
86
|
+
required: [],
|
|
87
|
+
};
|
|
88
|
+
if (element.inputs) {
|
|
89
|
+
const properties = inputSchema.properties;
|
|
90
|
+
const required = inputSchema.required;
|
|
91
|
+
for (const input of element.inputs) {
|
|
92
|
+
properties[input] = { type: "string" };
|
|
93
|
+
required.push(input);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
name: element.name,
|
|
98
|
+
description: element.description,
|
|
99
|
+
inputSchema,
|
|
100
|
+
execute: async (args) => {
|
|
101
|
+
const directive = {
|
|
102
|
+
raw: `:${element.name} ${Object.values(args).join(" ")}`,
|
|
103
|
+
element: element.name,
|
|
104
|
+
tags: [],
|
|
105
|
+
scope: null,
|
|
106
|
+
line: 0,
|
|
107
|
+
col: 0,
|
|
108
|
+
};
|
|
109
|
+
return await this.route(directive, element, {
|
|
110
|
+
mode: "default",
|
|
111
|
+
activeElements: new Map(),
|
|
112
|
+
overrides: new Map(),
|
|
113
|
+
dispatchHistory: [],
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
getToolSchemas() {
|
|
119
|
+
return Array.from(this.handlers.entries()).map(([handlerName]) => {
|
|
120
|
+
// Derive element-like metadata from handler name
|
|
121
|
+
const name = handlerName.split("::").pop() ?? handlerName;
|
|
122
|
+
return {
|
|
123
|
+
name,
|
|
124
|
+
description: `Harness handler: ${handlerName}`,
|
|
125
|
+
inputSchema: { type: "object", properties: {}, required: [] },
|
|
126
|
+
execute: async (args) => {
|
|
127
|
+
const directive = {
|
|
128
|
+
raw: `:${name} ${Object.values(args).join(" ")}`,
|
|
129
|
+
element: name,
|
|
130
|
+
tags: [],
|
|
131
|
+
scope: null,
|
|
132
|
+
line: 0,
|
|
133
|
+
col: 0,
|
|
134
|
+
};
|
|
135
|
+
const element = {
|
|
136
|
+
name,
|
|
137
|
+
description: "",
|
|
138
|
+
version: "",
|
|
139
|
+
class: "harness",
|
|
140
|
+
handler: handlerName,
|
|
141
|
+
tags: {},
|
|
142
|
+
uses: [],
|
|
143
|
+
bodyPath: "",
|
|
144
|
+
tomlPath: "",
|
|
145
|
+
};
|
|
146
|
+
return await this.route(directive, element, {
|
|
147
|
+
mode: "default",
|
|
148
|
+
activeElements: new Map(),
|
|
149
|
+
overrides: new Map(),
|
|
150
|
+
dispatchHistory: [],
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
extractArgs(directive) {
|
|
157
|
+
const args = {};
|
|
158
|
+
if (directive.tags.length > 0) {
|
|
159
|
+
args.tags = directive.tags;
|
|
160
|
+
args.color = directive.tags[0];
|
|
161
|
+
args.arg = directive.tags.join(" ");
|
|
162
|
+
}
|
|
163
|
+
return args;
|
|
164
|
+
}
|
|
165
|
+
parseColonCommands(message) {
|
|
166
|
+
const commands = [];
|
|
167
|
+
// Simple parsing: split by semicolon, trim, find colon at start.
|
|
168
|
+
const parts = message.split(";");
|
|
169
|
+
for (const part of parts) {
|
|
170
|
+
const trimmed = part.trim();
|
|
171
|
+
if (trimmed.startsWith(":")) {
|
|
172
|
+
const spaceIdx = trimmed.indexOf(" ");
|
|
173
|
+
if (spaceIdx === -1) {
|
|
174
|
+
commands.push({
|
|
175
|
+
command: trimmed.slice(1),
|
|
176
|
+
raw: trimmed,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
const command = trimmed.slice(1, spaceIdx);
|
|
181
|
+
const arg = trimmed.slice(spaceIdx + 1).trim();
|
|
182
|
+
commands.push({ command, arg, raw: trimmed });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return commands;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=harness-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness-router.js","sourceRoot":"","sources":["../src/harness-router.ts"],"names":[],"mappings":"AAUA,MAAM,OAAO,aAAa;IACjB,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;IAErD,QAAQ,CAAC,IAAY,EAAE,OA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C;oBACP,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;oBAC3C,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;oBAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;gBAC/C,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,QAAQ,CAAC;IAAA,CAChB;CACD","sourcesContent":["import type {\n\tCueDirective,\n\tCueRegisteredTool,\n\tElementDef,\n\tHarnessContext,\n\tHarnessHandler,\n\tHarnessResult,\n\tSessionState,\n} from \"./types.ts\";\n\nexport class HarnessRouter {\n\tprivate handlers = new Map<string, HarnessHandler>();\n\n\tregister(name: string, handler: HarnessHandler): void {\n\t\tthis.handlers.set(name, handler);\n\t}\n\n\tasync route(directive: CueDirective, element: ElementDef, session: SessionState): Promise<HarnessResult> {\n\t\tconst handlerName = element.handler;\n\t\tif (!handlerName) {\n\t\t\treturn { action: \"error\", error: `Element ${element.name} has no handler` };\n\t\t}\n\t\tconst handler = this.handlers.get(handlerName);\n\t\tif (!handler) {\n\t\t\treturn { action: \"error\", error: `Unknown handler: ${handlerName}` };\n\t\t}\n\n\t\tconst args = this.extractArgs(directive);\n\t\tconst ctx: HarnessContext = {\n\t\t\telement,\n\t\t\tdirective,\n\t\t\tsession,\n\t\t\targs,\n\t\t};\n\n\t\ttry {\n\t\t\treturn await handler(ctx);\n\t\t} catch (e) {\n\t\t\treturn { action: \"error\", error: String(e) };\n\t\t}\n\t}\n\n\tasync routeColonTier(message: string, session: SessionState): Promise<HarnessResult[]> {\n\t\tconst results: HarnessResult[] = [];\n\t\tconst commands = this.parseColonCommands(message);\n\t\tfor (const cmd of commands) {\n\t\t\t// For now, we need to resolve the element from the command name.\n\t\t\t// This will be integrated with the registry later.\n\t\t\t// For simplicity, we assume the command name maps to a handler name \"harness::<cmd>\".\n\t\t\tconst handlerName = `harness::${cmd.command}`;\n\t\t\tconst handler = this.handlers.get(handlerName);\n\t\t\tif (!handler) {\n\t\t\t\tresults.push({ action: \"error\", error: `Unknown handler: ${handlerName}` });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// We need a dummy element and directive for context.\n\t\t\t// This will be properly implemented when integrated with dispatcher.\n\t\t\tconst dummyElement: ElementDef = {\n\t\t\t\tname: cmd.command,\n\t\t\t\tdescription: \"\",\n\t\t\t\tversion: \"\",\n\t\t\t\tclass: \"harness\",\n\t\t\t\thandler: handlerName,\n\t\t\t\ttags: {},\n\t\t\t\tuses: [],\n\t\t\t\tbodyPath: \"\",\n\t\t\t\ttomlPath: \"\",\n\t\t\t};\n\t\t\tconst dummyDirective: CueDirective = {\n\t\t\t\traw: cmd.raw,\n\t\t\t\telement: cmd.command,\n\t\t\t\ttags: [],\n\t\t\t\tscope: null,\n\t\t\t\tline: 0,\n\t\t\t\tcol: 0,\n\t\t\t};\n\t\t\tconst ctx: HarnessContext = {\n\t\t\t\telement: dummyElement,\n\t\t\t\tdirective: dummyDirective,\n\t\t\t\tsession,\n\t\t\t\targs: cmd.arg ? { arg: cmd.arg } : {},\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tconst result = await handler(ctx);\n\t\t\t\tresults.push(result);\n\t\t\t} catch (e) {\n\t\t\t\tresults.push({ action: \"error\", error: String(e) });\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n\n\tgenerateToolSchema(element: ElementDef): CueRegisteredTool | null {\n\t\tif (element.class !== \"harness\" || !element.handler) {\n\t\t\treturn null;\n\t\t}\n\t\tconst inputSchema: Record<string, unknown> = {\n\t\t\ttype: \"object\",\n\t\t\tproperties: {},\n\t\t\trequired: [],\n\t\t};\n\t\tif (element.inputs) {\n\t\t\tconst properties = inputSchema.properties as Record<string, unknown>;\n\t\t\tconst required = inputSchema.required as string[];\n\t\t\tfor (const input of element.inputs) {\n\t\t\t\tproperties[input] = { type: \"string\" };\n\t\t\t\trequired.push(input);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tname: element.name,\n\t\t\tdescription: element.description,\n\t\t\tinputSchema,\n\t\t\texecute: async (args: Record<string, unknown>) => {\n\t\t\t\tconst directive: CueDirective = {\n\t\t\t\t\traw: `:${element.name} ${Object.values(args).join(\" \")}`,\n\t\t\t\t\telement: element.name,\n\t\t\t\t\ttags: [],\n\t\t\t\t\tscope: null,\n\t\t\t\t\tline: 0,\n\t\t\t\t\tcol: 0,\n\t\t\t\t};\n\t\t\t\treturn await this.route(directive, element, {\n\t\t\t\t\tmode: \"default\",\n\t\t\t\t\tactiveElements: new Map(),\n\t\t\t\t\toverrides: new Map(),\n\t\t\t\t\tdispatchHistory: [],\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\t}\n\n\tgetToolSchemas(): CueRegisteredTool[] {\n\t\treturn Array.from(this.handlers.entries()).map(([handlerName]) => {\n\t\t\t// Derive element-like metadata from handler name\n\t\t\tconst name = handlerName.split(\"::\").pop() ?? handlerName;\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\tdescription: `Harness handler: ${handlerName}`,\n\t\t\t\tinputSchema: { type: \"object\", properties: {}, required: [] },\n\t\t\t\texecute: async (args: Record<string, unknown>) => {\n\t\t\t\t\tconst directive: CueDirective = {\n\t\t\t\t\t\traw: `:${name} ${Object.values(args).join(\" \")}`,\n\t\t\t\t\t\telement: name,\n\t\t\t\t\t\ttags: [],\n\t\t\t\t\t\tscope: null,\n\t\t\t\t\t\tline: 0,\n\t\t\t\t\t\tcol: 0,\n\t\t\t\t\t};\n\t\t\t\t\tconst element: ElementDef = {\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tdescription: \"\",\n\t\t\t\t\t\tversion: \"\",\n\t\t\t\t\t\tclass: \"harness\",\n\t\t\t\t\t\thandler: handlerName,\n\t\t\t\t\t\ttags: {},\n\t\t\t\t\t\tuses: [],\n\t\t\t\t\t\tbodyPath: \"\",\n\t\t\t\t\t\ttomlPath: \"\",\n\t\t\t\t\t};\n\t\t\t\t\treturn await this.route(directive, element, {\n\t\t\t\t\t\tmode: \"default\",\n\t\t\t\t\t\tactiveElements: new Map(),\n\t\t\t\t\t\toverrides: new Map(),\n\t\t\t\t\t\tdispatchHistory: [],\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\t}\n\n\tprivate extractArgs(directive: CueDirective): Record<string, unknown> {\n\t\tconst args: Record<string, unknown> = {};\n\t\tif (directive.tags.length > 0) {\n\t\t\targs.tags = directive.tags;\n\t\t\targs.color = directive.tags[0];\n\t\t\targs.arg = directive.tags.join(\" \");\n\t\t}\n\t\treturn args;\n\t}\n\n\tprivate parseColonCommands(message: string): Array<{ command: string; arg?: string; raw: string }> {\n\t\tconst commands: Array<{ command: string; arg?: string; raw: string }> = [];\n\t\t// Simple parsing: split by semicolon, trim, find colon at start.\n\t\tconst parts = message.split(\";\");\n\t\tfor (const part of parts) {\n\t\t\tconst trimmed = part.trim();\n\t\t\tif (trimmed.startsWith(\":\")) {\n\t\t\t\tconst spaceIdx = trimmed.indexOf(\" \");\n\t\t\t\tif (spaceIdx === -1) {\n\t\t\t\t\tcommands.push({\n\t\t\t\t\t\tcommand: trimmed.slice(1),\n\t\t\t\t\t\traw: trimmed,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tconst command = trimmed.slice(1, spaceIdx);\n\t\t\t\t\tconst arg = trimmed.slice(spaceIdx + 1).trim();\n\t\t\t\t\tcommands.push({ command, arg, raw: trimmed });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn commands;\n\t}\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type { DispatcherOptions } from "./dispatcher.ts";
|
|
2
|
+
export { additionalContextFromDispatchResult, beforeTurn, cueDispatcher } from "./dispatcher.ts";
|
|
3
|
+
export { generateToolDefinition, registerHarnessTools, type ToolDefinition, } from "./harness-bridge.ts";
|
|
4
|
+
export { HarnessRouter } from "./harness-router.ts";
|
|
5
|
+
export { buildAdditionalContext, buildScopeInjection } from "./injector.ts";
|
|
6
|
+
export { collectMarks, type Mark } from "./marks.ts";
|
|
7
|
+
export type { CueMessage, CueMessageContent, CueTextContent, CueToolResultContent, CueToolUseContent, } from "./messages.ts";
|
|
8
|
+
export { CueRegistry, type CueRoot, cueDiscoveryRoots } from "./registry.ts";
|
|
9
|
+
export { type ResolvedDirective, resolveDirective, resolveSections, } from "./resolver.ts";
|
|
10
|
+
export { findFencedBlocks, scan, scanDirectives, stripSpans } from "./scanner.ts";
|
|
11
|
+
export { SecretStore, type SecretStoreOptions } from "./secret-store.ts";
|
|
12
|
+
export type { CueDoneEvent, CueErrorEvent, CueStreamEvent, CueTextDeltaEvent, CueToolUseDeltaEvent, CueToolUseEndEvent, } from "./stream-events.ts";
|
|
13
|
+
export { parseElementToml } from "./toml.ts";
|
|
14
|
+
export type { ActiveElement, AliasCommand, BehavioralDimension, CueAfterToolCallContext, CueAgentConfig, CueBeforeToolCallContext, CueBeforeToolCallResult, CueDirective, CueRegisteredTool, CueScope, CueToolSchema, Directive, DispatchEntry, DispatchResult, ElementDef, HarnessAction, HarnessContext, HarnessHandler, HarnessResult, Injection, SectionRange, SessionState, SystemNavCommand, TagDef, } from "./types.ts";
|
|
15
|
+
export { detectCircularUses, detectConflictingReplace, validateVersionPin } from "./validation.ts";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,mCAAmC,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjG,OAAO,EACN,sBAAsB,EACtB,oBAAoB,EACpB,KAAK,cAAc,GACnB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.ts\";\nexport { additionalContextFromDispatchResult, beforeTurn, cueDispatcher } from \"./dispatcher.ts\";\nexport {\n\tgenerateToolDefinition,\n\tregisterHarnessTools,\n\ttype ToolDefinition,\n} from \"./harness-bridge.ts\";\nexport { HarnessRouter } from \"./harness-router.ts\";\nexport { buildAdditionalContext, buildScopeInjection } from \"./injector.ts\";\nexport { collectMarks, type Mark } from \"./marks.ts\";\nexport type {\n\tCueMessage,\n\tCueMessageContent,\n\tCueTextContent,\n\tCueToolResultContent,\n\tCueToolUseContent,\n} from \"./messages.ts\";\nexport { CueRegistry, type CueRoot, cueDiscoveryRoots } from \"./registry.ts\";\nexport {\n\ttype ResolvedDirective,\n\tresolveDirective,\n\tresolveSections,\n} from \"./resolver.ts\";\nexport { findFencedBlocks, scan, scanDirectives, stripSpans } from \"./scanner.ts\";\nexport { SecretStore, type SecretStoreOptions } from \"./secret-store.ts\";\nexport type {\n\tCueDoneEvent,\n\tCueErrorEvent,\n\tCueStreamEvent,\n\tCueTextDeltaEvent,\n\tCueToolUseDeltaEvent,\n\tCueToolUseEndEvent,\n} from \"./stream-events.ts\";\nexport { parseElementToml } from \"./toml.ts\";\nexport type {\n\tActiveElement,\n\tAliasCommand,\n\tBehavioralDimension,\n\tCueAfterToolCallContext,\n\tCueAgentConfig,\n\tCueBeforeToolCallContext,\n\tCueBeforeToolCallResult,\n\tCueDirective,\n\tCueRegisteredTool,\n\tCueScope,\n\tCueToolSchema,\n\tDirective,\n\tDispatchEntry,\n\tDispatchResult,\n\tElementDef,\n\tHarnessAction,\n\tHarnessContext,\n\tHarnessHandler,\n\tHarnessResult,\n\tInjection,\n\tSectionRange,\n\tSessionState,\n\tSystemNavCommand,\n\tTagDef,\n} from \"./types.ts\";\nexport { detectCircularUses, detectConflictingReplace, validateVersionPin } from \"./validation.ts\";\n"]}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { additionalContextFromDispatchResult, beforeTurn, cueDispatcher } from "./dispatcher.js";
|
|
2
|
+
export { generateToolDefinition, registerHarnessTools, } from "./harness-bridge.js";
|
|
3
|
+
export { HarnessRouter } from "./harness-router.js";
|
|
4
|
+
export { buildAdditionalContext, buildScopeInjection } from "./injector.js";
|
|
5
|
+
export { collectMarks } from "./marks.js";
|
|
6
|
+
export { CueRegistry, cueDiscoveryRoots } from "./registry.js";
|
|
7
|
+
export { resolveDirective, resolveSections, } from "./resolver.js";
|
|
8
|
+
export { findFencedBlocks, scan, scanDirectives, stripSpans } from "./scanner.js";
|
|
9
|
+
export { SecretStore } from "./secret-store.js";
|
|
10
|
+
export { parseElementToml } from "./toml.js";
|
|
11
|
+
export { detectCircularUses, detectConflictingReplace, validateVersionPin } from "./validation.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mCAAmC,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjG,OAAO,EACN,sBAAsB,EACtB,oBAAoB,GAEpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAa,MAAM,YAAY,CAAC;AAQrD,OAAO,EAAE,WAAW,EAAgB,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,EAEN,gBAAgB,EAChB,eAAe,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;AASzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AA2B7C,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export type { DispatcherOptions } from \"./dispatcher.ts\";\nexport { additionalContextFromDispatchResult, beforeTurn, cueDispatcher } from \"./dispatcher.ts\";\nexport {\n\tgenerateToolDefinition,\n\tregisterHarnessTools,\n\ttype ToolDefinition,\n} from \"./harness-bridge.ts\";\nexport { HarnessRouter } from \"./harness-router.ts\";\nexport { buildAdditionalContext, buildScopeInjection } from \"./injector.ts\";\nexport { collectMarks, type Mark } from \"./marks.ts\";\nexport type {\n\tCueMessage,\n\tCueMessageContent,\n\tCueTextContent,\n\tCueToolResultContent,\n\tCueToolUseContent,\n} from \"./messages.ts\";\nexport { CueRegistry, type CueRoot, cueDiscoveryRoots } from \"./registry.ts\";\nexport {\n\ttype ResolvedDirective,\n\tresolveDirective,\n\tresolveSections,\n} from \"./resolver.ts\";\nexport { findFencedBlocks, scan, scanDirectives, stripSpans } from \"./scanner.ts\";\nexport { SecretStore, type SecretStoreOptions } from \"./secret-store.ts\";\nexport type {\n\tCueDoneEvent,\n\tCueErrorEvent,\n\tCueStreamEvent,\n\tCueTextDeltaEvent,\n\tCueToolUseDeltaEvent,\n\tCueToolUseEndEvent,\n} from \"./stream-events.ts\";\nexport { parseElementToml } from \"./toml.ts\";\nexport type {\n\tActiveElement,\n\tAliasCommand,\n\tBehavioralDimension,\n\tCueAfterToolCallContext,\n\tCueAgentConfig,\n\tCueBeforeToolCallContext,\n\tCueBeforeToolCallResult,\n\tCueDirective,\n\tCueRegisteredTool,\n\tCueScope,\n\tCueToolSchema,\n\tDirective,\n\tDispatchEntry,\n\tDispatchResult,\n\tElementDef,\n\tHarnessAction,\n\tHarnessContext,\n\tHarnessHandler,\n\tHarnessResult,\n\tInjection,\n\tSectionRange,\n\tSessionState,\n\tSystemNavCommand,\n\tTagDef,\n} from \"./types.ts\";\nexport { detectCircularUses, detectConflictingReplace, validateVersionPin } from \"./validation.ts\";\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Mark } from "./marks.ts";
|
|
2
|
+
import type { ResolvedDirective } from "./resolver.ts";
|
|
3
|
+
import type { CueScope } from "./types.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Build the context injections for a resolved cue.
|
|
6
|
+
*
|
|
7
|
+
* Cues are purely behavioral — the sections describe how the model should
|
|
8
|
+
* behave (Default + Tag sections). Scopes no longer attach to cues; they are
|
|
9
|
+
* standalone statements handled by buildScopeInjection.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildAdditionalContext(resolved: ResolvedDirective): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Build the injection for a standalone scope statement.
|
|
14
|
+
*
|
|
15
|
+
* - file → `--- path ---\n<content>` (a directory injects its absolute
|
|
16
|
+
* path, e.g. `{@ion/}` → `--- /home/user/projects/ion ---`)
|
|
17
|
+
* - glob → one block per file
|
|
18
|
+
* - id → `--- #id ---\n<marked content>` (resolved via marks)
|
|
19
|
+
*
|
|
20
|
+
* Unresolvable targets emit a warning marker instead of failing the message.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildScopeInjection(scope: CueScope, projectRoot: string | undefined, marks: Mark[]): string;
|
|
23
|
+
//# sourceMappingURL=injector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injector.d.ts","sourceRoot":"","sources":["../src/injector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAE5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,CA2B3G","sourcesContent":["import type { Mark } from \"./marks.ts\";\nimport type { ResolvedDirective } from \"./resolver.ts\";\nimport { resolveDirPath, resolveScope } from \"./scope.ts\";\nimport type { CueScope } from \"./types.ts\";\n\n/**\n * Build the context injections for a resolved cue.\n *\n * Cues are purely behavioral — the sections describe how the model should\n * behave (Default + Tag sections). Scopes no longer attach to cues; they are\n * standalone statements handled by buildScopeInjection.\n */\nexport function buildAdditionalContext(resolved: ResolvedDirective): string[] {\n\treturn resolved.sections.map((s) => s.trim()).filter(Boolean);\n}\n\n/**\n * Build the injection for a standalone scope statement.\n *\n * - file → `--- path ---\\n<content>` (a directory injects its absolute\n * path, e.g. `{@ion/}` → `--- /home/user/projects/ion ---`)\n * - glob → one block per file\n * - id → `--- #id ---\\n<marked content>` (resolved via marks)\n *\n * Unresolvable targets emit a warning marker instead of failing the message.\n */\nexport function buildScopeInjection(scope: CueScope, projectRoot: string | undefined, marks: Mark[]): string {\n\tif (scope.type === \"id\") {\n\t\tconst mark = marks.find((m) => m.id === scope.value);\n\t\tif (!mark) return `[warning: mark not found: #${scope.value}]`;\n\t\treturn `--- #${mark.id} ---\\n${mark.content}`;\n\t}\n\n\t// Skill references are passed through — skill expansion happens in agent-session.\n\tif (scope.type === \"skill\") {\n\t\treturn `$${scope.value}`;\n\t}\n\n\tif (scope.type === \"file\" && !scope.range) {\n\t\tconst dirPath = resolveDirPath(scope.value, projectRoot);\n\t\tif (dirPath) return `--- ${dirPath} ---`;\n\t}\n\n\tconst resolved = resolveScope(scope, projectRoot);\n\tif (!resolved) {\n\t\tconst label = scopeLabel(scope);\n\t\tif (scope.type === \"glob\") return `[warning: no files match: ${label}]`;\n\t\treturn `[warning: file not found: ${label}]`;\n\t}\n\tif (scope.type === \"file\") {\n\t\treturn `--- ${resolved.label} ---\\n${resolved.content}`;\n\t}\n\treturn resolved.content;\n}\n\nfunction scopeLabel(scope: CueScope): string {\n\tif (!scope.range) return scope.value;\n\tif (scope.range.start !== undefined && scope.range.end !== undefined) {\n\t\treturn scope.range.start === scope.range.end\n\t\t\t? `${scope.value}:${scope.range.start}`\n\t\t\t: `${scope.value}:${scope.range.start}-${scope.range.end}`;\n\t}\n\tif (scope.range.start !== undefined) return `${scope.value}:${scope.range.start}-`;\n\treturn `${scope.value}:-${scope.range.end}`;\n}\n"]}
|
package/dist/injector.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { resolveDirPath, resolveScope } from "./scope.js";
|
|
2
|
+
/**
|
|
3
|
+
* Build the context injections for a resolved cue.
|
|
4
|
+
*
|
|
5
|
+
* Cues are purely behavioral — the sections describe how the model should
|
|
6
|
+
* behave (Default + Tag sections). Scopes no longer attach to cues; they are
|
|
7
|
+
* standalone statements handled by buildScopeInjection.
|
|
8
|
+
*/
|
|
9
|
+
export function buildAdditionalContext(resolved) {
|
|
10
|
+
return resolved.sections.map((s) => s.trim()).filter(Boolean);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Build the injection for a standalone scope statement.
|
|
14
|
+
*
|
|
15
|
+
* - file → `--- path ---\n<content>` (a directory injects its absolute
|
|
16
|
+
* path, e.g. `{@ion/}` → `--- /home/user/projects/ion ---`)
|
|
17
|
+
* - glob → one block per file
|
|
18
|
+
* - id → `--- #id ---\n<marked content>` (resolved via marks)
|
|
19
|
+
*
|
|
20
|
+
* Unresolvable targets emit a warning marker instead of failing the message.
|
|
21
|
+
*/
|
|
22
|
+
export function buildScopeInjection(scope, projectRoot, marks) {
|
|
23
|
+
if (scope.type === "id") {
|
|
24
|
+
const mark = marks.find((m) => m.id === scope.value);
|
|
25
|
+
if (!mark)
|
|
26
|
+
return `[warning: mark not found: #${scope.value}]`;
|
|
27
|
+
return `--- #${mark.id} ---\n${mark.content}`;
|
|
28
|
+
}
|
|
29
|
+
// Skill references are passed through — skill expansion happens in agent-session.
|
|
30
|
+
if (scope.type === "skill") {
|
|
31
|
+
return `$${scope.value}`;
|
|
32
|
+
}
|
|
33
|
+
if (scope.type === "file" && !scope.range) {
|
|
34
|
+
const dirPath = resolveDirPath(scope.value, projectRoot);
|
|
35
|
+
if (dirPath)
|
|
36
|
+
return `--- ${dirPath} ---`;
|
|
37
|
+
}
|
|
38
|
+
const resolved = resolveScope(scope, projectRoot);
|
|
39
|
+
if (!resolved) {
|
|
40
|
+
const label = scopeLabel(scope);
|
|
41
|
+
if (scope.type === "glob")
|
|
42
|
+
return `[warning: no files match: ${label}]`;
|
|
43
|
+
return `[warning: file not found: ${label}]`;
|
|
44
|
+
}
|
|
45
|
+
if (scope.type === "file") {
|
|
46
|
+
return `--- ${resolved.label} ---\n${resolved.content}`;
|
|
47
|
+
}
|
|
48
|
+
return resolved.content;
|
|
49
|
+
}
|
|
50
|
+
function scopeLabel(scope) {
|
|
51
|
+
if (!scope.range)
|
|
52
|
+
return scope.value;
|
|
53
|
+
if (scope.range.start !== undefined && scope.range.end !== undefined) {
|
|
54
|
+
return scope.range.start === scope.range.end
|
|
55
|
+
? `${scope.value}:${scope.range.start}`
|
|
56
|
+
: `${scope.value}:${scope.range.start}-${scope.range.end}`;
|
|
57
|
+
}
|
|
58
|
+
if (scope.range.start !== undefined)
|
|
59
|
+
return `${scope.value}:${scope.range.start}-`;
|
|
60
|
+
return `${scope.value}:-${scope.range.end}`;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=injector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injector.js","sourceRoot":"","sources":["../src/injector.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1D;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAA2B,EAAY;IAC7E,OAAO,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,C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,CAAC;IACzD,CAAC;IACD,OAAO,QAAQ,CAAC,OAAO,CAAC;AAAA,CACxB;AAED,SAAS,UAAU,CAAC,KAAe,EAAU;IAC5C,IAAI,CAAC,KAAK,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC;IACrC,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QACtE,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,GAAG;YAC3C,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE;YACvC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IAC7D,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC;IACnF,OAAO,GAAG,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAAA,CAC5C","sourcesContent":["import type { Mark } from \"./marks.ts\";\nimport type { ResolvedDirective } from \"./resolver.ts\";\nimport { resolveDirPath, resolveScope } from \"./scope.ts\";\nimport type { CueScope } from \"./types.ts\";\n\n/**\n * Build the context injections for a resolved cue.\n *\n * Cues are purely behavioral — the sections describe how the model should\n * behave (Default + Tag sections). Scopes no longer attach to cues; they are\n * standalone statements handled by buildScopeInjection.\n */\nexport function buildAdditionalContext(resolved: ResolvedDirective): string[] {\n\treturn resolved.sections.map((s) => s.trim()).filter(Boolean);\n}\n\n/**\n * Build the injection for a standalone scope statement.\n *\n * - file → `--- path ---\\n<content>` (a directory injects its absolute\n * path, e.g. `{@ion/}` → `--- /home/user/projects/ion ---`)\n * - glob → one block per file\n * - id → `--- #id ---\\n<marked content>` (resolved via marks)\n *\n * Unresolvable targets emit a warning marker instead of failing the message.\n */\nexport function buildScopeInjection(scope: CueScope, projectRoot: string | undefined, marks: Mark[]): string {\n\tif (scope.type === \"id\") {\n\t\tconst mark = marks.find((m) => m.id === scope.value);\n\t\tif (!mark) return `[warning: mark not found: #${scope.value}]`;\n\t\treturn `--- #${mark.id} ---\\n${mark.content}`;\n\t}\n\n\t// Skill references are passed through — skill expansion happens in agent-session.\n\tif (scope.type === \"skill\") {\n\t\treturn `$${scope.value}`;\n\t}\n\n\tif (scope.type === \"file\" && !scope.range) {\n\t\tconst dirPath = resolveDirPath(scope.value, projectRoot);\n\t\tif (dirPath) return `--- ${dirPath} ---`;\n\t}\n\n\tconst resolved = resolveScope(scope, projectRoot);\n\tif (!resolved) {\n\t\tconst label = scopeLabel(scope);\n\t\tif (scope.type === \"glob\") return `[warning: no files match: ${label}]`;\n\t\treturn `[warning: file not found: ${label}]`;\n\t}\n\tif (scope.type === \"file\") {\n\t\treturn `--- ${resolved.label} ---\\n${resolved.content}`;\n\t}\n\treturn resolved.content;\n}\n\nfunction scopeLabel(scope: CueScope): string {\n\tif (!scope.range) return scope.value;\n\tif (scope.range.start !== undefined && scope.range.end !== undefined) {\n\t\treturn scope.range.start === scope.range.end\n\t\t\t? `${scope.value}:${scope.range.start}`\n\t\t\t: `${scope.value}:${scope.range.start}-${scope.range.end}`;\n\t}\n\tif (scope.range.start !== undefined) return `${scope.value}:${scope.range.start}-`;\n\treturn `${scope.value}:-${scope.range.end}`;\n}\n"]}
|
package/dist/marks.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface Mark {
|
|
2
|
+
id: string;
|
|
3
|
+
content: string;
|
|
4
|
+
/** Character offset of the `{` of the mark header line. */
|
|
5
|
+
startIndex: number;
|
|
6
|
+
/** Character offset just past the `}` of the header. */
|
|
7
|
+
headerEnd: number;
|
|
8
|
+
/** Character offset where the content block begins. */
|
|
9
|
+
contentStart: number;
|
|
10
|
+
/** Character offset just past the last content character. */
|
|
11
|
+
contentEnd: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Two-pass mark collection: find own-line `{#id}` headers and capture the
|
|
15
|
+
* content block that follows them.
|
|
16
|
+
*
|
|
17
|
+
* A header line is a line whose trimmed content is exactly `{#id}`. The
|
|
18
|
+
* content block runs until the next line that starts (trimmed) with `{`, `[`,
|
|
19
|
+
* `:`, `/`, or EOF. Headers inside fenced blocks (```, ~~~, inline `) are
|
|
20
|
+
* ignored.
|
|
21
|
+
*
|
|
22
|
+
* A header with no following content is not a mark — it is a reference, which
|
|
23
|
+
* the dispatcher resolves against collected marks.
|
|
24
|
+
*/
|
|
25
|
+
export declare function collectMarks(input: string): Mark[];
|
|
26
|
+
//# sourceMappingURL=marks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marks.d.ts","sourceRoot":"","sources":["../src/marks.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,IAAI;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,UAAU,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;CACnB;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,CAgDlD","sourcesContent":["import { findFencedBlocks, isInsideFencedBlock } from \"./scanner.ts\";\n\nexport interface Mark {\n\tid: string;\n\tcontent: string;\n\t/** Character offset of the `{` of the mark header line. */\n\tstartIndex: number;\n\t/** Character offset just past the `}` of the header. */\n\theaderEnd: number;\n\t/** Character offset where the content block begins. */\n\tcontentStart: number;\n\t/** Character offset just past the last content character. */\n\tcontentEnd: number;\n}\n\nconst MARK_LINE_RE = /^\\s*\\{#([A-Za-z0-9_-]+)\\}\\s*$/;\n\n/**\n * Two-pass mark collection: find own-line `{#id}` headers and capture the\n * content block that follows them.\n *\n * A header line is a line whose trimmed content is exactly `{#id}`. The\n * content block runs until the next line that starts (trimmed) with `{`, `[`,\n * `:`, `/`, or EOF. Headers inside fenced blocks (```, ~~~, inline `) are\n * ignored.\n *\n * A header with no following content is not a mark — it is a reference, which\n * the dispatcher resolves against collected marks.\n */\nexport function collectMarks(input: string): Mark[] {\n\tconst fencedRanges = findFencedBlocks(input);\n\tconst marks: Mark[] = [];\n\tconst lines = input.split(\"\\n\");\n\tlet offset = 0;\n\n\tfor (let i = 0; i < lines.length; i++) {\n\t\tconst line = lines[i];\n\t\tconst m = MARK_LINE_RE.exec(line);\n\t\tif (m && !isInsideFencedBlock(offset, fencedRanges)) {\n\t\t\tconst id = m[1] ?? \"\";\n\t\t\tconst headerEnd = offset + line.length;\n\n\t\t\tlet j = i + 1;\n\t\t\tlet contentStart = -1;\n\t\t\tlet contentEnd = headerEnd;\n\t\t\tlet nextOffset = offset + line.length + 1;\n\t\t\tfor (; j < lines.length; j++) {\n\t\t\t\tconst trimmed = lines[j].trim();\n\t\t\t\tif (\n\t\t\t\t\ttrimmed.startsWith(\"{\") ||\n\t\t\t\t\ttrimmed.startsWith(\"[\") ||\n\t\t\t\t\ttrimmed.startsWith(\":\") ||\n\t\t\t\t\ttrimmed.startsWith(\"/\")\n\t\t\t\t) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (contentStart === -1) contentStart = nextOffset;\n\t\t\t\tcontentEnd = nextOffset + lines[j].length;\n\t\t\t\tnextOffset += lines[j].length + 1;\n\t\t\t}\n\n\t\t\tif (contentStart !== -1) {\n\t\t\t\tconst content = input.slice(contentStart, contentEnd).trimEnd();\n\t\t\t\tmarks.push({\n\t\t\t\t\tid,\n\t\t\t\t\tcontent,\n\t\t\t\t\tstartIndex: offset,\n\t\t\t\t\theaderEnd,\n\t\t\t\t\tcontentStart,\n\t\t\t\t\tcontentEnd: contentStart + content.length,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\toffset += line.length + 1;\n\t}\n\n\treturn marks;\n}\n"]}
|
package/dist/marks.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { findFencedBlocks, isInsideFencedBlock } from "./scanner.js";
|
|
2
|
+
const MARK_LINE_RE = /^\s*\{#([A-Za-z0-9_-]+)\}\s*$/;
|
|
3
|
+
/**
|
|
4
|
+
* Two-pass mark collection: find own-line `{#id}` headers and capture the
|
|
5
|
+
* content block that follows them.
|
|
6
|
+
*
|
|
7
|
+
* A header line is a line whose trimmed content is exactly `{#id}`. The
|
|
8
|
+
* content block runs until the next line that starts (trimmed) with `{`, `[`,
|
|
9
|
+
* `:`, `/`, or EOF. Headers inside fenced blocks (```, ~~~, inline `) are
|
|
10
|
+
* ignored.
|
|
11
|
+
*
|
|
12
|
+
* A header with no following content is not a mark — it is a reference, which
|
|
13
|
+
* the dispatcher resolves against collected marks.
|
|
14
|
+
*/
|
|
15
|
+
export function collectMarks(input) {
|
|
16
|
+
const fencedRanges = findFencedBlocks(input);
|
|
17
|
+
const marks = [];
|
|
18
|
+
const lines = input.split("\n");
|
|
19
|
+
let offset = 0;
|
|
20
|
+
for (let i = 0; i < lines.length; i++) {
|
|
21
|
+
const line = lines[i];
|
|
22
|
+
const m = MARK_LINE_RE.exec(line);
|
|
23
|
+
if (m && !isInsideFencedBlock(offset, fencedRanges)) {
|
|
24
|
+
const id = m[1] ?? "";
|
|
25
|
+
const headerEnd = offset + line.length;
|
|
26
|
+
let j = i + 1;
|
|
27
|
+
let contentStart = -1;
|
|
28
|
+
let contentEnd = headerEnd;
|
|
29
|
+
let nextOffset = offset + line.length + 1;
|
|
30
|
+
for (; j < lines.length; j++) {
|
|
31
|
+
const trimmed = lines[j].trim();
|
|
32
|
+
if (trimmed.startsWith("{") ||
|
|
33
|
+
trimmed.startsWith("[") ||
|
|
34
|
+
trimmed.startsWith(":") ||
|
|
35
|
+
trimmed.startsWith("/")) {
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
if (contentStart === -1)
|
|
39
|
+
contentStart = nextOffset;
|
|
40
|
+
contentEnd = nextOffset + lines[j].length;
|
|
41
|
+
nextOffset += lines[j].length + 1;
|
|
42
|
+
}
|
|
43
|
+
if (contentStart !== -1) {
|
|
44
|
+
const content = input.slice(contentStart, contentEnd).trimEnd();
|
|
45
|
+
marks.push({
|
|
46
|
+
id,
|
|
47
|
+
content,
|
|
48
|
+
startIndex: offset,
|
|
49
|
+
headerEnd,
|
|
50
|
+
contentStart,
|
|
51
|
+
contentEnd: contentStart + content.length,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
offset += line.length + 1;
|
|
56
|
+
}
|
|
57
|
+
return marks;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=marks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marks.js","sourceRoot":"","sources":["../src/marks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAerE,MAAM,YAAY,GAAG,+BAA+B,CAAC;AAErD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa,EAAU;IACnD,MAAM,YAAY,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,KAAK,CAAC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,KAAK,CAAC,IAAI,CAAC;oBACV,EAAE;oBACF,OAAO;oBACP,UAAU,EAAE,MAAM;oBAClB,SAAS;oBACT,YAAY;oBACZ,UAAU,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM;iBACzC,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QACD,MAAM,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,KAAK,CAAC;AAAA,CACb","sourcesContent":["import { findFencedBlocks, isInsideFencedBlock } from \"./scanner.ts\";\n\nexport interface Mark {\n\tid: string;\n\tcontent: string;\n\t/** Character offset of the `{` of the mark header line. */\n\tstartIndex: number;\n\t/** Character offset just past the `}` of the header. */\n\theaderEnd: number;\n\t/** Character offset where the content block begins. */\n\tcontentStart: number;\n\t/** Character offset just past the last content character. */\n\tcontentEnd: number;\n}\n\nconst MARK_LINE_RE = /^\\s*\\{#([A-Za-z0-9_-]+)\\}\\s*$/;\n\n/**\n * Two-pass mark collection: find own-line `{#id}` headers and capture the\n * content block that follows them.\n *\n * A header line is a line whose trimmed content is exactly `{#id}`. The\n * content block runs until the next line that starts (trimmed) with `{`, `[`,\n * `:`, `/`, or EOF. Headers inside fenced blocks (```, ~~~, inline `) are\n * ignored.\n *\n * A header with no following content is not a mark — it is a reference, which\n * the dispatcher resolves against collected marks.\n */\nexport function collectMarks(input: string): Mark[] {\n\tconst fencedRanges = findFencedBlocks(input);\n\tconst marks: Mark[] = [];\n\tconst lines = input.split(\"\\n\");\n\tlet offset = 0;\n\n\tfor (let i = 0; i < lines.length; i++) {\n\t\tconst line = lines[i];\n\t\tconst m = MARK_LINE_RE.exec(line);\n\t\tif (m && !isInsideFencedBlock(offset, fencedRanges)) {\n\t\t\tconst id = m[1] ?? \"\";\n\t\t\tconst headerEnd = offset + line.length;\n\n\t\t\tlet j = i + 1;\n\t\t\tlet contentStart = -1;\n\t\t\tlet contentEnd = headerEnd;\n\t\t\tlet nextOffset = offset + line.length + 1;\n\t\t\tfor (; j < lines.length; j++) {\n\t\t\t\tconst trimmed = lines[j].trim();\n\t\t\t\tif (\n\t\t\t\t\ttrimmed.startsWith(\"{\") ||\n\t\t\t\t\ttrimmed.startsWith(\"[\") ||\n\t\t\t\t\ttrimmed.startsWith(\":\") ||\n\t\t\t\t\ttrimmed.startsWith(\"/\")\n\t\t\t\t) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (contentStart === -1) contentStart = nextOffset;\n\t\t\t\tcontentEnd = nextOffset + lines[j].length;\n\t\t\t\tnextOffset += lines[j].length + 1;\n\t\t\t}\n\n\t\t\tif (contentStart !== -1) {\n\t\t\t\tconst content = input.slice(contentStart, contentEnd).trimEnd();\n\t\t\t\tmarks.push({\n\t\t\t\t\tid,\n\t\t\t\t\tcontent,\n\t\t\t\t\tstartIndex: offset,\n\t\t\t\t\theaderEnd,\n\t\t\t\t\tcontentStart,\n\t\t\t\t\tcontentEnd: contentStart + content.length,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\toffset += line.length + 1;\n\t}\n\n\treturn marks;\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface CueTextContent {
|
|
2
|
+
type: "text";
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
export interface CueToolUseContent {
|
|
6
|
+
type: "tool_use";
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
input: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export interface CueToolResultContent {
|
|
12
|
+
type: "tool_result";
|
|
13
|
+
toolUseId: string;
|
|
14
|
+
content: string;
|
|
15
|
+
isError?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export type CueMessageContent = CueTextContent | CueToolUseContent | CueToolResultContent;
|
|
18
|
+
export interface CueMessage {
|
|
19
|
+
role: "user" | "assistant" | "system" | "tool";
|
|
20
|
+
content: string | CueMessageContent[];
|
|
21
|
+
toolCallId?: string;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;AAE1F,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB","sourcesContent":["export interface CueTextContent {\n\ttype: \"text\";\n\ttext: string;\n}\n\nexport interface CueToolUseContent {\n\ttype: \"tool_use\";\n\tid: string;\n\tname: string;\n\tinput: Record<string, unknown>;\n}\n\nexport interface CueToolResultContent {\n\ttype: \"tool_result\";\n\ttoolUseId: string;\n\tcontent: string;\n\tisError?: boolean;\n}\n\nexport type CueMessageContent = CueTextContent | CueToolUseContent | CueToolResultContent;\n\nexport interface CueMessage {\n\trole: \"user\" | \"assistant\" | \"system\" | \"tool\";\n\tcontent: string | CueMessageContent[];\n\ttoolCallId?: string;\n}\n"]}
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"","sourcesContent":["export interface CueTextContent {\n\ttype: \"text\";\n\ttext: string;\n}\n\nexport interface CueToolUseContent {\n\ttype: \"tool_use\";\n\tid: string;\n\tname: string;\n\tinput: Record<string, unknown>;\n}\n\nexport interface CueToolResultContent {\n\ttype: \"tool_result\";\n\ttoolUseId: string;\n\tcontent: string;\n\tisError?: boolean;\n}\n\nexport type CueMessageContent = CueTextContent | CueToolUseContent | CueToolResultContent;\n\nexport interface CueMessage {\n\trole: \"user\" | \"assistant\" | \"system\" | \"tool\";\n\tcontent: string | CueMessageContent[];\n\ttoolCallId?: string;\n}\n"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { BehavioralDimension, ElementDef, SectionRange } from "./types.ts";
|
|
2
|
+
export interface AliasConfig {
|
|
3
|
+
aliases: Record<string, string>;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Parse alias configuration from a cue.toml-style config string.
|
|
7
|
+
* Expects an [aliases] section with key = "value" pairs.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseAliasConfig(content: string): AliasConfig;
|
|
10
|
+
export interface CueRoot {
|
|
11
|
+
/** Element root directory. */
|
|
12
|
+
path: string;
|
|
13
|
+
/** Config scope the root belongs to (drives override matching). */
|
|
14
|
+
scope: "user" | "project";
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Single source of truth for cue element discovery roots. Used by
|
|
18
|
+
* CueRegistry.discover(), watchedPaths(), and the package manager's
|
|
19
|
+
* resource collection so the config UI lists exactly what will load.
|
|
20
|
+
*/
|
|
21
|
+
export declare function cueDiscoveryRoots(options?: {
|
|
22
|
+
projectRoot?: string;
|
|
23
|
+
skipHome?: boolean;
|
|
24
|
+
additionalRoots?: string[];
|
|
25
|
+
}): CueRoot[];
|
|
26
|
+
export declare class CueRegistry {
|
|
27
|
+
private elements;
|
|
28
|
+
private sharedTags;
|
|
29
|
+
private realpathCache;
|
|
30
|
+
private baseRoots;
|
|
31
|
+
private skipHome;
|
|
32
|
+
private disabledNames;
|
|
33
|
+
constructor(additionalRoots?: string[], options?: {
|
|
34
|
+
skipHome?: boolean;
|
|
35
|
+
});
|
|
36
|
+
private computeRoots;
|
|
37
|
+
/**
|
|
38
|
+
* Idempotent: clears all discovered state and re-scans, so it is safe
|
|
39
|
+
* to call again when watched files change (see watchedPaths).
|
|
40
|
+
* `disabled` holds lowercased element names to skip (config UI toggles).
|
|
41
|
+
*/
|
|
42
|
+
discover(projectRoot?: string, options?: {
|
|
43
|
+
disabled?: string[];
|
|
44
|
+
}): void;
|
|
45
|
+
/**
|
|
46
|
+
* Existing directories whose changes invalidate discovery: element
|
|
47
|
+
* roots, shared-tags dirs, and cue.toml parents. Callers watch these
|
|
48
|
+
* (non-recursively) and call discover() again on change, then re-arm
|
|
49
|
+
* to pick up newly created subdirectories.
|
|
50
|
+
*/
|
|
51
|
+
watchedPaths(projectRoot?: string): string[];
|
|
52
|
+
private discoverSharedTags;
|
|
53
|
+
getSharedTagSectionIndex(tagName: string): Map<string, SectionRange> | undefined;
|
|
54
|
+
loadSharedTagBody(tagName: string): string | undefined;
|
|
55
|
+
getSharedTagOverrides(tagName: string): BehavioralDimension[] | undefined;
|
|
56
|
+
getSharedTagDefs(): Map<string, {
|
|
57
|
+
description: string;
|
|
58
|
+
overrides: BehavioralDimension[];
|
|
59
|
+
}>;
|
|
60
|
+
private discoverFromRoot;
|
|
61
|
+
private registerElement;
|
|
62
|
+
private resolveRealpath;
|
|
63
|
+
private isDuplicate;
|
|
64
|
+
/**
|
|
65
|
+
* Load aliases from cue.toml config files in project root.
|
|
66
|
+
* Project-level aliases override home-level aliases.
|
|
67
|
+
*/
|
|
68
|
+
loadAliases(projectRoot?: string): Record<string, string>;
|
|
69
|
+
private validateElement;
|
|
70
|
+
private validateTagHeaderAlignment;
|
|
71
|
+
get(name: string): ElementDef | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Get an element by name and optional version.
|
|
74
|
+
* If version is provided, tries to find the exact version first, then falls back to latest compatible.
|
|
75
|
+
* If version is not provided, returns the latest version.
|
|
76
|
+
*/
|
|
77
|
+
getByVersion(name: string, version?: string): ElementDef | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Compare two semver versions.
|
|
80
|
+
* Returns positive if a > b, negative if a < b, 0 if equal.
|
|
81
|
+
*/
|
|
82
|
+
private compareVersions;
|
|
83
|
+
has(name: string): boolean;
|
|
84
|
+
list(): ElementDef[];
|
|
85
|
+
getSectionIndex(name: string): Map<string, SectionRange> | undefined;
|
|
86
|
+
loadBody(name: string): string | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Load body for a specific version of an element.
|
|
89
|
+
*/
|
|
90
|
+
loadBodyByVersion(name: string, version?: string): string | undefined;
|
|
91
|
+
getMdPath(name: string): string | undefined;
|
|
92
|
+
private buildSectionIndex;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=registry.d.ts.map
|