kiokuko-dsh 0.2.45 → 0.2.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/akinator/domain.d.ts +1 -0
  2. package/dist/akinator/domain.d.ts.map +1 -1
  3. package/dist/akinator/domain.js +18 -1
  4. package/dist/akinator/domain.js.map +1 -1
  5. package/dist/build-info.json +4 -4
  6. package/dist/client.cjs +268 -0
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/context/replay-model-memory.d.ts +5 -1
  9. package/dist/context/replay-model-memory.d.ts.map +1 -1
  10. package/dist/context/replay-model-memory.js +6 -3
  11. package/dist/context/replay-model-memory.js.map +1 -1
  12. package/dist/dsh/answer-context.d.ts.map +1 -1
  13. package/dist/dsh/answer-context.js +4 -1
  14. package/dist/dsh/answer-context.js.map +1 -1
  15. package/dist/dsh/core/host.d.ts.map +1 -1
  16. package/dist/dsh/core/host.js +5 -1
  17. package/dist/dsh/core/host.js.map +1 -1
  18. package/dist/dsh/decisions/akinator-classification.d.ts +12 -0
  19. package/dist/dsh/decisions/akinator-classification.d.ts.map +1 -1
  20. package/dist/dsh/decisions/akinator-classification.js +48 -0
  21. package/dist/dsh/decisions/akinator-classification.js.map +1 -1
  22. package/dist/dsh/decisions/workflows.d.ts +1 -1
  23. package/dist/dsh/decisions/workflows.d.ts.map +1 -1
  24. package/dist/dsh/decisions/workflows.js +1 -1
  25. package/dist/dsh/decisions/workflows.js.map +1 -1
  26. package/dist/dsh/harness/factory.d.ts.map +1 -1
  27. package/dist/dsh/harness/factory.js +22 -5
  28. package/dist/dsh/harness/factory.js.map +1 -1
  29. package/dist/dsh/host-adapter/admission.d.ts.map +1 -1
  30. package/dist/dsh/host-adapter/admission.js +0 -30
  31. package/dist/dsh/host-adapter/admission.js.map +1 -1
  32. package/dist/dsh/host-adapter/context.d.ts.map +1 -1
  33. package/dist/dsh/host-adapter/context.js +4 -7
  34. package/dist/dsh/host-adapter/context.js.map +1 -1
  35. package/dist/dsh/host-adapter/routing.d.ts.map +1 -1
  36. package/dist/dsh/host-adapter/routing.js +2 -0
  37. package/dist/dsh/host-adapter/routing.js.map +1 -1
  38. package/dist/dsh/host-adapter.d.ts.map +1 -1
  39. package/dist/dsh/host-adapter.js +3 -1
  40. package/dist/dsh/host-adapter.js.map +1 -1
  41. package/dist/dsh/lifecycle-memory.d.ts.map +1 -1
  42. package/dist/dsh/lifecycle-memory.js +7 -2
  43. package/dist/dsh/lifecycle-memory.js.map +1 -1
  44. package/dist/dsh/lisp/coding-preparation.d.ts +1 -1
  45. package/dist/dsh/lisp/coding-preparation.d.ts.map +1 -1
  46. package/dist/dsh/lisp/coding-preparation.js +1 -1
  47. package/dist/dsh/lisp/coding-preparation.js.map +1 -1
  48. package/dist/dsh/lisp/manager.d.ts.map +1 -1
  49. package/dist/dsh/lisp/manager.js +2 -1
  50. package/dist/dsh/lisp/manager.js.map +1 -1
  51. package/dist/dsh/lisp/model-result.d.ts.map +1 -1
  52. package/dist/dsh/lisp/model-result.js +12 -2
  53. package/dist/dsh/lisp/model-result.js.map +1 -1
  54. package/dist/dsh/lisp/surface.d.ts.map +1 -1
  55. package/dist/dsh/lisp/surface.js +4 -3
  56. package/dist/dsh/lisp/surface.js.map +1 -1
  57. package/dist/dsh/lisp/test-report.d.ts +40 -0
  58. package/dist/dsh/lisp/test-report.d.ts.map +1 -0
  59. package/dist/dsh/lisp/test-report.js +163 -0
  60. package/dist/dsh/lisp/test-report.js.map +1 -0
  61. package/dist/dsh/lisp/worker.d.ts.map +1 -1
  62. package/dist/dsh/lisp/worker.js +38 -34
  63. package/dist/dsh/lisp/worker.js.map +1 -1
  64. package/dist/dsh/memory-sidebar.d.ts +63 -0
  65. package/dist/dsh/memory-sidebar.d.ts.map +1 -0
  66. package/dist/dsh/memory-sidebar.js +221 -0
  67. package/dist/dsh/memory-sidebar.js.map +1 -0
  68. package/dist/dsh/model-selection-ui.d.ts +7 -12
  69. package/dist/dsh/model-selection-ui.d.ts.map +1 -1
  70. package/dist/dsh/model-selection-ui.js +12 -137
  71. package/dist/dsh/model-selection-ui.js.map +1 -1
  72. package/dist/dsh/models/metadata.d.ts +2 -0
  73. package/dist/dsh/models/metadata.d.ts.map +1 -1
  74. package/dist/dsh/models/metadata.js +11 -5
  75. package/dist/dsh/models/metadata.js.map +1 -1
  76. package/dist/dsh/models/session-selection.d.ts.map +1 -1
  77. package/dist/dsh/models/session-selection.js +4 -3
  78. package/dist/dsh/models/session-selection.js.map +1 -1
  79. package/dist/dsh/models/surface.d.ts.map +1 -1
  80. package/dist/dsh/models/surface.js +6 -4
  81. package/dist/dsh/models/surface.js.map +1 -1
  82. package/dist/dsh/on-demand-intake.d.ts +7 -0
  83. package/dist/dsh/on-demand-intake.d.ts.map +1 -1
  84. package/dist/dsh/on-demand-intake.js +20 -3
  85. package/dist/dsh/on-demand-intake.js.map +1 -1
  86. package/dist/dsh/task-completion-host.d.ts.map +1 -1
  87. package/dist/dsh/task-completion-host.js +33 -6
  88. package/dist/dsh/task-completion-host.js.map +1 -1
  89. package/dist/dsh/task-completion.d.ts +22 -0
  90. package/dist/dsh/task-completion.d.ts.map +1 -1
  91. package/dist/dsh/task-completion.js +54 -4
  92. package/dist/dsh/task-completion.js.map +1 -1
  93. package/dist/dsh/tool-exposure-diagnostics.d.ts.map +1 -1
  94. package/dist/dsh/tool-exposure-diagnostics.js +12 -1
  95. package/dist/dsh/tool-exposure-diagnostics.js.map +1 -1
  96. package/dist/locale/en.json +1 -1
  97. package/dist/locale/ja.json +1 -1
  98. package/dist/locale/ko.json +1 -1
  99. package/dist/locale/zh-CN.json +1 -1
  100. package/docs/lisp.md +33 -14
  101. package/docs/memory-evidence.md +4 -0
  102. package/docs/model-selection.md +12 -16
  103. package/lisp/supervisor.mjs +8 -19
  104. package/lisp/tools.lisp +38 -3
  105. package/package.json +1 -1
  106. package/lisp/repository-owner.d.mts +0 -1
  107. package/lisp/repository-owner.mjs +0 -58
package/lisp/tools.lisp CHANGED
@@ -3,6 +3,7 @@
3
3
  (defpackage :kioku.files (:use :cl) (:export :input :read-text :write-text :propose-write :propose-delete :scratch :search-text :diff-text :list-directory :head-lines :tail-lines :count-lines :glob-scratch :copy-scratch :delete-scratch :grep-scratch))
4
4
  (defpackage :kioku.objects (:use :cl) (:export :retain :inspect-ref :release :register-artifact))
5
5
  (defpackage :kioku.process (:use :cl) (:export :run :python :shell :start-job :job-status :cancel-job :result-code :result-stdout :result-stderr :result-ok? :split-lines :python-stdout :shell-stdout :run-lines :list-jobs :forget-job))
6
+ (defpackage :kioku.test (:use :cl) (:export :node :vitest))
6
7
  (defpackage :kioku.environment (:use :cl) (:export :status))
7
8
  (defpackage :kioku.ci (:use :cl) (:export :list-runs :failed-log :verify))
8
9
  (defpackage :kioku.packages (:use :cl) (:export :metadata :audit :update-lockfiles))
@@ -223,6 +224,40 @@
223
224
  id))
224
225
  (defun job-status (id) (kioku.internal:rpc "job-status" (kioku.internal:object "id" id)))
225
226
  (defun cancel-job (id) (kioku.internal:rpc "cancel-job" (kioku.internal:object "id" id)))
227
+ (in-package :kioku.test)
228
+ (defun test-files (files)
229
+ (let ((paths (if (stringp files) (list files) files)))
230
+ (unless (and (listp paths) paths
231
+ (let ((count (list-length paths))) (and count (<= count 100)))
232
+ (every (lambda (path)
233
+ (and (stringp path) (<= 1 (length path) 4096)
234
+ (char/= (char path 0) #\-)
235
+ (not (find (code-char 0) path))))
236
+ paths))
237
+ (error "TEST_FILES_INVALID: supply one path or a list of up to 100 paths."))
238
+ paths))
239
+ (defun run-tests (runner program arguments files name-pattern directory timeout-ms)
240
+ (unless (or (null name-pattern) (and (stringp name-pattern) (<= 1 (length name-pattern) 4096)
241
+ (not (find (code-char 0) name-pattern))))
242
+ (error "TEST_PATTERN_INVALID: supply a nonempty regular expression string."))
243
+ (kioku.internal:rpc "run"
244
+ (kioku.internal:object "program" program "testRunner" runner "directory" directory "timeoutMs" timeout-ms
245
+ "argv" (coerce (append arguments
246
+ (when name-pattern
247
+ (list (concatenate 'string (if (equal runner "node") "--test-name-pattern=" "--testNamePattern=") name-pattern)))
248
+ (test-files files)) 'vector))))
249
+ (defun node (files &key (directory ".") (timeout-ms 120000) tsx name-pattern isolation)
250
+ "Run selected Node tests with TAP. FILES is a path or list. TSX loads the project's tsx. ISOLATION :NONE supports protected scratch. Inspect testStatus, summary, failures and code."
251
+ (run-tests "node" "node"
252
+ (append (when tsx '("--import" "tsx")) '("--test" "--test-reporter=tap")
253
+ (ecase isolation ((nil) nil) (:none '("--experimental-test-isolation=none"))))
254
+ files name-pattern directory timeout-ms))
255
+ (defun vitest (files &key (directory ".") (timeout-ms 120000) config-loader name-pattern)
256
+ "Run selected tests with the project's installed Vitest and its JSON reporter. CONFIG-LOADER accepts :NATIVE, :RUNNER or :BUNDLE. Inspect testStatus, summary, failures and code."
257
+ (run-tests "vitest" "./node_modules/.bin/vitest"
258
+ (append '("run" "--reporter=json" "--includeTaskLocation")
259
+ (when config-loader (list "--configLoader" (ecase config-loader (:native "native") (:runner "runner") (:bundle "bundle")))))
260
+ files name-pattern directory timeout-ms))
226
261
  (in-package :kioku.ci)
227
262
  (defun list-runs (&key (limit 10))
228
263
  "List recent GitHub Actions runs for the bound workspace repository."
@@ -329,7 +364,7 @@ CHOICES contains 1-8 (restart-name description) pairs. No expression replay or a
329
364
  (kioku.internal:rpc "tool-call" (kioku.internal:object "name" name "args" arguments)))
330
365
  (defun describe-tools ()
331
366
  (mapcar (lambda (package) (cons package (sort (loop for symbol being the external-symbols of (find-package package) collect (symbol-name symbol)) #'string<)))
332
- '("KIOKU.TOOLS" "KIOKU.PROCESS" "KIOKU.FILES" "KIOKU.DATA" "KIOKU.OBJECTS" "KIOKU.ENVIRONMENT" "KIOKU.CI" "KIOKU.PACKAGES" "KIOKU.TYPESAFE" "KIOKU.DECISIONS" "KIOKU.RECOVERY")))
367
+ '("KIOKU.TOOLS" "KIOKU.PROCESS" "KIOKU.TEST" "KIOKU.FILES" "KIOKU.DATA" "KIOKU.OBJECTS" "KIOKU.ENVIRONMENT" "KIOKU.CI" "KIOKU.PACKAGES" "KIOKU.TYPESAFE" "KIOKU.DECISIONS" "KIOKU.RECOVERY")))
333
368
  (defun task-functions ()
334
369
  "List functions and macros defined in this worker's KIOKU.USER package."
335
370
  (let ((package (find-package :kioku.user)))
@@ -343,7 +378,7 @@ CHOICES contains 1-8 (restart-name description) pairs. No expression replay or a
343
378
  (kioku.internal:object "package" "kioku.user" "generation" kioku.internal:*generation*
344
379
  "symbols" (coerce (task-functions) 'vector))))
345
380
  (let ((package (find-package (string-upcase name))))
346
- (when (and package (member (package-name package) '("KIOKU.TOOLS" "KIOKU.PROCESS" "KIOKU.FILES" "KIOKU.DATA" "KIOKU.OBJECTS" "KIOKU.ENVIRONMENT" "KIOKU.CI" "KIOKU.PACKAGES" "KIOKU.TYPESAFE" "KIOKU.DECISIONS" "KIOKU.RECOVERY" "KIOKU.CODE") :test #'equal))
381
+ (when (and package (member (package-name package) '("KIOKU.TOOLS" "KIOKU.PROCESS" "KIOKU.TEST" "KIOKU.FILES" "KIOKU.DATA" "KIOKU.OBJECTS" "KIOKU.ENVIRONMENT" "KIOKU.CI" "KIOKU.PACKAGES" "KIOKU.TYPESAFE" "KIOKU.DECISIONS" "KIOKU.RECOVERY" "KIOKU.CODE") :test #'equal))
347
382
  (return-from describe-symbol
348
383
  (kioku.internal:object "package" (string-downcase (package-name package))
349
384
  "symbols" (coerce (sort (loop for symbol being the external-symbols of package
@@ -353,7 +388,7 @@ CHOICES contains 1-8 (restart-name description) pairs. No expression replay or a
353
388
  (multiple-value-bind (symbol end) (read-from-string name)
354
389
  (unless (and (symbolp symbol) (symbol-package symbol) (fboundp symbol)
355
390
  (zerop (length (string-trim '(#\Space #\Tab #\Newline #\Return) (subseq name end))))
356
- (member (package-name (symbol-package symbol)) '("KIOKU.USER" "KIOKU.TOOLS" "KIOKU.PROCESS" "KIOKU.FILES" "KIOKU.DATA" "KIOKU.OBJECTS" "KIOKU.ENVIRONMENT" "KIOKU.CI" "KIOKU.PACKAGES" "KIOKU.TYPESAFE" "KIOKU.DECISIONS" "KIOKU.RECOVERY" "KIOKU.CODE") :test #'equal))
391
+ (member (package-name (symbol-package symbol)) '("KIOKU.USER" "KIOKU.TOOLS" "KIOKU.PROCESS" "KIOKU.TEST" "KIOKU.FILES" "KIOKU.DATA" "KIOKU.OBJECTS" "KIOKU.ENVIRONMENT" "KIOKU.CI" "KIOKU.PACKAGES" "KIOKU.TYPESAFE" "KIOKU.DECISIONS" "KIOKU.RECOVERY" "KIOKU.CODE") :test #'equal))
357
392
  (error "UNKNOWN_SYMBOL"))
358
393
  (kioku.internal:object "symbol" name "arguments" (kioku.internal::printed (sb-introspect:function-lambda-list symbol)) "documentation" (or (documentation symbol 'function) "No function documentation."))))))
359
394
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kiokuko-dsh",
3
- "version": "0.2.45",
3
+ "version": "0.2.47",
4
4
  "description": "Kiokuko plugin for DeepSeek Harness",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- export function claimRepository(root: string): { recordRuntime(pid: number): string | null; close(): void }
@@ -1,58 +0,0 @@
1
- // The existing supervisor holds this OS-backed SQLite lock until its runtime exits.
2
- // The user directory is independent of DSH's DB, session and worker TMPDIR.
3
- import { DatabaseSync } from 'node:sqlite'
4
- import { createHash } from 'node:crypto'
5
- import { lstatSync, mkdirSync, realpathSync, readFileSync, writeFileSync, renameSync, unlinkSync } from 'node:fs'
6
- import { randomUUID } from 'node:crypto'
7
- import { processIdentity, sameProcess } from './process-identity.mjs'
8
- import { tmpdir } from 'node:os'
9
- import { join } from 'node:path'
10
-
11
- export function claimRepository(root) {
12
- const canonical = realpathSync(root)
13
- const directory = join(process.platform === 'win32' ? tmpdir() : '/tmp', `kiokuko-lisp-owners-${process.getuid?.() ?? 'user'}`)
14
- mkdirSync(directory, { recursive: true, mode: 0o700 })
15
- const info = lstatSync(directory)
16
- if (!info.isDirectory() || info.isSymbolicLink() || (process.getuid && info.uid !== process.getuid()) || (info.mode & 0o077))
17
- throw new Error('REPOSITORY_LOCK_DIRECTORY')
18
- const path = join(directory, `${createHash('sha256').update(canonical).digest('hex')}.sqlite3`)
19
- try { const file=lstatSync(path);if (!file.isFile() || file.isSymbolicLink()) throw new Error('REPOSITORY_LOCK_FILE') }
20
- catch(error) { if(error.code !== 'ENOENT') throw error }
21
- const db = new DatabaseSync(path)
22
- const metadata=path+'.owner.json',token=randomUUID()
23
- try {
24
- // Opening a new SQLite file briefly takes reader locks in *both* contenders.
25
- // A zero busy timeout can make both exclusive acquisitions fail before
26
- // either owns the repository. Allow those short initialization reads to
27
- // drain; an existing owner's lifetime transaction still rejects in 250ms.
28
- db.exec('PRAGMA busy_timeout=250; BEGIN EXCLUSIVE; CREATE TABLE IF NOT EXISTS repository_owner(root TEXT NOT NULL)')
29
- try {
30
- const owner=JSON.parse(readFileSync(metadata,'utf8'))
31
- if(!Number.isSafeInteger(owner.pid)||owner.pid<1||owner.root!==canonical||typeof owner.token!=='string'
32
- ||owner.identity!==null&&!/^[a-f0-9]{64}$/.test(owner.identity))throw new Error('REPOSITORY_LOCK_METADATA')
33
- // A supervisor killed before cleanup must not donate its still-live runtime.
34
- if(sameProcess(owner.pid,owner.identity??undefined))throw new Error('REPOSITORY_IN_USE')
35
- } catch(error) { if(error.code!=='ENOENT')throw error }
36
- db.prepare('DELETE FROM repository_owner').run()
37
- db.prepare('INSERT INTO repository_owner VALUES(?)').run(canonical)
38
- let recorded=false
39
- return {
40
- recordRuntime(pid){
41
- const temporary=metadata+'.'+token
42
- const identity=processIdentity(pid)??null
43
- writeFileSync(temporary,JSON.stringify({root:canonical,pid,identity,token})+'\n',{flag:'wx',mode:0o600})
44
- renameSync(temporary,metadata);recorded=true
45
- return identity
46
- },
47
- close(){
48
- // Called only after runtime exit. A crash leaves evidence for the next owner.
49
- if(recorded){const owner=JSON.parse(readFileSync(metadata,'utf8'));if(owner.token===token)unlinkSync(metadata)}
50
- db.close()
51
- },
52
- } // Transaction stays uncommitted; the OS releases it when this supervisor dies.
53
- } catch(error) {
54
- db.close()
55
- if(error.errcode === 5 || error.code === 'SQLITE_BUSY') throw new Error('REPOSITORY_IN_USE')
56
- throw error
57
- }
58
- }