Skip to content

Commit 73a0d35

Browse files
committed
sdk: Include agent config types via build step. Simplify publish script by publishing from sdk directory
1 parent 940f3f6 commit 73a0d35

File tree

7 files changed

+29
-61
lines changed

7 files changed

+29
-61
lines changed

sdk/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
All notable changes to the @codebuff/sdk package will be documented in this file.
44

5-
## [0.0.1] - 2025-01-05
5+
## [0.1.5] - 2025-08-09
6+
7+
### Added
8+
- Complete `CodebuffClient`
9+
- Better docs
10+
- New `run()` api
11+
12+
## [0.0.1] - 2025-08-05
613

714
### Added
815
- Initial release of the Codebuff SDK

sdk/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@
22
"name": "@codebuff/sdk",
33
"private": false,
44
"access": "public",
5-
"version": "0.1.5",
5+
"version": "0.1.6",
66
"description": "Official SDK for Codebuff — AI coding agent & framework",
77
"license": "MIT",
88
"type": "module",
9-
"main": "./dist/index.js",
10-
"types": "./dist/index.d.ts",
9+
"main": "./dist/sdk/src/index.js",
10+
"types": "./dist/sdk/src/index.d.ts",
1111
"exports": {
1212
".": {
13-
"types": "./dist/index.d.ts",
14-
"import": "./dist/index.js",
15-
"default": "./dist/index.js"
13+
"types": "./dist/sdk/src/index.d.ts",
14+
"import": "./dist/sdk/src/index.js",
15+
"default": "./dist/sdk/src/index.js"
1616
}
1717
},
1818
"files": [
1919
"dist",
20-
"README.md"
20+
"README.md",
21+
"CHANGELOG.md"
2122
],
2223
"scripts": {
2324
"build": "bun run copy-types && tsc",
24-
"copy-types": "mkdir -p src/util/types && cp ../common/src/util/types/agent-config.d.ts src/util/types/agent-config.ts && cp ../common/src/util/types/tools.d.ts src/util/types/tools.ts",
25+
"copy-types": "mkdir -p src/types && cp ../common/src/util/types/agent-config.d.ts src/types/agent-config.ts && cp ../common/src/util/types/tools.d.ts src/types/tools.ts",
2526
"clean": "rm -rf dist",
2627
"prepare-dist": "node scripts/publish.js --dry-run",
2728
"publish-sdk": "node scripts/publish.js --public",

sdk/scripts/publish.js

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -25,74 +25,34 @@ function run(command, options = {}) {
2525
function main() {
2626
const args = process.argv.slice(2)
2727
const isDryRun = args.includes('--dry-run')
28-
28+
2929
log('Starting SDK publishing process...')
30-
30+
3131
// Clean and build
3232
log('Cleaning previous build...')
3333
run('bun run clean')
34-
34+
3535
log('Building TypeScript...')
3636
run('bun run build')
37-
38-
// Prepare package.json for publishing
39-
log('Preparing package.json for publishing...')
40-
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'))
41-
42-
// No workspace dependencies to handle anymore
43-
44-
// Update paths for publishing from dist directory
45-
packageJson.main = './sdk/src/index.js'
46-
packageJson.types = './sdk/src/index.d.ts'
47-
packageJson.exports = {
48-
'.': {
49-
types: './sdk/src/index.d.ts',
50-
import: './sdk/src/index.js',
51-
default: './sdk/src/index.js'
52-
}
53-
}
54-
55-
// Update files field to include all built files
56-
packageJson.files = [
57-
'sdk/',
58-
'common/',
59-
'README.md',
60-
'CHANGELOG.md'
61-
]
62-
63-
// Write the modified package.json to dist
64-
fs.writeFileSync('dist/package.json', JSON.stringify(packageJson, null, 2))
65-
66-
// Copy other files
67-
log('Copying additional files...')
68-
const filesToCopy = ['README.md', 'CHANGELOG.md']
69-
70-
for (const file of filesToCopy) {
71-
if (fs.existsSync(file)) {
72-
fs.copyFileSync(file, `dist/${file}`)
73-
log(`Copied ${file}`)
74-
}
75-
}
76-
37+
7738
// Verify the package
7839
log('Verifying package contents...')
79-
run('npm pack --dry-run', { cwd: 'dist' })
80-
40+
run('npm pack --dry-run')
41+
8142
if (isDryRun) {
8243
log('Dry run complete! Package is ready for publishing.')
8344
log('To publish for real, run: bun run publish-sdk')
8445
return
8546
}
86-
47+
8748
// Publish
8849
log('Publishing to npm...')
89-
const publishCommand = 'npm publish'
90-
run(publishCommand, { cwd: 'dist' })
50+
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'))
51+
run('npm publish')
9152
log('✅ SDK published successfully!')
9253
log(`📦 Package: ${packageJson.name}@${packageJson.version}`)
9354
}
94-
55+
9556
if (import.meta.url === `file://${process.argv[1]}`) {
9657
main()
9758
}
98-

sdk/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { getInitialSessionState } from '../../common/src/types/session-state'
1414

1515
import type { PrintModeEvent } from '../../common/src/types/print-mode'
1616
import type { SessionState } from '../../common/src/types/session-state'
17-
import type { AgentConfig } from './util/types/agent-config'
17+
import type { AgentConfig } from './types/agent-config'
1818

1919
type ClientToolName = 'write_file' | 'run_terminal_command'
2020

sdk/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export { CodebuffClient } from './client'
22
export { WebSocketHandler } from './websocket-client'
33
export { getInitialSessionState } from '../../common/src/types/session-state'
4-
export type { AgentConfig } from './util/types/agent-config'
4+
export type { AgentConfig } from './types/agent-config'

0 commit comments

Comments
 (0)