@acryldev/harness-runtime 0.0.0-stage → 0.2.11
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/LICENSE +49 -0
- package/lib/index.mjs +5693 -0
- package/lib/index.mjs.map +1 -0
- package/lib/types/acryl-home.d.ts +81 -0
- package/lib/types/app/new-app.d.ts +65 -0
- package/lib/types/app/start-source.d.ts +47 -0
- package/lib/types/blueprint/blueprint.d.ts +74 -0
- package/lib/types/blueprint/brand-identity.d.ts +26 -0
- package/lib/types/blueprint/compose.d.ts +53 -0
- package/lib/types/blueprint/definition.d.ts +22 -0
- package/lib/types/blueprint/index.d.ts +7 -0
- package/lib/types/blueprint/manifest.d.ts +35 -0
- package/lib/types/blueprint/selection.d.ts +19 -0
- package/lib/types/cli-market-install.d.ts +97 -0
- package/lib/types/cli-market-plugins.d.ts +81 -0
- package/lib/types/coding-capabilities.d.ts +29 -0
- package/lib/types/durable-message.d.ts +18 -0
- package/lib/types/engine-dsh.d.ts +181 -0
- package/lib/types/engine-files.d.ts +8 -0
- package/lib/types/engine-host.d.ts +32 -0
- package/lib/types/engine-tools.d.ts +11 -0
- package/lib/types/index.d.ts +67 -0
- package/lib/types/instance/announce-self.d.ts +38 -0
- package/lib/types/instance/app-instance.d.ts +125 -0
- package/lib/types/instance/index.d.ts +6 -0
- package/lib/types/instance/offline-lock.d.ts +29 -0
- package/lib/types/instance/online-secret.d.ts +29 -0
- package/lib/types/instance/registry.d.ts +26 -0
- package/lib/types/instance/select.d.ts +43 -0
- package/lib/types/module-hooks.d.ts +19 -0
- package/lib/types/module-resolution.d.ts +31 -0
- package/lib/types/package-overlay.d.ts +41 -0
- package/lib/types/pinned-pnpm.d.ts +15 -0
- package/lib/types/plugin-acryl-workspace-status.d.ts +24 -0
- package/lib/types/plugin-doctor.d.ts +49 -0
- package/lib/types/plugin-lifecycle-state.d.ts +92 -0
- package/lib/types/plugin-lifecycle.d.ts +87 -0
- package/lib/types/profile-layout.d.ts +17 -0
- package/lib/types/profile-owner.d.ts +25 -0
- package/lib/types/profile-repair/backup.d.ts +37 -0
- package/lib/types/profile-repair/findings.d.ts +29 -0
- package/lib/types/profile-repair/index.d.ts +9 -0
- package/lib/types/profile-repair/inspector.d.ts +11 -0
- package/lib/types/profile-repair/repair.d.ts +38 -0
- package/lib/types/profile-resolution/moved-framework.d.ts +21 -0
- package/lib/types/profile-resolution/resolver.d.ts +41 -0
- package/lib/types/profile-resolution/service.d.ts +22 -0
- package/lib/types/prompt-budget.d.ts +44 -0
- package/lib/types/session-bridge.d.ts +57 -0
- package/lib/types/session-log-exporter.d.ts +31 -0
- package/lib/types/system-prompt-capture.d.ts +29 -0
- package/lib/types/web-favicon-data.d.ts +5 -0
- package/lib/types/web-favicon.d.ts +23 -0
- package/lib/types/web-market-install.d.ts +114 -0
- package/lib/types/web-market-plugins.d.ts +106 -0
- package/lib/types/web-port.d.ts +15 -0
- package/package.json +211 -3
- package/src/acryl-home.ts +103 -0
- package/src/app/new-app.ts +239 -0
- package/src/app/start-source.ts +110 -0
- package/src/blueprint/blueprint.ts +141 -0
- package/src/blueprint/brand-identity.ts +75 -0
- package/src/blueprint/compose.ts +222 -0
- package/src/blueprint/definition.ts +92 -0
- package/src/blueprint/index.ts +20 -0
- package/src/blueprint/manifest.ts +145 -0
- package/src/blueprint/selection.ts +74 -0
- package/src/cli-market-install.ts +181 -0
- package/src/cli-market-plugins.ts +176 -0
- package/src/coding-capabilities.ts +61 -0
- package/src/durable-message.ts +23 -0
- package/src/engine-dsh.ts +856 -0
- package/src/engine-files.ts +9 -0
- package/src/engine-host.ts +128 -0
- package/src/engine-tools.ts +26 -0
- package/src/index.ts +436 -0
- package/src/instance/announce-self.ts +88 -0
- package/src/instance/app-instance.ts +240 -0
- package/src/instance/index.ts +45 -0
- package/src/instance/offline-lock.ts +71 -0
- package/src/instance/online-secret.ts +55 -0
- package/src/instance/registry.ts +53 -0
- package/src/instance/select.ts +134 -0
- package/src/module-hooks.ts +41 -0
- package/src/module-resolution.ts +187 -0
- package/src/package-overlay.ts +160 -0
- package/src/pinned-pnpm.ts +67 -0
- package/src/plugin-acryl-workspace-status.ts +99 -0
- package/src/plugin-doctor.ts +141 -0
- package/src/plugin-lifecycle-state.ts +347 -0
- package/src/plugin-lifecycle.ts +223 -0
- package/src/profile-layout.ts +97 -0
- package/src/profile-owner.ts +52 -0
- package/src/profile-repair/backup.ts +119 -0
- package/src/profile-repair/findings.ts +43 -0
- package/src/profile-repair/index.ts +10 -0
- package/src/profile-repair/inspector.ts +156 -0
- package/src/profile-repair/repair.ts +137 -0
- package/src/profile-resolution/moved-framework.ts +64 -0
- package/src/profile-resolution/resolver.ts +876 -0
- package/src/profile-resolution/service.ts +99 -0
- package/src/prompt-budget.ts +118 -0
- package/src/session-bridge.ts +350 -0
- package/src/session-log-exporter.ts +68 -0
- package/src/system-prompt-capture.ts +99 -0
- package/src/web-favicon-data.ts +6 -0
- package/src/web-favicon.ts +43 -0
- package/src/web-market-install.ts +206 -0
- package/src/web-market-plugins.ts +215 -0
- package/src/web-port.ts +39 -0
- package/tests/account-callback.spec.ts +173 -0
- package/tests/acryl-home.spec.ts +39 -0
- package/tests/agent-self-hosting.spec.ts +101 -0
- package/tests/announce-self.spec.ts +84 -0
- package/tests/app-lifecycle.spec.ts +99 -0
- package/tests/blank-blueprint.spec.ts +110 -0
- package/tests/blueprint-definition.spec.ts +128 -0
- package/tests/blueprint.spec.ts +138 -0
- package/tests/bulkhead.spec.ts +187 -0
- package/tests/coding-vocabulary.spec.ts +15 -0
- package/tests/dump-system-prompt.spec.ts +65 -0
- package/tests/e2e-real-model.spec.ts +71 -0
- package/tests/e2e-restart-real-model.spec.ts +77 -0
- package/tests/engine-dsh.spec.ts +340 -0
- package/tests/engine-host-mount-root-include.spec.ts +118 -0
- package/tests/engine-host.spec.ts +176 -0
- package/tests/engine-optional.spec.ts +81 -0
- package/tests/extension-examples.spec.ts +261 -0
- package/tests/hooks-thread-stack.ts +27 -0
- package/tests/instance-patches.spec.ts +25 -0
- package/tests/instance.spec.ts +235 -0
- package/tests/live/community-plugins.spec.ts +83 -0
- package/tests/module-hooks.spec.ts +35 -0
- package/tests/module-resolution.spec.ts +265 -0
- package/tests/moved-framework.spec.ts +61 -0
- package/tests/new-app.spec.ts +132 -0
- package/tests/organizer-growth.spec.ts +117 -0
- package/tests/pinned-pnpm.spec.ts +34 -0
- package/tests/plugin-acryl-workspace-status.spec.ts +63 -0
- package/tests/plugin-context.spec.ts +640 -0
- package/tests/plugin-doctor.spec.ts +183 -0
- package/tests/plugin-enablement-one-store.spec.ts +130 -0
- package/tests/plugin-lifecycle-state.spec.ts +169 -0
- package/tests/profile-layout.spec.ts +58 -0
- package/tests/profile-owner.spec.ts +38 -0
- package/tests/profile-repair/profile-repair.spec.ts +231 -0
- package/tests/profile-resolution-port.spec.ts +30 -0
- package/tests/profile-resolution-service.spec.ts +273 -0
- package/tests/profile-resolution-swap.spec.ts +69 -0
- package/tests/profile-resolution.spec.ts +2535 -0
- package/tests/profile.spec.ts +70 -0
- package/tests/project-registry.spec.ts +81 -0
- package/tests/prompt-budget.spec.ts +58 -0
- package/tests/real-home-guard.spec.ts +178 -0
- package/tests/session-bridge.spec.ts +316 -0
- package/tests/start-source.spec.ts +65 -0
- package/tests/system-prompt-shape.spec.ts +95 -0
- package/tests/three-levels.spec.ts +84 -0
- package/tests/tool-gateway.spec.ts +116 -0
- package/tests/tool-schemas.spec.ts +41 -0
- package/tests/web-favicon.spec.ts +42 -0
- package/tests/web-port.spec.ts +38 -0
- package/tests/web-startup-hold.spec.ts +79 -0
- package/tsconfig.json +24 -0
- package/tsdown.config.ts +2 -0
- package/vitest.config.ts +18 -0
- package/README.md +0 -3
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The first use case of the framework (spec 036): start from the Blank Blueprint, grow a to-do list, calendar and meeting
|
|
3
|
+
* organizer as one local Cordis plugin with live reload, use it through the real tool runtime, capture the result as a Blend,
|
|
4
|
+
* and re-create it on a fresh app from that capture alone. No model is involved: the plugin is the one the agent would write.
|
|
5
|
+
*/
|
|
6
|
+
import { cpSync, existsSync, readFileSync } from 'node:fs'
|
|
7
|
+
import { mkdtemp, rm } from 'node:fs/promises'
|
|
8
|
+
import { tmpdir } from 'node:os'
|
|
9
|
+
import { join } from 'node:path'
|
|
10
|
+
import { provideCmdline } from '@deepseek-ai/dsh-cmdline'
|
|
11
|
+
import { SessionId } from '@deepseek-ai/dsh-session'
|
|
12
|
+
import { afterEach, describe, expect, it } from 'vitest'
|
|
13
|
+
import { createWebEngineDefinition } from '../src/engine-dsh.ts'
|
|
14
|
+
import { createAcrylEngineHost } from '../src/engine-host.ts'
|
|
15
|
+
import { createAcrylSessionBridge } from '../src/session-bridge.ts'
|
|
16
|
+
import { fileURLToPath } from 'node:url'
|
|
17
|
+
import { codingCapabilities } from '@acryldev/coding-capabilities'
|
|
18
|
+
|
|
19
|
+
const organizer = fileURLToPath(new URL('../../../examples/acryl-organizer/', import.meta.url))
|
|
20
|
+
const temporary: string[] = []
|
|
21
|
+
const saved = { home: process.env.DSH_HOME, blueprint: process.env.ACRYL_BLUEPRINT }
|
|
22
|
+
|
|
23
|
+
afterEach(async () => {
|
|
24
|
+
if (saved.home === undefined) delete process.env.DSH_HOME; else process.env.DSH_HOME = saved.home
|
|
25
|
+
if (saved.blueprint === undefined) delete process.env.ACRYL_BLUEPRINT; else process.env.ACRYL_BLUEPRINT = saved.blueprint
|
|
26
|
+
await Promise.all(temporary.splice(0).map(path => rm(path, { force: true, recursive: true })))
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
type Host = Awaited<ReturnType<typeof boot>>
|
|
30
|
+
const boot = () => createAcrylEngineHost({
|
|
31
|
+
engines: [createWebEngineDefinition(new URL('../package.json', import.meta.url).href, codingCapabilities)],
|
|
32
|
+
initialEngine: 'dsh',
|
|
33
|
+
prepare: hostCtx => { provideCmdline(hostCtx, { args: ['--no-open', '--port', '0'], exit: () => {} }) },
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
async function session(host: Host, generationId: string, cwd: string) {
|
|
37
|
+
const bridge = createAcrylSessionBridge(host.ctx, { profile: 'web', generationId, attachment: 'owner', cwd })
|
|
38
|
+
const sessionId = await bridge.open()
|
|
39
|
+
const agent = (host.ctx as unknown as { agents: { get(id: unknown): unknown } }).agents.get(SessionId(sessionId))
|
|
40
|
+
const commands = host.ctx.get('commands' as never) as unknown as {
|
|
41
|
+
execute(agent: unknown, line: string, attachments: unknown[], signal: AbortSignal): Promise<{ result: { kind: string, text?: string } } | undefined>
|
|
42
|
+
}
|
|
43
|
+
const tools = host.ctx.get('tools' as never) as unknown as {
|
|
44
|
+
execute(input: { callId: string, name: string, arguments: unknown, agent: unknown, signal: AbortSignal }): Promise<{ isError?: boolean, content?: { type: string, text?: string }[] }>
|
|
45
|
+
}
|
|
46
|
+
let call = 0
|
|
47
|
+
return {
|
|
48
|
+
bridge,
|
|
49
|
+
run: async (line: string) => (await commands.execute(agent, line, [], new AbortController().signal))?.result,
|
|
50
|
+
tool: async (name: string, args: Record<string, unknown>) => {
|
|
51
|
+
const result = await tools.execute({ callId: `organizer-${String(++call)}`, name, arguments: args, agent, signal: new AbortController().signal })
|
|
52
|
+
return { isError: result.isError === true, text: (result.content ?? []).map(block => block.text ?? '').join('') }
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function scratch(label: string): Promise<string> {
|
|
58
|
+
const path = await mkdtemp(join(tmpdir(), `acryl-organizer-${label}-`))
|
|
59
|
+
temporary.push(path)
|
|
60
|
+
return path
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
describe('grow an organizer from the Blank Blueprint', () => {
|
|
64
|
+
it('builds it live, uses it, captures it as a Blend, and re-creates it on a fresh app', async () => {
|
|
65
|
+
process.env.ACRYL_BLUEPRINT = 'acryl.blank'
|
|
66
|
+
|
|
67
|
+
// App A: blank, then the organizer, live.
|
|
68
|
+
const homeA = await scratch('home-a'); const wsA = await scratch('ws-a')
|
|
69
|
+
process.env.DSH_HOME = homeA
|
|
70
|
+
cpSync(organizer, join(wsA, '.acryl-plugins', 'acryl-organizer'), { recursive: true, filter: source => !source.includes('/tests') })
|
|
71
|
+
let host: Host = await boot()
|
|
72
|
+
let s = await session(host, 'organizer-a', wsA)
|
|
73
|
+
try {
|
|
74
|
+
const before = (await host.ctx.get('systemPrompt')!.assemble()).tools.map(tool => tool.name)
|
|
75
|
+
expect(before).not.toContain('todo_add')
|
|
76
|
+
expect((await s.run('/reload new'))?.text).toContain('installed (new)')
|
|
77
|
+
const after = (await host.ctx.get('systemPrompt')!.assemble()).tools.map(tool => tool.name)
|
|
78
|
+
expect(after).toEqual(expect.arrayContaining(['todo_add', 'todo_list', 'todo_done', 'meeting_book', 'meeting_cancel', 'calendar_agenda', 'calendar_free_slots']))
|
|
79
|
+
|
|
80
|
+
// Use it as the agent would on the user's behalf.
|
|
81
|
+
expect((await s.tool('todo_add', { title: 'Prepare the quarterly review', due: '2026-10-01' })).text).toContain('Added #1')
|
|
82
|
+
expect((await s.tool('meeting_book', { title: 'Design sync', start: '2026-10-01T14:00:00Z', minutes: 60, with: 'Sam' })).text).toContain('Booked #2')
|
|
83
|
+
const clash = await s.tool('meeting_book', { title: 'Overlap', start: '2026-10-01T14:30:00Z' })
|
|
84
|
+
expect(clash.isError).toBe(true)
|
|
85
|
+
expect(clash.text).toContain('overlaps meeting 2')
|
|
86
|
+
const agenda = (await s.tool('calendar_agenda', { day: '2026-10-01' })).text
|
|
87
|
+
expect(agenda).toContain('Design sync'); expect(agenda).toContain('Prepare the quarterly review')
|
|
88
|
+
expect((await s.tool('calendar_free_slots', { day: '2026-10-01', minutes: 60 })).text).toContain('2026-10-01T15:00:00.000Z to 2026-10-01T17:00:00.000Z')
|
|
89
|
+
expect((await s.tool('todo_done', { id: 1 })).text).toContain('Done')
|
|
90
|
+
expect((await s.tool('todo_list', {})).text).toBe('(none)')
|
|
91
|
+
// The data is a plain file in the project.
|
|
92
|
+
expect(JSON.parse(readFileSync(join(wsA, '.acryl', 'organizer.json'), 'utf8')).meetings).toHaveLength(1)
|
|
93
|
+
|
|
94
|
+
const snapshot = await s.run('/blend snapshot')
|
|
95
|
+
expect(snapshot?.kind, String(snapshot?.text)).toBe('success')
|
|
96
|
+
expect(snapshot?.text).toContain('1 local plugin(s) vendored')
|
|
97
|
+
} finally { await s.bridge.dispose(); await host.dispose() }
|
|
98
|
+
|
|
99
|
+
// App B: a different home, a different workspace, only the captured directory (and the data file, which is project data).
|
|
100
|
+
const homeB = await scratch('home-b'); const wsB = await scratch('ws-b')
|
|
101
|
+
process.env.DSH_HOME = homeB
|
|
102
|
+
cpSync(join(wsA, '.acryl', 'blend'), join(wsB, '.acryl', 'blend'), { recursive: true })
|
|
103
|
+
cpSync(join(wsA, '.acryl', 'organizer.json'), join(wsB, '.acryl', 'organizer.json'))
|
|
104
|
+
host = await boot()
|
|
105
|
+
s = await session(host, 'organizer-b', wsB)
|
|
106
|
+
try {
|
|
107
|
+
expect((await host.ctx.get('systemPrompt')!.assemble()).tools.map(tool => tool.name)).not.toContain('meeting_book')
|
|
108
|
+
const applied = await s.run('/blend apply')
|
|
109
|
+
expect(applied?.kind, String(applied?.text)).toBe('success')
|
|
110
|
+
expect(existsSync(join(wsB, '.acryl-plugins', 'acryl-organizer', 'index.js'))).toBe(true)
|
|
111
|
+
expect((await host.ctx.get('systemPrompt')!.assemble()).tools.map(tool => tool.name)).toContain('meeting_book')
|
|
112
|
+
// Restored, and it remembers what the project already held.
|
|
113
|
+
expect((await s.tool('calendar_agenda', { day: '2026-10-01' })).text).toContain('Design sync')
|
|
114
|
+
expect((await s.tool('meeting_book', { title: 'Overlap again', start: '2026-10-01T14:15:00Z' })).isError).toBe(true)
|
|
115
|
+
} finally { await s.bridge.dispose(); await host.dispose() }
|
|
116
|
+
}, 300_000)
|
|
117
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process'
|
|
2
|
+
import { mkdtemp, rm } from 'node:fs/promises'
|
|
3
|
+
import { tmpdir } from 'node:os'
|
|
4
|
+
import { delimiter, join } from 'node:path'
|
|
5
|
+
import { afterEach, describe, expect, it } from 'vitest'
|
|
6
|
+
import { pinnedPnpmEnv, resolvePinnedPnpm } from '../src/pinned-pnpm.ts'
|
|
7
|
+
|
|
8
|
+
const dirs: string[] = []
|
|
9
|
+
afterEach(async () => { await Promise.all(dirs.splice(0).map(dir => rm(dir, { force: true, recursive: true }))) })
|
|
10
|
+
|
|
11
|
+
describe('pinned pnpm for Web and CLI installs', () => {
|
|
12
|
+
it('resolves the pnpm this runtime depends on', () => {
|
|
13
|
+
const pinned = resolvePinnedPnpm()
|
|
14
|
+
expect(pinned?.version).toBe('11.11.0')
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('puts a shim for the pinned pnpm first on PATH and it runs that exact version', async () => {
|
|
18
|
+
const binDir = await mkdtemp(join(tmpdir(), 'acryl-pnpm-bin-'))
|
|
19
|
+
dirs.push(binDir)
|
|
20
|
+
const env = pinnedPnpmEnv({ PATH: '/usr/bin' }, binDir, 'linux')
|
|
21
|
+
expect(env.PATH?.split(delimiter)[0]).toBe(binDir)
|
|
22
|
+
expect(env.PATH).toContain('/usr/bin')
|
|
23
|
+
if (process.platform !== 'win32') {
|
|
24
|
+
// A synchronous spawn blocks vitest's own timeout, so a stuck pnpm would stall the whole suite (seen once on a Mac mini): bound it
|
|
25
|
+
// here. cwd is the empty shim folder so pnpm reads no repository config (packageManager, pnpm-workspace.yaml) on the way.
|
|
26
|
+
const out = execFileSync(join(binDir, 'pnpm'), ['--version'], {
|
|
27
|
+
cwd: binDir, env: { ...env, PATH: env.PATH ?? '' }, encoding: 'utf8', timeout: 20_000, killSignal: 'SIGKILL',
|
|
28
|
+
})
|
|
29
|
+
expect(out.trim()).toBe('11.11.0')
|
|
30
|
+
}
|
|
31
|
+
// Idempotent: a second call rewrites nothing and returns the same shape.
|
|
32
|
+
expect(pinnedPnpmEnv({ PATH: '/usr/bin' }, binDir, 'linux').PATH).toBe(env.PATH)
|
|
33
|
+
}, 30_000)
|
|
34
|
+
})
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { mkdtemp, rm, writeFile } from 'node:fs/promises'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import { afterEach, describe, expect, it } from 'vitest'
|
|
5
|
+
import { DEFAULT_PROFILE_BUNDLES, initProfile, resolveProfileDir } from '@deepseek-ai/dsh-app-boot'
|
|
6
|
+
import { bootAcrylHarnessProfile } from '../src/index.ts'
|
|
7
|
+
import { TOOL_NAME } from '../src/plugin-acryl-workspace-status.ts'
|
|
8
|
+
|
|
9
|
+
const temporaryHomes: string[] = []
|
|
10
|
+
const initialDshHome = process.env.DSH_HOME
|
|
11
|
+
|
|
12
|
+
async function bootRuntime(profile: string) {
|
|
13
|
+
process.env.DSH_HOME = await mkdtemp(join(tmpdir(), 'acryl-tool-'))
|
|
14
|
+
temporaryHomes.push(process.env.DSH_HOME)
|
|
15
|
+
const profileDirectory = resolveProfileDir(profile)
|
|
16
|
+
initProfile(profileDirectory, DEFAULT_PROFILE_BUNDLES)
|
|
17
|
+
await writeFile(join(profileDirectory, 'cordis.patch.yml'), '- id: hmr\n disabled: true\n')
|
|
18
|
+
return bootAcrylHarnessProfile({ profile })
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
afterEach(async () => {
|
|
22
|
+
// Assigning undefined would store the string "undefined" and the next boot would create a ./undefined profile directory.
|
|
23
|
+
if (initialDshHome === undefined) delete process.env.DSH_HOME
|
|
24
|
+
else process.env.DSH_HOME = initialDshHome
|
|
25
|
+
await Promise.all(temporaryHomes.splice(0).map(home => rm(home, { force: true, recursive: true })))
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
describe('acryl_workspace_status tool (the ACRYL Cordis Tool gate)', () => {
|
|
29
|
+
it('is auto-mounted on the booted ctx.tools, executes, and renders canonical typed output', async () => {
|
|
30
|
+
const runtime = await bootRuntime('acryl-tool-gate')
|
|
31
|
+
|
|
32
|
+
// The boot path must have registered the tool on the native ctx.tools seam.
|
|
33
|
+
const definition = runtime.ctx.tools.get(TOOL_NAME)
|
|
34
|
+
expect(definition).toBeDefined()
|
|
35
|
+
expect(definition?.name).toBe(TOOL_NAME)
|
|
36
|
+
expect(definition?.description).toContain('ACRYL workspace context')
|
|
37
|
+
expect(definition?.output?.schema).toBeDefined()
|
|
38
|
+
|
|
39
|
+
// Execute and assert the canonical value matches the declared output schema.
|
|
40
|
+
const value = await definition!.execute({}, { signal: new AbortController().signal } as never)
|
|
41
|
+
expect(value).toMatchObject({ cwd: expect.any(String) })
|
|
42
|
+
|
|
43
|
+
// Render to a model-facing text block.
|
|
44
|
+
const blocks = definition!.output.render({}, value)
|
|
45
|
+
expect(blocks[0]).toMatchObject({ type: 'text' })
|
|
46
|
+
expect((blocks[0] as { text: string }).text).toContain('ACRYL workspace context')
|
|
47
|
+
}, 60_000)
|
|
48
|
+
|
|
49
|
+
it('disposes cleanly with the owning runtime (no leak on dispose)', async () => {
|
|
50
|
+
const runtime = await bootRuntime('acryl-tool-gate')
|
|
51
|
+
expect(runtime.ctx.tools.get(TOOL_NAME)).toBeDefined()
|
|
52
|
+
// Disposing the runtime disposes the Fiber that owns the tool registration.
|
|
53
|
+
await expect(runtime.dispose()).resolves.toBeUndefined()
|
|
54
|
+
}, 60_000)
|
|
55
|
+
|
|
56
|
+
it('is a proper Cordis plugin entry (name/inject/apply)', async () => {
|
|
57
|
+
const mod = await import('../src/plugin-acryl-workspace-status.ts')
|
|
58
|
+
expect(mod.name).toBe('acryl-workspace-status')
|
|
59
|
+
expect(mod.inject).toEqual(['tools'])
|
|
60
|
+
expect(typeof mod.apply).toBe('function')
|
|
61
|
+
expect(typeof mod.installAcrylWorkspaceStatusTool).toBe('function')
|
|
62
|
+
}, 60_000)
|
|
63
|
+
})
|