modkh 0.0.0-stage → 0.2.0
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/README.md +66 -2
- package/dist/agent/bundled-skills.d.ts +13 -0
- package/dist/agent/bundled-skills.js +95 -0
- package/dist/agent/compaction.d.ts +53 -0
- package/dist/agent/compaction.js +191 -0
- package/dist/agent/images.d.ts +10 -0
- package/dist/agent/images.js +33 -0
- package/dist/agent/loop.d.ts +103 -0
- package/dist/agent/loop.js +267 -0
- package/dist/agent/skills.d.ts +26 -0
- package/dist/agent/skills.js +190 -0
- package/dist/agent/types.d.ts +137 -0
- package/dist/agent/types.js +12 -0
- package/dist/cli/agenticreplay.d.ts +1 -0
- package/dist/cli/agenticreplay.js +66 -0
- package/dist/cli/agents.d.ts +8 -0
- package/dist/cli/agents.js +12 -0
- package/dist/cli/answer-markdown.d.ts +3 -0
- package/dist/cli/answer-markdown.js +29 -0
- package/dist/cli/approval.d.ts +29 -0
- package/dist/cli/approval.js +92 -0
- package/dist/cli/catalog.d.ts +37 -0
- package/dist/cli/catalog.js +46 -0
- package/dist/cli/chat.d.ts +18 -0
- package/dist/cli/chat.js +1061 -0
- package/dist/cli/clipboard.d.ts +11 -0
- package/dist/cli/clipboard.js +82 -0
- package/dist/cli/color.d.ts +59 -0
- package/dist/cli/color.js +244 -0
- package/dist/cli/compaction-settings.d.ts +21 -0
- package/dist/cli/compaction-settings.js +54 -0
- package/dist/cli/completion-art.d.ts +2 -0
- package/dist/cli/completion-art.js +62 -0
- package/dist/cli/config.d.ts +50 -0
- package/dist/cli/config.js +192 -0
- package/dist/cli/editor.d.ts +23 -0
- package/dist/cli/editor.js +115 -0
- package/dist/cli/file-mentions.d.ts +14 -0
- package/dist/cli/file-mentions.js +141 -0
- package/dist/cli/head-checks.d.ts +41 -0
- package/dist/cli/head-checks.js +146 -0
- package/dist/cli/initial-connection.d.ts +7 -0
- package/dist/cli/initial-connection.js +20 -0
- package/dist/cli/keys.d.ts +29 -0
- package/dist/cli/keys.js +107 -0
- package/dist/cli/language.d.ts +1 -0
- package/dist/cli/language.js +105 -0
- package/dist/cli/limits.d.ts +13 -0
- package/dist/cli/limits.js +19 -0
- package/dist/cli/lines.d.ts +18 -0
- package/dist/cli/lines.js +80 -0
- package/dist/cli/model-catalog.d.ts +16 -0
- package/dist/cli/model-catalog.js +130 -0
- package/dist/cli/models.d.ts +4 -0
- package/dist/cli/models.js +101 -0
- package/dist/cli/official-models.d.ts +6 -0
- package/dist/cli/official-models.js +77 -0
- package/dist/cli/pdf.d.ts +8 -0
- package/dist/cli/pdf.js +71 -0
- package/dist/cli/permissions.d.ts +25 -0
- package/dist/cli/permissions.js +30 -0
- package/dist/cli/plugins.d.ts +1 -0
- package/dist/cli/plugins.js +53 -0
- package/dist/cli/providers.d.ts +10 -0
- package/dist/cli/providers.js +82 -0
- package/dist/cli/shell-display.d.ts +6 -0
- package/dist/cli/shell-display.js +35 -0
- package/dist/cli/stateright.d.ts +1 -0
- package/dist/cli/stateright.js +37 -0
- package/dist/cli/terminal-mouse.d.ts +21 -0
- package/dist/cli/terminal-mouse.js +51 -0
- package/dist/cli/terminal.d.ts +231 -0
- package/dist/cli/terminal.js +1417 -0
- package/dist/cli/tool-display.d.ts +9 -0
- package/dist/cli/tool-display.js +87 -0
- package/dist/cli/transcript-selection.d.ts +22 -0
- package/dist/cli/transcript-selection.js +75 -0
- package/dist/cli/usage.d.ts +22 -0
- package/dist/cli/usage.js +117 -0
- package/dist/cli/waiting-nyan.d.ts +3 -0
- package/dist/cli/waiting-nyan.js +17 -0
- package/dist/cli/waiting-whales.d.ts +3 -0
- package/dist/cli/waiting-whales.js +24 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +186 -0
- package/dist/language/catalog.d.ts +44 -0
- package/dist/language/catalog.js +100 -0
- package/dist/language/commonlisp-bundled.d.ts +11 -0
- package/dist/language/commonlisp-bundled.js +22 -0
- package/dist/language/commonlisp-dependencies.d.ts +16 -0
- package/dist/language/commonlisp-dependencies.js +68 -0
- package/dist/language/commonlisp-install.d.ts +15 -0
- package/dist/language/commonlisp-install.js +214 -0
- package/dist/language/commonlisp-reader.d.ts +17 -0
- package/dist/language/commonlisp-reader.js +47 -0
- package/dist/language/commonlisp-systems.d.ts +3 -0
- package/dist/language/commonlisp-systems.js +32 -0
- package/dist/language/commonlisp-tls.d.ts +10 -0
- package/dist/language/commonlisp-tls.js +51 -0
- package/dist/language/detect.d.ts +29 -0
- package/dist/language/detect.js +103 -0
- package/dist/language/grammars/LICENSE +24 -0
- package/dist/language/grammars/manifest.json +76 -0
- package/dist/language/grammars/tree-sitter-c.wasm +0 -0
- package/dist/language/grammars/tree-sitter-cpp.wasm +0 -0
- package/dist/language/grammars/tree-sitter-css.wasm +0 -0
- package/dist/language/grammars/tree-sitter-html.wasm +0 -0
- package/dist/language/grammars/tree-sitter-javascript.wasm +0 -0
- package/dist/language/grammars/tree-sitter-php.wasm +0 -0
- package/dist/language/grammars/tree-sitter-python.wasm +0 -0
- package/dist/language/grammars/tree-sitter-ruby.wasm +0 -0
- package/dist/language/grammars/tree-sitter-rust.wasm +0 -0
- package/dist/language/grammars/tree-sitter-swift.wasm +0 -0
- package/dist/language/grammars/tree-sitter-tsx.wasm +0 -0
- package/dist/language/grammars/tree-sitter-typescript.wasm +0 -0
- package/dist/language/install.d.ts +50 -0
- package/dist/language/install.js +293 -0
- package/dist/language/lsp/client.d.ts +97 -0
- package/dist/language/lsp/client.js +340 -0
- package/dist/language/lsp/pool.d.ts +75 -0
- package/dist/language/lsp/pool.js +140 -0
- package/dist/language/lsp/service.d.ts +50 -0
- package/dist/language/lsp/service.js +174 -0
- package/dist/language/native.d.ts +8 -0
- package/dist/language/native.js +100 -0
- package/dist/language/platform.d.ts +14 -0
- package/dist/language/platform.js +20 -0
- package/dist/language/positions.d.ts +20 -0
- package/dist/language/positions.js +46 -0
- package/dist/language/syntax/assets.d.ts +9 -0
- package/dist/language/syntax/assets.js +73 -0
- package/dist/language/syntax/parser.d.ts +33 -0
- package/dist/language/syntax/parser.js +162 -0
- package/dist/language/typescript-capability.d.ts +6 -0
- package/dist/language/typescript-capability.js +42 -0
- package/dist/lisp/builtin-agents.d.ts +5 -0
- package/dist/lisp/builtin-agents.js +52 -0
- package/dist/lisp/config.d.ts +25 -0
- package/dist/lisp/config.js +202 -0
- package/dist/lisp/routing.d.ts +5 -0
- package/dist/lisp/routing.js +24 -0
- package/dist/lisp/runtime.d.ts +26 -0
- package/dist/lisp/runtime.js +107 -0
- package/dist/memory/kiokuko.d.ts +32 -0
- package/dist/memory/kiokuko.js +102 -0
- package/dist/memory/mcp.d.ts +38 -0
- package/dist/memory/mcp.js +211 -0
- package/dist/model/ai-sdk.d.ts +27 -0
- package/dist/model/ai-sdk.js +185 -0
- package/dist/model/chatgpt/login.d.ts +42 -0
- package/dist/model/chatgpt/login.js +180 -0
- package/dist/model/chatgpt/responses.d.ts +41 -0
- package/dist/model/chatgpt/responses.js +254 -0
- package/dist/model/chatgpt/tokens.d.ts +11 -0
- package/dist/model/chatgpt/tokens.js +50 -0
- package/dist/model/connection.d.ts +6 -0
- package/dist/model/connection.js +67 -0
- package/dist/model/context-window.d.ts +3 -0
- package/dist/model/context-window.js +64 -0
- package/dist/model/context.d.ts +11 -0
- package/dist/model/context.js +69 -0
- package/dist/model/factory.d.ts +27 -0
- package/dist/model/factory.js +89 -0
- package/dist/model/fixed.d.ts +17 -0
- package/dist/model/fixed.js +41 -0
- package/dist/model/harness-profile.d.ts +6 -0
- package/dist/model/harness-profile.js +23 -0
- package/dist/model/providers.d.ts +32 -0
- package/dist/model/providers.js +72 -0
- package/dist/model/reasoning.d.ts +16 -0
- package/dist/model/reasoning.js +84 -0
- package/dist/model/record-fetch.d.ts +2 -0
- package/dist/model/record-fetch.js +19 -0
- package/dist/plugins/api.d.ts +60 -0
- package/dist/plugins/api.js +1 -0
- package/dist/plugins/manager.d.ts +35 -0
- package/dist/plugins/manager.js +280 -0
- package/dist/plugins/package.d.ts +13 -0
- package/dist/plugins/package.js +99 -0
- package/dist/plugins/registry.d.ts +8 -0
- package/dist/plugins/registry.js +14 -0
- package/dist/session/store.d.ts +93 -0
- package/dist/session/store.js +311 -0
- package/dist/session/workspace.d.ts +19 -0
- package/dist/session/workspace.js +73 -0
- package/dist/subagents/head-assignment.d.ts +11 -0
- package/dist/subagents/head-assignment.js +47 -0
- package/dist/subagents/limits.d.ts +4 -0
- package/dist/subagents/limits.js +6 -0
- package/dist/subagents/processes.d.ts +18 -0
- package/dist/subagents/processes.js +73 -0
- package/dist/subagents/request.d.ts +4 -0
- package/dist/subagents/request.js +38 -0
- package/dist/subagents/service.d.ts +73 -0
- package/dist/subagents/service.js +645 -0
- package/dist/subagents/settings.d.ts +10 -0
- package/dist/subagents/settings.js +32 -0
- package/dist/subagents/types.d.ts +63 -0
- package/dist/subagents/types.js +1 -0
- package/dist/subagents/verification.d.ts +34 -0
- package/dist/subagents/verification.js +215 -0
- package/dist/tools/browse.d.ts +13 -0
- package/dist/tools/browse.js +117 -0
- package/dist/tools/browser-capability.d.ts +3 -0
- package/dist/tools/browser-capability.js +29 -0
- package/dist/tools/diff.d.ts +6 -0
- package/dist/tools/diff.js +82 -0
- package/dist/tools/edit.d.ts +3 -0
- package/dist/tools/edit.js +152 -0
- package/dist/tools/files.d.ts +6 -0
- package/dist/tools/files.js +96 -0
- package/dist/tools/formal-input.d.ts +6 -0
- package/dist/tools/formal-input.js +29 -0
- package/dist/tools/formal.d.ts +9 -0
- package/dist/tools/formal.js +79 -0
- package/dist/tools/guard.d.ts +7 -0
- package/dist/tools/guard.js +48 -0
- package/dist/tools/job-tools.d.ts +19 -0
- package/dist/tools/job-tools.js +148 -0
- package/dist/tools/jobs.d.ts +79 -0
- package/dist/tools/jobs.js +186 -0
- package/dist/tools/language.d.ts +6 -0
- package/dist/tools/language.js +172 -0
- package/dist/tools/lean-proof.d.ts +38 -0
- package/dist/tools/lean-proof.js +83 -0
- package/dist/tools/registry.d.ts +30 -0
- package/dist/tools/registry.js +113 -0
- package/dist/tools/run.d.ts +13 -0
- package/dist/tools/run.js +163 -0
- package/dist/tools/search.d.ts +2 -0
- package/dist/tools/search.js +156 -0
- package/dist/tools/shell-process.d.ts +115 -0
- package/dist/tools/shell-process.js +297 -0
- package/dist/tools/skills.d.ts +2 -0
- package/dist/tools/skills.js +46 -0
- package/dist/tools/stateright-runtime.d.ts +3 -0
- package/dist/tools/stateright-runtime.js +16 -0
- package/dist/tools/stateright.d.ts +3 -0
- package/dist/tools/stateright.js +78 -0
- package/dist/tools/web.d.ts +24 -0
- package/dist/tools/web.js +391 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/docs/ci-repair-20261116.md +30 -0
- package/docs/commonlisp-build-output.md +14 -0
- package/docs/commonlisp-provider-migration.md +22 -0
- package/docs/commonlisp-qlot-recovery.md +28 -0
- package/docs/commonlisp-tls-recovery.md +28 -0
- package/docs/context-efficiency.md +122 -0
- package/docs/input.md +126 -0
- package/docs/languages.md +117 -0
- package/docs/models.md +109 -0
- package/docs/modkh-evidence.json +641 -0
- package/docs/modkh-failure-comparison.json +675 -0
- package/docs/modkh-namespace.md +39 -0
- package/docs/modkh-qlot-evidence.json +37 -0
- package/docs/modkh-verification.md +173 -0
- package/docs/modkh.md +128 -0
- package/docs/presets.md +64 -0
- package/docs/setup.md +99 -0
- package/docs/stateright.md +45 -0
- package/docs/subagents.md +152 -0
- package/docs/web.md +57 -0
- package/experiments/presets/common-lisp.lisp +38 -0
- package/experiments/presets/css.lisp +38 -0
- package/experiments/presets/formal.lisp +18 -0
- package/experiments/presets/html.lisp +38 -0
- package/experiments/presets/js.lisp +38 -0
- package/experiments/presets/language-microagents.lisp +29 -0
- package/experiments/presets/php.lisp +38 -0
- package/experiments/presets/svelte.lisp +38 -0
- package/experiments/presets/tailwindcss.lisp +24 -0
- package/experiments/presets/ts.lisp +38 -0
- package/native/stateright/Cargo.lock +478 -0
- package/native/stateright/Cargo.toml +11 -0
- package/native/stateright/src/lib.rs +163 -0
- package/native/stateright/src/main.rs +38 -0
- package/package.json +57 -4
- package/plugins/modkh-explorer/index.mjs +3 -0
- package/plugins/modkh-explorer/plugin.json +1 -0
- package/plugins/modkh-worker/index.mjs +3 -0
- package/plugins/modkh-worker/plugin.json +1 -0
- package/skills/kiokuko-dsh/LICENSE +21 -0
- package/skills/kiokuko-dsh/coding-ideal-routine-skill/SKILL.md +106 -0
- package/skills/kiokuko-dsh/japanese-translation-for-oss-models/SKILL.md +65 -0
- package/skills/kiokuko-dsh/kiokuko-architecture/SKILL.md +20 -0
- package/skills/kiokuko-dsh/kiokuko-architecture/references/cases.md +11 -0
- package/skills/kiokuko-dsh/kiokuko-benchmark/SKILL.md +20 -0
- package/skills/kiokuko-dsh/kiokuko-benchmark/references/cases.md +11 -0
- package/skills/kiokuko-dsh/kiokuko-investigate/SKILL.md +20 -0
- package/skills/kiokuko-dsh/kiokuko-investigate/references/cases.md +11 -0
- package/skills/kiokuko-dsh/kiokuko-lisp/SKILL.md +390 -0
- package/skills/kiokuko-dsh/kiokuko-review/SKILL.md +20 -0
- package/skills/kiokuko-dsh/kiokuko-review/references/cases.md +11 -0
- package/skills/kiokuko-dsh/kiokuko-simple-work/SKILL.md +70 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/SKILL.md +79 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/boundaries-and-ownership.md +52 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/domain-and-types.md +48 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/effects-and-data.md +43 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/kiokuko-patterns.md +314 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/problem-shaping-and-language.md +90 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/protocols-and-idempotency.md +42 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/review-checklist.md +92 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/verification.md +45 -0
- package/skills/kiokuko-dsh/kiokuko-skill-authoring/SKILL.md +20 -0
- package/skills/kiokuko-dsh/kiokuko-skill-authoring/references/cases.md +11 -0
- package/skills/kiokuko-dsh/kiokuko-soul/SKILL.md +25 -0
- package/skills/kiokuko-dsh/kiokuko-technical-writing/SKILL.md +20 -0
- package/skills/kiokuko-dsh/kiokuko-technical-writing/references/cases.md +11 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/SKILL.md +64 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/accessibility-and-navigation.md +31 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/async-recovery.md +49 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/forms-and-controls.md +35 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/interaction-feedback.md +34 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/responsive-and-platform.md +38 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/safety-and-review.md +43 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/ui-checklist.md +75 -0
- package/skills/kiokuko-dsh/kiokuko-verification/SKILL.md +20 -0
- package/skills/kiokuko-dsh/kiokuko-verification/references/cases.md +11 -0
- package/skills/kiokuko-dsh/manifest.json +168 -0
- package/skills/kiokuko-dsh/memory-reasoning/SKILL.md +44 -0
- package/skills/kiokuko-dsh/one-shot-software-completion/SKILL.md +113 -0
- package/skills/kiokuko-dsh/one-shot-software-completion/references/boundaries-and-lifecycle.md +70 -0
- package/skills/kiokuko-dsh/one-shot-software-completion/references/discovery-and-scope.md +71 -0
- package/skills/kiokuko-dsh/one-shot-software-completion/references/failure-recovery.md +43 -0
- package/skills/kiokuko-dsh/one-shot-software-completion/references/verification-and-completion.md +73 -0
- package/skills/kiokuko-dsh/veteran-programmer-skill/SKILL.md +66 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import { ToolError } from "../agent/types.js";
|
|
2
|
+
import { resolveApiKey } from "../cli/keys.js";
|
|
3
|
+
/**
|
|
4
|
+
* 外部ネットワークへの取得。ワークスペース内に閉じない唯一の読み取り系ツールなので、
|
|
5
|
+
* `outsideWorkspace: true` で承認を求める。既定の `workspace` ポリシーでも `none` でも
|
|
6
|
+
* 毎回確認され、`all` のときだけ設定どおり自動になる(OSレベルの隔離ではない)。
|
|
7
|
+
*
|
|
8
|
+
* ここで行うのは取得だけであり、結果の真偽は保証しない。本文は上限で打ち切り、
|
|
9
|
+
* 打ち切ったことを必ず明示する(黙って切り詰めない)。
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_MAX_BYTES = 512 * 1024;
|
|
12
|
+
const MAX_BYTES_LIMIT = 2 * 1024 * 1024;
|
|
13
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
14
|
+
const MAX_TIMEOUT_MS = 120_000;
|
|
15
|
+
const MAX_REDIRECTS = 5;
|
|
16
|
+
/** 抽出後の本文としてモデルへ返す上限。超えたら末尾を落として明示する。 */
|
|
17
|
+
const TEXT_BUDGET = 32 * 1024;
|
|
18
|
+
const SEARCH_TIMEOUT_MS = 20_000;
|
|
19
|
+
const BRAVE_ENDPOINT = 'https://api.search.brave.com/res/v1/web/search';
|
|
20
|
+
const BRAVE_ENV = 'BRAVE_SEARCH_API_KEY';
|
|
21
|
+
const BRAVE_PROVIDER = 'brave-search';
|
|
22
|
+
function positiveInt(value, name, max) {
|
|
23
|
+
if (value === undefined)
|
|
24
|
+
return undefined;
|
|
25
|
+
const n = typeof value === 'string' && /^\d+$/.test(value.trim()) ? Number(value.trim()) : typeof value === 'number' ? value : Number.NaN;
|
|
26
|
+
if (!Number.isSafeInteger(n) || n < 1 || n > max)
|
|
27
|
+
throw new ToolError('INVALID_ARGS', `${name} は1〜${max}の整数で指定する`);
|
|
28
|
+
return n;
|
|
29
|
+
}
|
|
30
|
+
/** http/https のみ。資格情報つきURLは承認ログに秘密が載るため拒否する。 */
|
|
31
|
+
function parseTarget(input) {
|
|
32
|
+
if (typeof input !== 'string' || input.trim().length === 0 || input.length > 4096) {
|
|
33
|
+
throw new ToolError('INVALID_ARGS', 'url は1〜4096文字の文字列で指定する');
|
|
34
|
+
}
|
|
35
|
+
let url;
|
|
36
|
+
try {
|
|
37
|
+
url = new URL(input.trim());
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
throw new ToolError('INVALID_ARGS', `url を解釈できない: ${input}`);
|
|
41
|
+
}
|
|
42
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
43
|
+
throw new ToolError('INVALID_ARGS', `http/https のみ取得できる: ${url.protocol}`);
|
|
44
|
+
}
|
|
45
|
+
if (url.username || url.password) {
|
|
46
|
+
throw new ToolError('INVALID_ARGS', 'URLに資格情報を埋め込まない(承認の表示に秘密が載る)');
|
|
47
|
+
}
|
|
48
|
+
return url;
|
|
49
|
+
}
|
|
50
|
+
const ENTITIES = {
|
|
51
|
+
amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ', copy: '©', reg: '®',
|
|
52
|
+
hellip: '…', mdash: '—', ndash: '–', laquo: '«', raquo: '»', middot: '·',
|
|
53
|
+
};
|
|
54
|
+
function decodeEntities(text) {
|
|
55
|
+
return text.replace(/&(#[xX]?[0-9a-fA-F]+|[a-zA-Z]+);/g, (match, body) => {
|
|
56
|
+
if (body.startsWith('#')) {
|
|
57
|
+
const hex = body[1] === 'x' || body[1] === 'X';
|
|
58
|
+
const code = Number.parseInt(hex ? body.slice(2) : body.slice(1), hex ? 16 : 10);
|
|
59
|
+
if (!Number.isFinite(code) || code <= 0 || code > 0x10ffff)
|
|
60
|
+
return match;
|
|
61
|
+
try {
|
|
62
|
+
return String.fromCodePoint(code);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return match;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return ENTITIES[body.toLowerCase()] ?? match;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** タグを落とし、ブロック境界だけ改行として残す。整形結果の見た目は保証しない。 */
|
|
72
|
+
export function htmlToText(html) {
|
|
73
|
+
let text = html.replace(/<!--[\s\S]*?-->/g, ' ');
|
|
74
|
+
text = text.replace(/<(script|style|noscript|template|svg|head)\b[\s\S]*?<\/\1\s*>/gi, ' ');
|
|
75
|
+
text = text.replace(/<\/(p|div|li|tr|h[1-6]|section|article|header|footer|blockquote|pre|table|ul|ol)\s*>/gi, '\n');
|
|
76
|
+
text = text.replace(/<br\s*\/?>/gi, '\n');
|
|
77
|
+
text = text.replace(/<\/t[dh]\s*>/gi, '\t');
|
|
78
|
+
text = text.replace(/<[^>]*>/g, '');
|
|
79
|
+
text = decodeEntities(text);
|
|
80
|
+
return text
|
|
81
|
+
.replace(/\r\n?/g, '\n')
|
|
82
|
+
.replace(/[ \t\u00a0]+/g, ' ')
|
|
83
|
+
.replace(/ *\n */g, '\n')
|
|
84
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
85
|
+
.trim();
|
|
86
|
+
}
|
|
87
|
+
function clipText(text, budget) {
|
|
88
|
+
if (text.length <= budget)
|
|
89
|
+
return { text, clipped: 0 };
|
|
90
|
+
return { text: text.slice(0, budget), clipped: text.length - budget };
|
|
91
|
+
}
|
|
92
|
+
function charsetOf(contentType) {
|
|
93
|
+
const match = /charset\s*=\s*"?([^\s;"]+)/i.exec(contentType ?? '');
|
|
94
|
+
return match?.[1] ?? 'utf-8';
|
|
95
|
+
}
|
|
96
|
+
function decodeBody(bytes, contentType) {
|
|
97
|
+
try {
|
|
98
|
+
return new TextDecoder(charsetOf(contentType), { fatal: false }).decode(bytes);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return new TextDecoder('utf-8', { fatal: false }).decode(bytes);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function isTextual(contentType) {
|
|
105
|
+
if (!contentType)
|
|
106
|
+
return true;
|
|
107
|
+
const type = contentType.split(';')[0].trim().toLowerCase();
|
|
108
|
+
return type.startsWith('text/') || type === 'application/json' || type === 'application/xml'
|
|
109
|
+
|| type === 'application/xhtml+xml' || type === 'application/javascript' || type.endsWith('+json') || type.endsWith('+xml');
|
|
110
|
+
}
|
|
111
|
+
function isHtml(contentType) {
|
|
112
|
+
const type = (contentType ?? '').split(';')[0].trim().toLowerCase();
|
|
113
|
+
return type === 'text/html' || type === 'application/xhtml+xml';
|
|
114
|
+
}
|
|
115
|
+
async function readBounded(body, limit) {
|
|
116
|
+
if (!body)
|
|
117
|
+
return { bytes: new Uint8Array(0), truncated: false, total: 0 };
|
|
118
|
+
const reader = body.getReader();
|
|
119
|
+
const chunks = [];
|
|
120
|
+
let total = 0;
|
|
121
|
+
let truncated = false;
|
|
122
|
+
try {
|
|
123
|
+
for (;;) {
|
|
124
|
+
const { done, value } = await reader.read();
|
|
125
|
+
if (done)
|
|
126
|
+
break;
|
|
127
|
+
if (!value)
|
|
128
|
+
continue;
|
|
129
|
+
total += value.byteLength;
|
|
130
|
+
if (total > limit) {
|
|
131
|
+
chunks.push(value.subarray(0, value.byteLength - (total - limit)));
|
|
132
|
+
truncated = true;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
chunks.push(value);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
finally {
|
|
139
|
+
if (truncated)
|
|
140
|
+
await reader.cancel().catch(() => { });
|
|
141
|
+
else
|
|
142
|
+
reader.releaseLock();
|
|
143
|
+
}
|
|
144
|
+
const kept = Math.min(total, limit);
|
|
145
|
+
const joined = new Uint8Array(kept);
|
|
146
|
+
let offset = 0;
|
|
147
|
+
for (const chunk of chunks) {
|
|
148
|
+
if (offset >= kept)
|
|
149
|
+
break;
|
|
150
|
+
const slice = chunk.subarray(0, Math.min(chunk.byteLength, kept - offset));
|
|
151
|
+
joined.set(slice, offset);
|
|
152
|
+
offset += slice.byteLength;
|
|
153
|
+
}
|
|
154
|
+
return { bytes: joined, truncated, total };
|
|
155
|
+
}
|
|
156
|
+
function signalFor(ctx, timeoutMs) {
|
|
157
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
158
|
+
let timedOut = false;
|
|
159
|
+
timeout.addEventListener('abort', () => { timedOut = true; }, { once: true });
|
|
160
|
+
return {
|
|
161
|
+
signal: ctx.signal ? AbortSignal.any([ctx.signal, timeout]) : timeout,
|
|
162
|
+
timedOut: () => timedOut && !(ctx.signal?.aborted ?? false),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/** 1ホップごとに承認を取る。転送先は人間が承認したURLとは別の場所になり得るため。 */
|
|
166
|
+
async function approveFetch(ctx, url, step, extra) {
|
|
167
|
+
if (ctx.signal?.aborted)
|
|
168
|
+
throw new ToolError('NOT_EXECUTED', '中断済みのため取得しない');
|
|
169
|
+
const ok = await ctx.approval.approve({
|
|
170
|
+
kind: 'command',
|
|
171
|
+
title: `外部取得 (GET ${url.host})`,
|
|
172
|
+
detail: `${step}\nGET ${url.href}\n${extra}\n\n外部への通信であり、応答内容は検証されない。`,
|
|
173
|
+
outsideWorkspace: true,
|
|
174
|
+
...(ctx.signal ? { signal: ctx.signal } : {}),
|
|
175
|
+
});
|
|
176
|
+
if (!ok)
|
|
177
|
+
throw new ToolError('DENIED', '承認されなかったため取得しない');
|
|
178
|
+
if (ctx.signal?.aborted)
|
|
179
|
+
throw new ToolError('NOT_EXECUTED', '中断済みのため取得しない');
|
|
180
|
+
}
|
|
181
|
+
function describeFailure(url, error, signal, timedOut, timeoutMs) {
|
|
182
|
+
if (signal.aborted) {
|
|
183
|
+
if (timedOut())
|
|
184
|
+
return new ToolError('TIMEOUT', `${timeoutMs}ms で応答がないため打ち切った: ${url.href}`);
|
|
185
|
+
// 要求は送信済みかもしれない。再送の判断は呼び出し側に持たせる。
|
|
186
|
+
return new ToolError('RESULT_UNKNOWN', `中断により結果不明(要求は送信済みの可能性がある): ${url.href}`);
|
|
187
|
+
}
|
|
188
|
+
const cause = error instanceof Error ? (error.cause instanceof Error ? `${error.message} (${error.cause.message})` : error.message) : String(error);
|
|
189
|
+
return new ToolError('FETCH_FAILED', `取得できない: ${url.href} — ${cause}`);
|
|
190
|
+
}
|
|
191
|
+
export function createFetchUrlTool(options = {}) {
|
|
192
|
+
const maxBytesLimit = options.maxBytes ?? MAX_BYTES_LIMIT;
|
|
193
|
+
const defaultTimeout = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
194
|
+
return {
|
|
195
|
+
readOnly: true,
|
|
196
|
+
name: 'fetch_url',
|
|
197
|
+
operationIdentity: (args) => ({ url: typeof args.url === 'string' ? args.url.trim() : '' }),
|
|
198
|
+
description: 'http/https のURLを1件取得し、テキストとして返す。ワークスペース外への通信なので毎回承認を求める。'
|
|
199
|
+
+ 'HTMLはタグを落として本文だけにする。上限で打ち切った場合は明示する。'
|
|
200
|
+
+ '取得結果は事実の保証ではない(内容の検証はしない)。',
|
|
201
|
+
parameters: {
|
|
202
|
+
type: 'object',
|
|
203
|
+
properties: {
|
|
204
|
+
url: { type: 'string', maxLength: 4096, description: '取得するURL(http/https)' },
|
|
205
|
+
maxBytes: { type: 'number', description: `本文のバイト上限(既定 ${DEFAULT_MAX_BYTES}、最大 ${MAX_BYTES_LIMIT})` },
|
|
206
|
+
timeoutMs: { type: 'number', description: `制限時間(ms、既定 ${DEFAULT_TIMEOUT_MS}、最大 ${MAX_TIMEOUT_MS})` },
|
|
207
|
+
},
|
|
208
|
+
required: ['url'],
|
|
209
|
+
},
|
|
210
|
+
async execute(args, ctx) {
|
|
211
|
+
const target = parseTarget(args.url);
|
|
212
|
+
const maxBytes = Math.min(positiveInt(args.maxBytes, 'maxBytes', maxBytesLimit) ?? DEFAULT_MAX_BYTES, MAX_BYTES_LIMIT);
|
|
213
|
+
const timeoutMs = positiveInt(args.timeoutMs, 'timeoutMs', MAX_TIMEOUT_MS) ?? defaultTimeout;
|
|
214
|
+
let remainingMs = timeoutMs;
|
|
215
|
+
let url = target;
|
|
216
|
+
const hops = [];
|
|
217
|
+
for (let hop = 0;; hop++) {
|
|
218
|
+
await approveFetch(ctx, url, hop === 0 ? '外部URLの取得' : `転送 ${hop} 回目の取得先`, `本文上限 ${maxBytes} バイト / 通信時間の上限 ${timeoutMs}ms(承認待ちを除く)`);
|
|
219
|
+
const started = performance.now();
|
|
220
|
+
const { signal, timedOut } = signalFor(ctx, Math.ceil(remainingMs));
|
|
221
|
+
let response;
|
|
222
|
+
try {
|
|
223
|
+
response = await fetch(url, { method: 'GET', redirect: 'manual', signal, headers: { accept: 'text/html,application/json,text/plain;q=0.9,*/*;q=0.5' } });
|
|
224
|
+
}
|
|
225
|
+
catch (e) {
|
|
226
|
+
throw describeFailure(url, e, signal, timedOut, timeoutMs);
|
|
227
|
+
}
|
|
228
|
+
const location = response.headers.get('location');
|
|
229
|
+
if (response.status >= 300 && response.status < 400 && location) {
|
|
230
|
+
await response.body?.cancel().catch(() => { });
|
|
231
|
+
if (hop >= MAX_REDIRECTS) {
|
|
232
|
+
throw new ToolError('FETCH_FAILED', `転送が ${MAX_REDIRECTS} 回を超えたため打ち切った: ${target.href} → ${url.href}`);
|
|
233
|
+
}
|
|
234
|
+
let next;
|
|
235
|
+
try {
|
|
236
|
+
next = new URL(location, url);
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
throw new ToolError('FETCH_FAILED', `転送先のURLを解釈できない: ${location}`);
|
|
240
|
+
}
|
|
241
|
+
// 転送先も同じ規則で検証してから、改めて承認を取る。
|
|
242
|
+
if (next.protocol !== 'http:' && next.protocol !== 'https:') {
|
|
243
|
+
throw new ToolError('FETCH_FAILED', `転送先が http/https ではない: ${next.protocol}`);
|
|
244
|
+
}
|
|
245
|
+
if (next.username || next.password)
|
|
246
|
+
throw new ToolError('FETCH_FAILED', '転送先のURLに資格情報が含まれる');
|
|
247
|
+
hops.push(`${response.status} ${url.href} → ${next.href}`);
|
|
248
|
+
remainingMs -= performance.now() - started;
|
|
249
|
+
if (remainingMs <= 0)
|
|
250
|
+
throw new ToolError('TIMEOUT', `通信時間が上限 ${timeoutMs}ms に達した: ${url.href}`);
|
|
251
|
+
url = next;
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
let read;
|
|
255
|
+
try {
|
|
256
|
+
read = await readBounded(response.body, maxBytes);
|
|
257
|
+
}
|
|
258
|
+
catch (e) {
|
|
259
|
+
if (signal.aborted)
|
|
260
|
+
throw describeFailure(url, e, signal, timedOut, timeoutMs);
|
|
261
|
+
throw new ToolError('RESULT_UNKNOWN', `本文の受信が途中で失敗した(欠けている可能性がある): ${e.message}`);
|
|
262
|
+
}
|
|
263
|
+
if (signal.aborted)
|
|
264
|
+
throw describeFailure(url, undefined, signal, timedOut, timeoutMs);
|
|
265
|
+
const contentType = response.headers.get('content-type');
|
|
266
|
+
const head = [
|
|
267
|
+
`GET ${target.href}`,
|
|
268
|
+
`状態: ${response.status} ${response.statusText}`.trimEnd(),
|
|
269
|
+
`content-type: ${contentType ?? '(なし)'}`,
|
|
270
|
+
`受信: ${read.total} バイト${read.truncated ? `(上限 ${maxBytes} バイトで打ち切り)` : ''}`,
|
|
271
|
+
...(url.href !== target.href ? [`最終URL: ${url.href}`] : []),
|
|
272
|
+
...(hops.length ? [`転送: ${hops.length} 回`] : []),
|
|
273
|
+
];
|
|
274
|
+
if (!isTextual(contentType)) {
|
|
275
|
+
return [...head, '', '本文はテキストではないため表示しない(バイナリ)。'].join('\n');
|
|
276
|
+
}
|
|
277
|
+
if (read.bytes.byteLength === 0)
|
|
278
|
+
return [...head, '', '本文は空。'].join('\n');
|
|
279
|
+
const raw = decodeBody(read.bytes, contentType);
|
|
280
|
+
const bodyText = isHtml(contentType) ? htmlToText(raw) : raw;
|
|
281
|
+
const clipped = clipText(bodyText, TEXT_BUDGET);
|
|
282
|
+
return [
|
|
283
|
+
...head,
|
|
284
|
+
'',
|
|
285
|
+
isHtml(contentType) ? '本文(HTML→テキスト):' : '本文:',
|
|
286
|
+
clipped.text.length ? clipped.text : '(本文なし)',
|
|
287
|
+
...(clipped.clipped ? [`…(本文は上限 ${TEXT_BUDGET} 文字で打ち切り。残り ${clipped.clipped} 文字)`] : []),
|
|
288
|
+
...(read.truncated ? ['…(受信は上記のバイト上限で打ち切り。続きは未取得)'] : []),
|
|
289
|
+
].join('\n');
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
/** Brave の応答から必要な3項目だけを取り出す。形が違う場合は失敗として返す。 */
|
|
295
|
+
export function parseBraveResults(body, limit) {
|
|
296
|
+
const results = body?.web?.results;
|
|
297
|
+
if (!Array.isArray(results))
|
|
298
|
+
return [];
|
|
299
|
+
const out = [];
|
|
300
|
+
for (const row of results) {
|
|
301
|
+
if (out.length >= limit)
|
|
302
|
+
break;
|
|
303
|
+
if (typeof row?.url !== 'string' || !row.url.startsWith('http'))
|
|
304
|
+
continue;
|
|
305
|
+
out.push({
|
|
306
|
+
title: htmlToText(typeof row.title === 'string' ? row.title : ''),
|
|
307
|
+
url: row.url,
|
|
308
|
+
description: htmlToText(typeof row.description === 'string' ? row.description : ''),
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
return out;
|
|
312
|
+
}
|
|
313
|
+
export function createWebSearchTool(options = {}) {
|
|
314
|
+
const endpoint = options.searchEndpoint ?? BRAVE_ENDPOINT;
|
|
315
|
+
const lookup = options.keyLookup ?? ((env) => resolveApiKey(BRAVE_PROVIDER, env, BRAVE_ENV));
|
|
316
|
+
return {
|
|
317
|
+
readOnly: true,
|
|
318
|
+
name: 'web_search',
|
|
319
|
+
description: 'Web検索を1回行い、タイトル・URL・要約だけを返す(本文は fetch_url で取る)。'
|
|
320
|
+
+ `ワークスペース外への通信なので毎回承認を求める。キーは環境変数 ${BRAVE_ENV} か保存済みキー(${BRAVE_PROVIDER})を使う。`,
|
|
321
|
+
parameters: {
|
|
322
|
+
type: 'object',
|
|
323
|
+
properties: {
|
|
324
|
+
query: { type: 'string', maxLength: 400, description: '検索語(1〜400文字)' },
|
|
325
|
+
count: { type: 'number', description: '件数(1〜10、既定5)' },
|
|
326
|
+
},
|
|
327
|
+
required: ['query'],
|
|
328
|
+
},
|
|
329
|
+
operationIdentity: (args) => ({ query: typeof args.query === 'string' ? args.query.trim() : '', count: args.count ?? 5 }),
|
|
330
|
+
async execute(args, ctx) {
|
|
331
|
+
const query = typeof args.query === 'string' ? args.query.trim() : '';
|
|
332
|
+
if (!query || query.length > 400 || /[\r\n\0]/.test(query)) {
|
|
333
|
+
throw new ToolError('INVALID_ARGS', 'query は1〜400文字で改行を含まない文字列で指定する');
|
|
334
|
+
}
|
|
335
|
+
const count = positiveInt(args.count, 'count', 10) ?? 5;
|
|
336
|
+
const key = lookup(process.env);
|
|
337
|
+
if (!key) {
|
|
338
|
+
throw new ToolError('NO_KEY', `検索にはAPIキーが必要(環境変数 ${BRAVE_ENV} か、/keys の保存先に ${BRAVE_PROVIDER} を登録する)`);
|
|
339
|
+
}
|
|
340
|
+
const url = new URL(endpoint);
|
|
341
|
+
url.searchParams.set('q', query);
|
|
342
|
+
url.searchParams.set('count', String(count));
|
|
343
|
+
if (ctx.signal?.aborted)
|
|
344
|
+
throw new ToolError('NOT_EXECUTED', '中断済みのため実行しない');
|
|
345
|
+
const ok = await ctx.approval.approve({
|
|
346
|
+
kind: 'command',
|
|
347
|
+
title: `Web検索 (${url.host})`,
|
|
348
|
+
detail: `GET ${url.href}\nクエリ: ${query}\n件数: ${count} 件まで\n\n検索語と利用状況が外部サービスへ送られる。`,
|
|
349
|
+
outsideWorkspace: true,
|
|
350
|
+
...(ctx.signal ? { signal: ctx.signal } : {}),
|
|
351
|
+
});
|
|
352
|
+
if (!ok)
|
|
353
|
+
throw new ToolError('DENIED', '承認されなかったため実行しない');
|
|
354
|
+
if (ctx.signal?.aborted)
|
|
355
|
+
throw new ToolError('NOT_EXECUTED', '中断済みのため実行しない');
|
|
356
|
+
const { signal, timedOut } = signalFor(ctx, options.timeoutMs ?? SEARCH_TIMEOUT_MS);
|
|
357
|
+
let response;
|
|
358
|
+
try {
|
|
359
|
+
response = await fetch(url, {
|
|
360
|
+
method: 'GET',
|
|
361
|
+
redirect: 'error',
|
|
362
|
+
signal,
|
|
363
|
+
headers: { accept: 'application/json', 'x-subscription-token': key },
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
catch (e) {
|
|
367
|
+
throw describeFailure(url, e, signal, timedOut, options.timeoutMs ?? SEARCH_TIMEOUT_MS);
|
|
368
|
+
}
|
|
369
|
+
if (!response.ok) {
|
|
370
|
+
await response.body?.cancel().catch(() => { });
|
|
371
|
+
// キーは応答にも要求にも出さない。状態だけを返す。
|
|
372
|
+
throw new ToolError('SEARCH_FAILED', `検索APIが失敗した: ${response.status} ${response.statusText}`.trimEnd());
|
|
373
|
+
}
|
|
374
|
+
let body;
|
|
375
|
+
try {
|
|
376
|
+
body = await response.json();
|
|
377
|
+
}
|
|
378
|
+
catch {
|
|
379
|
+
throw new ToolError('RESULT_UNKNOWN', '検索結果をJSONとして読めなかった(結果不明)');
|
|
380
|
+
}
|
|
381
|
+
const hits = parseBraveResults(body, count);
|
|
382
|
+
if (hits.length === 0)
|
|
383
|
+
return `検索 "${query}": 0 件。結果の形が想定と違うか、該当なし。`;
|
|
384
|
+
const lines = hits.map((hit, i) => `${i + 1}. ${hit.title || '(無題)'}\n ${hit.url}${hit.description ? `\n ${hit.description}` : ''}`);
|
|
385
|
+
return [`検索 "${query}": ${hits.length} 件(上限 ${count} 件)`, ...lines].join('\n');
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
export const fetchUrlTool = createFetchUrlTool();
|
|
390
|
+
export const webSearchTool = createWebSearchTool();
|
|
391
|
+
export const webTools = [fetchUrlTool, webSearchTool];
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# CIとCL+SSL依存ロードの修正
|
|
2
|
+
|
|
3
|
+
2026-11-16 JST。実装先 `/Users/dkc/Sites/Src/mdkh`、開始HEAD `59d4dd7`。
|
|
4
|
+
|
|
5
|
+
## 確認したCI
|
|
6
|
+
|
|
7
|
+
[run 43768392131](https://github.com/askdkc/MoDKH/actions/runs/43768392131)、対象 `b84ab3d`。
|
|
8
|
+
|
|
9
|
+
- Ubuntu:424成功・18失敗・10skip。17件がSBCL欠落に伴う失敗、1件がTUIの表記不一致。
|
|
10
|
+
- macOS:425成功・19失敗・8skip。上記に加えてバックグラウンドジョブの終了判定試験が失敗。
|
|
11
|
+
- 両OSともbuildは成功。tarball受入工程はテスト失敗により未実行。
|
|
12
|
+
|
|
13
|
+
workflowにLinuxのSBCL/build-essential導入とmacOSのSBCL導入を追加。実行前にSBCL/ASDF・cc・makeを確認する。従来buildのみだった工程でtypecheckも実行する。TUI試験の期待表記を実仕様の `MoDKH` に修正。ジョブ試験は経過時間で完了を仮定せず、呼出元が子の後半を解放し、増分出力と実際の完了状態を別々に確認する。
|
|
14
|
+
|
|
15
|
+
## 追加で報告されたCommon Lisp障害
|
|
16
|
+
|
|
17
|
+
ユーザーの新しい `last-failure.json` で、`runtime-warmup` の `TRIVIAL-GRAY-STREAMS not found` を確認。専用Quicklisp環境で `cl+ssl/config` のみをロードした後、ASDFにCL+SSL全体の強制ロードを要求していた。ASDFは不足した依存を取得しないため、先に `ql:quickload "cl+ssl"` で依存を解決するよう修正した。
|
|
18
|
+
|
|
19
|
+
実SBCLの隔離fixtureで、依存が未登録の旧順序は失敗し、Quicklisp役が依存ASDを供給する新順序は成功することを確認。これは実Quicklispのネットワーク取得試験ではない。実CL-LSP全体の起動成功も未確認。
|
|
20
|
+
|
|
21
|
+
## 最終検証
|
|
22
|
+
|
|
23
|
+
- `npm run typecheck` / `npm run build` / `git diff --check`:成功。YAML構文チェック成功。
|
|
24
|
+
- 関連63試験成功(jobs、Lisp設定・委譲、Common Lisp、packed grammar)。
|
|
25
|
+
- source入口と再build済みdist入口をTTYストリームとして起動し、MoDKH表示と `/exit` の終了0を確認。初回の補助probeはTERM=dumbを引き継いでplain表示になりタイムアウトしたため、実CI試験と同じTERMで再確認した。HTTP通信を含む全TUI試験の成功とは区別する。
|
|
26
|
+
- `npm test`:457件、391成功・58失敗・8skip。58失敗の名前・error・codeは履歴 `tls-fix/full-final.log` と一致。ローカル実行環境のHTTP待受EPERM57件、watch EMFILE1件。GitHub上の18/19失敗とは異なる。
|
|
27
|
+
- `sh scripts/acceptance.sh`:tarball作成後、隔離インストールで `registry.npmjs.org` のENOTFOUND。受入成功とは扱わない。
|
|
28
|
+
- 証跡:`.dkh-feasibility/ci-repair/`。source/dist digestは同ディレクトリの `identity.json`。
|
|
29
|
+
|
|
30
|
+
既存・並行編集のREADMEとドキュメントは保持。グローバル環境更新・commit・pushは未実施。修正後のGitHub Actions実行は未確認。
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# CL-LSPビルド出力の上限修正(2026-11-16)
|
|
2
|
+
|
|
3
|
+
ユーザーの `last-failure.json` で、`bundled-runtime-install` のstderrが524,288バイトちょうどで途切れていた。従来の実行器は512 KiBを超えるとプロセス群を停止し、後始末を確認できなかった場合は元の停止原因をunknownで上書きしていた。
|
|
4
|
+
|
|
5
|
+
CL-LSPのbundled buildのみ、保持上限を16 MiB(16,777,216バイト)へ拡大し、超過時は末尾を保持して処理を続ける方式に変更。総出力量と省略の有無をreceiptに記録する。通常の検証コマンドは従来どおり超過で停止する。timeout/abortと終了処理の確認は両方式で維持。終了処理がunknownでも、元の停止原因をterminationReasonに保持する。
|
|
6
|
+
|
|
7
|
+
- 17 MiB超のstderrを出す実プロセスがexit0で完了し、末尾16 MiBと完了マーカーを保持する回帰試験に成功。
|
|
8
|
+
- 通常の出力量制限による停止、UTF-8境界、tail方式でもtimeoutすること、stderrが満杯でも最後のstdoutを取得できることを確認。
|
|
9
|
+
- 関連11試験成功。最終sourceの型検査・build・diff check成功。
|
|
10
|
+
- リポジトリ内の検証用snapshotから実CL-LSPを新しいprefix/cacheへ再ビルド。588,347バイトの出力を生成し、exit0・cleanup settled。生成ランチャーの `--help` も成功。LSP初期化・定義応答の検証とは別。
|
|
11
|
+
|
|
12
|
+
ログ:`.dkh-feasibility/build-output/`。実ビルド後に追加したstdout/stderr間の保持枠調整は、最終の実プロセス回帰試験で確認した。グローバルインストールと、以前cleanupがunknownだった試行の削除・プロセス操作は行っていない。
|
|
13
|
+
|
|
14
|
+
旧失敗記録が再試行を止める場合は、更新したグローバル版で `modkh language retry commonlisp` を実行してから導入する。commit・pushはしていない。
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Common Lispサーバー切替(2026-11-16)
|
|
2
|
+
|
|
3
|
+
現在のMacリポジトリで、自動導入元を `askdkc/cl-lsp` に変更。
|
|
4
|
+
|
|
5
|
+
- 専用領域に新しいcheckoutを取得し、付属 `scripts/install-headless.ros --prefix` で構築する。依存は `vendor/`。取得revision、同梱ソース一覧・installer・launcherのdigestを記録。
|
|
6
|
+
- 旧Lemの追加取得、Qlot、独自ASDFレジストリ修復、Autotools、CL+SSL/OpenSSL選択コードを削除。不要になった専用テストを、新しい導入契約と失敗経路のテストに置換。
|
|
7
|
+
- 旧提供元の成功receiptを再利用しない。旧提供元の失敗キャッシュで新しい導入を停止させない。autoInstall=falseは従来どおり通信・書込みを行わない。
|
|
8
|
+
- 実initialize、ファイル同期、定義応答によるready判定、未評価global定義と診断の観測、SBCL補助診断の非評価境界は維持。
|
|
9
|
+
- 手動手順は `ros install askdkc/cl-lsp`。既存のグローバル設定やインストールは変更していない。
|
|
10
|
+
|
|
11
|
+
## 検証
|
|
12
|
+
|
|
13
|
+
Darwin arm64。既存のローカル `askdkc/cl-lsp` checkout(clean、revision `594f9be291159e146fc2d51d3c3b56f93f227a7c`)をリポジトリ内の検証専用snapshotにコピー。private HOME/ROSWELL_HOMEと既存のsystem SBCLで、新しいMoDKH導入関数を実行し、ネイティブ/Lispビルドと生成ランチャーの `--help` が成功した。ネットワークからの冷開始取得試験とは区別する。
|
|
14
|
+
|
|
15
|
+
生成ランチャーを実LSPクライアントから `--stdio` で起動。最初の8秒期限では初期化が完了せず、45秒期限で再確認すると `USOCKET:OPERATION-NOT-PERMITTED-ERROR` が記録された。内部ソケットが実行環境に拒否され、initializeはタイムアウト。両試行とも終了処理は確認済み。同期・定義・診断の実応答には到達していない。未応答をreadyに変更していない。
|
|
16
|
+
|
|
17
|
+
- 最終sourceの型検査・build・`git diff --check`:成功。dist再生成済み。
|
|
18
|
+
- Common Lisp・Roswell関連:17成功。
|
|
19
|
+
- 全体:450件、384成功・58失敗・8skip。58失敗は履歴 `ci-repair/full-final.log` と試験名・error・codeが一致(HTTP EPERM57、watch EMFILE1)。旧依存処理の削除に伴い全試験数は減っている。
|
|
20
|
+
- Linux実動作、ネットワークからの全自動導入、グローバル版への反映は未検証/未実施。PLAN全体は未完了。
|
|
21
|
+
|
|
22
|
+
証跡:`.dkh-feasibility/askdkc-cl-lsp/`(build-receipts.json、lsp-45s.json、full-final.log、comparison.json、identity.json)。commit・pushは行っていない。
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# CL-LSP導入のQlot判定修正
|
|
2
|
+
|
|
3
|
+
2026-11-15、`/Users/dkc/Sites/Src/mdkh`、HEAD `018c1bc` に対する未コミット変更。Darwin arm64。開始時の作業ツリーはclean。
|
|
4
|
+
|
|
5
|
+
## 実測と修正
|
|
6
|
+
|
|
7
|
+
ユーザー環境の `last-failure.json` はQlot bootstrap成功後、`qlot-capability` が stdout `Qlot 1.8.4\n`、stderr空、exit255、cleanup settledで停止していた。
|
|
8
|
+
|
|
9
|
+
[Qlot CLI](https://github.com/fukamachi/qlot/blob/master/src/cli.lisp) の `--version` は `print-version` 後に `(uiop:quit -1)` を呼ぶ。この終了を導入失敗と扱ったMoDKH側のバグ。255全般を許容せず、RoswellからASDFの `qlot/cli` ロード、関数の存在、版情報付き専用証跡を確認する方式に変更した。正常終了と終了処理の確認も必要。
|
|
10
|
+
|
|
11
|
+
[async-process ASD](https://github.com/lem-project/async-process/blob/master/src/async-process.asd) は `src/` にあり、[GNUmakefile](https://github.com/lem-project/async-process/blob/master/GNUmakefile) は親にある。旧コードはASDのディレクトリでmakeしていた。所有領域内の実ソースからビルド入口を探索し、欠落時は拒否する。Autoconf・Automake・Libtoolの能力確認を追加。macOSではHomebrewのglibtoolizeを確認する。
|
|
12
|
+
|
|
13
|
+
失敗メッセージにstdoutとcleanupを追加。定義参照probeは空白のcharacter16から、参照するvalueの開始位置17に修正した。ただし実CL-LSPでの定義応答は今回未検証。
|
|
14
|
+
|
|
15
|
+
## 検証
|
|
16
|
+
|
|
17
|
+
- `npm run typecheck`: 成功。
|
|
18
|
+
- `npm run build`: 成功、文法12件・スキル17件。同じsourceからdistを再生成。
|
|
19
|
+
- `node --test test/language.commonlisp*.test.ts test/language.roswell-archive.test.ts`: 最終変更後19成功。
|
|
20
|
+
- 実SBCLの回帰試験で旧version判定が255になること、新しい生成probeがfixture CLIをロードして専用証跡を返すことを確認。実Qlot全体の再導入試験とは区別する。
|
|
21
|
+
- `npm test`: 最終変更後452件、386成功・58失敗・8skip。
|
|
22
|
+
- 58失敗は履歴ログ `namespace/full.log` と試験名・error・codeを重複も含め照合し一致。57 HTTP EPERM、1 watch EMFILE。変更直前の全体再実行との比較ではない。
|
|
23
|
+
- skipはLean6件(transitive sorry、sorry、false theorem、custom axiom、generated axiom、true theorem)、TLC2件(good.cfg、bad.cfg)。必要runtime/設定なし。
|
|
24
|
+
- `git diff --check`: 成功。
|
|
25
|
+
|
|
26
|
+
再ビルド済み `dist/language/commonlisp-install.js` から、リポジトリ内の空の専用領域に実導入を試行。`release-metadata` で `ENOTFOUND: getaddrinfo ENOTFOUND api.github.com`。ユーザーのQlotまで進んだ実行とは別の制限。実CL-LSP起動・同期・定義・診断は未検証。Linux実機も未検証。PLAN全体は未完了。
|
|
27
|
+
|
|
28
|
+
ログは `.dkh-feasibility/qlot-exit-fix/`。source SHA256: `6b47e6ef35178575382eb62e57ebdc91e333c688b2033d9a652a02f095fedf50`。dist SHA256: `10376e47264238d2eda156d78f2ca81a1ca5b7265da9fff5a251dfab4839fe48`(`scripts/modkh-source-identity.mjs`)。グローバルインストール・commit・pushは行っていない。
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# macOSのQlot / CL+SSL修正(2026-11-16 JST)
|
|
2
|
+
|
|
3
|
+
対象は `/Users/dkc/Sites/Src/mdkh`、Darwin arm64。既存のロゴ変更とREADMEの編集用ファイルには触れていない。
|
|
4
|
+
|
|
5
|
+
## 原因と変更
|
|
6
|
+
|
|
7
|
+
ユーザーの `last-failure.json` の `lem-dependencies` には、`The alien function "ASN1_STRING_data" is undefined.` が記録されていた。今回の直接原因はDNSではない。Qlotが案内した詳細ログは、MoDKHの失敗後cleanupによって既に削除されていた。
|
|
8
|
+
|
|
9
|
+
このMacの `/opt/homebrew/opt/openssl/lib/libcrypto.dylib` は `ASN1_STRING_get0_data` を提供するが `ASN1_STRING_data` を提供しない。CL+SSLの実ソースは後者を使用する。標準の選択で実SBCLから同じエラー(exit1)を再現した。
|
|
10
|
+
|
|
11
|
+
- macOSのHomebrew配下にあるOpenSSLのペアを探索し、別プロセスで実ロードして必要なAPIを確認する。バージョン番号で合否を決めない。今回は標準のライブラリを拒否し、既存の `/opt/homebrew/Cellar/openssl@3/3.5.9/lib` を選択した。コードにこの版は固定していない。
|
|
12
|
+
- CL+SSLの公式設定APIでライブラリの実パスを指定し、再コンパイルして、別ライブラリ向けのコンパイル済み条件分岐を持ち越さない。Qlotは設定を読み込んだRoswellプロセスから呼ぶ。CL-LSPの起動準備にも同じ設定を渡す。
|
|
13
|
+
- コンパイル出力はstderrに流し、LSPのstdoutを汚さない。証明書検証の無効化、HTTPへの置換、Homebrewのリンク変更は行わない。
|
|
14
|
+
- 失敗時の `qlot-error-*.log` は、通常ファイルかつ2 MiB以下のものを `last-failure.json` の `diagnostics` に保存してから作業領域を削除する。
|
|
15
|
+
|
|
16
|
+
参照した実ソース:[Qlot HTTP](https://github.com/fukamachi/qlot/blob/master/src/http.lisp)、[CL+SSL FFI](https://github.com/cl-plus-ssl/cl-plus-ssl/blob/master/src/ffi.lisp)、[CL+SSLライブラリ選択](https://github.com/cl-plus-ssl/cl-plus-ssl/blob/master/src/reload.lisp)。ローカルCL+SSLの `src/config.lisp` で明示設定APIも確認した。
|
|
17
|
+
|
|
18
|
+
## 最終検証
|
|
19
|
+
|
|
20
|
+
- 実SBCL / 実CL+SSL:標準設定は同じ未定義関数エラー。生成した修正設定ではASN1文字列を作成し、`ASN1_STRING_data` を呼び、解放してexit0。stdoutは専用成功証跡のみ。この試験はローカルASDF依存を使用し、Quicklispのダウンロードは行っていない。
|
|
21
|
+
- `npm run typecheck`、`npm run build`、`git diff --check`:成功。
|
|
22
|
+
- `node --test test/language.commonlisp*.test.ts`:21成功。ロード対象のAPI欠損、未完了出力、TLS設定の順序、失敗ログ保存を含む。
|
|
23
|
+
- `npm test`:456件、390成功・58失敗・8skip。履歴 `qlot-exit-fix/full-final.log` と58件の試験名・error・codeが一致。HTTP待受EPERM57件、watch EMFILE1件。変更直前の新規実行との比較ではない。
|
|
24
|
+
- skipはLean6件とTLC2件で、必要runtimeまたは設定がない既存試験。
|
|
25
|
+
|
|
26
|
+
詳細ログとsource/distの同一性記録:`.dkh-feasibility/tls-fix/`。最終sourceからdistを再ビルドした。グローバル版の更新・commit・pushはしていない。
|
|
27
|
+
|
|
28
|
+
CL-LSPの冷開始からの依存取得、initialize、定義参照、診断までの通し試験は今回未実施。今回実証したのは、このMacでのCL+SSLエラーの再現と解消、導入コードへの接続、回帰試験の範囲。Linuxの実ライブラリ試験は行っていない。PLAN全体は未完了。
|