Skip to content
Open
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.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ Five packages under `packages/*`, split along a strict seam so that adding a new

**Call resolution favors a missing edge over a wrong one.** Order: import-resolved-to-an-indexed-file wins; else a workspace-unique name wins; else no edge is emitted and the site is recorded as unresolved. A wrong `callers` result sends the model to edit the wrong file; a missing one just falls back to text search.

**The on-disk format is an external contract, not ours to change freely.** `sqlite`/`tree-sitter` read and write schema v4 at `<projectRoot>/.codegraph/codegraph.db`, the same path/format as the `@colbymchenry/codegraph` CLI. Compatibility here is deliberate — don't add fields or change the schema without checking that CLI-built graphs still load and vice versa.
**The on-disk format is an external contract, not ours to change freely.** `tree-sitter` writes schema v4 and `sqlite` reads both v4 and v8 at `<projectRoot>/.codegraph/codegraph.db`, the same path/format as the `@colbymchenry/codegraph` CLI — the CLI ≥1.5 stamps v8, whose `nodes`/`edges`/`files`/`nodes_fts` keep every column the store reads (its reshaped `unresolved_refs`, `project_metadata`, and `name_segment_vocab` are unread by any store query). Compatibility here is deliberate — don't add fields or change the schema without checking that CLI-built graphs still load and vice versa.

**A `DefinitionRule.kind` is not always fixed per rule.** For a grammar where one node type conflates several seam kinds by an inspectable value or keyword rather than a distinct node type per kind — Zig's `variable_declaration` (struct/enum/constant/variable, by the value's shape), Kotlin's `class_declaration` (class/interface/enum, by a bare keyword), Swift's `class_declaration`/`property_declaration` (struct/class/enum; field/constant/variable) — `LANGUAGE_TABLE` carries a placeholder `kind`, and `extractFile` (`extract.ts`) computes the real one per node instead, keyed on `spec.language === '…' && node.type === '…'`. Also worth knowing before adding a new grammar: some bundled `tree-sitter-wasms` grammars bind zero fields at all (verified via `Language.fieldCount`/`fieldNameForId`, not guessed) — Kotlin is one — which forces name/callee resolution onto positional child access and a language-guarded bypass of `callFunctionField` in `extractFile`'s call-handling branch (see `kotlinDeclaredName`/`kotlinCallee`); always check `fieldCount` for a new grammar before assuming `childForFieldName` will work at all.

**Every package (except `bundle`) ships an `invariant.ts` companion**, exported at the `<pkg>/invariant` subpath. It's a Cordis plugin (`name`, `inject: ['invariants']`, `apply(ctx)`) that registers a package-owned runtime invariant with `ctx.invariants` when that optional service is present in the host. Follow the existing shape (see any `packages/*/src/invariant.ts`) when adding one for a new package: `PACKAGE_NAME` constant, an `InvariantInstaller`, `apply` returning the registration's disposer.
**No package ships an `invariant.ts` companion.** Upstream v0.1.2-rc.1 tightened the invariant rule (AGENTS.md): publish `./invariant` only when independent observations can diverge; empty installers and service-presence checks are invalid. All four packages' former companions were empty installers, so the `./invariant` subpath exports, `src/invariant.ts` files, and `@deepseek-ai/dsh-invariants` peer/dev deps were removed in the rc.1 adaptation. Don't reintroduce one without a real divergent observation.

**Tests resolve to live `src/`, never to built `lib/`.** `tsconfig.base.json`'s `paths` map (e.g. `dsh-plugin-codegraph-service` → `./packages/service/src`) is read by `vite-tsconfig-paths` in `vitest.config.ts` and takes priority over each package's `exports`. This exists so a test never accidentally loads a second copy of a module singleton through a stale `lib/` build — don't add `include`/`files` to `tsconfig.base.json`, it would narrow that match-all facade and break resolution for other packages' tests.

Expand Down
139 changes: 139 additions & 0 deletions docs/plans/2026-08-30-dsh-0.1.2-alpha2-migration.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"devDependencies": {
"@deepseek-ai/cordis-plugin-include": "^1.0.6",
"@deepseek-ai/cordis-plugin-loader": "^1.0.2",
"@deepseek-ai/dsh-agent": "0.1.0-rc.6",
"@deepseek-ai/dsh-fs-local": "0.1.0-rc.6",
"@deepseek-ai/dsh-session": "0.1.0-rc.6",
"@deepseek-ai/dsh-agent": "0.1.2-rc.1",
"@deepseek-ai/dsh-fs-local": "0.1.2-rc.1",
"@deepseek-ai/dsh-session": "0.1.2-rc.1",
"@types/node": "^22.10.0",
"@vitest/coverage-v8": "^4.1.8",
"typescript": "^5.9.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/bundle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dsh-plugin-codegraph",
"version": "0.1.6",
"version": "0.1.8",
"description": "Structural code intelligence for DeepSeek Harness — gives the agent codegraph and codegraph_index tools to find where a symbol is declared, what calls it, what a change reaches, and how one symbol reaches another, from a tree-sitter index it builds itself",
"keywords": [
"dsh",
Expand Down
14 changes: 4 additions & 10 deletions packages/service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dsh-plugin-codegraph-service",
"version": "0.1.6",
"version": "0.1.8",
"description": "Service Definition for the DeepSeek Harness code-graph capability seam (ctx.codegraph): a graph-store and graph-indexer provider registry with per-query, order-independent selection over eight normalized structural queries",
"keywords": [
"dsh",
Expand Down Expand Up @@ -31,10 +31,6 @@
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"./invariant": {
"types": "./lib/invariant.d.ts",
"default": "./lib/invariant.js"
},
"./package.json": "./package.json"
},
"files": [
Expand All @@ -48,13 +44,11 @@
"peerDependencies": {
"@deepseek-ai/cordis": ">=4.0.1",
"@deepseek-ai/dsh-brand": ">=0.1.0-rc.6",
"@deepseek-ai/dsh-invariants": ">=0.1.0-rc.6",
"@deepseek-ai/dsh-llm": ">=0.1.0-rc.6"
"@deepseek-ai/dsh-llm": ">=0.1.2-rc.1"
},
"devDependencies": {
"@deepseek-ai/cordis": "^4.0.1",
"@deepseek-ai/dsh-brand": "0.1.0-rc.6",
"@deepseek-ai/dsh-invariants": "0.1.0-rc.6",
"@deepseek-ai/dsh-llm": "0.1.0-rc.6"
"@deepseek-ai/dsh-brand": "0.1.2-rc.1",
"@deepseek-ai/dsh-llm": "0.1.2-rc.1"
}
}
30 changes: 0 additions & 30 deletions packages/service/src/invariant.ts

This file was deleted.

30 changes: 0 additions & 30 deletions packages/service/tests/invariant.spec.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/sqlite/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dsh-plugin-codegraph-sqlite

Read-only SQLite store for the code-graph seam. Serves structural queries from the schema-v4 graph at `.codegraph/codegraph.db` — the same on-disk format the `codegraph` CLI writes — opening it read-only and gating on its recorded format version.
Read-only SQLite store for the code-graph seam. Serves structural queries from the graph at `.codegraph/codegraph.db` — the same on-disk format the `codegraph` CLI writes — opening it read-only and gating on its recorded format version. Reads schema v4 (what `dsh-plugin-codegraph-tree-sitter` builds) and schema v8 (what the `codegraph` CLI ≥1.5 writes); the queries touch only the tables both versions share.

Part of **[dsh-plugin-codegraph](https://github.com/CC19990113/dsh-plugin-codegraph)** — structural code intelligence for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness).

Expand Down
14 changes: 5 additions & 9 deletions packages/sqlite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dsh-plugin-codegraph-sqlite",
"version": "0.1.6",
"version": "0.1.8",
"description": "Read-only SQLite store for the DeepSeek Harness code-graph seam — serves structural queries from the schema-v4 graph at .codegraph/codegraph.db, the same on-disk format the codegraph CLI writes",
"keywords": [
"dsh",
Expand Down Expand Up @@ -31,10 +31,6 @@
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"./invariant": {
"types": "./lib/invariant.d.ts",
"default": "./lib/invariant.js"
},
"./package.json": "./package.json"
},
"files": [
Expand All @@ -51,12 +47,12 @@
},
"peerDependencies": {
"@deepseek-ai/cordis": ">=4.0.1",
"@deepseek-ai/dsh-invariants": ">=0.1.0-rc.6",
"@deepseek-ai/dsh-llm": ">=0.1.0-rc.6"
"@deepseek-ai/dsh-llm": ">=0.1.2-rc.1",
"@deepseek-ai/dsh-util-values": ">=0.1.2-rc.1"
},
"devDependencies": {
"@deepseek-ai/cordis": "^4.0.1",
"@deepseek-ai/dsh-invariants": "0.1.0-rc.6",
"@deepseek-ai/dsh-llm": "0.1.0-rc.6"
"@deepseek-ai/dsh-llm": "0.1.2-rc.1",
"@deepseek-ai/dsh-util-values": "0.1.2-rc.1"
}
}
18 changes: 12 additions & 6 deletions packages/sqlite/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ import { CodegraphError } from 'dsh-plugin-codegraph-service'
export const DATABASE_RELATIVE_PATH = '.codegraph/codegraph.db'

/**
* The single on-disk format version this store reads. The format is an external specification, so
* support is a fixed fact rather than a deployment choice; a database at any other version fails
* loud instead of being read through assumptions that no longer hold.
* The on-disk format versions this store reads. The format is an external specification, so support
* is a fixed fact rather than a deployment choice; a database at any other version fails loud
* instead of being read through assumptions that no longer hold.
*
* Two writers share this file, one per version: `dsh-plugin-codegraph-tree-sitter` builds schema v4,
* and the `@colbymchenry/codegraph` CLI (≥1.5, whose daemon may own the same index) stamps schema
* v8 — its `nodes`/`edges`/`files`/`nodes_fts` tables keep every column the store reads and only add
* ones the store never touches (`unresolved_refs` is reshaped, `project_metadata` and
* `name_segment_vocab` are new, and no store query reads any of the three).
*/
export const SUPPORTED_FORMAT_VERSION = 4
export const SUPPORTED_FORMAT_VERSIONS: readonly number[] = [4, 8]

/**
* The absolute path of a project root's graph database.
Expand Down Expand Up @@ -108,10 +114,10 @@ export function openGraph(projectRoot: string): DatabaseSync {
db.close()
throw error
}
if (version !== SUPPORTED_FORMAT_VERSION) {
if (!SUPPORTED_FORMAT_VERSIONS.includes(version)) {
db.close()
throw new CodegraphError(
`the code graph at "${path}" is format version ${version}; this store reads version ${SUPPORTED_FORMAT_VERSION}`,
`the code graph at "${path}" is format version ${version}; this store reads version ${SUPPORTED_FORMAT_VERSIONS.join(' or ')}`,
'CODEGRAPH_UNSUPPORTED_FORMAT',
)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/sqlite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import type {
CodegraphStoreProvider,
} from 'dsh-plugin-codegraph-service'
import type {} from 'dsh-plugin-codegraph-service'
import { assertNever } from '@deepseek-ai/dsh-llm'
import { assertNever } from '@deepseek-ai/dsh-util-values'
import { GraphPool, databasePath } from './database.ts'
import { files, impact, node, relations, search, status, trace } from './queries.ts'
import { walkImpact, walkTrace } from './traverse.ts'

export {
DATABASE_RELATIVE_PATH,
GraphPool,
SUPPORTED_FORMAT_VERSION,
SUPPORTED_FORMAT_VERSIONS,
databasePath,
openGraph,
} from './database.ts'
Expand Down
31 changes: 0 additions & 31 deletions packages/sqlite/src/invariant.ts

This file was deleted.

6 changes: 4 additions & 2 deletions packages/sqlite/src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import type {
CodegraphTraceRequest,
CodegraphTraceResult,
} from 'dsh-plugin-codegraph-service'
import { SUPPORTED_FORMAT_VERSION } from './database.ts'
import type { ImpactWalk, TraceWalk } from './traverse.ts'
import { toEdge, toFile, toNode } from './rows.ts'
import type { NodeRow } from './rows.ts'
Expand Down Expand Up @@ -379,7 +378,10 @@ export function status(db: DatabaseSync, projectRoot: string, maxStalenessChecks
nodeCount: scalar(db, 'SELECT count(*) AS c FROM nodes'),
edgeCount: scalar(db, 'SELECT count(*) AS c FROM edges'),
languages,
formatVersion: SUPPORTED_FORMAT_VERSION,
// The version actually recorded on disk, not the store's support ceiling: two writers stamp
// different supported versions (tree-sitter writes v4, the CLI writes v8), so echoing the
// database's own row is the honest answer.
formatVersion: scalar(db, 'SELECT MAX(version) AS version FROM schema_versions'),
indexedAt: indexedAt === 0 ? null : indexedAt,
staleFileCount,
staleFileCountTruncated,
Expand Down
30 changes: 0 additions & 30 deletions packages/sqlite/tests/invariant.spec.ts

This file was deleted.

14 changes: 14 additions & 0 deletions packages/sqlite/tests/store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ describe('graph database', () => {
)
})

it('serves a schema-v8 database the codegraph CLI wrote', async () => {
// The CLI (≥1.5) stamps v8: same nodes/edges/files/fts shape the store reads, plus columns and
// tables (unresolved_refs reshaped, project_metadata, name_segment_vocab) no store query touches.
// The fixture's stand-in keeps the shared tables and stamps v8, which is exactly the surface the
// store's SQL reaches.
const root = await project({ ...SEED, formatVersion: 8 })
const db = openGraph(root)
const summary = status(db, root, 100)
expect(summary.formatVersion).toBe(8)
expect(search(db, { operation: 'search', ...AT(root), query: 'helper', limit: 5 }).nodes.length)
.toBeGreaterThan(0)
db.close()
})

it('refuses a graph that records no version at all', async () => {
const root = await project({})
const db = new DatabaseSync(databasePath(root))
Expand Down
28 changes: 12 additions & 16 deletions packages/tool/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dsh-plugin-codegraph-tool",
"version": "0.1.6",
"version": "0.1.8",
"description": "Model-facing codegraph tools for DeepSeek Harness — a read-only codegraph tool with ten structural query operations plus a codegraph_index tool that builds or refreshes the index on its own timeout budget",
"keywords": [
"dsh",
Expand Down Expand Up @@ -33,10 +33,6 @@
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"./invariant": {
"types": "./lib/invariant.d.ts",
"default": "./lib/invariant.js"
},
"./package.json": "./package.json"
},
"files": [
Expand All @@ -53,21 +49,21 @@
},
"peerDependencies": {
"@deepseek-ai/cordis": ">=4.0.1",
"@deepseek-ai/dsh-fs": ">=0.1.0-rc.6",
"@deepseek-ai/dsh-invariants": ">=0.1.0-rc.6",
"@deepseek-ai/dsh-llm": ">=0.1.0-rc.6",
"@deepseek-ai/dsh-system-prompt": ">=0.1.0-rc.6",
"@deepseek-ai/dsh-fs": ">=0.1.2-rc.1",
"@deepseek-ai/dsh-llm": ">=0.1.2-rc.1",
"@deepseek-ai/dsh-system-prompt": ">=0.1.2-rc.1",
"@deepseek-ai/dsh-timeout": ">=0.1.0-rc.6",
"@deepseek-ai/dsh-tools": ">=0.1.0-rc.6"
"@deepseek-ai/dsh-tools": ">=0.1.2-rc.1",
"@deepseek-ai/dsh-util-values": ">=0.1.2-rc.1"
},
"devDependencies": {
"@deepseek-ai/cordis": "^4.0.1",
"@deepseek-ai/dsh-fs": "0.1.0-rc.6",
"@deepseek-ai/dsh-invariants": "0.1.0-rc.6",
"@deepseek-ai/dsh-llm": "0.1.0-rc.6",
"@deepseek-ai/dsh-system-prompt": "0.1.0-rc.6",
"@deepseek-ai/dsh-timeout": "0.1.0-rc.6",
"@deepseek-ai/dsh-tools": "0.1.0-rc.6",
"@deepseek-ai/dsh-fs": "0.1.2-rc.1",
"@deepseek-ai/dsh-llm": "0.1.2-rc.1",
"@deepseek-ai/dsh-system-prompt": "0.1.2-rc.1",
"@deepseek-ai/dsh-timeout": "0.1.2-rc.1",
"@deepseek-ai/dsh-tools": "0.1.2-rc.1",
"@deepseek-ai/dsh-util-values": "0.1.2-rc.1",
"dsh-plugin-codegraph-sqlite": "workspace:^",
"dsh-plugin-codegraph-tree-sitter": "workspace:^"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/tool/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { CodegraphError } from 'dsh-plugin-codegraph-service'
import type { CodegraphNode, CodegraphRelation } from 'dsh-plugin-codegraph-service'
import type {} from '@deepseek-ai/dsh-fs'
import type {} from '@deepseek-ai/dsh-system-prompt'
import { assertNever } from '@deepseek-ai/dsh-llm'
import { assertNever } from '@deepseek-ai/dsh-util-values'
import { MAX_TIMER_DELAY_MS } from '@deepseek-ai/dsh-timeout'
import { declarationsOnly, groupByFile, mergeByHits, mergeRelations, taskTerms } from './compose.ts'
import type { FileGroup } from './compose.ts'
Expand Down
Loading