@felan-ai/ext-output-style 0.2.1 → 0.2.2
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 +22 -7
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,24 +3,39 @@
|
|
|
3
3
|
Portable output-style instructions for Felan sessions.
|
|
4
4
|
|
|
5
5
|
The extension appends one clearly bounded `## Output Style` section to the
|
|
6
|
-
system prompt before each model run. It
|
|
7
|
-
`explanatory`, and `caveman` styles
|
|
8
|
-
|
|
6
|
+
system prompt before each model run. It provides the built-in `concise`,
|
|
7
|
+
`explanatory`, and `caveman` styles plus a `custom` style for caller-provided
|
|
8
|
+
instructions. `concise` is the default. File-backed styles are not supported.
|
|
9
9
|
|
|
10
10
|
```ts
|
|
11
11
|
import { createOutputStyleExtension } from '@felan-ai/ext-output-style';
|
|
12
12
|
|
|
13
13
|
const extension = createOutputStyleExtension('explanatory');
|
|
14
14
|
const caveman = createOutputStyleExtension('caveman');
|
|
15
|
+
const experiment = createOutputStyleExtension('custom', 'Answer in one compact paragraph.');
|
|
15
16
|
```
|
|
16
17
|
|
|
17
|
-
Felan declares the style as `extensionConfig.outputStyle.style`.
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
Felan declares the style as `extensionConfig.outputStyle.style`. Custom
|
|
19
|
+
instructions use `extensionConfig.outputStyle.instructions`:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"extensionConfig": {
|
|
24
|
+
"outputStyle": {
|
|
25
|
+
"style": "custom",
|
|
26
|
+
"instructions": "Answer in one compact paragraph without omitting blockers."
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The local TUI, CLI, `/settings`, and Agent Core consumers resolve these fields
|
|
33
|
+
before activating the extension for root and child sessions. A custom style
|
|
34
|
+
requires non-empty instructions.
|
|
20
35
|
|
|
21
36
|
## Package boundary and requirements
|
|
22
37
|
|
|
23
|
-
The package owns the supported style names,
|
|
38
|
+
The package owns the supported style names, built-in instructions, custom-text
|
|
24
39
|
validation, and prompt-section formatting. A host owns style selection,
|
|
25
40
|
built-in enablement, and session lifecycle. The package requires a compatible
|
|
26
41
|
`@felan-ai/agent-core` peer and does not read settings, prompt files, or ambient
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { type FelanExtension } from '@felan-ai/agent-core';
|
|
2
|
-
export declare const OUTPUT_STYLES: readonly ["concise", "explanatory", "caveman"];
|
|
2
|
+
export declare const OUTPUT_STYLES: readonly ["concise", "explanatory", "caveman", "custom"];
|
|
3
3
|
export type OutputStyle = typeof OUTPUT_STYLES[number];
|
|
4
4
|
export declare const DEFAULT_OUTPUT_STYLE: OutputStyle;
|
|
5
5
|
export declare const OUTPUT_STYLE_CONFIG: import("@felan-ai/agent-core").ExtensionConfigDefinition<{
|
|
6
|
-
readonly style: import("@felan-ai/agent-core").ExtensionConfigField<"concise" | "explanatory" | "caveman">;
|
|
6
|
+
readonly style: import("@felan-ai/agent-core").ExtensionConfigField<"concise" | "explanatory" | "caveman" | "custom">;
|
|
7
|
+
readonly instructions: import("@felan-ai/agent-core").ExtensionConfigField<string>;
|
|
7
8
|
}>;
|
|
8
9
|
export declare function parseOutputStyle(value?: unknown): OutputStyle;
|
|
9
|
-
export declare function formatOutputStyleSection(style: OutputStyle): string;
|
|
10
|
-
export declare function createOutputStyleExtension(value?: unknown): FelanExtension;
|
|
10
|
+
export declare function formatOutputStyleSection(style: OutputStyle, instructions?: unknown): string;
|
|
11
|
+
export declare function createOutputStyleExtension(value?: unknown, instructions?: unknown): FelanExtension;
|
|
11
12
|
declare const outputStyleExtension: FelanExtension;
|
|
12
13
|
export default outputStyleExtension;
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgE,KAAK,cAAc,EAA0B,MAAM,sBAAsB,CAAC;AAEjJ,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgE,KAAK,cAAc,EAA0B,MAAM,sBAAsB,CAAC;AAEjJ,eAAO,MAAM,aAAa,0DAA2D,CAAC;AACtF,MAAM,MAAM,WAAW,GAAG,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;AAEvD,eAAO,MAAM,oBAAoB,EAAE,WAAuB,CAAC;AAC3D,eAAO,MAAM,mBAAmB;;;EAe9B,CAAC;AAyBH,wBAAgB,gBAAgB,CAAC,KAAK,GAAE,OAA8B,GAAG,WAAW,CAKnF;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM,CAW3F;AAED,wBAAgB,0BAA0B,CACxC,KAAK,GAAE,OAA8B,EACrC,YAAY,CAAC,EAAE,OAAO,GACrB,cAAc,CAShB;AAED,QAAA,MAAM,oBAAoB,EAAE,cAGtB,CAAC;AAGP,eAAe,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { associateExtensionConfig, configField, defineExtensionConfig } from '@felan-ai/agent-core';
|
|
2
|
-
export const OUTPUT_STYLES = ['concise', 'explanatory', 'caveman'];
|
|
2
|
+
export const OUTPUT_STYLES = ['concise', 'explanatory', 'caveman', 'custom'];
|
|
3
3
|
export const DEFAULT_OUTPUT_STYLE = 'concise';
|
|
4
4
|
export const OUTPUT_STYLE_CONFIG = defineExtensionConfig({
|
|
5
5
|
id: 'outputStyle',
|
|
@@ -10,6 +10,11 @@ export const OUTPUT_STYLE_CONFIG = defineExtensionConfig({
|
|
|
10
10
|
description: 'Response detail and explanation style',
|
|
11
11
|
cliName: 'output-style',
|
|
12
12
|
}),
|
|
13
|
+
instructions: configField.string({
|
|
14
|
+
default: '',
|
|
15
|
+
description: 'Custom system-prompt instructions used when output style is custom',
|
|
16
|
+
cliName: 'output-style-instructions',
|
|
17
|
+
}),
|
|
13
18
|
},
|
|
14
19
|
});
|
|
15
20
|
const OUTPUT_STYLE_START = '<output_style>';
|
|
@@ -39,25 +44,34 @@ export function parseOutputStyle(value = DEFAULT_OUTPUT_STYLE) {
|
|
|
39
44
|
}
|
|
40
45
|
throw new Error(`outputStyle must be one of: ${OUTPUT_STYLES.join(', ')}`);
|
|
41
46
|
}
|
|
42
|
-
export function formatOutputStyleSection(style) {
|
|
47
|
+
export function formatOutputStyleSection(style, instructions) {
|
|
48
|
+
const body = style === 'custom'
|
|
49
|
+
? parseCustomInstructions(instructions)
|
|
50
|
+
: STYLE_INSTRUCTIONS[style].map((instruction) => `- ${instruction}`).join('\n');
|
|
43
51
|
return [
|
|
44
52
|
'## Output Style',
|
|
45
53
|
'',
|
|
46
54
|
OUTPUT_STYLE_START,
|
|
47
|
-
|
|
55
|
+
body,
|
|
48
56
|
OUTPUT_STYLE_END,
|
|
49
57
|
].join('\n');
|
|
50
58
|
}
|
|
51
|
-
export function createOutputStyleExtension(value = DEFAULT_OUTPUT_STYLE) {
|
|
59
|
+
export function createOutputStyleExtension(value = DEFAULT_OUTPUT_STYLE, instructions) {
|
|
52
60
|
const style = parseOutputStyle(value);
|
|
53
|
-
const section = formatOutputStyleSection(style);
|
|
61
|
+
const section = formatOutputStyleSection(style, instructions);
|
|
54
62
|
return (pi) => {
|
|
55
63
|
pi.on('before_agent_start', (event) => {
|
|
56
64
|
return { systemPrompt: `${event.systemPrompt}\n\n${section}` };
|
|
57
65
|
});
|
|
58
66
|
};
|
|
59
67
|
}
|
|
60
|
-
const outputStyleExtension = ((pi) => createOutputStyleExtension(pi.config?.style ?? DEFAULT_OUTPUT_STYLE)(pi));
|
|
68
|
+
const outputStyleExtension = ((pi) => createOutputStyleExtension(pi.config?.style ?? DEFAULT_OUTPUT_STYLE, pi.config?.instructions)(pi));
|
|
61
69
|
associateExtensionConfig(outputStyleExtension, OUTPUT_STYLE_CONFIG);
|
|
62
70
|
export default outputStyleExtension;
|
|
71
|
+
function parseCustomInstructions(value) {
|
|
72
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
73
|
+
throw new Error('outputStyle.instructions must be a non-empty string when outputStyle is custom');
|
|
74
|
+
}
|
|
75
|
+
return value.trim();
|
|
76
|
+
}
|
|
63
77
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,qBAAqB,EAA+C,MAAM,sBAAsB,CAAC;AAEjJ,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,CAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,qBAAqB,EAA+C,MAAM,sBAAsB,CAAC;AAEjJ,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,CAAU,CAAC;AAGtF,MAAM,CAAC,MAAM,oBAAoB,GAAgB,SAAS,CAAC;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;IACvD,EAAE,EAAE,aAAa;IACjB,KAAK,EAAE,cAAc;IACrB,MAAM,EAAE;QACN,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE;YACrC,OAAO,EAAE,oBAAoB;YAC7B,WAAW,EAAE,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,IAAI,CAAC,CAAC;AACf,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,QAAiB,oBAAoB,EACrC,YAAsB;IAEtB,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,wBAAwB,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAE9D,OAAO,CAAC,EAAE,EAAE,EAAE;QACZ,EAAE,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE;YACpC,OAAO,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC,YAAY,OAAO,OAAO,EAAE,EAAE,CAAC;QACjE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,oBAAoB,GAAmB,CAAC,CAAC,EAAqB,EAAE,EAAE,CAAC,0BAA0B,CACjG,EAAE,CAAC,MAAM,EAAE,KAAK,IAAI,oBAAoB,EACxC,EAAE,CAAC,MAAM,EAAE,YAAY,CACxB,CAAC,EAAE,CAAC,CAAC,CAAC;AACP,wBAAwB,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,CAAC;AAEpE,eAAe,oBAAoB,CAAC;AAEpC,SAAS,uBAAuB,CAAC,KAAc;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACpG,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@felan-ai/ext-output-style",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Portable output-style system prompt extension for Felan",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@felan-ai/agent-core": "^0.5.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@felan-ai/agent-core": "0.5.
|
|
31
|
+
"@felan-ai/agent-core": "0.5.3"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public",
|