kiokuko-dsh 0.2.36 → 0.2.37

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.
package/dist/dsh/setup.js CHANGED
@@ -3,7 +3,7 @@ import path from 'node:path';
3
3
  import { readRegularFile } from '../config/read-regular-file.js';
4
4
  import { KiokukoError } from '../errors.js';
5
5
  import { deploymentParent, publishFile } from './managed-file-deployment.js';
6
- import { planStandardSkills } from './standard-skill-deployment.js';
6
+ import { planStandardSkills, retireStandardSkills } from './standard-skill-deployment.js';
7
7
  import { SOUL_ROUTING_ENTRY_CONTRACT } from './standard-skills.js';
8
8
  const BEGIN = '<!-- BEGIN KIOKUKO-DSH MANAGED BLOCK -->';
9
9
  const END = '<!-- END KIOKUKO-DSH MANAGED BLOCK -->';
@@ -41,8 +41,8 @@ For generated artifacts, update the owning schema, template or generator, then u
41
41
  Choose design tokens by semantic role, not by current appearance. If a role is missing, extend the design system instead of repurposing an unrelated token; when changing theme contracts, verify supported light, dark and custom-theme fallback behavior.
42
42
 
43
43
  ${END}`;
44
- /** Replace only a DSH-owned block, preserving every other product's instructions. */
45
- export function renderDshInstructions(existing) {
44
+ /** Locate one complete DSH-owned block and reject ambiguous ownership markers. */
45
+ export function locateDshBlock(existing) {
46
46
  const conflict = () => new KiokukoError('CONFLICT', 'AGENTS.md must contain exactly one complete kiokuko-dsh managed block; repair its markers before setup');
47
47
  const starts = existing.split(BEGIN).length - 1;
48
48
  const ends = existing.split(END).length - 1;
@@ -66,9 +66,28 @@ export function renderDshInstructions(existing) {
66
66
  closing = LEGACY_END;
67
67
  }
68
68
  else
69
+ return undefined;
70
+ return { start, end: end + closing.length };
71
+ }
72
+ /** Replace only a DSH-owned block, preserving every other product's instructions. */
73
+ export function renderDshInstructions(existing) {
74
+ const location = locateDshBlock(existing);
75
+ if (location === undefined)
69
76
  return existing;
70
77
  const newline = existing.includes('\r\n') ? '\r\n' : '\n';
71
- return existing.slice(0, start) + DSH_MANAGED_BLOCK.replaceAll('\n', newline) + existing.slice(end + closing.length);
78
+ return existing.slice(0, location.start) + DSH_MANAGED_BLOCK.replaceAll('\n', newline) + existing.slice(location.end);
79
+ }
80
+ /** Remove only a DSH-owned block and its following setup separator newline. */
81
+ export function renderDshRemoval(existing) {
82
+ const location = locateDshBlock(existing);
83
+ if (location === undefined)
84
+ return existing;
85
+ let suffix = existing.slice(location.end);
86
+ if (suffix.startsWith('\r\n'))
87
+ suffix = suffix.slice(2);
88
+ else if (suffix.startsWith('\n'))
89
+ suffix = suffix.slice(1);
90
+ return existing.slice(0, location.start) + suffix;
72
91
  }
73
92
  async function planInstructions(workspace) {
74
93
  const target = path.join(workspace, 'AGENTS.md');
@@ -103,6 +122,33 @@ export async function setupDsh(options = {}) {
103
122
  result.current = !options.check || result.skills.created + result.skills.updated === 0 && result.instructions.status !== 'update-needed';
104
123
  return result;
105
124
  }
125
+ async function planInstructionRemoval(workspace) {
126
+ const target = path.join(workspace, 'AGENTS.md');
127
+ const previous = await readRegularFile(target, { containmentRoot: workspace });
128
+ if (previous === undefined)
129
+ return undefined;
130
+ const content = renderDshRemoval(previous.content);
131
+ if (content === previous.content)
132
+ return undefined;
133
+ await deploymentParent(workspace, target, false);
134
+ return { target, previous, content };
135
+ }
136
+ /** Explicitly retire matching deployed Skills and remove this product's AGENTS.md block. */
137
+ export async function removeDshSetup(options = {}) {
138
+ const workspace = await realpath(options.cwd ?? process.cwd());
139
+ // Validate instruction ownership before deleting any deployed Skill.
140
+ const instructions = await planInstructionRemoval(workspace);
141
+ const skills = await retireStandardSkills(options.homeDirectory, { check: options.check ?? false });
142
+ const result = {
143
+ current: true,
144
+ skills,
145
+ instructions: { path: path.join(workspace, 'AGENTS.md'), status: instructions ? 'unchanged' : 'unmanaged-or-absent' },
146
+ };
147
+ if (instructions)
148
+ result.instructions.status = options.check ? 'update-needed' : await publishFile(workspace, instructions);
149
+ result.current = !options.check || result.skills.removed === 0 && result.instructions.status !== 'update-needed';
150
+ return result;
151
+ }
106
152
  export async function setupDshOnLoad() {
107
153
  try {
108
154
  const result = await setupDsh();
@@ -1 +1 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/dsh/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAuB,MAAM,8BAA8B,CAAA;AACjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA;AAElE,MAAM,KAAK,GAAG,0CAA0C,CAAA;AACxD,MAAM,GAAG,GAAG,wCAAwC,CAAA;AACpD,MAAM,YAAY,GAAG,sCAAsC,CAAA;AAC3D,MAAM,UAAU,GAAG,oCAAoC,CAAA;AACvD,mEAAmE;AACnE,MAAM,gBAAgB,GAAG,0FAA0F,CAAA;AAEnH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,KAAK;;;;;;;;;;;;EAYvC,2BAA2B;;;;;;;;;;;;;;;;;EAiB3B,GAAG,EAAE,CAAA;AAEP,qFAAqF;AACrF,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACpD,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,IAAI,YAAY,CAAC,UAAU,EAAE,wGAAwG,CAAC,CAAA;IAC7J,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;IAC/C,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;IAC3C,MAAM,YAAY,GAAG,CAAC,GAAG,QAAQ,CAAC,QAA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CAAC,SAAS,gBAAgB,MAAM,CAAC,YAAY,CAAC,MAAM,KAAK,MAAM,CAAC,YAAY,CAAC,IAAI,4DAA4D,CAAC,CAAA;QAC7R,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,GAAG,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QACvF,OAAO,CAAC,IAAI,CAAC,sDAAsD,IAAI,iDAAiD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,qBAAqB,+HAA+H,CAAC,CAAA;IACxT,CAAC;AACH,CAAC"}
@@ -5,11 +5,22 @@ export interface StandardSkillDeployment {
5
5
  readonly updated: number;
6
6
  readonly unchanged: number;
7
7
  }
8
+ export interface StandardSkillRetirement {
9
+ readonly directory: string;
10
+ readonly removed: number;
11
+ readonly preserved: number;
12
+ }
8
13
  /** Preflight all standard Skills plus Japanese output without writing files. */
9
- export declare function planStandardSkills(homeDirectory?: string): Promise<{
14
+ export declare function planStandardSkills(homeDirectory?: string, options?: {
15
+ preserveUnmanaged?: boolean;
16
+ }): Promise<{
10
17
  home: string;
11
18
  directory: string;
12
19
  files: DeploymentFile[];
13
20
  }>;
14
21
  export declare function synchronizeStandardSkills(homeDirectory?: string): Promise<StandardSkillDeployment>;
22
+ /** Remove only deployed files that still match this package byte-for-byte. */
23
+ export declare function retireStandardSkills(homeDirectory?: string, options?: {
24
+ check?: boolean;
25
+ }): Promise<StandardSkillRetirement>;
15
26
  //# sourceMappingURL=standard-skill-deployment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"standard-skill-deployment.d.ts","sourceRoot":"","sources":["../../src/dsh/standard-skill-deployment.ts"],"names":[],"mappings":"AAQA,OAAO,EAAiC,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAA;A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E,cAAc,EAAE,CAAA;CAAE,CAAC,CAuBnM;AAED,wBAAsB,yBAAyB,CAAC,aAAa,GAAE,MAAqB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAStH;AA+BD,8EAA8E;AAC9E,wBAAsB,oBAAoB,CAAC,aAAa,GAAE,MAAqB,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA6BpJ"}
@@ -1,4 +1,4 @@
1
- import { realpath } from 'node:fs/promises';
1
+ import { readdir, realpath, rmdir, unlink } from 'node:fs/promises';
2
2
  import os from 'node:os';
3
3
  import path from 'node:path';
4
4
  import { readRegularFile } from '../config/read-regular-file.js';
@@ -8,7 +8,7 @@ import { renderStandardSkillFile } from './standard-skills.js';
8
8
  import { JAPANESE_OUTPUT_SKILL_DIRECTORY, JAPANESE_OUTPUT_SKILL_MANAGED_MARKER, loadJapaneseOutputSkill } from './japanese-output-skill.js';
9
9
  import { deploymentParent, publishFile } from './managed-file-deployment.js';
10
10
  /** Preflight all standard Skills plus Japanese output without writing files. */
11
- export async function planStandardSkills(homeDirectory = os.homedir()) {
11
+ export async function planStandardSkills(homeDirectory = os.homedir(), options = {}) {
12
12
  if (!path.isAbsolute(homeDirectory) || homeDirectory.includes('\0') || path.resolve(homeDirectory) === path.parse(homeDirectory).root) {
13
13
  throw new KiokukoError('VALIDATION_ERROR', 'Standard Skill deployment requires an absolute user home');
14
14
  }
@@ -27,8 +27,8 @@ export async function planStandardSkills(homeDirectory = os.homedir()) {
27
27
  const target = path.join(directory, bundled.directoryName, bundled.relativePath);
28
28
  await deploymentParent(home, target, false);
29
29
  const previous = await readRegularFile(target, { containmentRoot: home });
30
- const rendered = renderStandardSkillFile(previous?.content, bundled, target);
31
- files.push({ target, content: rendered.content, previous });
30
+ const content = options.preserveUnmanaged ? bundled.content : renderStandardSkillFile(previous?.content, bundled, target).content;
31
+ files.push({ target, content, previous });
32
32
  }
33
33
  return { home, directory, files };
34
34
  }
@@ -44,4 +44,76 @@ export async function synchronizeStandardSkills(homeDirectory = os.homedir()) {
44
44
  // Atomicity is per file. An interrupted tree is completed on the next plugin load.
45
45
  return result;
46
46
  }
47
+ async function countUnplannedEntries(directory, planned) {
48
+ let entries;
49
+ try {
50
+ entries = await readdir(directory, { withFileTypes: true });
51
+ }
52
+ catch (error) {
53
+ if (error.code === 'ENOENT')
54
+ return 0;
55
+ throw error;
56
+ }
57
+ let count = 0;
58
+ for (const entry of entries) {
59
+ const target = path.join(directory, entry.name);
60
+ if (entry.isDirectory())
61
+ count += await countUnplannedEntries(target, planned);
62
+ else if (!planned.has(target))
63
+ count++;
64
+ }
65
+ return count;
66
+ }
67
+ async function removeEmptyDeploymentDirectories(directory, files) {
68
+ const directories = new Set();
69
+ for (const file of files) {
70
+ let current = path.dirname(file.target);
71
+ while (current !== directory && current.startsWith(`${directory}${path.sep}`)) {
72
+ directories.add(current);
73
+ current = path.dirname(current);
74
+ }
75
+ }
76
+ for (const target of [...directories].sort((left, right) => right.length - left.length)) {
77
+ try {
78
+ await rmdir(target);
79
+ }
80
+ catch { /* Preserve non-empty, absent, or otherwise unavailable directories. */ }
81
+ }
82
+ }
83
+ /** Remove only deployed files that still match this package byte-for-byte. */
84
+ export async function retireStandardSkills(homeDirectory = os.homedir(), options = {}) {
85
+ const { home, directory, files } = await planStandardSkills(homeDirectory, { preserveUnmanaged: true });
86
+ const planned = new Set(files.map(file => file.target));
87
+ const result = { directory, removed: 0, preserved: await countUnplannedEntries(directory, planned) };
88
+ for (const file of files) {
89
+ if (file.previous === undefined)
90
+ continue;
91
+ if (file.previous.content !== file.content) {
92
+ result.preserved++;
93
+ continue;
94
+ }
95
+ if (options.check) {
96
+ result.removed++;
97
+ continue;
98
+ }
99
+ const current = await readRegularFile(file.target, { containmentRoot: home });
100
+ if (current === undefined)
101
+ continue;
102
+ if (current.content !== file.content) {
103
+ result.preserved++;
104
+ continue;
105
+ }
106
+ try {
107
+ await unlink(file.target);
108
+ result.removed++;
109
+ }
110
+ catch (error) {
111
+ if (error.code !== 'ENOENT')
112
+ throw error;
113
+ }
114
+ }
115
+ if (!options.check)
116
+ await removeEmptyDeploymentDirectories(directory, files);
117
+ return result;
118
+ }
47
119
  //# sourceMappingURL=standard-skill-deployment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standard-skill-deployment.js","sourceRoot":"","sources":["../../src/dsh/standard-skill-deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAC9D,OAAO,EAAE,+BAA+B,EAAE,oCAAoC,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AAC3I,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAuB,MAAM,8BAA8B,CAAA;AASjG,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,gBAAwB,EAAE,CAAC,OAAO,EAAE;IAC3E,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC;QACtI,MAAM,IAAI,YAAY,CAAC,kBAAkB,EAAE,0DAA0D,CAAC,CAAA;IACxG,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,CAAA;IAC1C,MAAM,SAAS,G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ACH,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YACzB,MAAM,CAAC,OAAO,EAAE,CAAA;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;gBAAE,MAAM,KAAK,CAAA;QACrE,CAAC;IACH,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,KAAK;QAAE,MAAM,gCAAgC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;IAC5E,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "kiokuko-dsh",
4
- "description": "Version 0.2.36 — Kiokuko plugin for DeepSeek Harness"
4
+ "description": "Version 0.2.37 — Kiokuko plugin for DeepSeek Harness"
5
5
  }
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "kiokuko-dsh",
4
- "description": "バージョン 0.2.36 — DeepSeek Harness 向け Kiokuko プラグイン"
4
+ "description": "バージョン 0.2.37 — DeepSeek Harness 向け Kiokuko プラグイン"
5
5
  }
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "kiokuko-dsh",
4
- "description": "버전 0.2.36 — DeepSeek Harness용 Kiokuko 플러그인"
4
+ "description": "버전 0.2.37 — DeepSeek Harness용 Kiokuko 플러그인"
5
5
  }
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "kiokuko-dsh",
4
- "description": "版本 0.2.36 — DeepSeek Harness 的 Kiokuko 插件"
4
+ "description": "版本 0.2.37 — DeepSeek Harness 的 Kiokuko 插件"
5
5
  }
6
6
  }
package/docs/README.ja.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  目的別に参照してください。
4
4
 
5
+ - [OpenAI Decisionsの設定](../README.ja.md#openai-decisions-setup) — APIキーの保存先・自動再読・優先順位・判定providerの切替。[詳細な設定(英語)](typed-decisions.md#openai-credentials)。
5
6
  - [導入ガイド](getting-started.ja.md) — DeepSeek Harness Pluginの導入と実行。
6
7
  - [基本概念](concepts.ja.md) — RAG、記憶のライフサイクル、Project/Ecosystem/Global、Akinator。
7
8
  - [役小角(enno-oduno)](enno-oduno.ja.md) — Agent Loop、確認、回復、継続、検証、Advisory Round。
package/docs/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  Choose a guide by what you need to do:
4
4
 
5
+ - [OpenAI Decisions setup](../README.md#openai-decisions-setup) — API key, credential file paths, automatic reload, precedence and provider switching; [detailed configuration](typed-decisions.md#openai-credentials).
5
6
  - [Getting started](getting-started.md) — install and run the DeepSeek Harness plugin.
6
7
  - [Concepts](concepts.md) — RAG, memory lifecycle, Project/Ecosystem/Global scopes, and Akinator.
7
8
  - [役小角(enno-oduno)](enno-oduno.md) — the agent loop, confirmation, recovery, continuation, verification, and Advisory Round.
@@ -53,7 +53,7 @@ requires an explicit resume and a new generation. Old results cannot complete
53
53
  or modify that new generation. Model changes transfer the same task to the
54
54
  verified primary continuation; CLI resume rereads its persisted state.
55
55
 
56
- Jev/Laya interpretations are advisory. If they are unavailable or abstain, the
56
+ Jev/Laya/OpenAI interpretations are advisory. If they are unavailable or abstain, the
57
57
  host records an unresolved decision and accepts a validated main-model
58
58
  interpretation or an explicit operation. The original request and authority
59
59
  checks remain in force. The CLI displays this SQLite snapshot and committed
@@ -220,6 +220,20 @@ Released v0/v1/v2/v3 history readers are bundled privately into the npm artifact
220
220
 
221
221
  ## Remove
222
222
 
223
+ | Target | After `dsh plugin remove` | How to remove it |
224
+ |---|---|---|
225
+ | DSH rows (`kiokuko-dsh` / `kiokuko-models`) | Removed; the stock export row is restored | No further action |
226
+ | Deployed Skills under `~/.agents/skills` | Remain | `setup-dsh.mjs --remove` |
227
+ | DSH block in `AGENTS.md` | Remains | `setup-dsh.mjs --remove` |
228
+ | `kiokuko-models.json` | Remains | Remove manually only when the saved provider definitions are no longer needed |
229
+ | Kiokuko database and `.agenticreplay/runs` | Remain intentionally | Do not remove them as part of plugin removal |
230
+
231
+ Disable individual rows when temporarily turning Kiokuko off. Disabling the whole
232
+ bundle also removes the provider referenced by `agent-default-model`, leaving its
233
+ default-model binding unresolved. `patchReload: "live"` has no reader in the
234
+ current DSH and must not be treated as evidence that a profile change took effect
235
+ immediately.
236
+
223
237
  ```bash
224
238
  dsh plugin --profile web remove kiokuko-dsh
225
239
  ```
@@ -268,19 +282,24 @@ block in the startup directory’s `AGENTS.md`, as described below.
268
282
  ## Bundled standard Skills: canonical source and refresh
269
283
 
270
284
  The repository's `skills/<name>/` directories are the single canonical source
271
- for the eight standard Skills and for the bundled Japanese output Skill.
285
+ for the 16 standard Skills and for the separately bundled Japanese output and
286
+ Lisp Skills.
272
287
  `src/dsh/standard-skills.ts` resolves them relative to the built module
273
288
  (`dist/dsh/` → `../../skills/<name>`), and `src/dsh/standard-skill-integrity.ts`
274
289
  refuses to load a tree that breaks the manifest: exactly one management marker
275
290
  per file, frontmatter `name` equal to the manifest name with a non-empty
276
291
  description and no `disable-model-invocation`, every local Markdown link
277
- resolvable inside its own Skill, and exactly 8 Skills with 27 Markdown files and
278
- 19 reference files.
292
+ resolvable inside its own Skill, and exactly 16 standard Skills with 42 Markdown
293
+ files and 26 reference files.
279
294
 
280
- The Japanese output Skill is an additional ninth Skill. Its directory is
295
+ The Japanese output Skill and Lisp Skill bring the package inventory to 18 Skill
296
+ directories. The Japanese output directory is
281
297
  `japanese-translation-for-oss-models/`; its frontmatter/provider name is
282
- `natural-japanese-output`. Both names refer to the same Skill. Deployment includes
283
- all nine Skills and 28 Markdown files, including the 19 references.
298
+ `natural-japanese-output`. Both names refer to the same Skill. Setup deploys the
299
+ 16 standard Skills plus
300
+ Japanese output: 17 directories and 43 files, including the 26 references. Lisp
301
+ is supplied through the DSH Skill provider and is not installed globally by this
302
+ setup path.
284
303
 
285
304
  `veteran-programmer-skill` checks workflow completeness before and after changes
286
305
  spanning setup, delivery, persisted state or runtime handoffs. SOUL and the code
@@ -300,8 +319,9 @@ alone does not establish remaining input budget or model quality.
300
319
  The enabled plugin runs setup on every load, before registering its DSH surfaces:
301
320
 
302
321
  1. Validate the bundled Skills and preflight the deployment targets.
303
- 2. Synchronize all eight managed Skill directories to the process user's
304
- `~/.agents/skills/`, creating missing files and replacing stale managed files.
322
+ 2. Synchronize all 16 standard Skill directories and the Japanese output Skill
323
+ to the process user's `~/.agents/skills/`, creating missing files and replacing
324
+ stale managed files.
305
325
  3. Replace the existing `<!-- BEGIN KIOKUKO-DSH MANAGED BLOCK -->` through
306
326
  `<!-- END KIOKUKO-DSH MANAGED BLOCK -->` section of the startup directory's
307
327
  `AGENTS.md` with the DSH contract. Preserve all text outside those markers.
@@ -356,6 +376,9 @@ npm run build
356
376
  node scripts/setup-dsh.mjs --cwd /absolute/path/to/project --check
357
377
  node scripts/setup-dsh.mjs --cwd /absolute/path/to/project
358
378
  node scripts/setup-dsh.mjs --cwd /absolute/path/to/project --check
379
+ # Explicitly remove byte-identical deployed copies and the DSH AGENTS.md block.
380
+ node scripts/setup-dsh.mjs --cwd /absolute/path/to/project --remove
381
+ node scripts/setup-dsh.mjs --cwd /absolute/path/to/project --remove --check
359
382
  ```
360
383
 
361
384
  The same `scripts/setup-dsh.mjs` ships in the installed package. Use the **actual
@@ -374,8 +397,8 @@ runtime user. Check the reported paths: a successful source build or bundled
374
397
  parity check alone does not prove that another process's deployed files match.
375
398
 
376
399
  `node scripts/verify-standard-skills.mjs` remains a source/bundle integrity check
377
- for the eight standard Skills (27 files, 19 references). Use `setup-dsh.mjs --check`
378
- for the complete nine-Skill deployment **and** project instruction check.
400
+ for the 16 standard Skills (42 files, 26 references). Use `setup-dsh.mjs --check`
401
+ for the complete 17-directory, 43-file deployment **and** project instruction check.
379
402
 
380
403
  ## STORE contract and permissions
381
404
 
@@ -402,9 +425,14 @@ Runtime effects are explicit:
402
425
  - optional GitHub or embedding credentials are supplied by the user and are
403
426
  never bundled or persisted by the plugin.
404
427
 
405
- `prepare` runs only `npm run build`. Git installs need build approval in the
406
- consuming profile; use the repository-scoped rule in [Install](#install) so
407
- ordinary updates do not require another commit-specific permission.
428
+ `prepare` runs `node scripts/prepare-build.mjs`, which normally builds through
429
+ the invoking package manager. Only `CI=true` together with
430
+ `KIOKUKO_CI_DEFER_PREPARE=1` defers this package's duplicate build to the selected
431
+ verifier's clean build; dependency lifecycle scripts remain enabled. See
432
+ [CI build ownership](verification.md#consolidated-duplicate-invocations).
433
+ Git installs still need build approval in the consuming profile; use the
434
+ repository-scoped rule in [Install](#install) so ordinary updates do not require
435
+ another commit-specific permission.
408
436
 
409
437
  The npm tarball already contains `dist/`, so its normal install path does not
410
438
  depend on a consumer-side build permission.
@@ -3,6 +3,8 @@
3
3
  `kiokuko-dsh`はDeepSeek Harness向けPluginです。公開パッケージが提供する
4
4
  のは`./dsh` Plugin entrypointだけです。導入、session、lifecycleはDSHが所有します。
5
5
 
6
+ 補助判定でOpenAIを使う場合は、[OpenAI Decisionsの設定](../README.ja.md#openai-decisions-setup)でAPIキーの保存先とWeb profileとの違いを確認してください。主モデルのChatGPT/Codex OAuthとは別です。手順は現行ソースの対応を示し、公開済みnpmの `latest` に含まれることを保証しません。
7
+
6
8
  ## インストール
7
9
 
8
10
  公式 DeepSeek Harness の現在のソースと Node.js 24.16.0 以上を使用します。DSH の版名による固定判定はせず、実際のホスト API と解決したソース revision に対する隔離試験で互換性を確認します。[検証範囲](current-upstream-compatibility-report.md)を参照してください。
@@ -3,6 +3,8 @@
3
3
  `kiokuko-dsh` is a DeepSeek Harness plugin. The published package contains the
4
4
  `./dsh` plugin entrypoint. DSH owns installation, sessions, and lifecycle.
5
5
 
6
+ Before choosing OpenAI for auxiliary decisions, follow the [OpenAI Decisions setup](../README.md#openai-decisions-setup) for API-key storage and the Web-profile path distinction. Main-model ChatGPT/Codex OAuth is separate. The guide describes current source support, not a guarantee about the published npm `latest`.
7
+
6
8
  ## Install
7
9
 
8
10
  Use current official DeepSeek Harness and Node.js 24.16.0 or newer. Compatibility is checked against actual host APIs and the resolved upstream source revision, not a fixed DSH release label. See [verified scope](current-upstream-compatibility-report.md).
@@ -14,7 +14,7 @@ DSHの権限判定、必要な検証を維持し、役小角の契約・WorkUnit
14
14
 
15
15
  Webプロファイルでは [Kiokuko Models](kiokuko-models.md) から接続を設定できます。DSH本体のModelsで設定する必要はありません。登録したモデルは、通常会話・Enno・Deepでネイティブ接続と併用できます。
16
16
 
17
- 通常版・modular coreとも `modelAutoMode.mode: off` が既定です。同じDSHプロファイルでKiokuko Modelsまたはdsh-codexからCodexを認証し、JevかLayaの判定を準備したうえで、まず `observe` で選択案を確認します。
17
+ 通常版・modular coreとも `modelAutoMode.mode: off` が既定です。同じDSHプロファイルでKiokuko Modelsまたはdsh-codexからCodexを認証し、Jev・Laya・[OpenAI](typed-decisions.md#openai-credentials)のいずれかの判定を準備したうえで、まず `observe` で選択案を確認します。
18
18
 
19
19
  ```yaml
20
20
  modelAutoMode:
@@ -34,7 +34,7 @@ modelAutoMode:
34
34
 
35
35
  初期候補は `gpt-6-luna` の low・medium・high と `gpt-6-sol` の high です。`modelAutoMode.routes` には最大4件、`id`(`luna-low`、`luna-medium`、`luna-high`、`sol-high`)と `binding`(`provider`、`model`、`reasoningEffort`)を指定できます。IDは経路のラベルなので、登録済みのAstraなども正確なbindingで割り当てられます。候補はCodex由来とResponses方式を確認でき、現在のモデル一覧、文脈容量・入力形式・推論強度、要求設定の検証、token meterを通った接続に限定します。ネイティブの `openai-codex` とKiokuko所有のCodex接続が対象です。名前だけを似せた接続やOpenAI API接続は対象外です。有効なbindingが2件未満なら判定しません。
36
36
 
37
- 新しい受付済みの通常タスクでは、現在の依頼文、タスク種別、添付の種類、経路IDと判定基準を選択中のJevかLayaへ送ります。この判定のために添付の内容、全履歴、リポジトリ全体は送信しません。Choice 1問の結果をrunに保存し、継続では同じ経路を使います。再起動時に判定結果が不明なら再送せず元のモデルを維持します。`observe`、棄権、probe失敗、metadata不足、非対応effort、timeout、入力超過でも元のモデルを維持します。取消、セッション同一性の不一致、保存の整合性エラーでは要求を止めます。認証・利用枠・モデル利用不可によるdispatch失敗を別モデルへ自動再送しません。
37
+ 新しい受付済みの通常タスクでは、現在の依頼文、タスク種別、添付の種類、経路IDと判定基準を選択中のJev・Laya・OpenAIへ送ります。この判定のために添付の内容、全履歴、リポジトリ全体は送信しません。Choice 1問の結果をrunに保存し、継続では同じ経路を使います。再起動時に判定結果が不明なら再送せず元のモデルを維持します。`observe`、棄権、probe失敗、metadata不足、非対応effort、timeout、入力超過でも元のモデルを維持します。取消、セッション同一性の不一致、保存の整合性エラーでは要求を止めます。認証・利用枠・モデル利用不可によるdispatch失敗を別モデルへ自動再送しません。
38
38
 
39
39
  状態表示では、設定・準備状態・選択案・適用したbindingと、nativeの `request/header` で確認した実モデルを区別します。初期候補は判定基準であり、品質・時間・利用枠の改善を保証しません。Enno、Deep、子、雑談、回答の再検討、保護されたLisp実行は既存の経路を使います。実装失敗後の自動昇格は初期版に含めません。
40
40
 
@@ -15,7 +15,7 @@ plan approval or automatic Enno continuation.
15
15
 
16
16
  In Web profiles, [Kiokuko Models](kiokuko-models.md) manages connections without requiring DSH's Models settings. Its registered models are available to ordinary chat, Enno and Deep alongside native connections.
17
17
 
18
- `modelAutoMode` is off by default in both the full plugin and modular core. To try it, authenticate Codex through Kiokuko Models or dsh-codex in the same DSH profile, configure a Jev or Laya typed-decision backend, then use `observe` before enabling automatic routing:
18
+ `modelAutoMode` is off by default in both the full plugin and modular core. To try it, authenticate Codex through Kiokuko Models or dsh-codex in the same DSH profile, configure a Jev, Laya or [OpenAI typed-decision backend](typed-decisions.md#openai-credentials), then use `observe` before enabling automatic routing:
19
19
 
20
20
  ```yaml
21
21
  modelAutoMode:
@@ -35,7 +35,7 @@ The command changes only the current native session. `on` also clears its manual
35
35
 
36
36
  The initial preset offers `gpt-6-luna` at low, medium and high effort, plus `gpt-6-sol` at high effort. Up to four exact route bindings can be configured under `modelAutoMode.routes`; each has an `id` from `luna-low`, `luna-medium`, `luna-high`, `sol-high`, and a `binding` with `provider`, `model`, and `reasoningEffort`. These are route labels, so a registered Astra or other GPT model may be assigned explicitly. No new model ID is guessed or substituted. A candidate must have a validated Codex origin and Responses protocol, live model context and modality metadata, supported efforts, call-config validation and token meter. Both native `openai-codex` and Kiokuko-owned Codex routes qualify; an arbitrary provider name or OpenAI API connection does not. Fewer than two valid bindings skips classification.
37
37
 
38
- For a new admitted normal task, Kiokuko sends the current task text, task type, attachment kinds, route IDs and rubric to the selected Jev or Laya backend. It does not send attachment bytes, full history or repository contents for this classification. One Choice result selects a route or abstains. The route is stored against the exact run and reused for continuations; an unknown in-flight decision after restart is retained without another classifier call. `observe` records a proposal but keeps the current model. A failed probe, missing metadata, unsupported effort, timeout, oversized input or abstention also keeps the current model. Cancellation, stale session identity and storage integrity failures stop the request. Dispatch authentication, quota and unavailable-model errors remain ordinary failures; no alternate model is retried automatically.
38
+ For a new admitted normal task, Kiokuko sends the current task text, task type, attachment kinds, route IDs and rubric to the selected Jev, Laya or OpenAI backend. It does not send attachment bytes, full history or repository contents for this classification. One Choice result selects a route or abstains. The route is stored against the exact run and reused for continuations; an unknown in-flight decision after restart is retained without another classifier call. `observe` records a proposal but keeps the current model. A failed probe, missing metadata, unsupported effort, timeout, oversized input or abstention also keeps the current model. Cancellation, stale session identity and storage integrity failures stop the request. Dispatch authentication, quota and unavailable-model errors remain ordinary failures; no alternate model is retried automatically.
39
39
 
40
40
  The status distinguishes the configured mode, readiness, proposal and selected binding from the model observed in a native `request/header`. The initial preset is a rubric, not a claim that it improves quality, elapsed time or subscription usage. Enno, Deep, children, chat, review continuation and protected Lisp execution retain their existing owners. Automatic escalation after a failed implementation pass is not enabled.
41
41
 
@@ -17,6 +17,12 @@ permissions, and disposable-profile result independently.
17
17
  | npm lifecycle | `prepare: npm run build` |
18
18
  | Automatic size policy | intentionally exceeded; manual `user-reviewed` track |
19
19
 
20
+ This table records the **0.1.3 review snapshot**, including its original lifecycle
21
+ command; it is not the current package's release evidence. Current source uses
22
+ `prepare: node scripts/prepare-build.mjs` with normal builds and an explicit CI-only
23
+ deferral. See [current lifecycle and permissions](../PERMISSIONS.md#installation-lifecycle)
24
+ and [CI build ownership](verification.md#consolidated-duplicate-invocations).
25
+
20
26
  The Commit field is filled only after the user commits and pushes the verified
21
27
  working tree. The catalog must point to that full immutable Commit, not a branch
22
28
  name or moving tag.
@@ -23,7 +23,7 @@ excerpted or rewritten, and classification grants no execution permission.
23
23
  The common API also accepts explicit `noul` (yes probability) and `score`
24
24
  (ordered rubric) questions. Their validated answers have `status: "measured"`;
25
25
  they grant no permission. The existing Choice request and answer shapes remain
26
- valid. TypeSafe can evaluate all three question types in one batch. Nimble and
26
+ valid. TypeSafe and OpenAI can evaluate all three question types in one batch. Nimble and
27
27
  Laya accept Choice only and return `DECISION_UNSUPPORTED` before inference for
28
28
  other kinds. The separate Lisp `kioku.typesafe:evaluate` API retains its own
29
29
  wire contract.
@@ -49,6 +49,59 @@ base configuration. A stale host cannot overwrite a selection saved by another
49
49
  host; restart it to load the latest choice. Changing the base configuration uses
50
50
  that configuration's selection, with the YAML provider as the default.
51
51
 
52
+ <a id="openai-credentials"></a>
53
+ ## OpenAI credentials
54
+
55
+ Jev remains the default; OpenAI, local Laya and Nimble are alternatives. OpenAI uses the official [Decisions API](https://developers.openai.com/api/docs/guides/decisions), `POST /v1/decisions`, with `gpt-6-luna` as this checkout's default decision model. This is separate from the main chat model: ChatGPT/Codex OAuth login does not supply `OPENAI_API_KEY`, and a TypeSafe/Jev key cannot replace it.
56
+
57
+ These instructions describe the current source. They do not assert that the published npm `latest` already includes OpenAI support. If `use openai` is unavailable, check the installed build's command support first.
58
+
59
+ 1. Create an API key for your OpenAI API project and add it to the credential store used by the running DSH. With the standard `credentials-local` provider, choose the path as follows:
60
+
61
+ | Configuration | Credential file |
62
+ |---|---|
63
+ | Default harness home | `~/.dsh/.credentials.yaml` |
64
+ | Custom `DSH_HOME` | `$DSH_HOME/.credentials.yaml` |
65
+ | Explicit `credentials.path` (the provider's `config.path`) | The configured path, overriding the home default |
66
+
67
+ `--profile web` keeps profile packages and patches under `$DSH_HOME/profiles/web`; it does **not** by itself move credentials there. A profile can override `credentials.path`, or its launcher can use another `DSH_HOME`. Use that effective file, not a guessed `profiles/web/.credentials.yaml`.
68
+
69
+ 2. In an existing file, add only `OPENAI_API_KEY` under `refs` and preserve all other `refs` and `records`. This is a minimal **new-file example**, with a nonfunctional placeholder:
70
+
71
+ ```yaml
72
+ version: 1
73
+ refs:
74
+ OPENAI_API_KEY: "OPENAI_API_KEY_EXAMPLE_ONLY"
75
+ records: {}
76
+ ```
77
+
78
+ Replace the placeholder privately with your key. On macOS/Linux, protect the actual file; for the default path:
79
+
80
+ ```sh
81
+ chmod 600 "$HOME/.dsh/.credentials.yaml"
82
+ ```
83
+
84
+ Use your configured path instead when it differs. The default `watch: true` reloads valid file edits automatically for subsequent requests; restarting DSH is unnecessary. Do not paste keys into chat, screenshots or Git.
85
+
86
+ 3. In DSH's command input, select OpenAI and inspect the result:
87
+
88
+ ```text
89
+ /kioku-decisions use openai
90
+ /kioku-decisions status
91
+ ```
92
+
93
+ `use openai` makes a real API probe, which may incur usage charges. Only a successful probe and save persist the choice for this project and new requests; failure or cancellation keeps the prior choice. Existing requests keep their binding. `status` makes no inference call. Optional `/kioku-decisions probe` makes another real probe.
94
+
95
+ The standard provider resolves **saved file > launch environment > project `.env` > harness-home `.env`**. Environment variables still work when the credentials service is present, unless a saved value overrides them. For an environment-only setup, export the key **before** launching DSH from that shell:
96
+
97
+ ```sh
98
+ export OPENAI_API_KEY='OPENAI_API_KEY_EXAMPLE_ONLY'
99
+ ```
100
+
101
+ This is a placeholder, not a usable key. An export in another shell after DSH has started does not update its launch snapshot; use the watched file to update an already running instance. Keep credential-bearing `.env` files out of Git.
102
+
103
+ ## Provider configuration
104
+
52
105
  Configure `typedDecisions` on the full plugin or modular core:
53
106
 
54
107
  OpenAI uses the distinct official [Decisions API](https://developers.openai.com/api/docs/guides/decisions),
@@ -56,13 +109,30 @@ OpenAI uses the distinct official [Decisions API](https://developers.openai.com/
56
109
  It maps Choice, Noul (predicate) and Score to the native API and validates ordered
57
110
  named answers, distributions, rubric levels and individual refusals. The default
58
111
  model is `gpt-6-luna`; probability ≥ 0.9 and margin ≥ 0.2 are required for Choice.
59
- Set `OPENAI_API_KEY` through DSH credentials (or the environment when no credentials
60
- service exists). TypeSafe credentials are never substituted. No redirects,
112
+ Kiokuko resolves `OPENAI_API_KEY` through `ctx.credentials.resolve` when the service
113
+ exists; the standard local provider includes the launch environment and `.env`
114
+ fallbacks described [above](#openai-credentials). Only a composition without that
115
+ service uses Kiokuko's direct `process.env` fallback. A different credential
116
+ provider may have different resolution rules. TypeSafe credentials are never substituted. No redirects,
61
117
  automatic retries, or provider fallback are added. `use openai` probes before
62
118
  persisting; missing credentials, failed probes and cancellation leave selection unchanged.
63
119
  Existing Jev/Laya stored configuration digests retain their original shape.
64
120
  Current token records retain input/output totals; cached-token breakdown is not recorded.
65
121
 
122
+ To select OpenAI in the plugin or core configuration instead of a project command:
123
+
124
+ ```yaml
125
+ typedDecisions:
126
+ mode: auto
127
+ provider: openai
128
+ openai:
129
+ model: gpt-6-luna
130
+ timeoutMs: 5000
131
+ ```
132
+
133
+ Keep keys in the credential store, not in `typedDecisions`. A configured provider
134
+ is not evidence of a successful API call; use the command probe to verify access.
135
+
66
136
  The normal startup card offers the four decision/Lisp ON/OFF combinations and Cancel
67
137
  in one question before model tool assembly. It uses the currently selected backend,
68
138
  shown in the card; selection does not prove authentication or successful inference.
@@ -129,7 +199,8 @@ A live comparison requires explicit
129
199
  `TYPESAFE_API_KEY`; it sends only the checked-in synthetic fixture and must not
130
200
  be interpreted as a production accuracy estimate.
131
201
 
132
- Set the TypeSafe key through DSH, then inspect status:
202
+ The following commands manage only the TypeSafe/Jev key; for OpenAI, use the
203
+ [credential-file setup](#openai-credentials). Set the TypeSafe key through DSH, then inspect status:
133
204
 
134
205
  ```text
135
206
  /kioku-typesafe-key <key>