@funkai/prompts 0.1.1 → 0.1.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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +10 -0
- package/dist/lib/index.d.mts +2 -2
- package/dist/lib/index.d.mts.map +1 -1
- package/dist/lib/index.mjs +2 -2
- package/dist/lib/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/engine.test.ts +5 -5
- package/src/engine.ts +1 -1
- package/src/index.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
> @funkai/prompts@0.1.
|
|
2
|
+
> @funkai/prompts@0.1.2 build /home/runner/work/funkai/funkai/packages/prompts
|
|
3
3
|
> tsdown && cp -r src/prompts dist/prompts
|
|
4
4
|
|
|
5
|
-
[34mℹ[39m tsdown [2mv0.21.
|
|
5
|
+
[34mℹ[39m tsdown [2mv0.21.3[22m powered by rolldown [2mv1.0.0-rc.9[22m
|
|
6
6
|
[34mℹ[39m config file: [4m/home/runner/work/funkai/funkai/packages/prompts/tsdown.config.ts[24m
|
|
7
7
|
[34mℹ[39m entry: [34msrc/index.ts[39m
|
|
8
8
|
[34mℹ[39m target: [34mnode22[39m
|
|
9
9
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
10
10
|
[34mℹ[39m Build start
|
|
11
|
-
[34mℹ[39m [2mdist/lib/[22m[1mindex.mjs[22m [2m3.
|
|
11
|
+
[34mℹ[39m [2mdist/lib/[22m[1mindex.mjs[22m [2m3.73 kB[22m [2m│ gzip: 1.66 kB[22m
|
|
12
12
|
[34mℹ[39m [2mdist/lib/[22mindex.mjs.map [2m5.24 kB[22m [2m│ gzip: 2.18 kB[22m
|
|
13
|
-
[34mℹ[39m [2mdist/lib/[22mindex.d.mts.map [2m0.89 kB[22m [2m│ gzip: 0.
|
|
14
|
-
[34mℹ[39m [2mdist/lib/[22m[32m[1mindex.d.mts[22m[39m [2m3.
|
|
15
|
-
[34mℹ[39m 4 files, total: 13.
|
|
16
|
-
[32m✔[39m Build complete in [
|
|
13
|
+
[34mℹ[39m [2mdist/lib/[22mindex.d.mts.map [2m0.89 kB[22m [2m│ gzip: 0.43 kB[22m
|
|
14
|
+
[34mℹ[39m [2mdist/lib/[22m[32m[1mindex.d.mts[22m[39m [2m3.63 kB[22m [2m│ gzip: 1.49 kB[22m
|
|
15
|
+
[34mℹ[39m 4 files, total: 13.49 kB
|
|
16
|
+
[32m✔[39m Build complete in [32m1629ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @funkai/prompts
|
|
2
2
|
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 153c393: refactor: deep review cleanup across all packages
|
|
8
|
+
|
|
9
|
+
- **@funkai/agents**: Remove dead code (`resolve.ts`, `attempt.ts`), fix stale "Workflow" JSDoc references, deduplicate `buildOnFinishHandler`, complete `writeLog` JSDoc, remove orphaned `ResolveParam` export
|
|
10
|
+
- **@funkai/models**: Export missing `ProviderFactory` and `ProviderMap` types, convert per-provider `*Model()` lookup from O(n) `.find()` to O(1) Map, fix floating-point precision artifacts in generated pricing data
|
|
11
|
+
- **@funkai/prompts**: Rename generic `engine` export to `liquidEngine` for clarity
|
|
12
|
+
|
|
3
13
|
## 0.1.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/lib/index.d.mts
CHANGED
|
@@ -58,7 +58,7 @@ declare function createEngine(partialsDir: string, options?: Partial<CreateEngin
|
|
|
58
58
|
* only needs to handle `{{ var }}` expressions and basic Liquid
|
|
59
59
|
* control flow (`{% if %}`, `{% for %}`). No filesystem access required.
|
|
60
60
|
*/
|
|
61
|
-
declare const
|
|
61
|
+
declare const liquidEngine: Liquid$1;
|
|
62
62
|
//#endregion
|
|
63
63
|
//#region src/clean.d.ts
|
|
64
64
|
/**
|
|
@@ -95,5 +95,5 @@ declare const PARTIALS_DIR: string;
|
|
|
95
95
|
*/
|
|
96
96
|
declare function createPromptRegistry<T extends PromptNamespace>(modules: T): PromptRegistry<T>;
|
|
97
97
|
//#endregion
|
|
98
|
-
export { type CreateEngineOptions, type Liquid, PARTIALS_DIR, type PromptModule, type PromptNamespace, type PromptRegistry, clean, createEngine, createPromptRegistry,
|
|
98
|
+
export { type CreateEngineOptions, type Liquid, PARTIALS_DIR, type PromptModule, type PromptNamespace, type PromptRegistry, clean, createEngine, createPromptRegistry, liquidEngine };
|
|
99
99
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/lib/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/types.ts","../../src/engine.ts","../../src/clean.ts","../../src/partials-dir.ts","../../src/registry.ts"],"mappings":";;;;;;AAMA;KAAY,mBAAA,GAAsB,IAAA,CAChC,aAAA;;;;AAeF;;UAAiB,YAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA,EAAQ,OAAA,CAAQ,CAAA;EACzB,MAAA,CAAO,SAAA,EAAW,CAAA;EAClB,QAAA,CAAS,SAAA,YAAqB,CAAA;AAAA;;;;;KAOpB,eAAA;EAAA,UACA,GAAA,WAAc,YAAA,GAAe,eAAA;AAAA;;;;;;;;AADzC;;;;;KAgBY,cAAA,WAAyB,eAAA,2BACd,CAAA,GAAI,CAAA,CAAE,CAAA,UAAW,YAAA,GAClC,CAAA,CAAE,CAAA,IACF,CAAA,CAAE,CAAA,UAAW,eAAA,GACX,cAAA,CAAe,CAAA,CAAE,CAAA,KACjB,CAAA,CAAE,CAAA;;;;;AAjDV;;;;;AAgBA;;;iBCRgB,YAAA,CAAa,WAAA,UAAqB,OAAA,GAAU,OAAA,CAAQ,mBAAA,IAAuB,QAAA;;;;;;;;cAmB9E,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/types.ts","../../src/engine.ts","../../src/clean.ts","../../src/partials-dir.ts","../../src/registry.ts"],"mappings":";;;;;;AAMA;KAAY,mBAAA,GAAsB,IAAA,CAChC,aAAA;;;;AAeF;;UAAiB,YAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA,EAAQ,OAAA,CAAQ,CAAA;EACzB,MAAA,CAAO,SAAA,EAAW,CAAA;EAClB,QAAA,CAAS,SAAA,YAAqB,CAAA;AAAA;;;;;KAOpB,eAAA;EAAA,UACA,GAAA,WAAc,YAAA,GAAe,eAAA;AAAA;;;;;;;;AADzC;;;;;KAgBY,cAAA,WAAyB,eAAA,2BACd,CAAA,GAAI,CAAA,CAAE,CAAA,UAAW,YAAA,GAClC,CAAA,CAAE,CAAA,IACF,CAAA,CAAE,CAAA,UAAW,eAAA,GACX,cAAA,CAAe,CAAA,CAAE,CAAA,KACjB,CAAA,CAAE,CAAA;;;;;AAjDV;;;;;AAgBA;;;iBCRgB,YAAA,CAAa,WAAA,UAAqB,OAAA,GAAU,OAAA,CAAQ,mBAAA,IAAuB,QAAA;;;;;;;;cAmB9E,YAAA,EAAY,QAAA;;;;;;;AD3BzB;;iBEgBgB,KAAA,CAAM,IAAA;;;;cClBT,YAAA;;;;;;AHEb;;;;;AAgBA;;;;;;;;;;;iBIwCgB,oBAAA,WAA+B,eAAA,CAAA,CAAiB,OAAA,EAAS,CAAA,GAAI,cAAA,CAAe,CAAA"}
|
package/dist/lib/index.mjs
CHANGED
|
@@ -31,7 +31,7 @@ function createEngine(partialsDir, options) {
|
|
|
31
31
|
* only needs to handle `{{ var }}` expressions and basic Liquid
|
|
32
32
|
* control flow (`{% if %}`, `{% for %}`). No filesystem access required.
|
|
33
33
|
*/
|
|
34
|
-
const
|
|
34
|
+
const liquidEngine = new Liquid({
|
|
35
35
|
strictFilters: true,
|
|
36
36
|
ownPropertyOnly: true
|
|
37
37
|
});
|
|
@@ -112,6 +112,6 @@ function createPromptRegistry(modules) {
|
|
|
112
112
|
return deepFreeze({ ...modules });
|
|
113
113
|
}
|
|
114
114
|
//#endregion
|
|
115
|
-
export { PARTIALS_DIR, clean, createEngine, createPromptRegistry,
|
|
115
|
+
export { PARTIALS_DIR, clean, createEngine, createPromptRegistry, liquidEngine };
|
|
116
116
|
|
|
117
117
|
//# sourceMappingURL=index.mjs.map
|
package/dist/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/engine.ts","../../src/clean.ts","../../src/partials-dir.ts","../../src/registry.ts"],"sourcesContent":["import { Liquid } from \"liquidjs\";\n\nimport type { CreateEngineOptions } from \"./types.js\";\n\n/**\n * Create a LiquidJS engine with custom options.\n *\n * The `partialsDir` is used as the root for `{% render %}` resolution.\n * The `.prompt` extension is appended automatically.\n *\n * @param partialsDir - Root directory for `{% render %}` partial resolution.\n * @param options - Optional overrides for the LiquidJS engine configuration.\n * @returns A configured {@link Liquid} engine instance.\n */\nexport function createEngine(partialsDir: string, options?: Partial<CreateEngineOptions>): Liquid {\n return new Liquid({\n root: [partialsDir],\n partials: [partialsDir],\n extname: \".prompt\",\n cache: true,\n strictFilters: true,\n ownPropertyOnly: true,\n ...options,\n });\n}\n\n/**\n * Shared LiquidJS engine for rendering prompt templates at runtime.\n *\n * Partials are flattened at codegen time by the CLI, so this engine\n * only needs to handle `{{ var }}` expressions and basic Liquid\n * control flow (`{% if %}`, `{% for %}`). No filesystem access required.\n */\nexport const
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/engine.ts","../../src/clean.ts","../../src/partials-dir.ts","../../src/registry.ts"],"sourcesContent":["import { Liquid } from \"liquidjs\";\n\nimport type { CreateEngineOptions } from \"./types.js\";\n\n/**\n * Create a LiquidJS engine with custom options.\n *\n * The `partialsDir` is used as the root for `{% render %}` resolution.\n * The `.prompt` extension is appended automatically.\n *\n * @param partialsDir - Root directory for `{% render %}` partial resolution.\n * @param options - Optional overrides for the LiquidJS engine configuration.\n * @returns A configured {@link Liquid} engine instance.\n */\nexport function createEngine(partialsDir: string, options?: Partial<CreateEngineOptions>): Liquid {\n return new Liquid({\n root: [partialsDir],\n partials: [partialsDir],\n extname: \".prompt\",\n cache: true,\n strictFilters: true,\n ownPropertyOnly: true,\n ...options,\n });\n}\n\n/**\n * Shared LiquidJS engine for rendering prompt templates at runtime.\n *\n * Partials are flattened at codegen time by the CLI, so this engine\n * only needs to handle `{{ var }}` expressions and basic Liquid\n * control flow (`{% if %}`, `{% for %}`). No filesystem access required.\n */\nexport const liquidEngine = new Liquid({\n strictFilters: true,\n ownPropertyOnly: true,\n});\n","import { flow } from \"es-toolkit\";\n\nconst FRONTMATTER_RE = /^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n?/;\n\n/**\n * Remove YAML frontmatter from the beginning of a string.\n *\n * Frontmatter is a block delimited by `---` at the start of the file.\n * If no frontmatter is present, the string is returned unchanged.\n */\nfunction stripFrontmatter(text: string): string {\n return text.replace(FRONTMATTER_RE, \"\");\n}\n\nconst pipeline = flow(stripFrontmatter);\n\n/**\n * Clean a raw `.prompt` file into a render-ready template.\n *\n * Runs the source through a pipeline of transforms — currently\n * strips frontmatter, with more steps added over time.\n */\nexport function clean(text: string): string {\n return pipeline(text);\n}\n","import { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/** Absolute path to the SDK's built-in partials directory. */\nexport const PARTIALS_DIR = resolve(dirname(fileURLToPath(import.meta.url)), \"../prompts\");\n","import type { PromptModule, PromptNamespace, PromptRegistry } from \"./types.js\";\n\n/**\n * Check whether a value looks like a PromptModule leaf.\n * Leaves have `name`, `schema`, and `render` — namespaces do not.\n *\n * @private\n */\nfunction isPromptModule(value: unknown): value is PromptModule {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"render\" in value &&\n \"schema\" in value &&\n \"name\" in value\n );\n}\n\n/**\n * Recursively freeze a prompt namespace tree.\n * Only recurses into plain namespace nodes — PromptModule leaves\n * (which contain Zod schemas) are frozen shallowly.\n *\n * @param obj - The namespace object to freeze.\n * @returns The frozen object cast to its deep-readonly type.\n *\n * @private\n */\nfunction deepFreeze<T extends PromptNamespace>(obj: T): PromptRegistry<T> {\n Object.freeze(obj);\n Object.values(obj).forEach((value) => {\n if (\n typeof value === \"object\" &&\n value !== null &&\n !Object.isFrozen(value) &&\n !isPromptModule(value)\n ) {\n deepFreeze(value as PromptNamespace);\n }\n });\n return obj as PromptRegistry<T>;\n}\n\n/**\n * Create a typed, frozen prompt registry from a (possibly nested) map of prompt modules.\n *\n * The registry is typically created by generated code — the CLI produces\n * an `index.ts` that calls `createPromptRegistry()` with all discovered\n * prompt modules keyed by camelCase name, nested by group.\n *\n * @param modules - Record mapping camelCase prompt names (or group namespaces) to their modules.\n * @returns A deep-frozen, typed record with direct property access.\n *\n * @example\n * ```ts\n * const prompts = createPromptRegistry({\n * agents: { coverageAssessor },\n * greeting,\n * })\n * prompts.agents.coverageAssessor.render({ scope: 'full' })\n * ```\n */\nexport function createPromptRegistry<T extends PromptNamespace>(modules: T): PromptRegistry<T> {\n return deepFreeze({ ...modules });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAgB,aAAa,aAAqB,SAAgD;AAChG,QAAO,IAAI,OAAO;EAChB,MAAM,CAAC,YAAY;EACnB,UAAU,CAAC,YAAY;EACvB,SAAS;EACT,OAAO;EACP,eAAe;EACf,iBAAiB;EACjB,GAAG;EACJ,CAAC;;;;;;;;;AAUJ,MAAa,eAAe,IAAI,OAAO;CACrC,eAAe;CACf,iBAAiB;CAClB,CAAC;;;AClCF,MAAM,iBAAiB;;;;;;;AAQvB,SAAS,iBAAiB,MAAsB;AAC9C,QAAO,KAAK,QAAQ,gBAAgB,GAAG;;AAGzC,MAAM,WAAW,KAAK,iBAAiB;;;;;;;AAQvC,SAAgB,MAAM,MAAsB;AAC1C,QAAO,SAAS,KAAK;;;;;ACnBvB,MAAa,eAAe,QAAQ,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC,EAAE,aAAa;;;;;;;;;ACI1F,SAAS,eAAe,OAAuC;AAC7D,QACE,OAAO,UAAU,YACjB,UAAU,QACV,YAAY,SACZ,YAAY,SACZ,UAAU;;;;;;;;;;;;AAcd,SAAS,WAAsC,KAA2B;AACxE,QAAO,OAAO,IAAI;AAClB,QAAO,OAAO,IAAI,CAAC,SAAS,UAAU;AACpC,MACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,OAAO,SAAS,MAAM,IACvB,CAAC,eAAe,MAAM,CAEtB,YAAW,MAAyB;GAEtC;AACF,QAAO;;;;;;;;;;;;;;;;;;;;;AAsBT,SAAgB,qBAAgD,SAA+B;AAC7F,QAAO,WAAW,EAAE,GAAG,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funkai/prompts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Prompt SDK with LiquidJS templating and Zod validation",
|
|
6
6
|
"keywords": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^25.5.0",
|
|
39
39
|
"@vitest/coverage-v8": "^4.1.0",
|
|
40
|
-
"tsdown": "^0.21.
|
|
40
|
+
"tsdown": "^0.21.3",
|
|
41
41
|
"typescript": "^5.9.3",
|
|
42
42
|
"vitest": "^4.1.0"
|
|
43
43
|
},
|
package/src/engine.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Liquid } from "liquidjs";
|
|
2
2
|
import { describe, expect, it } from "vitest";
|
|
3
3
|
|
|
4
|
-
import { createEngine,
|
|
4
|
+
import { createEngine, liquidEngine } from "@/engine.js";
|
|
5
5
|
|
|
6
6
|
describe("createEngine", () => {
|
|
7
7
|
it("should return a Liquid instance", () => {
|
|
@@ -26,19 +26,19 @@ describe("createEngine", () => {
|
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
describe("
|
|
29
|
+
describe("liquidEngine", () => {
|
|
30
30
|
it("should be a Liquid instance", () => {
|
|
31
|
-
expect(
|
|
31
|
+
expect(liquidEngine).toBeInstanceOf(Liquid);
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
it("should render variable expressions", () => {
|
|
35
|
-
const result =
|
|
35
|
+
const result = liquidEngine.parseAndRenderSync("Hello {{ name }}", { name: "World" });
|
|
36
36
|
expect(result).toBe("Hello World");
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
it("should throw on unknown filters (strictFilters)", () => {
|
|
40
40
|
expect(() => {
|
|
41
|
-
|
|
41
|
+
liquidEngine.parseAndRenderSync("{{ name | bogus }}", { name: "test" });
|
|
42
42
|
}).toThrow();
|
|
43
43
|
});
|
|
44
44
|
});
|
package/src/engine.ts
CHANGED
|
@@ -31,7 +31,7 @@ export function createEngine(partialsDir: string, options?: Partial<CreateEngine
|
|
|
31
31
|
* only needs to handle `{{ var }}` expressions and basic Liquid
|
|
32
32
|
* control flow (`{% if %}`, `{% for %}`). No filesystem access required.
|
|
33
33
|
*/
|
|
34
|
-
export const
|
|
34
|
+
export const liquidEngine = new Liquid({
|
|
35
35
|
strictFilters: true,
|
|
36
36
|
ownPropertyOnly: true,
|
|
37
37
|
});
|
package/src/index.ts
CHANGED