@zcy2nn/agent-forge 1.1.1 → 1.1.3

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.
@@ -1,8 +1,7 @@
1
1
  /**
2
- * Filter and inject available_skills block based on the current agent's permission.skill rules.
3
- * OpenCode core injects `<available_skills>` from installed skills, so this hook rewrites that
4
- * block before the prompt is sent. Built-in skills from the package are also injected so they
5
- * are always visible even without being copied to the OpenCode skills directory.
2
+ * Filter available_skills blocks based on the current agent's permission.skill rules.
3
+ * OpenCode core injects `<available_skills>` from installed skills, so this hook only rewrites
4
+ * that block before the prompt is sent.
6
5
  */
7
6
  import type { PluginInput } from '@opencode-ai/plugin';
8
7
  import { type PluginConfig } from '../../config';
@@ -20,14 +19,6 @@ interface MessageWithParts {
20
19
  parts: MessagePart[];
21
20
  }
22
21
  type SkillRule = 'allow' | 'ask' | 'deny';
23
- interface SkillEntry {
24
- name: string;
25
- block: string;
26
- }
27
- /**
28
- * Merge installed skill entries with built-in entries (dedup by name, installed takes precedence).
29
- */
30
- declare function mergeWithBuiltinSkills(installedEntries: SkillEntry[]): SkillEntry[];
31
22
  declare function filterAvailableSkillsText(text: string, permissionRules: Record<string, SkillRule>): string;
32
23
  /**
33
24
  * Creates the experimental.chat.messages.transform hook for filtering available skills.
@@ -38,4 +29,4 @@ export declare function createFilterAvailableSkillsHook(_ctx: PluginInput, confi
38
29
  messages: MessageWithParts[];
39
30
  }) => Promise<void>;
40
31
  };
41
- export { filterAvailableSkillsText, mergeWithBuiltinSkills };
32
+ export { filterAvailableSkillsText };
package/dist/index.js CHANGED
@@ -22797,19 +22797,6 @@ ${buildRetryGuidance(detected)}`;
22797
22797
  // src/hooks/filter-available-skills/index.ts
22798
22798
  var AVAILABLE_SKILLS_BLOCK_REGEX = /<available_skills>\s*([\s\S]*?)\s*<\/available_skills>/g;
22799
22799
  var SKILL_NAME_REGEX = /<name>([^<]+)<\/name>/;
22800
- function builtinSkillBlock(name, description) {
22801
- return `<skill>
22802
- <name>${name}</name>
22803
- <description>${description}</description>
22804
- <location>builtin</location>
22805
- </skill>`;
22806
- }
22807
- function getBuiltinSkillEntries() {
22808
- return CUSTOM_SKILLS.map((skill) => ({
22809
- name: skill.name,
22810
- block: builtinSkillBlock(skill.name, skill.description)
22811
- }));
22812
- }
22813
22800
  function getCurrentAgent(messages) {
22814
22801
  for (let index = messages.length - 1;index >= 0; index -= 1) {
22815
22802
  const message = messages[index];
@@ -22842,20 +22829,9 @@ function isSkillAllowed(skillName, permissionRules) {
22842
22829
  }
22843
22830
  return permissionRules["*"] === "allow";
22844
22831
  }
22845
- function mergeWithBuiltinSkills(installedEntries) {
22846
- const builtinEntries = getBuiltinSkillEntries();
22847
- const installedNames = new Set(installedEntries.map((e) => e.name));
22848
- for (const entry of builtinEntries) {
22849
- if (!installedNames.has(entry.name)) {
22850
- installedEntries.push(entry);
22851
- }
22852
- }
22853
- return installedEntries;
22854
- }
22855
22832
  function filterAvailableSkillsText(text, permissionRules) {
22856
22833
  return text.replace(AVAILABLE_SKILLS_BLOCK_REGEX, (_fullMatch, blockContent) => {
22857
- let allEntries = extractSkillEntries(blockContent);
22858
- allEntries = mergeWithBuiltinSkills(allEntries);
22834
+ const allEntries = extractSkillEntries(blockContent);
22859
22835
  const allowedEntries = allEntries.filter((entry) => isSkillAllowed(entry.name, permissionRules));
22860
22836
  if (allowedEntries.length === 0) {
22861
22837
  return `<available_skills>
@@ -22868,22 +22844,6 @@ ${allowedEntries.map((entry) => entry.block).join(`
22868
22844
  </available_skills>`;
22869
22845
  });
22870
22846
  }
22871
- function injectBuiltinSkillsIfMissing(text, permissionRules) {
22872
- if (text.includes("<available_skills>")) {
22873
- return text;
22874
- }
22875
- const builtinEntries = getBuiltinSkillEntries();
22876
- const allowedEntries = builtinEntries.filter((entry) => isSkillAllowed(entry.name, permissionRules));
22877
- if (allowedEntries.length === 0) {
22878
- return text;
22879
- }
22880
- const block = `<available_skills>
22881
- ${allowedEntries.map((entry) => entry.block).join(`
22882
- `)}
22883
- </available_skills>`;
22884
- return `${text}
22885
- ${block}`;
22886
- }
22887
22847
  function createFilterAvailableSkillsHook(_ctx, config) {
22888
22848
  const permissionRulesByAgent = new Map;
22889
22849
  const getPermissionRules = (agentName) => {
@@ -22911,8 +22871,6 @@ function createFilterAvailableSkillsHook(_ctx, config) {
22911
22871
  }
22912
22872
  if (part.text.includes("<available_skills>")) {
22913
22873
  part.text = filterAvailableSkillsText(part.text, permissionRules);
22914
- } else {
22915
- part.text = injectBuiltinSkillsIfMissing(part.text, permissionRules);
22916
22874
  }
22917
22875
  }
22918
22876
  }
@@ -0,0 +1,51 @@
1
+ import type { ThreadManager } from '~/threads/thread-manager';
2
+ import type { LaceEvent, LaceEventType } from '~/threads/types';
3
+ /**
4
+ * Wait for a specific event type to appear in thread
5
+ *
6
+ * @param threadManager - The thread manager to query
7
+ * @param threadId - Thread to check for events
8
+ * @param eventType - Type of event to wait for
9
+ * @param timeoutMs - Maximum time to wait (default 5000ms)
10
+ * @returns Promise resolving to the first matching event
11
+ *
12
+ * Example:
13
+ * await waitForEvent(threadManager, agentThreadId, 'TOOL_RESULT');
14
+ */
15
+ export declare function waitForEvent(threadManager: ThreadManager, threadId: string, eventType: LaceEventType, timeoutMs?: number): Promise<LaceEvent>;
16
+ /**
17
+ * Wait for a specific number of events of a given type
18
+ *
19
+ * @param threadManager - The thread manager to query
20
+ * @param threadId - Thread to check for events
21
+ * @param eventType - Type of event to wait for
22
+ * @param count - Number of events to wait for
23
+ * @param timeoutMs - Maximum time to wait (default 5000ms)
24
+ * @returns Promise resolving to all matching events once count is reached
25
+ *
26
+ * Example:
27
+ * // Wait for 2 AGENT_MESSAGE events (initial response + continuation)
28
+ * await waitForEventCount(threadManager, agentThreadId, 'AGENT_MESSAGE', 2);
29
+ */
30
+ export declare function waitForEventCount(threadManager: ThreadManager, threadId: string, eventType: LaceEventType, count: number, timeoutMs?: number): Promise<LaceEvent[]>;
31
+ /**
32
+ * Wait for an event matching a custom predicate
33
+ * Useful when you need to check event data, not just type
34
+ *
35
+ * @param threadManager - The thread manager to query
36
+ * @param threadId - Thread to check for events
37
+ * @param predicate - Function that returns true when event matches
38
+ * @param description - Human-readable description for error messages
39
+ * @param timeoutMs - Maximum time to wait (default 5000ms)
40
+ * @returns Promise resolving to the first matching event
41
+ *
42
+ * Example:
43
+ * // Wait for TOOL_RESULT with specific ID
44
+ * await waitForEventMatch(
45
+ * threadManager,
46
+ * agentThreadId,
47
+ * (e) => e.type === 'TOOL_RESULT' && e.data.id === 'call_123',
48
+ * 'TOOL_RESULT with id=call_123'
49
+ * );
50
+ */
51
+ export declare function waitForEventMatch(threadManager: ThreadManager, threadId: string, predicate: (event: LaceEvent) => boolean, description: string, timeoutMs?: number): Promise<LaceEvent>;
package/package.json CHANGED
@@ -1,104 +1,104 @@
1
- {
2
- "name": "@zcy2nn/agent-forge",
3
- "version": "1.1.1",
4
- "description": "Lightweight agent orchestration plugin for OpenCode - a slimmed-down fork of oh-my-opencode",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "import": "./dist/index.js",
10
- "types": "./dist/index.d.ts"
11
- },
12
- "./tui": {
13
- "import": "./dist/tui.js",
14
- "types": "./dist/tui.d.ts"
15
- }
16
- },
17
- "bin": {
18
- "agent-forge": "./dist/cli/index.js"
19
- },
20
- "type": "module",
21
- "license": "MIT",
22
- "publishConfig": {
23
- "access": "public"
24
- },
25
- "keywords": [
26
- "opencode",
27
- "opencode-plugin",
28
- "ai",
29
- "agents",
30
- "orchestration",
31
- "llm",
32
- "claude",
33
- "gpt",
34
- "gemini"
35
- ],
36
- "repository": {
37
- "type": "git",
38
- "url": "https://cnb.cool/zcyoop/ai-assistant/agent-forge"
39
- },
40
- "bugs": {
41
- "url": "https://cnb.cool/zcyoop/ai-assistant/agent-forge/issues"
42
- },
43
- "homepage": "https://cnb.cool/zcyoop/ai-assistant/agent-forge#readme",
44
- "files": [
45
- "dist",
46
- "src/skills",
47
- "agent-forge.schema.json",
48
- "README.md",
49
- "LICENSE"
50
- ],
51
- "scripts": {
52
- "build:plugin": "bun build src/index.ts src/tui.ts --outdir dist --target node --format esm --external @ast-grep/napi --external @opencode-ai/plugin --external @opencode-ai/sdk --external @opentui/core --external @opentui/solid --external jsdom --external zod",
53
- "build:cli": "bun build src/cli/index.ts --outdir dist/cli --target node --format esm --external @ast-grep/napi --external @opencode-ai/plugin --external @opencode-ai/sdk --external jsdom --external zod",
54
- "copy:divoom-assets": "bun run scripts/copy-divoom-assets.ts",
55
- "build": "bun run build:plugin && bun run build:cli && bun run copy:divoom-assets && tsc --emitDeclarationOnly && bun run generate-schema",
56
- "prepare": "bun run build",
57
- "contributors:add": "all-contributors add",
58
- "contributors:check": "all-contributors check",
59
- "contributors:generate": "all-contributors generate",
60
- "generate-schema": "bun run scripts/generate-schema.ts",
61
- "verify:release": "bun run scripts/verify-release-artifact.ts",
62
- "verify:host-smoke": "bun run scripts/verify-opencode-host-smoke.ts",
63
- "typecheck": "tsc --noEmit",
64
- "test": "bun test",
65
- "lint": "biome lint .",
66
- "format": "biome format . --write",
67
- "check": "biome check --write .",
68
- "check:ci": "biome check .",
69
- "dev": "bun run build && opencode",
70
- "prepublishOnly": "bun run build",
71
- "release:patch": "npm version patch && git push --follow-tags && npm publish --access public",
72
- "release:minor": "npm version minor && git push --follow-tags && npm publish --access public",
73
- "release:major": "npm version major && git push --follow-tags && npm publish --access public"
74
- },
75
- "dependencies": {
76
- "@ast-grep/cli": "^0.42.1",
77
- "@modelcontextprotocol/sdk": "^1.29.0",
78
- "@mozilla/readability": "^0.6.0",
79
- "@opencode-ai/plugin": "^1.3.17",
80
- "@opencode-ai/sdk": "^1.3.17",
81
- "jsdom": "^26.1.0",
82
- "lru-cache": "^11.3.3",
83
- "turndown": "^7.2.4"
84
- },
85
- "optionalDependencies": {
86
- "@opentui/solid": "^0.1.97"
87
- },
88
- "devDependencies": {
89
- "@biomejs/biome": "2.4.11",
90
- "@types/jsdom": "^21.1.7",
91
- "@types/node": "^24.6.1",
92
- "@types/turndown": "^5.0.6",
93
- "all-contributors-cli": "^6.26.1",
94
- "bun-types": "1.3.12",
95
- "typescript": "^5.9.3",
96
- "zod": "^4.3.6"
97
- },
98
- "peerDependencies": {
99
- "zod": "^4.0.0"
100
- },
101
- "trustedDependencies": [
102
- "@ast-grep/cli"
103
- ]
104
- }
1
+ {
2
+ "name": "@zcy2nn/agent-forge",
3
+ "version": "1.1.3",
4
+ "description": "Lightweight agent orchestration plugin for OpenCode - a slimmed-down fork of oh-my-opencode",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
+ },
12
+ "./tui": {
13
+ "import": "./dist/tui.js",
14
+ "types": "./dist/tui.d.ts"
15
+ }
16
+ },
17
+ "bin": {
18
+ "agent-forge": "./dist/cli/index.js"
19
+ },
20
+ "type": "module",
21
+ "license": "MIT",
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "keywords": [
26
+ "opencode",
27
+ "opencode-plugin",
28
+ "ai",
29
+ "agents",
30
+ "orchestration",
31
+ "llm",
32
+ "claude",
33
+ "gpt",
34
+ "gemini"
35
+ ],
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://cnb.cool/zcyoop/ai-assistant/agent-forge"
39
+ },
40
+ "bugs": {
41
+ "url": "https://cnb.cool/zcyoop/ai-assistant/agent-forge/issues"
42
+ },
43
+ "homepage": "https://cnb.cool/zcyoop/ai-assistant/agent-forge#readme",
44
+ "files": [
45
+ "dist",
46
+ "src/skills",
47
+ "agent-forge.schema.json",
48
+ "README.md",
49
+ "LICENSE"
50
+ ],
51
+ "scripts": {
52
+ "build:plugin": "bun build src/index.ts src/tui.ts --outdir dist --target node --format esm --external @ast-grep/napi --external @opencode-ai/plugin --external @opencode-ai/sdk --external @opentui/core --external @opentui/solid --external jsdom --external zod",
53
+ "build:cli": "bun build src/cli/index.ts --outdir dist/cli --target node --format esm --external @ast-grep/napi --external @opencode-ai/plugin --external @opencode-ai/sdk --external jsdom --external zod",
54
+ "copy:divoom-assets": "bun run scripts/copy-divoom-assets.ts",
55
+ "build": "bun run build:plugin && bun run build:cli && bun run copy:divoom-assets && tsc --emitDeclarationOnly && bun run generate-schema",
56
+ "prepare": "bun run build",
57
+ "contributors:add": "all-contributors add",
58
+ "contributors:check": "all-contributors check",
59
+ "contributors:generate": "all-contributors generate",
60
+ "generate-schema": "bun run scripts/generate-schema.ts",
61
+ "verify:release": "bun run scripts/verify-release-artifact.ts",
62
+ "verify:host-smoke": "bun run scripts/verify-opencode-host-smoke.ts",
63
+ "typecheck": "tsc --noEmit",
64
+ "test": "bun test",
65
+ "lint": "biome lint .",
66
+ "format": "biome format . --write",
67
+ "check": "biome check --write .",
68
+ "check:ci": "biome check .",
69
+ "dev": "bun run build && opencode",
70
+ "prepublishOnly": "bun run build",
71
+ "release:patch": "npm version patch && git push --follow-tags && npm publish --access public",
72
+ "release:minor": "npm version minor && git push --follow-tags && npm publish --access public",
73
+ "release:major": "npm version major && git push --follow-tags && npm publish --access public"
74
+ },
75
+ "dependencies": {
76
+ "@ast-grep/cli": "^0.42.1",
77
+ "@modelcontextprotocol/sdk": "^1.29.0",
78
+ "@mozilla/readability": "^0.6.0",
79
+ "@opencode-ai/plugin": "^1.3.17",
80
+ "@opencode-ai/sdk": "^1.3.17",
81
+ "jsdom": "^26.1.0",
82
+ "lru-cache": "^11.3.3",
83
+ "turndown": "^7.2.4"
84
+ },
85
+ "optionalDependencies": {
86
+ "@opentui/solid": "^0.1.97"
87
+ },
88
+ "devDependencies": {
89
+ "@biomejs/biome": "2.4.11",
90
+ "@types/jsdom": "^21.1.7",
91
+ "@types/node": "^24.6.1",
92
+ "@types/turndown": "^5.0.6",
93
+ "all-contributors-cli": "^6.26.1",
94
+ "bun-types": "1.3.12",
95
+ "typescript": "^5.9.3",
96
+ "zod": "^4.3.6"
97
+ },
98
+ "peerDependencies": {
99
+ "zod": "^4.0.0"
100
+ },
101
+ "trustedDependencies": [
102
+ "@ast-grep/cli"
103
+ ]
104
+ }