@zhijiewang/openharness 2.5.0 → 2.9.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 +1 -1
- package/data/registry.json +262 -0
- package/data/skills/code-review.md +19 -0
- package/data/skills/commit.md +17 -0
- package/data/skills/debug.md +24 -0
- package/data/skills/diagnose.md +24 -0
- package/data/skills/plan.md +25 -0
- package/data/skills/simplify.md +24 -0
- package/data/skills/tdd.md +22 -0
- package/dist/agents/roles.d.ts +12 -2
- package/dist/agents/roles.js +65 -6
- package/dist/commands/ai.d.ts +6 -0
- package/dist/commands/ai.js +264 -0
- package/dist/commands/git.d.ts +6 -0
- package/dist/commands/git.js +167 -0
- package/dist/commands/index.d.ts +10 -31
- package/dist/commands/index.js +22 -1096
- package/dist/commands/info.d.ts +8 -0
- package/dist/commands/info.js +671 -0
- package/dist/commands/session.d.ts +6 -0
- package/dist/commands/session.js +214 -0
- package/dist/commands/settings.d.ts +6 -0
- package/dist/commands/settings.js +187 -0
- package/dist/commands/skills.d.ts +6 -0
- package/dist/commands/skills.js +162 -0
- package/dist/commands/types.d.ts +36 -0
- package/dist/commands/types.js +5 -0
- package/dist/components/App.js +7 -1
- package/dist/components/InitWizard.js +60 -62
- package/dist/harness/config.d.ts +11 -0
- package/dist/harness/hooks.d.ts +14 -0
- package/dist/harness/hooks.js +56 -10
- package/dist/harness/marketplace.d.ts +77 -2
- package/dist/harness/marketplace.js +260 -38
- package/dist/harness/memory.d.ts +34 -0
- package/dist/harness/memory.js +96 -0
- package/dist/harness/plugins.d.ts +13 -3
- package/dist/harness/plugins.js +98 -17
- package/dist/harness/session-db.d.ts +8 -1
- package/dist/harness/session-db.js +24 -3
- package/dist/harness/skill-registry.d.ts +26 -2
- package/dist/harness/skill-registry.js +42 -4
- package/dist/providers/anthropic.js +7 -8
- package/dist/providers/openai.js +3 -2
- package/dist/renderer/layout-sections.d.ts +56 -0
- package/dist/renderer/layout-sections.js +462 -0
- package/dist/renderer/layout.d.ts +4 -2
- package/dist/renderer/layout.js +25 -500
- package/dist/tools/AgentTool/index.d.ts +2 -2
- package/dist/tools/DiagnosticsTool/index.d.ts +1 -1
- package/dist/tools/GrepTool/index.d.ts +6 -6
- package/dist/tools/MemoryTool/index.d.ts +6 -6
- package/dist/tools/MonitorTool/index.js +5 -1
- package/dist/tools/TodoWriteTool/index.d.ts +37 -0
- package/dist/tools/TodoWriteTool/index.js +78 -0
- package/dist/tools.js +2 -0
- package/dist/types/permissions.js +104 -42
- package/dist/utils/bash-safety.d.ts +19 -0
- package/dist/utils/bash-safety.js +179 -1
- package/dist/utils/safe-env.d.ts +5 -1
- package/dist/utils/safe-env.js +19 -1
- package/package.json +3 -1
package/dist/harness/plugins.js
CHANGED
|
@@ -12,10 +12,31 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
14
14
|
import { homedir } from "node:os";
|
|
15
|
-
import { join, relative } from "node:path";
|
|
15
|
+
import { dirname, join, relative } from "node:path";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
16
17
|
const PROJECT_SKILLS_DIR = join(".oh", "skills");
|
|
17
18
|
const GLOBAL_SKILLS_DIR = join(homedir(), ".oh", "skills");
|
|
18
|
-
|
|
19
|
+
// Claude Code ecosystem mirror paths (Anthropic convention)
|
|
20
|
+
const CC_PROJECT_SKILLS_DIR = join(".claude", "skills");
|
|
21
|
+
const CC_GLOBAL_SKILLS_DIR = join(homedir(), ".claude", "skills");
|
|
22
|
+
// Bundled skills shipped with the openharness package itself.
|
|
23
|
+
// At runtime this resolves to <package-root>/data/skills/ both in dev (src/) and prod (dist/).
|
|
24
|
+
const BUNDLED_SKILLS_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "data", "skills");
|
|
25
|
+
/** Parse a frontmatter list value. Accepts `[a, b]` (YAML inline) or `a b c` (space-separated, Anthropic spec). */
|
|
26
|
+
function parseListValue(raw) {
|
|
27
|
+
const trimmed = raw.trim();
|
|
28
|
+
if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
29
|
+
return trimmed
|
|
30
|
+
.slice(1, -1)
|
|
31
|
+
.split(",")
|
|
32
|
+
.map((t) => t.trim())
|
|
33
|
+
.filter(Boolean);
|
|
34
|
+
}
|
|
35
|
+
// Strip surrounding quotes if present
|
|
36
|
+
const unquoted = trimmed.replace(/^["']|["']$/g, "");
|
|
37
|
+
return unquoted.split(/\s+/).filter(Boolean);
|
|
38
|
+
}
|
|
39
|
+
/** Parse YAML frontmatter from a skill markdown file. Accepts both OH camelCase and Anthropic kebab-case. */
|
|
19
40
|
function parseSkillFrontmatter(content) {
|
|
20
41
|
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
21
42
|
if (!match)
|
|
@@ -28,33 +49,74 @@ function parseSkillFrontmatter(content) {
|
|
|
28
49
|
const descMatch = frontmatter.match(/^description:\s*(.+)$/m);
|
|
29
50
|
if (descMatch)
|
|
30
51
|
result.description = descMatch[1].trim();
|
|
52
|
+
// trigger: OH-native field; when-to-use / whenToUse: Anthropic-style hint (also used as trigger fallback)
|
|
31
53
|
const triggerMatch = frontmatter.match(/^trigger:\s*(.+)$/m);
|
|
32
54
|
if (triggerMatch)
|
|
33
55
|
result.trigger = triggerMatch[1].trim();
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
result.
|
|
37
|
-
//
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
56
|
+
const whenToUseMatch = frontmatter.match(/^(?:when-to-use|whenToUse):\s*(.+)$/m);
|
|
57
|
+
if (whenToUseMatch)
|
|
58
|
+
result.whenToUse = whenToUseMatch[1].trim();
|
|
59
|
+
// tools / allowedTools / allowed-tools — array OR space-separated. Merge all forms found.
|
|
60
|
+
const toolsCollected = new Set();
|
|
61
|
+
for (const re of [/^tools:\s*(.+)$/m, /^allowedTools:\s*(.+)$/m, /^allowed-tools:\s*(.+)$/m]) {
|
|
62
|
+
const m = frontmatter.match(re);
|
|
63
|
+
if (m)
|
|
64
|
+
for (const t of parseListValue(m[1]))
|
|
65
|
+
toolsCollected.add(t);
|
|
42
66
|
}
|
|
43
|
-
|
|
67
|
+
if (toolsCollected.size > 0)
|
|
68
|
+
result.tools = [...toolsCollected];
|
|
69
|
+
// args / argument-hint
|
|
70
|
+
const argsMatch = frontmatter.match(/^(?:args|argument-hint):\s*(.+)$/m);
|
|
44
71
|
if (argsMatch)
|
|
45
|
-
result.args = argsMatch[1]
|
|
72
|
+
result.args = parseListValue(argsMatch[1]);
|
|
46
73
|
// invokeModel: false OR disable-model-invocation: true → hidden from system prompt
|
|
47
74
|
if (frontmatter.match(/^invokeModel:\s*false$/m) || frontmatter.match(/^disable-model-invocation:\s*true$/m)) {
|
|
48
75
|
result.invokeModel = false;
|
|
49
76
|
}
|
|
77
|
+
// license: SPDX identifier (e.g. MIT, Apache-2.0)
|
|
78
|
+
const licenseMatch = frontmatter.match(/^license:\s*(.+)$/m);
|
|
79
|
+
if (licenseMatch)
|
|
80
|
+
result.license = licenseMatch[1].trim().replace(/^["']|["']$/g, "");
|
|
81
|
+
// paths: glob list — scopes auto-surfacing to matching files
|
|
82
|
+
const pathsMatch = frontmatter.match(/^paths:\s*(.+)$/m);
|
|
83
|
+
if (pathsMatch)
|
|
84
|
+
result.paths = parseListValue(pathsMatch[1]);
|
|
85
|
+
// context: "default" | "fork" — when "fork", skill runs in a new sub-agent context
|
|
86
|
+
const contextMatch = frontmatter.match(/^context:\s*(.+)$/m);
|
|
87
|
+
if (contextMatch) {
|
|
88
|
+
const v = contextMatch[1].trim().replace(/^["']|["']$/g, "");
|
|
89
|
+
if (v === "fork" || v === "default")
|
|
90
|
+
result.context = v;
|
|
91
|
+
}
|
|
92
|
+
// agent: sub-agent type name (only meaningful when context: fork)
|
|
93
|
+
const agentMatch = frontmatter.match(/^agent:\s*(.+)$/m);
|
|
94
|
+
if (agentMatch)
|
|
95
|
+
result.agent = agentMatch[1].trim().replace(/^["']|["']$/g, "");
|
|
50
96
|
return result;
|
|
51
97
|
}
|
|
52
|
-
/** Recursively collect
|
|
98
|
+
/** Recursively collect skill .md files from a directory tree.
|
|
99
|
+
* Anthropic / Claude Code convention: a directory containing `SKILL.md` is a single
|
|
100
|
+
* directory-packaged skill — only the SKILL.md surfaces; sibling .md files are
|
|
101
|
+
* companion documentation (referenced via Read at runtime). Directories without
|
|
102
|
+
* SKILL.md fall through to the legacy flat-file behavior (every .md is a skill).
|
|
103
|
+
*/
|
|
53
104
|
function walkMdFiles(dir) {
|
|
54
105
|
if (!existsSync(dir))
|
|
55
106
|
return [];
|
|
107
|
+
let entries;
|
|
108
|
+
try {
|
|
109
|
+
entries = readdirSync(dir);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
// Directory-packaged skill: only SKILL.md counts; siblings are companions.
|
|
115
|
+
if (entries.includes("SKILL.md")) {
|
|
116
|
+
return [join(dir, "SKILL.md")];
|
|
117
|
+
}
|
|
56
118
|
const results = [];
|
|
57
|
-
for (const entry of
|
|
119
|
+
for (const entry of entries) {
|
|
58
120
|
const full = join(dir, entry);
|
|
59
121
|
try {
|
|
60
122
|
if (statSync(full).isDirectory()) {
|
|
@@ -86,6 +148,11 @@ function loadSkillsFromDir(dir, source) {
|
|
|
86
148
|
trigger: meta.trigger,
|
|
87
149
|
tools: meta.tools,
|
|
88
150
|
args: meta.args,
|
|
151
|
+
whenToUse: meta.whenToUse,
|
|
152
|
+
license: meta.license,
|
|
153
|
+
paths: meta.paths,
|
|
154
|
+
context: meta.context,
|
|
155
|
+
agent: meta.agent,
|
|
89
156
|
content,
|
|
90
157
|
filePath,
|
|
91
158
|
source,
|
|
@@ -98,11 +165,17 @@ function loadSkillsFromDir(dir, source) {
|
|
|
98
165
|
})
|
|
99
166
|
.filter((s) => s !== null);
|
|
100
167
|
}
|
|
101
|
-
/** Discover all available skills from project + global dirs + installed plugins */
|
|
168
|
+
/** Discover all available skills from bundled + project + global dirs + installed plugins */
|
|
102
169
|
export function discoverSkills() {
|
|
103
170
|
const skills = [];
|
|
171
|
+
// Bundled (shipped with the openharness package)
|
|
172
|
+
skills.push(...loadSkillsFromDir(BUNDLED_SKILLS_DIR, "bundled"));
|
|
173
|
+
// OH-native paths
|
|
104
174
|
skills.push(...loadSkillsFromDir(PROJECT_SKILLS_DIR, "project"));
|
|
105
175
|
skills.push(...loadSkillsFromDir(GLOBAL_SKILLS_DIR, "global"));
|
|
176
|
+
// Claude Code ecosystem mirror paths — same source labels (project/global)
|
|
177
|
+
skills.push(...loadSkillsFromDir(CC_PROJECT_SKILLS_DIR, "project"));
|
|
178
|
+
skills.push(...loadSkillsFromDir(CC_GLOBAL_SKILLS_DIR, "global"));
|
|
106
179
|
// Load skills from installed marketplace plugins (namespaced as plugin-name:skill-name)
|
|
107
180
|
try {
|
|
108
181
|
const { getInstalledPlugins } = require("./marketplace.js");
|
|
@@ -119,14 +192,22 @@ export function discoverSkills() {
|
|
|
119
192
|
catch {
|
|
120
193
|
/* marketplace module may not be loaded yet */
|
|
121
194
|
}
|
|
122
|
-
|
|
195
|
+
// De-duplicate by name+filePath: if same skill appears in multiple paths (e.g. CC mirror), keep first.
|
|
196
|
+
const seen = new Set();
|
|
197
|
+
return skills.filter((s) => {
|
|
198
|
+
const key = `${s.name}::${s.filePath}`;
|
|
199
|
+
if (seen.has(key))
|
|
200
|
+
return false;
|
|
201
|
+
seen.add(key);
|
|
202
|
+
return true;
|
|
203
|
+
});
|
|
123
204
|
}
|
|
124
205
|
/** Find a skill by name (case-insensitive) */
|
|
125
206
|
export function findSkill(name) {
|
|
126
207
|
const skills = discoverSkills();
|
|
127
208
|
return skills.find((s) => s.name.toLowerCase() === name.toLowerCase()) ?? null;
|
|
128
209
|
}
|
|
129
|
-
/** Find skills that match a trigger condition */
|
|
210
|
+
/** Find skills that match a trigger condition (substring match against `trigger` field). */
|
|
130
211
|
export function findTriggeredSkills(userMessage) {
|
|
131
212
|
const skills = discoverSkills();
|
|
132
213
|
return skills.filter((s) => {
|
|
@@ -48,7 +48,14 @@ export declare function sessionToIndexEntry(session: Session): SessionIndexEntry
|
|
|
48
48
|
* Rebuilds the FTS5 index from session JSON files on disk.
|
|
49
49
|
*/
|
|
50
50
|
export declare function rebuildIndex(db: Database.Database, sessionsDir?: string): number;
|
|
51
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Get a shared DB connection (opens once, reuses thereafter).
|
|
53
|
+
*
|
|
54
|
+
* Honors the `OH_SESSION_DB_PATH` environment variable for test isolation.
|
|
55
|
+
* When the env var changes between calls, the old singleton is closed and a
|
|
56
|
+
* new one is opened at the new path — this lets tests point at a tmp dir
|
|
57
|
+
* without leaking into the user's real `~/.oh/sessions.db`.
|
|
58
|
+
*/
|
|
52
59
|
export declare function getSessionDb(): Database.Database;
|
|
53
60
|
/** Close the singleton connection (call on process exit) */
|
|
54
61
|
export declare function closeGlobalSessionDb(): void;
|
|
@@ -145,11 +145,32 @@ export function rebuildIndex(db, sessionsDir) {
|
|
|
145
145
|
}
|
|
146
146
|
// ── Singleton Connection ──
|
|
147
147
|
let _singletonDb = null;
|
|
148
|
-
|
|
148
|
+
let _singletonDbPath = null;
|
|
149
|
+
/**
|
|
150
|
+
* Get a shared DB connection (opens once, reuses thereafter).
|
|
151
|
+
*
|
|
152
|
+
* Honors the `OH_SESSION_DB_PATH` environment variable for test isolation.
|
|
153
|
+
* When the env var changes between calls, the old singleton is closed and a
|
|
154
|
+
* new one is opened at the new path — this lets tests point at a tmp dir
|
|
155
|
+
* without leaking into the user's real `~/.oh/sessions.db`.
|
|
156
|
+
*/
|
|
149
157
|
export function getSessionDb() {
|
|
150
|
-
|
|
151
|
-
|
|
158
|
+
const envPath = process.env.OH_SESSION_DB_PATH;
|
|
159
|
+
const targetPath = envPath || DEFAULT_DB_PATH;
|
|
160
|
+
if (_singletonDb && _singletonDbPath === targetPath) {
|
|
161
|
+
return _singletonDb;
|
|
162
|
+
}
|
|
163
|
+
if (_singletonDb) {
|
|
164
|
+
try {
|
|
165
|
+
_singletonDb.close();
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
/* ignore */
|
|
169
|
+
}
|
|
170
|
+
_singletonDb = null;
|
|
152
171
|
}
|
|
172
|
+
_singletonDb = openSessionDb(targetPath);
|
|
173
|
+
_singletonDbPath = targetPath;
|
|
153
174
|
return _singletonDb;
|
|
154
175
|
}
|
|
155
176
|
/** Close the singleton connection (call on process exit) */
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Skills Registry — search and install community skills from a remote registry.
|
|
3
3
|
*/
|
|
4
|
+
/** SPDX identifiers for licenses we install without explicit user acceptance. */
|
|
5
|
+
export declare const PERMISSIVE_LICENSES: Set<string>;
|
|
4
6
|
export type RegistrySkill = {
|
|
5
7
|
name: string;
|
|
6
8
|
description: string;
|
|
@@ -8,6 +10,14 @@ export type RegistrySkill = {
|
|
|
8
10
|
version: string;
|
|
9
11
|
source: string;
|
|
10
12
|
tags: string[];
|
|
13
|
+
/** SPDX license identifier (e.g. "MIT"). Required for new entries; absent for legacy. */
|
|
14
|
+
license?: string;
|
|
15
|
+
/** Attribution string to preserve when installing (e.g. "© 2025 Jesse Vincent"). */
|
|
16
|
+
attribution?: string;
|
|
17
|
+
/** Upstream homepage / repo URL. */
|
|
18
|
+
upstream?: string;
|
|
19
|
+
/** When false, skill cannot be installed via this command — only linked to upstream. Used for viral licenses (CC-BY-SA, GPL). */
|
|
20
|
+
installable?: boolean;
|
|
11
21
|
};
|
|
12
22
|
export type Registry = {
|
|
13
23
|
skills: RegistrySkill[];
|
|
@@ -16,6 +26,20 @@ export type Registry = {
|
|
|
16
26
|
export declare function fetchRegistry(url?: string): Promise<Registry>;
|
|
17
27
|
/** Search registry by query (matches name, description, tags) */
|
|
18
28
|
export declare function searchRegistry(registry: Registry, query: string): RegistrySkill[];
|
|
19
|
-
/**
|
|
20
|
-
export
|
|
29
|
+
/** Result returned by installSkill — either success with path, or refusal with reason. */
|
|
30
|
+
export type InstallResult = {
|
|
31
|
+
ok: true;
|
|
32
|
+
filePath: string;
|
|
33
|
+
} | {
|
|
34
|
+
ok: false;
|
|
35
|
+
reason: "not-installable" | "license-not-accepted";
|
|
36
|
+
message: string;
|
|
37
|
+
};
|
|
38
|
+
/** Install a skill from the registry to ~/.oh/skills/.
|
|
39
|
+
* Refuses non-permissive licenses unless `acceptLicense` matches the entry's license.
|
|
40
|
+
* Refuses entries with `installable: false` (e.g. viral-license skills that must be installed upstream).
|
|
41
|
+
*/
|
|
42
|
+
export declare function installSkill(skill: RegistrySkill, opts?: {
|
|
43
|
+
acceptLicense?: string;
|
|
44
|
+
}): Promise<InstallResult>;
|
|
21
45
|
//# sourceMappingURL=skill-registry.d.ts.map
|
|
@@ -6,6 +6,16 @@ import { homedir } from "node:os";
|
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
const DEFAULT_REGISTRY_URL = "https://raw.githubusercontent.com/zhijiewong/openharness/main/data/registry.json";
|
|
8
8
|
const GLOBAL_SKILLS_DIR = join(homedir(), ".oh", "skills");
|
|
9
|
+
/** SPDX identifiers for licenses we install without explicit user acceptance. */
|
|
10
|
+
export const PERMISSIVE_LICENSES = new Set([
|
|
11
|
+
"MIT",
|
|
12
|
+
"Apache-2.0",
|
|
13
|
+
"BSD-2-Clause",
|
|
14
|
+
"BSD-3-Clause",
|
|
15
|
+
"ISC",
|
|
16
|
+
"CC0-1.0",
|
|
17
|
+
"Unlicense",
|
|
18
|
+
]);
|
|
9
19
|
/** Fetch the registry from remote URL */
|
|
10
20
|
export async function fetchRegistry(url = DEFAULT_REGISTRY_URL) {
|
|
11
21
|
const response = await fetch(url);
|
|
@@ -20,16 +30,44 @@ export function searchRegistry(registry, query) {
|
|
|
20
30
|
s.description.toLowerCase().includes(q) ||
|
|
21
31
|
s.tags.some((t) => t.toLowerCase().includes(q)));
|
|
22
32
|
}
|
|
23
|
-
/** Install a skill from the registry to ~/.oh/skills
|
|
24
|
-
|
|
33
|
+
/** Install a skill from the registry to ~/.oh/skills/.
|
|
34
|
+
* Refuses non-permissive licenses unless `acceptLicense` matches the entry's license.
|
|
35
|
+
* Refuses entries with `installable: false` (e.g. viral-license skills that must be installed upstream).
|
|
36
|
+
*/
|
|
37
|
+
export async function installSkill(skill, opts = {}) {
|
|
38
|
+
// Gate 1: link-only entries
|
|
39
|
+
if (skill.installable === false) {
|
|
40
|
+
const upstream = skill.upstream ? ` Visit ${skill.upstream} to install under its license terms.` : "";
|
|
41
|
+
return {
|
|
42
|
+
ok: false,
|
|
43
|
+
reason: "not-installable",
|
|
44
|
+
message: `Skill "${skill.name}" is link-only (license: ${skill.license ?? "unknown"}).${upstream}`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Gate 2: license check
|
|
48
|
+
if (skill.license && !PERMISSIVE_LICENSES.has(skill.license)) {
|
|
49
|
+
if (opts.acceptLicense !== skill.license) {
|
|
50
|
+
return {
|
|
51
|
+
ok: false,
|
|
52
|
+
reason: "license-not-accepted",
|
|
53
|
+
message: `Skill "${skill.name}" is licensed under ${skill.license}, which is not in the auto-install allowlist.\n` +
|
|
54
|
+
`To install, re-run with --accept-license=${skill.license} to acknowledge its terms.`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
25
58
|
const response = await fetch(skill.source);
|
|
26
59
|
if (!response.ok)
|
|
27
60
|
throw new Error(`Failed to download skill: ${response.status}`);
|
|
28
|
-
|
|
61
|
+
let content = await response.text();
|
|
62
|
+
// Preserve attribution by prepending an HTML comment if present and not already in the file
|
|
63
|
+
if (skill.attribution && !content.includes(skill.attribution)) {
|
|
64
|
+
const header = `<!-- Source: ${skill.upstream ?? skill.source}\n License: ${skill.license ?? "unknown"}\n ${skill.attribution} -->\n`;
|
|
65
|
+
content = header + content;
|
|
66
|
+
}
|
|
29
67
|
mkdirSync(GLOBAL_SKILLS_DIR, { recursive: true });
|
|
30
68
|
const slug = skill.name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
31
69
|
const filePath = join(GLOBAL_SKILLS_DIR, `${slug}.md`);
|
|
32
70
|
writeFileSync(filePath, content);
|
|
33
|
-
return filePath;
|
|
71
|
+
return { ok: true, filePath };
|
|
34
72
|
}
|
|
35
73
|
//# sourceMappingURL=skill-registry.js.map
|
|
@@ -87,15 +87,18 @@ export class AnthropicProvider {
|
|
|
87
87
|
// Prompt caching: send system prompt as content blocks with cache_control.
|
|
88
88
|
// Anthropic caches matching prefixes — 90% cost reduction on repeat turns.
|
|
89
89
|
const systemBlocks = [{ type: "text", text: systemPrompt, cache_control: { type: "ephemeral" } }];
|
|
90
|
+
// Scale max_tokens and thinking budget based on model
|
|
91
|
+
const isOpus = m.includes("opus");
|
|
92
|
+
const maxTokens = isOpus ? 16384 : 8192;
|
|
93
|
+
const thinkingBudget = isOpus ? 32000 : 10000;
|
|
90
94
|
const body = {
|
|
91
95
|
model: m,
|
|
92
|
-
max_tokens:
|
|
96
|
+
max_tokens: maxTokens,
|
|
93
97
|
system: systemBlocks,
|
|
94
98
|
messages: this.convertMessages(messages),
|
|
95
99
|
stream: true,
|
|
100
|
+
thinking: { type: "enabled", budget_tokens: thinkingBudget },
|
|
96
101
|
};
|
|
97
|
-
// Enable extended thinking for Claude models
|
|
98
|
-
body.thinking = { type: "enabled", budget_tokens: 10000 };
|
|
99
102
|
const anthropicTools = this.convertTools(tools);
|
|
100
103
|
if (anthropicTools) {
|
|
101
104
|
// Mark last tool definition as cacheable (cache covers all tools before it)
|
|
@@ -131,7 +134,6 @@ export class AnthropicProvider {
|
|
|
131
134
|
let currentToolId = "";
|
|
132
135
|
let currentToolName = "";
|
|
133
136
|
let currentToolArgs = "";
|
|
134
|
-
let _inThinkingBlock = false;
|
|
135
137
|
while (true) {
|
|
136
138
|
const { done, value } = await reader.read();
|
|
137
139
|
if (done)
|
|
@@ -169,9 +171,7 @@ export class AnthropicProvider {
|
|
|
169
171
|
callId: block.id,
|
|
170
172
|
};
|
|
171
173
|
}
|
|
172
|
-
|
|
173
|
-
_inThinkingBlock = true;
|
|
174
|
-
}
|
|
174
|
+
// thinking blocks are handled via thinking_delta in content_block_delta
|
|
175
175
|
break;
|
|
176
176
|
}
|
|
177
177
|
case "content_block_delta": {
|
|
@@ -188,7 +188,6 @@ export class AnthropicProvider {
|
|
|
188
188
|
break;
|
|
189
189
|
}
|
|
190
190
|
case "content_block_stop": {
|
|
191
|
-
_inThinkingBlock = false;
|
|
192
191
|
if (currentToolId) {
|
|
193
192
|
let parsedArgs = {};
|
|
194
193
|
if (currentToolArgs) {
|
package/dist/providers/openai.js
CHANGED
|
@@ -75,8 +75,9 @@ export class OpenAIProvider {
|
|
|
75
75
|
if (tools?.length)
|
|
76
76
|
body.tools = tools;
|
|
77
77
|
// Enable reasoning for o-series models
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
const isReasoning = m.startsWith("o1") || m.startsWith("o3") || m.startsWith("o4");
|
|
79
|
+
if (isReasoning) {
|
|
80
|
+
body.reasoning_effort = m.includes("mini") ? "medium" : "high";
|
|
80
81
|
}
|
|
81
82
|
let res;
|
|
82
83
|
try {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout section renderers — individual UI widgets rasterized into a CellGrid.
|
|
3
|
+
* Each function takes (state, grid, row, limit, ...options) and returns next row.
|
|
4
|
+
*/
|
|
5
|
+
import type { CellGrid, Style } from "./cells.js";
|
|
6
|
+
import type { LayoutState } from "./layout.js";
|
|
7
|
+
export declare const S_TEXT: Style;
|
|
8
|
+
export declare const S_DIM: Style;
|
|
9
|
+
export declare const S_BORDER: Style;
|
|
10
|
+
export declare const S_BANNER: Style;
|
|
11
|
+
export declare const S_BANNER_DIM: Style;
|
|
12
|
+
export declare let S_USER: Style;
|
|
13
|
+
export declare let S_ASSISTANT: Style;
|
|
14
|
+
export declare let S_ERROR: Style;
|
|
15
|
+
export declare let S_YELLOW: Style;
|
|
16
|
+
export declare let S_GREEN: Style;
|
|
17
|
+
/** Reset style cache — call after theme change */
|
|
18
|
+
export declare function resetStyleCache(): void;
|
|
19
|
+
export declare function ensureStyles(): void;
|
|
20
|
+
export declare const SPINNER_CHARS: string[];
|
|
21
|
+
export declare function renderBannerSection(state: LayoutState, grid: CellGrid, r: number, limit: number, opts: {
|
|
22
|
+
compact: boolean;
|
|
23
|
+
}): number;
|
|
24
|
+
export declare function renderThinkingSection(state: LayoutState, grid: CellGrid, r: number, limit: number): number;
|
|
25
|
+
export declare function renderThinkingSummarySection(state: LayoutState, grid: CellGrid, r: number, limit: number): number;
|
|
26
|
+
export declare function renderSpinnerSection(state: LayoutState, grid: CellGrid, r: number, limit: number): number;
|
|
27
|
+
export declare function renderErrorSection(state: LayoutState, grid: CellGrid, r: number, limit: number): number;
|
|
28
|
+
export declare function renderToolCallsSection(state: LayoutState, grid: CellGrid, r: number, limit: number, opts: {
|
|
29
|
+
maxLiveLines: number;
|
|
30
|
+
showOverflow: boolean;
|
|
31
|
+
}): number;
|
|
32
|
+
export declare function renderContextWarningSection(state: LayoutState, grid: CellGrid, r: number, limit: number): number;
|
|
33
|
+
export declare function renderPermissionBoxSection(state: LayoutState, grid: CellGrid, nextRow: number, h: number, opts: {
|
|
34
|
+
boxed: boolean;
|
|
35
|
+
maxDiffHeight: number;
|
|
36
|
+
}): number;
|
|
37
|
+
export declare function renderQuestionPromptSection(state: LayoutState, grid: CellGrid, nextRow: number, h: number, opts: {
|
|
38
|
+
boxed: boolean;
|
|
39
|
+
}): {
|
|
40
|
+
nextRow: number;
|
|
41
|
+
questionInputRow: number;
|
|
42
|
+
};
|
|
43
|
+
export declare function renderStatusLineSection(state: LayoutState, grid: CellGrid, nextRow: number, limit: number): number;
|
|
44
|
+
export declare function renderAutocompleteSection(state: LayoutState, grid: CellGrid, nextRow: number, limit: number, promptWidth: number): number;
|
|
45
|
+
export declare function renderNotificationsSection(state: LayoutState, grid: CellGrid, nextRow: number, limit: number): number;
|
|
46
|
+
export declare function renderInputSection(state: LayoutState, grid: CellGrid, inputRow: number, limit: number, promptText: string, promptWidth: number): number;
|
|
47
|
+
export declare function renderCompanionSection(state: LayoutState, grid: CellGrid, anchorRow: number, limit: number, promptWidth: number): void;
|
|
48
|
+
export declare function computeCursorPosition(state: LayoutState, inputRow: number, inputStart: number, questionInputRow: number): {
|
|
49
|
+
cursorRow: number;
|
|
50
|
+
cursorCol: number;
|
|
51
|
+
};
|
|
52
|
+
export declare function getPromptText(state: LayoutState): {
|
|
53
|
+
promptText: string;
|
|
54
|
+
promptWidth: number;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=layout-sections.d.ts.map
|