modkh 0.0.0-stage → 0.1.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 +24 -2
- package/dist/agent/bundled-skills.d.ts +13 -0
- package/dist/agent/bundled-skills.js +95 -0
- package/dist/agent/images.d.ts +10 -0
- package/dist/agent/images.js +33 -0
- package/dist/agent/loop.d.ts +56 -0
- package/dist/agent/loop.js +155 -0
- package/dist/agent/skills.d.ts +20 -0
- package/dist/agent/skills.js +169 -0
- package/dist/agent/types.d.ts +132 -0
- package/dist/agent/types.js +12 -0
- package/dist/cli/agents.d.ts +8 -0
- package/dist/cli/agents.js +12 -0
- package/dist/cli/approval.d.ts +27 -0
- package/dist/cli/approval.js +62 -0
- package/dist/cli/catalog.d.ts +39 -0
- package/dist/cli/catalog.js +76 -0
- package/dist/cli/chat.d.ts +18 -0
- package/dist/cli/chat.js +733 -0
- package/dist/cli/clipboard.d.ts +9 -0
- package/dist/cli/clipboard.js +54 -0
- package/dist/cli/color.d.ts +42 -0
- package/dist/cli/color.js +176 -0
- package/dist/cli/config.d.ts +41 -0
- package/dist/cli/config.js +188 -0
- package/dist/cli/editor.d.ts +16 -0
- package/dist/cli/editor.js +77 -0
- package/dist/cli/keys.d.ts +18 -0
- package/dist/cli/keys.js +82 -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/models.d.ts +4 -0
- package/dist/cli/models.js +69 -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 +46 -0
- package/dist/cli/providers.js +76 -0
- package/dist/cli/terminal.d.ts +143 -0
- package/dist/cli/terminal.js +742 -0
- package/dist/cli/usage.d.ts +29 -0
- package/dist/cli/usage.js +75 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +164 -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 +14 -0
- package/dist/language/commonlisp-install.js +213 -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 +337 -0
- package/dist/language/lsp/pool.d.ts +67 -0
- package/dist/language/lsp/pool.js +122 -0
- package/dist/language/lsp/service.d.ts +46 -0
- package/dist/language/lsp/service.js +138 -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 +24 -0
- package/dist/language/syntax/parser.js +144 -0
- package/dist/language/typescript-capability.d.ts +6 -0
- package/dist/language/typescript-capability.js +42 -0
- package/dist/lisp/config.d.ts +16 -0
- package/dist/lisp/config.js +159 -0
- package/dist/lisp/routing.d.ts +5 -0
- package/dist/lisp/routing.js +24 -0
- package/dist/lisp/runtime.d.ts +21 -0
- package/dist/lisp/runtime.js +83 -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 +180 -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 +202 -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 +65 -0
- package/dist/model/context.d.ts +9 -0
- package/dist/model/context.js +69 -0
- package/dist/model/factory.d.ts +25 -0
- package/dist/model/factory.js +88 -0
- package/dist/model/fixed.d.ts +17 -0
- package/dist/model/fixed.js +41 -0
- package/dist/model/reasoning.d.ts +16 -0
- package/dist/model/reasoning.js +62 -0
- package/dist/plugins/api.d.ts +60 -0
- package/dist/plugins/api.js +1 -0
- package/dist/plugins/manager.d.ts +34 -0
- package/dist/plugins/manager.js +261 -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 +82 -0
- package/dist/session/store.js +285 -0
- package/dist/session/workspace.d.ts +19 -0
- package/dist/session/workspace.js +73 -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 +21 -0
- package/dist/subagents/service.d.ts +39 -0
- package/dist/subagents/service.js +352 -0
- package/dist/subagents/settings.d.ts +10 -0
- package/dist/subagents/settings.js +32 -0
- package/dist/subagents/types.d.ts +43 -0
- package/dist/subagents/types.js +1 -0
- package/dist/subagents/verification.d.ts +31 -0
- package/dist/subagents/verification.js +178 -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.d.ts +8 -0
- package/dist/tools/formal.js +77 -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 +77 -0
- package/dist/tools/jobs.js +181 -0
- package/dist/tools/language.d.ts +6 -0
- package/dist/tools/language.js +174 -0
- package/dist/tools/registry.d.ts +28 -0
- package/dist/tools/registry.js +105 -0
- package/dist/tools/run.d.ts +13 -0
- package/dist/tools/run.js +159 -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 +286 -0
- package/dist/tools/skills.d.ts +2 -0
- package/dist/tools/skills.js +46 -0
- package/dist/tools/web.d.ts +24 -0
- package/dist/tools/web.js +386 -0
- package/docs/ci-repair-20261116.md +30 -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 +100 -0
- package/docs/input.md +66 -0
- package/docs/languages.md +117 -0
- package/docs/models.md +85 -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 +124 -0
- package/docs/presets.md +19 -0
- package/docs/setup.md +112 -0
- package/docs/subagents.md +134 -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 +7 -0
- package/experiments/presets/html.lisp +38 -0
- package/experiments/presets/js.lisp +38 -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/package.json +49 -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,29 @@
|
|
|
1
|
+
export interface UsageTotals {
|
|
2
|
+
/** Input tokens, including cached prefixes. */
|
|
3
|
+
input: number;
|
|
4
|
+
output: number;
|
|
5
|
+
/** Input tokens served from the provider's prompt cache. */
|
|
6
|
+
cacheRead: number;
|
|
7
|
+
/** Input tokens written to the provider's prompt cache. */
|
|
8
|
+
cacheWrite: number;
|
|
9
|
+
/** Responses counted into the totals; lets the footer stay quiet until real data exists. */
|
|
10
|
+
responses: number;
|
|
11
|
+
}
|
|
12
|
+
export declare const EMPTY_USAGE: UsageTotals;
|
|
13
|
+
export interface ReportedUsage {
|
|
14
|
+
input?: number | undefined;
|
|
15
|
+
output?: number | undefined;
|
|
16
|
+
cacheRead?: number | undefined;
|
|
17
|
+
cacheWrite?: number | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare function addUsage(total: UsageTotals, reported: ReportedUsage): UsageTotals;
|
|
20
|
+
/** 142,296,676 -> 142M. Keeps the footer short while staying recognizable. */
|
|
21
|
+
export declare function compactTokens(value: number): string;
|
|
22
|
+
/** Share of input tokens served from cache. Undefined when the provider reports no input. */
|
|
23
|
+
export declare function cacheHitRate(usage: UsageTotals): number | undefined;
|
|
24
|
+
/** One footer line, most useful numbers first. `width` is the usable cell width; narrower terminals
|
|
25
|
+
* drop trailing fields instead of wrapping, so the composer never moves. */
|
|
26
|
+
export declare function usageFooter(usage: UsageTotals, width: number): string;
|
|
27
|
+
/** 右下ステータス用のコンパクトな使用量表示。maxWidth を超えるときは後ろの項目から落とす。
|
|
28
|
+
* 幅は textWidth(表示幅)で測る(全角の「計」なども2セルとして数える)。 */
|
|
29
|
+
export declare function usageBadgeLine(usage: UsageTotals, maxWidth?: number): string;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** Token accounting for the status footer. Values are reported by the provider, never estimated. */
|
|
2
|
+
import { textWidth } from "./editor.js";
|
|
3
|
+
export const EMPTY_USAGE = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, responses: 0 };
|
|
4
|
+
/** Invalid, negative or non-finite provider values are ignored rather than shown as data. */
|
|
5
|
+
function count(value) {
|
|
6
|
+
return typeof value === 'number' && Number.isFinite(value) && value > 0 ? Math.floor(value) : 0;
|
|
7
|
+
}
|
|
8
|
+
export function addUsage(total, reported) {
|
|
9
|
+
const input = count(reported.input), output = count(reported.output);
|
|
10
|
+
const cacheRead = count(reported.cacheRead), cacheWrite = count(reported.cacheWrite);
|
|
11
|
+
if (input === 0 && output === 0 && cacheRead === 0 && cacheWrite === 0)
|
|
12
|
+
return total;
|
|
13
|
+
return {
|
|
14
|
+
input: total.input + input,
|
|
15
|
+
output: total.output + output,
|
|
16
|
+
cacheRead: total.cacheRead + cacheRead,
|
|
17
|
+
cacheWrite: total.cacheWrite + cacheWrite,
|
|
18
|
+
responses: total.responses + 1,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** 142,296,676 -> 142M. Keeps the footer short while staying recognizable. */
|
|
22
|
+
export function compactTokens(value) {
|
|
23
|
+
if (value < 1000)
|
|
24
|
+
return String(value);
|
|
25
|
+
if (value < 1_000_000)
|
|
26
|
+
return `${Math.round(value / 1000)}k`;
|
|
27
|
+
if (value < 100_000_000)
|
|
28
|
+
return `${(value / 1_000_000).toFixed(1)}M`;
|
|
29
|
+
return `${Math.round(value / 1_000_000)}M`;
|
|
30
|
+
}
|
|
31
|
+
/** Share of input tokens served from cache. Undefined when the provider reports no input. */
|
|
32
|
+
export function cacheHitRate(usage) {
|
|
33
|
+
if (usage.input <= 0)
|
|
34
|
+
return undefined;
|
|
35
|
+
return Math.min(100, Math.round((usage.cacheRead / usage.input) * 100));
|
|
36
|
+
}
|
|
37
|
+
/** One footer line, most useful numbers first. `width` is the usable cell width; narrower terminals
|
|
38
|
+
* drop trailing fields instead of wrapping, so the composer never moves. */
|
|
39
|
+
export function usageFooter(usage, width) {
|
|
40
|
+
if (usage.responses === 0)
|
|
41
|
+
return '';
|
|
42
|
+
const rate = cacheHitRate(usage);
|
|
43
|
+
const fields = [
|
|
44
|
+
`計 ${compactTokens(usage.input + usage.output)} tok`,
|
|
45
|
+
...(rate === undefined ? [] : [`cache ${rate}%`]),
|
|
46
|
+
`入 ${compactTokens(usage.input)}`,
|
|
47
|
+
`出 ${compactTokens(usage.output)}`,
|
|
48
|
+
];
|
|
49
|
+
// Drop trailing fields rather than wrapping: the footer must never move the composer.
|
|
50
|
+
const lines = fields.map((_, index) => fields.slice(0, index + 1).join(' · '));
|
|
51
|
+
for (const line of [...lines].reverse())
|
|
52
|
+
if (line.length <= width)
|
|
53
|
+
return line;
|
|
54
|
+
return fields[fields.length - 1];
|
|
55
|
+
}
|
|
56
|
+
/** 右下ステータス用のコンパクトな使用量表示。maxWidth を超えるときは後ろの項目から落とす。
|
|
57
|
+
* 幅は textWidth(表示幅)で測る(全角の「計」なども2セルとして数える)。 */
|
|
58
|
+
export function usageBadgeLine(usage, maxWidth) {
|
|
59
|
+
if (usage.responses === 0)
|
|
60
|
+
return '';
|
|
61
|
+
const rate = cacheHitRate(usage);
|
|
62
|
+
const fields = [
|
|
63
|
+
`計 ${compactTokens(usage.input + usage.output)} tok`,
|
|
64
|
+
...(rate === undefined ? [] : [`cache ${rate}%`]),
|
|
65
|
+
`in ${compactTokens(usage.input)}`,
|
|
66
|
+
`out ${compactTokens(usage.output)}`,
|
|
67
|
+
];
|
|
68
|
+
const lines = fields.map((_, index) => fields.slice(0, index + 1).join(' · '));
|
|
69
|
+
if (maxWidth === undefined)
|
|
70
|
+
return lines[lines.length - 1];
|
|
71
|
+
for (const line of [...lines].reverse())
|
|
72
|
+
if (textWidth(line) <= maxWidth)
|
|
73
|
+
return line;
|
|
74
|
+
return '';
|
|
75
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export interface ParsedInvocation {
|
|
3
|
+
cmd: string;
|
|
4
|
+
args: Record<string, string | undefined>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 引数を解釈する。最初の非フラグ引数がコマンド。
|
|
8
|
+
* コマンドがない(引数なし、または --cwd 等のフラグのみ)場合は chat を既定とする。
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseInvocation(argv: readonly string[]): ParsedInvocation;
|
|
11
|
+
export declare function main(argv: readonly string[]): void;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// modkh — MoDKH (Mixture of DKH)
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
const VERSION = '0.1.0';
|
|
6
|
+
const HELP = `modkh ${VERSION} — MoDKH (Mixture of DKH)
|
|
7
|
+
|
|
8
|
+
使い方:
|
|
9
|
+
modkh [--model <provider>/<model>] [--cwd <dir>] [--resume <id>] [--base-url <url>]
|
|
10
|
+
(サブコマンドなしで起動すると対話ハーネスを開く)
|
|
11
|
+
modkh chat --model <provider>/<model> [--cwd <dir>] [--resume <id>] [--base-url <url>]
|
|
12
|
+
modkh chat --lisp-config agents.lisp --trust-lisp-sha256 SHA256 [--sbcl PATH] [--verification-isolation required|integrity-only]
|
|
13
|
+
[--routing auto] [--lean PATH] [--java PATH --tla-jar PATH]
|
|
14
|
+
modkh auth login chatgpt
|
|
15
|
+
modkh session list
|
|
16
|
+
modkh plugin list | add <directory> | enable <id> | disable <id> | remove <id>
|
|
17
|
+
modkh language status | install [--detected] | retry <id> | update
|
|
18
|
+
|
|
19
|
+
対話中のコマンド:
|
|
20
|
+
/connect 検索できるプロバイダー一覧
|
|
21
|
+
/connect openai ChatGPT OAuth / APIキーを選択
|
|
22
|
+
/connect chatgpt ブラウザで ChatGPT 認証
|
|
23
|
+
/connect ollama Ollama Local のモデル選択
|
|
24
|
+
/connect ollama-cloud Ollama Cloud の認証・モデル選択
|
|
25
|
+
/agents 子エージェント一覧
|
|
26
|
+
/agents run [ID] [依頼] 子を選んで限定した仕事を委譲
|
|
27
|
+
/models [検索語] 名前の部分一致検索・番号でモデル選択
|
|
28
|
+
/reasoning [レベル] [--save] 推論レベル off/minimal/low/medium/high(既定は前回保存値)
|
|
29
|
+
/connect <provider>/<model> [--base-url <url>] モデルをその場で接続(AI API / chatgpt / fixed)
|
|
30
|
+
|
|
31
|
+
接続先:
|
|
32
|
+
fixed/scripted 固定応答モデル(オフライン検証用)
|
|
33
|
+
openai|anthropic|google|deepseek/<model> AI SDK アダプター
|
|
34
|
+
opencode|openrouter|infron|ollama|hermes/<model> OpenAI互換アダプター
|
|
35
|
+
ollama-cloud/<model> Ollama Cloud (OLLAMA_API_KEY)
|
|
36
|
+
groq|xai|lmstudio/<model> 既存の互換アダプター
|
|
37
|
+
compatible/<model> --base-url <url> 任意のOpenAI互換URL
|
|
38
|
+
chatgpt/<model> Sign in with ChatGPT(/connect で認証可能)
|
|
39
|
+
|
|
40
|
+
キーは環境変数から読む(例: OPENAI_API_KEY, ANTHROPIC_API_KEY,
|
|
41
|
+
GOOGLE_GENERATIVE_AI_API_KEY, DEEPSEEK_API_KEY, OPENCODE_API_KEY, OPENROUTER_API_KEY,
|
|
42
|
+
INFRON_API_KEY, HERMES_API_KEY, OLLAMA_API_KEY, GROQ_API_KEY, XAI_API_KEY)。
|
|
43
|
+
|
|
44
|
+
TTYではMODKHロゴ・コマンド補完・検索メニューを表示。↑↓/Enterで選択、Escで戻る。
|
|
45
|
+
出力は通常のスクリーンバッファに流れるので、端末のスクロール(マウスホイール等)で履歴を辿れる。
|
|
46
|
+
各セッションの記録はワークスペースの .modkh/sessions/<id>.md にも保存される(.gitignoreに .modkh/ を追加している)。
|
|
47
|
+
timeoutMs(既定600000=10分)は応答の無通信時間の上限。config.json で 5000〜1800000 ms に変更できる。
|
|
48
|
+
MODKH_PLAIN=1 modkh で行入力モード(スクリーンリーダー向け)。NO_COLORで色を無効化。
|
|
49
|
+
`;
|
|
50
|
+
/**
|
|
51
|
+
* 引数を解釈する。最初の非フラグ引数がコマンド。
|
|
52
|
+
* コマンドがない(引数なし、または --cwd 等のフラグのみ)場合は chat を既定とする。
|
|
53
|
+
*/
|
|
54
|
+
export function parseInvocation(argv) {
|
|
55
|
+
const args = {};
|
|
56
|
+
let positional = [];
|
|
57
|
+
let cmd;
|
|
58
|
+
for (let i = 0; i < argv.length; i++) {
|
|
59
|
+
const a = argv[i];
|
|
60
|
+
if (a === '--help' || a === '-h') {
|
|
61
|
+
args['help'] = 'true';
|
|
62
|
+
}
|
|
63
|
+
else if (a === '--version' || a === '-v') {
|
|
64
|
+
args['version'] = 'true';
|
|
65
|
+
}
|
|
66
|
+
else if (a?.startsWith('--')) {
|
|
67
|
+
const next = argv[i + 1];
|
|
68
|
+
if (next !== undefined && !next.startsWith('--')) {
|
|
69
|
+
args[a.slice(2)] = next;
|
|
70
|
+
i++;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
args[a.slice(2)] = 'true';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else if (cmd === undefined) {
|
|
77
|
+
cmd = a;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
positional = [...positional, a];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
args['@positional'] = positional.join(' ');
|
|
84
|
+
return { cmd: cmd ?? 'chat', args };
|
|
85
|
+
}
|
|
86
|
+
export function main(argv) {
|
|
87
|
+
const { cmd, args } = parseInvocation(argv);
|
|
88
|
+
if (args['help'] === 'true') {
|
|
89
|
+
process.stdout.write(HELP);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (args['version'] === 'true') {
|
|
93
|
+
process.stdout.write(`${VERSION}\n`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
void dispatch(cmd, args);
|
|
97
|
+
}
|
|
98
|
+
async function dispatch(cmd, args) {
|
|
99
|
+
try {
|
|
100
|
+
if (cmd === 'chat') {
|
|
101
|
+
const { runChat } = await import("./cli/chat.js");
|
|
102
|
+
await runChat({ args });
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (cmd === 'language') {
|
|
106
|
+
const { runLanguageCommand } = await import("./cli/language.js");
|
|
107
|
+
await runLanguageCommand(args['@positional'] ?? '', process.cwd());
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (cmd === 'plugin') {
|
|
111
|
+
const { runPluginCommand } = await import("./cli/plugins.js");
|
|
112
|
+
await runPluginCommand(args['@positional'] ?? '');
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (cmd === 'auth') {
|
|
116
|
+
if (args['@positional'] !== 'login chatgpt') {
|
|
117
|
+
process.stderr.write('使い方: modkh auth login chatgpt\n');
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
const { loginChatGpt } = await import("./model/chatgpt/login.js");
|
|
121
|
+
const tokens = await loginChatGpt();
|
|
122
|
+
process.stdout.write('ログインしました(トークンはハーネス専用の保存先に保存済み)。\n');
|
|
123
|
+
if (tokens.expiresAt)
|
|
124
|
+
process.stdout.write(`有効期限: ${tokens.expiresAt}\n`);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (cmd === 'session') {
|
|
128
|
+
const { SessionStore } = await import("./session/store.js");
|
|
129
|
+
if (args['@positional'] === 'list') {
|
|
130
|
+
const list = new SessionStore().list();
|
|
131
|
+
if (list.length === 0) {
|
|
132
|
+
process.stdout.write('セッションはまだありません。\n');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
for (const s of list) {
|
|
136
|
+
process.stdout.write(`${s.id} ${s.status.padEnd(11)} ${s.createdAt} ${s.model} ${s.cwd}\n`);
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
process.stderr.write('使い方: modkh session list\n');
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
process.stderr.write(`不明なコマンド: ${cmd}\n\n${HELP}`);
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
catch (e) {
|
|
147
|
+
process.stderr.write(`エラー: ${e.message}\n`);
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// 直接起動されたときだけ main を走らせる(import された場合は副作用なし)。
|
|
152
|
+
// realpath で比較する(/tmp のようなシンボリックリンク経由の起動に対応)。
|
|
153
|
+
const entryArg = process.argv[1];
|
|
154
|
+
let isMainModule = false;
|
|
155
|
+
if (entryArg !== undefined) {
|
|
156
|
+
try {
|
|
157
|
+
isMainModule = fs.realpathSync(entryArg) === fs.realpathSync(fileURLToPath(import.meta.url));
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
isMainModule = false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (isMainModule)
|
|
164
|
+
main(process.argv.slice(2));
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixed, reviewed installation recipes. Runtime code never invents a URL or a shell string.
|
|
3
|
+
* A language is only advertised as `ready` after its own verification passes; this table is a
|
|
4
|
+
* declaration of the intended route, not proof that a route works on every OS.
|
|
5
|
+
*/
|
|
6
|
+
export type LanguageId = 'typescript' | 'javascript' | 'tsx' | 'svelte' | 'html' | 'css' | 'tailwind' | 'rust' | 'python' | 'c' | 'cpp' | 'ruby' | 'swift' | 'php' | 'commonlisp';
|
|
7
|
+
export interface LaunchSpec {
|
|
8
|
+
/** Executable inside an installed npm prefix, or an absolute host binary. */
|
|
9
|
+
readonly bin: string;
|
|
10
|
+
readonly args: readonly string[];
|
|
11
|
+
/** Some servers need the workspace URI as the final argument. */
|
|
12
|
+
readonly needsRootUri?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface NpmRecipe {
|
|
15
|
+
readonly kind: 'npm';
|
|
16
|
+
readonly packages: readonly string[];
|
|
17
|
+
/** Which installed package's `.bin` entry is the server. */
|
|
18
|
+
readonly entry: string;
|
|
19
|
+
}
|
|
20
|
+
export interface HostRecipe {
|
|
21
|
+
readonly kind: 'host';
|
|
22
|
+
/** Absolute candidates probed in order; the first executable wins. */
|
|
23
|
+
readonly candidates: readonly string[];
|
|
24
|
+
readonly requirement?: string;
|
|
25
|
+
}
|
|
26
|
+
export type Recipe = NpmRecipe | HostRecipe;
|
|
27
|
+
export interface LanguageDefinition {
|
|
28
|
+
readonly id: LanguageId;
|
|
29
|
+
/** File extensions without a dot, lower case. */
|
|
30
|
+
readonly extensions: readonly string[];
|
|
31
|
+
/** Manifest files whose presence suggests this language, relative to a project root. */
|
|
32
|
+
readonly manifests: readonly string[];
|
|
33
|
+
/** tree-sitter grammar id when a reviewed WASM grammar exists for this language. */
|
|
34
|
+
readonly grammar?: string;
|
|
35
|
+
/** Grammar used to parse embedded regions of this file type, e.g. Vue/Svelte markup. */
|
|
36
|
+
readonly lsp?: LaunchSpec;
|
|
37
|
+
readonly install?: Recipe;
|
|
38
|
+
/** Reason semantic analysis is expected to be unavailable without a user-provided SDK. */
|
|
39
|
+
readonly hostRequirement?: string;
|
|
40
|
+
}
|
|
41
|
+
export declare const LANGUAGES: readonly LanguageDefinition[];
|
|
42
|
+
export declare function languageById(id: string): LanguageDefinition | undefined;
|
|
43
|
+
export declare function languageForPath(filePath: string): LanguageDefinition | undefined;
|
|
44
|
+
export declare function grammarFor(language: LanguageDefinition): string | undefined;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const TYPESCRIPT = {
|
|
2
|
+
id: 'typescript', extensions: ['ts', 'mts', 'cts'], manifests: ['tsconfig.json', 'package.json'],
|
|
3
|
+
grammar: 'typescript',
|
|
4
|
+
install: { kind: 'npm', packages: ['typescript-language-server@latest', 'typescript@latest'], entry: 'typescript-language-server' },
|
|
5
|
+
lsp: { bin: 'typescript-language-server', args: ['--stdio'] },
|
|
6
|
+
};
|
|
7
|
+
export const LANGUAGES = [
|
|
8
|
+
TYPESCRIPT,
|
|
9
|
+
{
|
|
10
|
+
id: 'javascript', extensions: ['js', 'mjs', 'cjs'], manifests: ['package.json'],
|
|
11
|
+
grammar: 'javascript', install: { kind: 'npm', packages: ['typescript-language-server@latest', 'typescript@latest'], entry: 'typescript-language-server' },
|
|
12
|
+
lsp: { bin: 'typescript-language-server', args: ['--stdio'] },
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: 'tsx', extensions: ['tsx'], manifests: ['tsconfig.json', 'package.json'],
|
|
16
|
+
grammar: 'tsx', install: { kind: 'npm', packages: ['typescript-language-server@latest', 'typescript@latest'], entry: 'typescript-language-server' },
|
|
17
|
+
lsp: { bin: 'typescript-language-server', args: ['--stdio'] },
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'svelte', extensions: ['svelte'], manifests: ['svelte.config.js', 'svelte.config.ts', 'package.json'],
|
|
21
|
+
grammar: 'svelte', install: { kind: 'npm', packages: ['svelte-language-server@latest'], entry: 'svelteserver' },
|
|
22
|
+
lsp: { bin: 'svelteserver', args: ['--stdio'] },
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'html', extensions: ['html', 'htm'], manifests: [],
|
|
26
|
+
grammar: 'html', install: { kind: 'npm', packages: ['vscode-langservers-extracted@latest'], entry: 'vscode-html-language-server' },
|
|
27
|
+
lsp: { bin: 'vscode-html-language-server', args: ['--stdio'] },
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'css', extensions: ['css', 'pcss'], manifests: [],
|
|
31
|
+
grammar: 'css', install: { kind: 'npm', packages: ['vscode-langservers-extracted@latest'], entry: 'vscode-css-language-server' },
|
|
32
|
+
lsp: { bin: 'vscode-css-language-server', args: ['--stdio'] },
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'tailwind', extensions: ['css', 'pcss', 'html', 'svelte', 'tsx', 'jsx'], manifests: ['tailwind.config.js', 'tailwind.config.ts', 'tailwind.config.cjs'],
|
|
36
|
+
install: { kind: 'npm', packages: ['@tailwindcss/language-server@latest'], entry: 'tailwindcss-language-server' },
|
|
37
|
+
lsp: { bin: 'tailwindcss-language-server', args: ['--stdio'] },
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'rust', extensions: ['rs'], manifests: ['Cargo.toml'],
|
|
41
|
+
grammar: 'rust',
|
|
42
|
+
install: { kind: 'host', candidates: ['rust-analyzer', '/opt/homebrew/bin/rust-analyzer', '/usr/local/bin/rust-analyzer'], requirement: 'rust-analyzer か Rust toolchain が必要' },
|
|
43
|
+
lsp: { bin: 'rust-analyzer', args: [] },
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 'python', extensions: ['py', 'pyi'], manifests: ['pyproject.toml', 'setup.py', 'requirements.txt'],
|
|
47
|
+
grammar: 'python', install: { kind: 'npm', packages: ['basedpyright@latest'], entry: 'basedpyright-langserver' },
|
|
48
|
+
lsp: { bin: 'basedpyright-langserver', args: ['--stdio'] },
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'c', extensions: ['c', 'h'], manifests: ['compile_commands.json', 'Makefile', 'CMakeLists.txt'],
|
|
52
|
+
grammar: 'c',
|
|
53
|
+
install: { kind: 'host', candidates: ['clangd', '/opt/homebrew/opt/llvm/bin/clangd', '/usr/local/opt/llvm/bin/clangd', '/usr/bin/clangd'], requirement: 'clangd が必要' },
|
|
54
|
+
lsp: { bin: 'clangd', args: [] },
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'cpp', extensions: ['cc', 'cpp', 'cxx', 'hpp', 'hxx', 'hh'], manifests: ['compile_commands.json', 'CMakeLists.txt'],
|
|
58
|
+
grammar: 'cpp',
|
|
59
|
+
install: { kind: 'host', candidates: ['clangd', '/opt/homebrew/opt/llvm/bin/clangd', '/usr/local/opt/llvm/bin/clangd', '/usr/bin/clangd'], requirement: 'clangd が必要' },
|
|
60
|
+
lsp: { bin: 'clangd', args: [] },
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: 'ruby', extensions: ['rb', 'rake'], manifests: ['Gemfile', '*.gemspec'],
|
|
64
|
+
grammar: 'ruby', install: { kind: 'host', candidates: ['ruby-lsp', '/opt/homebrew/bin/ruby-lsp'], requirement: 'Ruby と ruby-lsp gem が必要' },
|
|
65
|
+
lsp: { bin: 'ruby-lsp', args: [] },
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'swift', extensions: ['swift'], manifests: ['Package.swift'],
|
|
69
|
+
grammar: 'swift',
|
|
70
|
+
install: { kind: 'host', candidates: ['sourcekit-lsp', '/usr/bin/sourcekit-lsp', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp'], requirement: 'Xcode / Swift toolchain が必要' },
|
|
71
|
+
lsp: { bin: 'sourcekit-lsp', args: [] },
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: 'php', extensions: ['php', 'phtml'], manifests: ['composer.json'],
|
|
75
|
+
grammar: 'php',
|
|
76
|
+
install: { kind: 'host', candidates: ['phpantom_lsp', 'phpantom-lsp'], requirement: 'PHPantom か PHP 用LSPが必要' },
|
|
77
|
+
lsp: { bin: 'phpantom_lsp', args: [] },
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: 'commonlisp', extensions: ['lisp', 'lsp', 'asd', 'cl'], manifests: ['*.asd'],
|
|
81
|
+
grammar: 'commonlisp',
|
|
82
|
+
install: { kind: 'host', candidates: ['cl-lsp', '/opt/homebrew/bin/cl-lsp'], requirement: 'SBCL と CL-LSP が必要' },
|
|
83
|
+
lsp: { bin: 'cl-lsp', args: [] },
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
export function languageById(id) {
|
|
87
|
+
return LANGUAGES.find(language => language.id === id);
|
|
88
|
+
}
|
|
89
|
+
export function languageForPath(filePath) {
|
|
90
|
+
const name = filePath.toLowerCase();
|
|
91
|
+
const dot = name.lastIndexOf('.');
|
|
92
|
+
if (dot < 0)
|
|
93
|
+
return undefined;
|
|
94
|
+
const extension = name.slice(dot + 1);
|
|
95
|
+
// tsx and php have distinct grammars; check the more specific extension first.
|
|
96
|
+
return LANGUAGES.find(language => language.extensions.includes(extension));
|
|
97
|
+
}
|
|
98
|
+
export function grammarFor(language) {
|
|
99
|
+
return language.grammar;
|
|
100
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const CL_LSP_REPOSITORY = "askdkc/cl-lsp";
|
|
2
|
+
type Run = (name: string, command: string, args: string[], cwd?: string) => Promise<string>;
|
|
3
|
+
/** Upstream's headless installer loads vendor/, without Lem/Qlot/Quicklisp resolution. */
|
|
4
|
+
export declare function installBundledCommonLisp(root: string, source: string, ros: string, run: Run): Promise<{
|
|
5
|
+
command: string;
|
|
6
|
+
repository: string;
|
|
7
|
+
sourcesSha256: string;
|
|
8
|
+
installerSha256: string;
|
|
9
|
+
launcherSha256: string;
|
|
10
|
+
}>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { sha256 } from "../lisp/runtime.js";
|
|
4
|
+
export const CL_LSP_REPOSITORY = 'askdkc/cl-lsp';
|
|
5
|
+
/** Upstream's headless installer loads vendor/, without Lem/Qlot/Quicklisp resolution. */
|
|
6
|
+
export async function installBundledCommonLisp(root, source, ros, run) {
|
|
7
|
+
const installer = path.join(source, 'scripts/install-headless.ros');
|
|
8
|
+
const manifest = path.join(source, 'vendor/SOURCES.md');
|
|
9
|
+
for (const file of [installer, manifest, path.join(source, 'vendor/setup.lisp')]) {
|
|
10
|
+
if (!fs.lstatSync(file).isFile())
|
|
11
|
+
throw new Error(`Bundled CL-LSP input is not a regular file: ${file}`);
|
|
12
|
+
}
|
|
13
|
+
const prefix = path.join(root, 'server');
|
|
14
|
+
await run('bundled-runtime-install', ros, ['-Q', '--', installer, '--prefix', prefix], source);
|
|
15
|
+
const command = path.join(prefix, 'cl-lsp');
|
|
16
|
+
if (!fs.lstatSync(command).isFile())
|
|
17
|
+
throw new Error('Bundled CL-LSP launcher missing or not a regular file');
|
|
18
|
+
await run('runtime-warmup', command, ['--help'], root);
|
|
19
|
+
// Actual initialize, document synchronization and definition responses are checked by the caller.
|
|
20
|
+
return { command, repository: CL_LSP_REPOSITORY, sourcesSha256: sha256(fs.readFileSync(manifest)),
|
|
21
|
+
installerSha256: sha256(fs.readFileSync(installer)), launcherSha256: sha256(fs.readFileSync(command)) };
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type RunStage = (name: string, command: string, args: string[], cwd?: string) => Promise<string>;
|
|
2
|
+
/** Resolve the upstream manifest in an owned prefix, without touching the user's Quicklisp. */
|
|
3
|
+
export declare function installLemDependencies(root: string, lem: string, ros: string, rosHome: string, run: RunStage, tlsFile?: string): Promise<{
|
|
4
|
+
home: string;
|
|
5
|
+
version: string;
|
|
6
|
+
manifestSha256: string;
|
|
7
|
+
setupSha256: string;
|
|
8
|
+
lockSha256: string;
|
|
9
|
+
lock: string;
|
|
10
|
+
provider: string;
|
|
11
|
+
}>;
|
|
12
|
+
/** Locate the source actually resolved by ASDF, not a second unrelated Git checkout. */
|
|
13
|
+
export declare function resolvedDependencyDirectory(discovery: string, system: string, root: string): string;
|
|
14
|
+
/** async-process keeps its ASD in src/, while its Autotools entry lives above it. */
|
|
15
|
+
export declare function resolvedNativeBuildDirectory(discovery: string, root: string): string;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { sha256 } from "../lisp/runtime.js";
|
|
4
|
+
/** Resolve the upstream manifest in an owned prefix, without touching the user's Quicklisp. */
|
|
5
|
+
export async function installLemDependencies(root, lem, ros, rosHome, run, tlsFile) {
|
|
6
|
+
const directory = path.join(root, 'dependencies');
|
|
7
|
+
fs.mkdirSync(directory, { mode: 0o700 });
|
|
8
|
+
const manifest = fs.readFileSync(path.join(lem, 'qlfile'));
|
|
9
|
+
fs.writeFileSync(path.join(directory, 'qlfile'), manifest, { flag: 'wx' });
|
|
10
|
+
// Resolve the current upstream manifest; don't copy Lem's historical lock into a fresh install.
|
|
11
|
+
await run('qlot-bootstrap', ros, ['install', 'fukamachi/qlot']);
|
|
12
|
+
const qlot = path.join(rosHome, 'bin', 'qlot');
|
|
13
|
+
// Qlot deliberately quits -1 for --version; test the loadable CLI instead.
|
|
14
|
+
const probe = path.join(directory, 'probe-qlot.lisp');
|
|
15
|
+
fs.writeFileSync(probe, `(require :asdf)
|
|
16
|
+
(asdf:load-system "qlot/cli")
|
|
17
|
+
(assert (fboundp (find-symbol "QLOT-COMMAND" "QLOT/CLI")))
|
|
18
|
+
(format t "MODKH_QLOT_READY ~A~%" (asdf:component-version (asdf:find-system "qlot")))
|
|
19
|
+
`, { flag: 'wx' });
|
|
20
|
+
const bootstrap = ['-Q', '-e', '(ros:ensure-asdf)', ...(tlsFile ? ['-l', tlsFile] : [])];
|
|
21
|
+
const output = await run('qlot-capability', ros, [...bootstrap, '-l', probe, '-q']);
|
|
22
|
+
const evidence = output.split(/\r?\n/).filter(line => /^MODKH_QLOT_READY \S+$/.test(line));
|
|
23
|
+
if (evidence.length !== 1)
|
|
24
|
+
throw new Error('Qlot capability missing completion evidence');
|
|
25
|
+
const version = evidence[0].slice('MODKH_QLOT_READY '.length);
|
|
26
|
+
if (tlsFile) {
|
|
27
|
+
await run('lem-dependencies', ros, [...bootstrap, '-l', probe, '-e', '(qlot/cli:qlot-command "install" "--no-deps")', '-q'], directory);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
await run('lem-dependencies', qlot, ['install', '--no-deps'], directory);
|
|
31
|
+
}
|
|
32
|
+
const home = path.join(directory, '.qlot');
|
|
33
|
+
// Exit 0 alone is insufficient. Loading and ASDF resolution are checked by the next stage.
|
|
34
|
+
const setupDigest = sha256(fs.readFileSync(path.join(home, 'setup.lisp')));
|
|
35
|
+
const lock = fs.readFileSync(path.join(directory, 'qlfile.lock'), 'utf8');
|
|
36
|
+
return { home: home + path.sep, version, manifestSha256: sha256(manifest), setupSha256: setupDigest,
|
|
37
|
+
lockSha256: sha256(lock), lock, provider: 'https://github.com/fukamachi/qlot' };
|
|
38
|
+
}
|
|
39
|
+
/** Locate the source actually resolved by ASDF, not a second unrelated Git checkout. */
|
|
40
|
+
export function resolvedDependencyDirectory(discovery, system, root) {
|
|
41
|
+
const prefix = `MODKH_ASDF_SYSTEM ${system} `;
|
|
42
|
+
const matches = discovery.split(/\r?\n/).filter(line => line.startsWith(prefix));
|
|
43
|
+
if (matches.length !== 1)
|
|
44
|
+
throw new Error(`Missing or ambiguous ASDF source: ${system}`);
|
|
45
|
+
const source = fs.realpathSync(matches[0].slice(prefix.length));
|
|
46
|
+
const relative = path.relative(fs.realpathSync(root), source);
|
|
47
|
+
if (relative === '..' || relative.startsWith('..' + path.sep) || path.isAbsolute(relative)
|
|
48
|
+
|| !source.endsWith('.asd') || !fs.statSync(source).isFile()) {
|
|
49
|
+
throw new Error(`ASDF source outside owned dependency prefix: ${system}`);
|
|
50
|
+
}
|
|
51
|
+
return path.dirname(source);
|
|
52
|
+
}
|
|
53
|
+
/** async-process keeps its ASD in src/, while its Autotools entry lives above it. */
|
|
54
|
+
export function resolvedNativeBuildDirectory(discovery, root) {
|
|
55
|
+
const source = resolvedDependencyDirectory(discovery, 'async-process', root);
|
|
56
|
+
const owned = fs.realpathSync(root);
|
|
57
|
+
for (const candidate of [source, path.dirname(source)]) {
|
|
58
|
+
const relative = path.relative(owned, candidate);
|
|
59
|
+
if (relative === '..' || relative.startsWith('..' + path.sep) || path.isAbsolute(relative))
|
|
60
|
+
continue;
|
|
61
|
+
if (['GNUmakefile', 'Makefile.am', 'configure.ac'].every(name => {
|
|
62
|
+
const file = path.join(candidate, name);
|
|
63
|
+
return fs.existsSync(file) && fs.lstatSync(file).isFile();
|
|
64
|
+
}))
|
|
65
|
+
return candidate;
|
|
66
|
+
}
|
|
67
|
+
throw new Error('ASDF-resolved async-process has no supported native build entry');
|
|
68
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type HostPlatform, type ReleaseAsset } from './platform.ts';
|
|
2
|
+
/** Official Roswell Lisp filenames include '+' (for example install+sigsegv.lisp). */
|
|
3
|
+
export declare function validateRoswellArchivePaths(output: string): void;
|
|
4
|
+
export declare function roswellAsset(assets: ReleaseAsset[], platform: HostPlatform, glibc?: string): ReleaseAsset;
|
|
5
|
+
/** Called under install.ts's per-language lock. Every attempt owns a new non-relocated prefix. */
|
|
6
|
+
export declare function installCommonLisp(target: string, signal?: AbortSignal): Promise<{
|
|
7
|
+
command: string;
|
|
8
|
+
args: never[];
|
|
9
|
+
version: string;
|
|
10
|
+
digest: string;
|
|
11
|
+
receipt: Record<string, unknown>;
|
|
12
|
+
}>;
|
|
13
|
+
/** A partial directory or modified launcher is never a reusable managed installation. */
|
|
14
|
+
export declare function reusableCommonLisp(command: string, digest: string): boolean;
|