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
2 changes: 1 addition & 1 deletion CODEBASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ don't duplicate it here.
- **`permissions.ts`** — `ensureWriteAllowed`, `isMutatingMethod` (read-only-scope guard).
- **`markdown.ts`** — `preloadMarkdown` / `renderMarkdown` (cli-core renderer).
- **`usage-tracking.ts`** — `usageTracking` (cli-core's `createUsageTracking`:
the `User-Agent` / `doist-*` / `request-id` / `session-id` / `cli-command` headers on every
the `User-Agent` / `doist-*` / `request-id` / `session-id` / `cli-command` / `cli-agent` headers on every
request), `trackCommandUsage(program)` (the `preAction` hook that sets
`cli-command`; `tdc view` adds it to its routing program too), and
`withUsageHeaders(fetch)` for requests that bypass the SDK. Any new raw
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"CHANGELOG.md"
],
"dependencies": {
"@doist/cli-core": "1.9.0",
"@doist/cli-core": "1.10.0",
"@doist/comms-sdk": "3.11.0",
"@pnpm/tabtab": "0.5.4",
"chalk": "5.6.2",
Expand Down
7 changes: 7 additions & 0 deletions src/lib/search-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { DEFAULT_API_VERSION } from '@doist/comms-sdk'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import packageJson from '../../package.json' with { type: 'json' }

// `usageTracking` reads the agent once, when its module loads, so the stub runs before the
// import. Without it, `cli-agent` would depend on whichever agent (if any) runs the tests.
vi.hoisted(() => {
vi.stubEnv('AI_AGENT', 'claude-code_1.0.0_agent')
})

const authMocks = vi.hoisted(() => ({
getApiTokenSnapshot: vi.fn(),
}))
Expand Down Expand Up @@ -73,6 +79,7 @@ describe('extendedSearch', () => {
'request-id': expect.any(String),
'session-id': expect.any(String),
'cli-command': 'search',
'cli-agent': 'claude-code',
})
})
})
7 changes: 7 additions & 0 deletions src/lib/usage-tracking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import type { Command } from 'commander'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import packageJson from '../../package.json' with { type: 'json' }

// `usageTracking` reads the agent once, when its module loads, so the stub runs before the
// import. Without it, `cli-agent` would depend on whichever agent (if any) runs the tests.
vi.hoisted(() => {
vi.stubEnv('AI_AGENT', 'claude-code_1.0.0_agent')
})

type RecordedRequest = { method: string; headers: Record<string, string> }

const sdk = vi.hoisted(() => ({ requests: [] as RecordedRequest[] }))
Expand Down Expand Up @@ -105,6 +111,7 @@ describe('CLI usage headers on API requests', () => {
'request-id': expect.stringMatching(UUID),
'session-id': expect.stringMatching(UUID),
'cli-command': 'user',
'cli-agent': 'claude-code',
})
})

Expand Down
Loading