Files
HarvmasterandClaude Opus 5.5 87d3c3c3bf
ci / build (push) Canceled after 0s
Extension 0.6.0: next-edit, token healing, TS errors context, cursor-move, prewarm
- shared/nextedit.ts: next-edit prompt format (region rewrite or NO_EDIT, Qwen spare special tokens)
- shared/diagnostics.ts: TS errors near the cursor as context; symbols format 2 adds namespace imports
- shared/prompt.ts: token healing (cut the half-typed word, force it via grammar), errors header section
- daemon: model profiles carry contextFormat/errors/members/nextEdit; /v1/next-edit with edit-burst
  tracking; /v1/prewarm; /v1/debug/last; token healing on by default
- extension: next-edit decorations (Tab apply / Esc dismiss), suggest on cursor move, prewarm on focus,
  Show Last Prompt, update check against releases, diagnostics in the edit recorder
- models/README: training-data attribution; release script profiles for stage-d/stage-e
- .gitea/workflows/ci.yml: build + test, publish release on vscode-v* tags (needs a runner + RELEASE_TOKEN)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J39imRDT8L7xYbWzsVWd8A
2026-10-03 17:21:38 +00:00

64 lines
2.7 KiB
JavaScript

import test from 'node:test'
import assert from 'node:assert/strict'
import { sliceDocument, applySelectedSuggestion, repoAndPath, statusText } from '../dist/logic.js'
test('slices at the cursor', () => {
const s = sliceDocument('abc\ndef', 5, 1000, 1000)
assert.deepEqual(s, { prefix: 'abc\nd', suffix: 'ef', prefixLineOffset: 0 })
})
test('large prefixes are cut at a stable line chunk', () => {
const doc = Array.from({ length: 2000 }, (_, i) => `line ${i}`).join('\n')
const a = sliceDocument(doc, doc.length - 5, 5000, 100, 256)
const b = sliceDocument(doc, doc.length - 2, 5000, 100, 256) // typed 3 more chars
assert.equal(a.prefixLineOffset % 256, 0)
assert.equal(a.prefixLineOffset, b.prefixLineOffset)
assert.ok(a.prefix.startsWith(`line ${a.prefixLineOffset}\n`))
assert.ok(a.prefix.length <= 5000 + 20 * 256)
})
test('suffix is cut at a line boundary', () => {
const s = sliceDocument('x' + '\nabcdef'.repeat(10), 1, 1000, 15)
assert.ok(s.suffix.endsWith('\n'))
})
test('selected IntelliSense item is treated as typed', () => {
const r = applySelectedSuggestion('this.conn', 5, 9, 'connections')
assert.deepEqual(r, { text: 'this.connections', cursorOffset: 16 })
})
test('repo/path normalisation', () => {
assert.deepEqual(repoAndPath('wrapped.cash', 'src\\a\\b.ts', '/x/src/a/b.ts'), { repo: 'wrapped.cash', path: 'src/a/b.ts' })
assert.deepEqual(repoAndPath(undefined, '', '/tmp/scratch.ts'), { repo: 'untitled', path: 'scratch.ts' })
})
test('status text', () => {
assert.match(statusText({ enabled: true, mode: 'symbols', effectiveMode: 'simple', model: 'stage-c' }, 41.6), /symbols→simple · 42 ms/)
assert.match(statusText(null, null), /no daemon/)
})
import { lineBlockDiff, charDiff, insertionMakesSense, newerVersion } from '../dist/logic.js'
test('leftover paren is a one-character deletion', () => {
const d = charDiff('const v = fromString(someString))', 'const v = fromString(someString)')
assert.deepEqual(d, { start: 32, deleteEnd: 33, insert: '' })
})
test('line block diff finds the changed lines', () => {
const d = lineBlockDiff('a\nb\nc\nd\n', 'a\nB\nB2\nd\n')
assert.deepEqual(d, { oldStart: 1, oldEnd: 3, oldLines: ['b', 'c'], newLines: ['B', 'B2'] })
assert.equal(lineBlockDiff('x\n', 'x\n'), null)
})
test('cursor-move gate', () => {
assert.equal(insertionMakesSense(' ', 4, false), true)
assert.equal(insertionMakesSense(' foo()', 7, false), true)
assert.equal(insertionMakesSense(' foo()', 3, false), false)
assert.equal(insertionMakesSense(' foo()', 3, true), true)
})
test('version comparison', () => {
assert.equal(newerVersion('0.10.0', '0.9.3'), true)
assert.equal(newerVersion('0.5.0', '0.5.0'), false)
})