Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
},
"metadata": {
"description": "Basalt — the trust layer for AI-generated work. Connect your AI to publish, update and share governed docs by URL.",
"version": "0.3.1"
"version": "0.3.2"
},
"plugins": [
{
"name": "basalt",
"source": "./plugins/basalt",
"description": "Connect your AI to Basalt — publish, update and share governed docs by URL. Bundles the Basalt MCP server (OAuth) + a skill that converges on it when you ask to publish or share written work.",
"version": "0.3.1",
"version": "0.3.2",
"author": {
"name": "Cofoundy SAC"
},
Expand Down
2 changes: 1 addition & 1 deletion plugins/basalt/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "basalt",
"description": "Connect your AI to Basalt — publish, update and share governed docs by URL. Bundles the Basalt MCP server (OAuth), a skill that converges on it when you ask to publish or share written work, and quiet session hooks (auth probe · edit tracking · publish nudge).",
"version": "0.3.1",
"version": "0.3.2",
"author": {
"name": "Cofoundy SAC",
"url": "https://cofoundy.dev"
Expand Down
18 changes: 13 additions & 5 deletions plugins/basalt/hooks/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ const strings = (value: unknown, out: string[] = []): string[] => {
return out
}

// The calls that publish: `basalt publish|move` from a shell, `publish_doc|update_doc` over MCP.
export const isPublish = (tool: string, command: unknown): boolean =>
tool === 'Bash'
? typeof command === 'string' && /(^|[\s;&|(])basalt\s+(publish|move)\b/.test(command)
: /basalt/i.test(tool) && /__(publish_doc|update_doc)$/.test(tool)

// Canonical URLs are /{workspace}/{space}/{doc…}; the workspace is always the
// same for one person, so the trail starts at the space.
export const toLink = (url: string, by: string, at: number): BasaltLink => {
Expand Down Expand Up @@ -173,10 +179,12 @@ export const register: Register = on => {
return { text: (await labels($)).opened }
})

// Every row the conversation keeps (the person's, the model's, a tool's, a subagent's) is scanned.
on('session.append', async ($, e, next) => {
const stored = await next(e)
const found = strings(e.message.content).flatMap(text => text.match(URL_RE) ?? [])
// Only what this session published: the result of a publish, never a link it merely read
// (a subagent grepping old transcripts filled the band with docs nobody made).
on('tool.call', async ($, e, next) => {
const out = await next(e)
if (!isPublish(e.tool, (e as { command?: unknown }).command) || out.deny !== undefined || out.isError) return out
const found = strings([out.text, out.result]).flatMap(text => text.match(URL_RE) ?? [])
if (found.length > 0) {
const now = await $.clock.now()
const by = e.agentId ? 'subagent' : 'session'
Expand All @@ -190,7 +198,7 @@ export const register: Register = on => {
})
}

return stored
return out
})

on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
Expand Down
49 changes: 49 additions & 0 deletions plugins/basalt/tests/links.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { describe, expect, mock, test } from 'claude-code/testing'

import { isPublish } from '../hooks/register'

const Box = 'Box' as any
const URL = 'https://app.basalt.cofoundy.ai/cofoundy/factory/intent/panel'
const BAND = { component: 'AbovePrompt', props: { hasSurvey: false, isWorking: false, maxRows: 20 } } as const

function engine(on: any) {
mock.clock(on)
mock.store(on)
mock.env(on, {})
on('session.start', ($: any, e: any) => ({ cwd: e.cwd }))
on('command.register', ($: any, e: any) => ({ value: { command: e.name } }))
on('ui.render', () => <Box key="engine" />)
on('tool.call', () => ({ result: { stdout: `ok ${URL}` }, text: `ok ${URL}` }))
}

const band = async ($: any) => {
await $.session.start({ cwd: '/w', surface: 'terminal', isInteractive: true })
const ui = await $.ui.mount({ plugin: 'basalt', surface: 'terminal', ...BAND } as any)
const shown = (await ui.find({ key: 'abrir' })) !== undefined
await ui.unmount()
return shown
}

describe('links band', () => {
test('a link the session only read is not a doc it made', async ($, on) => {
engine(on)
await $.tool.call({ tool: 'Bash', command: `grep -r basalt ~/.claude/projects` } as any)
expect(await band($)).toBe(false)
})

test('a publish puts its link in the band', async ($, on) => {
engine(on)
await $.tool.call({ tool: 'Bash', command: 'basalt publish docs/panel.md' } as any)
expect(await band($)).toBe(true)
})

test('which calls publish', () => {
expect(isPublish('Bash', 'cd vault && basalt publish a.md')).toBe(true)
expect(isPublish('Bash', 'basalt move p/a p/b')).toBe(true)
expect(isPublish('Bash', 'basalt list')).toBe(false)
expect(isPublish('Bash', 'cat basalt-publish.log')).toBe(false)
expect(isPublish('mcp__plugin_basalt_basalt__publish_doc', undefined)).toBe(true)
expect(isPublish('mcp__basalt__update_doc', undefined)).toBe(true)
expect(isPublish('mcp__basalt__get_doc', undefined)).toBe(false)
})
})
Loading