feat(prompts-core): add package skeleton
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -108,6 +108,14 @@
|
|||||||
"@oh-my-opencode/utils": "workspace:*",
|
"@oh-my-opencode/utils": "workspace:*",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"packages/prompts-core": {
|
||||||
|
"name": "@oh-my-opencode/prompts-core",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"peerDependencies": {
|
||||||
|
"@oh-my-opencode/model-core": "workspace:*",
|
||||||
|
"@oh-my-opencode/utils": "workspace:*",
|
||||||
|
},
|
||||||
|
},
|
||||||
"packages/rules-engine": {
|
"packages/rules-engine": {
|
||||||
"name": "@oh-my-opencode/rules-engine",
|
"name": "@oh-my-opencode/rules-engine",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
@@ -209,6 +217,8 @@
|
|||||||
|
|
||||||
"@oh-my-opencode/model-core": ["@oh-my-opencode/model-core@workspace:packages/model-core"],
|
"@oh-my-opencode/model-core": ["@oh-my-opencode/model-core@workspace:packages/model-core"],
|
||||||
|
|
||||||
|
"@oh-my-opencode/prompts-core": ["@oh-my-opencode/prompts-core@workspace:packages/prompts-core"],
|
||||||
|
|
||||||
"@oh-my-opencode/rules-engine": ["@oh-my-opencode/rules-engine@workspace:packages/rules-engine"],
|
"@oh-my-opencode/rules-engine": ["@oh-my-opencode/rules-engine@workspace:packages/rules-engine"],
|
||||||
|
|
||||||
"@oh-my-opencode/utils": ["@oh-my-opencode/utils@workspace:packages/utils"],
|
"@oh-my-opencode/utils": ["@oh-my-opencode/utils@workspace:packages/utils"],
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"packages/ast-grep-mcp",
|
"packages/ast-grep-mcp",
|
||||||
"packages/utils",
|
"packages/utils",
|
||||||
"packages/model-core",
|
"packages/model-core",
|
||||||
|
"packages/prompts-core",
|
||||||
"packages/comment-checker-core",
|
"packages/comment-checker-core",
|
||||||
"packages/hashline-core",
|
"packages/hashline-core",
|
||||||
"packages/boulder-state",
|
"packages/boulder-state",
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "@oh-my-opencode/prompts-core",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"type": "module",
|
||||||
|
"private": true,
|
||||||
|
"description": "Harness-agnostic markdown prompt loading and model-variant routing for oh-my-opencode.",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./index.d.ts",
|
||||||
|
"import": "./src/index.ts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"types": "./index.d.ts",
|
||||||
|
"scripts": {
|
||||||
|
"typecheck": "tsgo --noEmit -p tsconfig.json",
|
||||||
|
"test": "bun test src/*.test.ts test/*.test.ts"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@oh-my-opencode/model-core": "workspace:*",
|
||||||
|
"@oh-my-opencode/utils": "workspace:*"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export type {
|
||||||
|
LoadedPrompt,
|
||||||
|
LoadPromptInput,
|
||||||
|
ModelVariant,
|
||||||
|
PromptSource,
|
||||||
|
RuntimeInjection,
|
||||||
|
VariantTable,
|
||||||
|
} from "./types"
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { describe, expect, test } from "bun:test"
|
||||||
|
import type { LoadPromptInput, LoadedPrompt, PromptSource, RuntimeInjection } from "./types"
|
||||||
|
|
||||||
|
describe("prompt core types", () => {
|
||||||
|
test("#given loader input shape #then accepts source name variant and runtime injections", () => {
|
||||||
|
const source: PromptSource = { baseDir: "/tmp/prompts" }
|
||||||
|
const injection: RuntimeInjection = { placeholder: "{X}", resolver: () => "Y" }
|
||||||
|
|
||||||
|
const input = {
|
||||||
|
source,
|
||||||
|
name: "test",
|
||||||
|
variant: "default",
|
||||||
|
inject: [injection],
|
||||||
|
} satisfies LoadPromptInput
|
||||||
|
|
||||||
|
expect(input.source.baseDir).toBe("/tmp/prompts")
|
||||||
|
expect(input.inject[0]?.placeholder).toBe("{X}")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("#given loaded prompt shape #then carries frontmatter and rendered body", () => {
|
||||||
|
const loaded = {
|
||||||
|
frontmatter: { title: "Fixture" },
|
||||||
|
body: "Prompt body",
|
||||||
|
hadFrontmatter: true,
|
||||||
|
parseError: false,
|
||||||
|
filePath: "/tmp/prompts/test/default.md",
|
||||||
|
} satisfies LoadedPrompt<{ readonly title: string }>
|
||||||
|
|
||||||
|
expect(loaded.frontmatter.title).toBe("Fixture")
|
||||||
|
expect(loaded.body).toBe("Prompt body")
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
export type ModelVariant =
|
||||||
|
| "default"
|
||||||
|
| "gpt"
|
||||||
|
| "gemini"
|
||||||
|
| "kimi"
|
||||||
|
| "glm"
|
||||||
|
| "planner"
|
||||||
|
| "opus-4-7"
|
||||||
|
| "minimax"
|
||||||
|
|
||||||
|
export type PromptSource = {
|
||||||
|
readonly baseDir: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RuntimeInjection = {
|
||||||
|
readonly placeholder: string
|
||||||
|
readonly resolver: () => string | Promise<string>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type LoadPromptInput = {
|
||||||
|
readonly source: PromptSource
|
||||||
|
readonly name: string
|
||||||
|
readonly variant: string
|
||||||
|
readonly inject?: readonly RuntimeInjection[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type LoadedPrompt<TFrontmatter = Record<string, unknown>> = {
|
||||||
|
readonly frontmatter: TFrontmatter
|
||||||
|
readonly body: string
|
||||||
|
readonly hadFrontmatter: boolean
|
||||||
|
readonly parseError: boolean
|
||||||
|
readonly filePath: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type VariantTable = Readonly<Record<string, PromptSource>>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ESNext",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"strict": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"lib": ["ESNext"],
|
||||||
|
"types": ["bun-types"]
|
||||||
|
},
|
||||||
|
"include": ["src/**/*", "test/**/*"]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user