@gyoungwe/research-suite 0.1.3 → 0.1.6
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/build-manifest.json +2 -2
- package/node_modules/@gyoungwe/pi-core/README.md +5 -3
- package/node_modules/@gyoungwe/pi-core/build-manifest.json +2 -2
- package/node_modules/@gyoungwe/pi-core/dist/index.mjs +435 -151
- package/node_modules/@gyoungwe/pi-core/package.json +1 -1
- package/node_modules/@gyoungwe/pi-knowledge/build-manifest.json +68 -3
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/capability-discovery.d.ts +7 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/capability-discovery.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/claim-conflicts.d.ts +30 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/claim-conflicts.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/config.d.ts +55 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/config.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/daily-discovery-prompt.d.ts +11 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/daily-discovery-prompt.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/daily-discovery.d.ts +26 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/daily-discovery.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/deliverable-review.d.ts +127 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/deliverable-review.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/evolution.d.ts +39 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/evolution.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/experience-store.d.ts +290 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/experience-store.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/extension-helpers.d.ts +38 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/extension-helpers.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/files.d.ts +39 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/files.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/flow-cards.d.ts +77 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/flow-cards.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/graph-cache.d.ts +14 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/graph-cache.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/graph-retrieval.d.ts +44 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/graph-retrieval.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/host.d.ts +9 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/host.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/index.d.ts +46 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/index.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/ingest-frontmatter.d.ts +125 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/ingest-frontmatter.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/ingest-identity.d.ts +93 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/ingest-identity.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/ingest-policy.d.ts +63 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/ingest-policy.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/layout.d.ts +47 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/layout.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/maintenance.d.ts +16 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/maintenance.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/memory-note.d.ts +14 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/memory-note.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/metacognitive-policy.d.ts +116 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/metacognitive-policy.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/note-title.d.ts +8 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/note-title.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/orchestration-policy.d.ts +84 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/orchestration-policy.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/project-identity.d.ts +70 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/project-identity.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/publication-policy.d.ts +39 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/publication-policy.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/publication.d.ts +24 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/publication.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/recent-by-category.d.ts +15 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/recent-by-category.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/related-notes.d.ts +4 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/related-notes.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/reuse.d.ts +124 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/reuse.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/review-policy.d.ts +12 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/review-policy.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/runtime-host.d.ts +98 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/runtime-host.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/search-policy.d.ts +14 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/search-policy.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/semantic-model.d.ts +85 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/semantic-model.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/semantic-provider.d.ts +41 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/semantic-provider.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/semantic-settings.d.ts +30 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/semantic-settings.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/service.d.ts +171 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/service.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/source-links.d.ts +13 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/source-links.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/specialist-delivery.d.ts +8 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/specialist-delivery.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/specialist-host.d.ts +61 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/specialist-host.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/specialists.d.ts +55 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/specialists.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/task-feedback.d.ts +57 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/task-feedback.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/tool-budget.d.ts +24 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/tool-budget.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/topic-candidate.d.ts +22 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/topic-candidate.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/topic-memory.d.ts +79 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/topic-memory.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/topic-probe.d.ts +2 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/topic-probe.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/ui-service.d.ts +360 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/ui-service.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/ui-state.d.ts +28 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/ui-state.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/wiki-model-review.d.ts +167 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/wiki-model-review.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/wiki-policy.d.ts +34 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/wiki-policy.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/wiki-review.d.ts +74 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/wiki-review.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/worker.d.ts +2 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/core/worker.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/extension/internal-knowledge-extension.d.ts +42 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/extension/internal-knowledge-extension.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/extension/knowledge-extension.d.ts +5 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/extension/knowledge-extension.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/extension/knowledge-worker.d.ts +6 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/extension/knowledge-worker.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/host.d.ts +7 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/host.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/host.mjs +11638 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/index.d.ts +6 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/index.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/index.mjs +4728 -10301
- package/node_modules/@gyoungwe/pi-knowledge/dist/maintenance/plan.d.ts +41 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/maintenance/plan.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/maintenance/prompts.d.ts +10 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/maintenance/prompts.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/maintenance/run.d.ts +31 -0
- package/node_modules/@gyoungwe/pi-knowledge/dist/maintenance/run.d.ts.map +1 -0
- package/node_modules/@gyoungwe/pi-knowledge/lib/knowledge/runtime/.knowledge-worker-manifest.json +9 -0
- package/node_modules/@gyoungwe/pi-knowledge/lib/knowledge/runtime/worker.mjs +142 -12
- package/node_modules/@gyoungwe/pi-knowledge/package.json +21 -3
- package/node_modules/@gyoungwe/pi-knowledge/plugin.manifest.json +23 -1
- package/node_modules/@gyoungwe/pi-research/build-manifest.json +2 -2
- package/node_modules/@gyoungwe/pi-research/dist/index.mjs +3141 -613
- package/node_modules/@gyoungwe/pi-research/package.json +1 -1
- package/node_modules/@gyoungwe/plugin-api/dist/index.d.ts +101 -0
- package/node_modules/@gyoungwe/plugin-api/dist/index.d.ts.map +1 -1
- package/node_modules/@gyoungwe/plugin-api/dist/index.js +124 -0
- package/node_modules/@gyoungwe/plugin-api/dist/index.js.map +1 -1
- package/node_modules/@gyoungwe/plugin-api/dist/knowledge.d.ts +486 -0
- package/node_modules/@gyoungwe/plugin-api/dist/knowledge.d.ts.map +1 -0
- package/node_modules/@gyoungwe/plugin-api/dist/knowledge.js +251 -0
- package/node_modules/@gyoungwe/plugin-api/dist/knowledge.js.map +1 -0
- package/node_modules/@gyoungwe/plugin-api/package.json +6 -1
- package/package.json +58 -44
- package/plugin.manifest.json +39 -3
|
@@ -101,7 +101,8 @@ function createStandaloneRuntime(log = {}) {
|
|
|
101
101
|
return runtime;
|
|
102
102
|
}
|
|
103
103
|
function currentRuntime() {
|
|
104
|
-
|
|
104
|
+
const scoped = contexts.getStore();
|
|
105
|
+
if (scoped) return scoped;
|
|
105
106
|
if (installedRuntime) return installedRuntime;
|
|
106
107
|
if (!standaloneRuntime) standaloneRuntime = createStandaloneRuntime();
|
|
107
108
|
return standaloneRuntime;
|
|
@@ -144,10 +145,7 @@ function runtimeSlot(domain, slot, create) {
|
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
147
|
);
|
|
147
|
-
return
|
|
148
|
-
/** @type {T} */
|
|
149
|
-
proxy
|
|
150
|
-
);
|
|
148
|
+
return proxy;
|
|
151
149
|
}
|
|
152
150
|
|
|
153
151
|
// ../tasks/src/runtime-compiled/acceptance.mjs
|
|
@@ -2818,6 +2816,257 @@ Use task_status for operational delivery. Verify unknown outcomes before repeati
|
|
|
2818
2816
|
return journal;
|
|
2819
2817
|
}
|
|
2820
2818
|
|
|
2819
|
+
// src/drone-commands.ts
|
|
2820
|
+
import { readFileSync } from "node:fs";
|
|
2821
|
+
import { createRequire } from "node:module";
|
|
2822
|
+
import { dirname, join } from "node:path";
|
|
2823
|
+
import { fileURLToPath } from "node:url";
|
|
2824
|
+
var DRONE_COMMAND_SCHEMA_VERSION = 1;
|
|
2825
|
+
var PI_CORE_PACKAGE_VERSION = "0.1.5";
|
|
2826
|
+
var PI_HOST_RANGE = ">=1.1.0 <2.0.0";
|
|
2827
|
+
var CORE_TOOLS = [
|
|
2828
|
+
"ask_user",
|
|
2829
|
+
"set_status",
|
|
2830
|
+
"todo",
|
|
2831
|
+
"deliver_files",
|
|
2832
|
+
"memory_save",
|
|
2833
|
+
"task_plan",
|
|
2834
|
+
"task_status",
|
|
2835
|
+
"task_wait",
|
|
2836
|
+
"task_reconcile",
|
|
2837
|
+
"task_evidence_restore"
|
|
2838
|
+
];
|
|
2839
|
+
var EXAMPLE_PROFILES = {
|
|
2840
|
+
knowledge: {
|
|
2841
|
+
title: "Knowledge Vault example",
|
|
2842
|
+
steps: ["check the local Vault", "search local knowledge", "cite the retrieved note paths"],
|
|
2843
|
+
requiredTools: ["knowledge_status", "knowledge_search"],
|
|
2844
|
+
missingToolsNext: "\u5B89\u88C5\u5E76\u542F\u7528 pi-knowledge \u540E\u91CD\u8BD5 /drone-example knowledge",
|
|
2845
|
+
missingDataNext: "\u63D0\u4F9B\u4E00\u4E2A\u77E5\u8BC6\u95EE\u9898\uFF1A/drone-example knowledge --run <\u95EE\u9898>"
|
|
2846
|
+
},
|
|
2847
|
+
research: {
|
|
2848
|
+
title: "Evidence-gated local research example",
|
|
2849
|
+
steps: ["inspect local knowledge", "read at least two sources", "answer with source receipts"],
|
|
2850
|
+
requiredTools: ["research_search_sources", "research_read_source", "research_answer_sources"],
|
|
2851
|
+
missingToolsNext: "\u5B89\u88C5\u5E76\u542F\u7528 pi-research \u540E\u91CD\u8BD5 /drone-example research",
|
|
2852
|
+
missingDataNext: "\u63D0\u4F9B\u4E00\u4E2A\u7814\u7A76\u95EE\u9898\uFF1A/drone-example research --run <\u7814\u7A76\u95EE\u9898>"
|
|
2853
|
+
},
|
|
2854
|
+
analysis: {
|
|
2855
|
+
title: "Analysis readiness example",
|
|
2856
|
+
requiresContainer: true,
|
|
2857
|
+
steps: [
|
|
2858
|
+
"list compatible analysis adapters",
|
|
2859
|
+
"assess input readiness",
|
|
2860
|
+
"report missing data before execution"
|
|
2861
|
+
],
|
|
2862
|
+
requiredTools: ["analysis_list_adapters", "analysis_assess_readiness"],
|
|
2863
|
+
missingToolsNext: "\u5B89\u88C5\u5E76\u542F\u7528 pi-analysis \u540E\u91CD\u8BD5 /drone-example analysis",
|
|
2864
|
+
missingDataNext: "\u63D0\u4F9B\u8F93\u5165\u4E0E\u5206\u6790\u95EE\u9898\uFF1A/drone-example analysis --run <\u5206\u6790\u95EE\u9898>"
|
|
2865
|
+
},
|
|
2866
|
+
evidence: {
|
|
2867
|
+
title: "Evidence validation example",
|
|
2868
|
+
steps: ["validate an artifact manifest", "validate an evidence capsule", "verify replay metadata"],
|
|
2869
|
+
requiredTools: ["evidence_validate_manifest", "evidence_validate_capsule", "evidence_verify_replay"],
|
|
2870
|
+
missingToolsNext: "\u5B89\u88C5\u5E76\u542F\u7528 pi-evidence \u540E\u91CD\u8BD5 /drone-example evidence",
|
|
2871
|
+
missingDataNext: "\u63D0\u4F9B\u5F85\u6838\u9A8C\u7684\u8BC1\u636E\u5BF9\u8C61\uFF1A/drone-example evidence --run <\u5BF9\u8C61>"
|
|
2872
|
+
}
|
|
2873
|
+
};
|
|
2874
|
+
var EXAMPLE_KINDS = new Set(Object.keys(EXAMPLE_PROFILES));
|
|
2875
|
+
function packageVersion() {
|
|
2876
|
+
const configured = process.env.PI_VERSION?.trim();
|
|
2877
|
+
if (configured) return { version: configured, source: "PI_VERSION" };
|
|
2878
|
+
const readPackageFrom = (entry) => {
|
|
2879
|
+
let current = entry;
|
|
2880
|
+
try {
|
|
2881
|
+
current = dirname(current);
|
|
2882
|
+
} catch {
|
|
2883
|
+
return void 0;
|
|
2884
|
+
}
|
|
2885
|
+
for (let depth = 0; depth < 8; depth += 1) {
|
|
2886
|
+
const packagePath = join(current, "package.json");
|
|
2887
|
+
try {
|
|
2888
|
+
const metadata = JSON.parse(readFileSync(packagePath, "utf8"));
|
|
2889
|
+
if (metadata?.name === "@earendil-works/pi-coding-agent" && typeof metadata.version === "string" && metadata.version.length > 0)
|
|
2890
|
+
return { version: metadata.version, source: "resolved-package" };
|
|
2891
|
+
} catch {
|
|
2892
|
+
}
|
|
2893
|
+
const parent = dirname(current);
|
|
2894
|
+
if (parent === current) break;
|
|
2895
|
+
current = parent;
|
|
2896
|
+
}
|
|
2897
|
+
return void 0;
|
|
2898
|
+
};
|
|
2899
|
+
const candidates = [fileURLToPath(import.meta.url), process.argv[1], process.cwd()].filter(
|
|
2900
|
+
(entry) => typeof entry === "string" && entry.length > 0
|
|
2901
|
+
);
|
|
2902
|
+
for (const candidate of candidates) {
|
|
2903
|
+
const resolved = readPackageFrom(candidate);
|
|
2904
|
+
if (resolved) return resolved;
|
|
2905
|
+
}
|
|
2906
|
+
try {
|
|
2907
|
+
const require2 = createRequire(import.meta.url);
|
|
2908
|
+
for (const base of require2.resolve.paths("@earendil-works/pi-coding-agent") ?? []) {
|
|
2909
|
+
const packagePath = join(base, "@earendil-works/pi-coding-agent", "package.json");
|
|
2910
|
+
try {
|
|
2911
|
+
const metadata = JSON.parse(readFileSync(packagePath, "utf8"));
|
|
2912
|
+
if (metadata.name === "@earendil-works/pi-coding-agent" && typeof metadata.version === "string" && metadata.version.length > 0)
|
|
2913
|
+
return { version: metadata.version, source: "resolved-package" };
|
|
2914
|
+
} catch {
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
} catch {
|
|
2918
|
+
}
|
|
2919
|
+
return { version: null, source: "unavailable" };
|
|
2920
|
+
}
|
|
2921
|
+
function snapshot(pi) {
|
|
2922
|
+
const tools = typeof pi?.getAllTools === "function" ? pi.getAllTools().map((tool) => String(tool?.name || "")).filter(Boolean) : typeof pi?.getActiveTools === "function" ? pi.getActiveTools().map((name) => String(name)).filter(Boolean) : [];
|
|
2923
|
+
const commands = typeof pi?.getCommands === "function" ? pi.getCommands().map((command) => String(command?.name || "")).filter(Boolean) : [];
|
|
2924
|
+
return { tools: [...new Set(tools)].sort(), commands: [...new Set(commands)].sort() };
|
|
2925
|
+
}
|
|
2926
|
+
function isSupportedPiHost(version) {
|
|
2927
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(version.trim());
|
|
2928
|
+
if (!match) return false;
|
|
2929
|
+
const major = Number(match[1]);
|
|
2930
|
+
const minor = Number(match[2]);
|
|
2931
|
+
const patch = Number(match[3]);
|
|
2932
|
+
return major === 1 && (minor > 1 || minor === 1 && patch >= 0);
|
|
2933
|
+
}
|
|
2934
|
+
function buildDoctorReport(pi, options = {}) {
|
|
2935
|
+
const current = snapshot(pi);
|
|
2936
|
+
const missingTools = CORE_TOOLS.filter((name) => !current.tools.includes(name));
|
|
2937
|
+
const missingCommands = ["drone-doctor", "drone-example"].filter(
|
|
2938
|
+
(name) => !current.commands.includes(name)
|
|
2939
|
+
);
|
|
2940
|
+
const resolved = options.hostVersion === void 0 ? packageVersion() : { version: options.hostVersion, source: "host-contract" };
|
|
2941
|
+
const hostCompatible = resolved.version ? isSupportedPiHost(resolved.version) : null;
|
|
2942
|
+
const hostKind = options.hostKind || "native-pi";
|
|
2943
|
+
const checks = [
|
|
2944
|
+
{
|
|
2945
|
+
id: "core-tools",
|
|
2946
|
+
status: missingTools.length ? "blocked" : "pass",
|
|
2947
|
+
detail: missingTools.length ? "pi-core tools are missing" : "all pi-core tools are registered",
|
|
2948
|
+
...missingTools.length ? { missing: missingTools } : {}
|
|
2949
|
+
},
|
|
2950
|
+
{
|
|
2951
|
+
id: "drone-commands",
|
|
2952
|
+
status: missingCommands.length ? "blocked" : "pass",
|
|
2953
|
+
detail: missingCommands.length ? "Drone onboarding commands are missing" : "doctor and example commands are registered",
|
|
2954
|
+
...missingCommands.length ? { missing: missingCommands } : {}
|
|
2955
|
+
},
|
|
2956
|
+
{
|
|
2957
|
+
id: "pi-host-version",
|
|
2958
|
+
status: resolved.version ? hostCompatible ? "pass" : "incompatible" : "unknown",
|
|
2959
|
+
detail: resolved.version ? hostCompatible ? `resolved Pi host ${resolved.version}` : `Pi host ${resolved.version} is outside ${PI_HOST_RANGE}` : "Pi host version is not exposed by this host"
|
|
2960
|
+
}
|
|
2961
|
+
];
|
|
2962
|
+
const blocked = checks.some((check) => check.status === "blocked");
|
|
2963
|
+
const incompatible = checks.some((check) => check.status === "incompatible");
|
|
2964
|
+
return {
|
|
2965
|
+
schemaVersion: DRONE_COMMAND_SCHEMA_VERSION,
|
|
2966
|
+
command: "drone-doctor",
|
|
2967
|
+
status: blocked ? "blocked" : incompatible ? "incompatible" : resolved.version ? "pass" : "unknown",
|
|
2968
|
+
plugin: { name: "@gyoungwe/pi-core", version: PI_CORE_PACKAGE_VERSION, piRange: PI_HOST_RANGE },
|
|
2969
|
+
host: { kind: hostKind, version: resolved.version || null, source: resolved.source },
|
|
2970
|
+
checks,
|
|
2971
|
+
commands: current.commands,
|
|
2972
|
+
tools: current.tools,
|
|
2973
|
+
next: blocked ? "\u5B89\u88C5\u6216\u91CD\u65B0\u52A0\u8F7D\u7F3A\u5931\u7684 Drone \u63D2\u4EF6\u540E\u91CD\u8BD5 /drone-doctor" : incompatible ? `\u5347\u7EA7 Pi \u5230 ${PI_HOST_RANGE} \u540E\u91CD\u8BD5 /drone-doctor` : null
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2976
|
+
function buildExampleReport(pi, mode = "preview", question, options = {}) {
|
|
2977
|
+
const example = options.example ?? "research";
|
|
2978
|
+
const profile = EXAMPLE_PROFILES[example];
|
|
2979
|
+
const current = snapshot(pi);
|
|
2980
|
+
const missingTools = profile.requiredTools.filter((name) => !current.tools.includes(name));
|
|
2981
|
+
const hasQuestion = Boolean(question?.trim());
|
|
2982
|
+
const knowledgeStatus = example === "knowledge" ? options.knowledgeStatus ?? (process.env.DRONE_KNOWLEDGE_DIR?.trim() ? "unknown" : "unconfigured") : void 0;
|
|
2983
|
+
const containerAvailable = options.containerAvailable ?? Boolean(process.env.DRONE_CONTAINER_RUNTIME?.trim());
|
|
2984
|
+
const missingContainer = Boolean(profile.requiresContainer && !containerAvailable);
|
|
2985
|
+
const status2 = missingTools.length ? "blocked" : knowledgeStatus === "unconfigured" ? "unconfigured" : knowledgeStatus === "unknown" ? "needs-data" : missingContainer ? "needs-container" : mode === "run" && hasQuestion ? "started" : hasQuestion ? "ready" : "needs-data";
|
|
2986
|
+
return {
|
|
2987
|
+
schemaVersion: DRONE_COMMAND_SCHEMA_VERSION,
|
|
2988
|
+
command: "drone-example",
|
|
2989
|
+
example,
|
|
2990
|
+
status: status2,
|
|
2991
|
+
mode,
|
|
2992
|
+
title: profile.title,
|
|
2993
|
+
steps: [...profile.steps],
|
|
2994
|
+
requiredTools: [...profile.requiredTools],
|
|
2995
|
+
missingTools: [...missingTools],
|
|
2996
|
+
next: missingTools.length ? profile.missingToolsNext : missingContainer ? "\u767B\u8BB0\u5E76\u542F\u7528\u4E00\u4E2A\u5BB9\u5668\u8FD0\u884C\u65F6\u540E\u91CD\u8BD5 /drone-example analysis" : knowledgeStatus === "unconfigured" ? "\u5148\u8FD0\u884C /drone-init \u7ED1\u5B9A\u672C\u5730 Vault\uFF0C\u518D\u91CD\u8BD5 /drone-example knowledge" : knowledgeStatus === "unknown" ? "\u65E0\u6CD5\u786E\u8BA4\u672C\u5730 Vault \u72B6\u6001\uFF1B\u5148\u8FD0\u884C /drone-init \u6216\u68C0\u67E5\u77E5\u8BC6\u5E93\u63D2\u4EF6\u540E\u91CD\u8BD5" : hasQuestion ? mode === "run" ? `${profile.title} \u5DF2\u6392\u961F\uFF1B\u7B49\u5F85\u771F\u5B9E\u56DE\u6267` : `\u8FD0\u884C /drone-example ${example} --run <\u95EE\u9898> \u5F00\u59CB\u53EA\u8BFB\u793A\u4F8B` : profile.missingDataNext,
|
|
2997
|
+
...hasQuestion ? { question: question?.trim() } : {}
|
|
2998
|
+
};
|
|
2999
|
+
}
|
|
3000
|
+
function parseExampleArgs(args) {
|
|
3001
|
+
const tokens = args.trim().split(/\s+/).filter(Boolean);
|
|
3002
|
+
let mode = "preview";
|
|
3003
|
+
const remaining = tokens.filter((token) => {
|
|
3004
|
+
if (token === "--run") {
|
|
3005
|
+
mode = "run";
|
|
3006
|
+
return false;
|
|
3007
|
+
}
|
|
3008
|
+
return true;
|
|
3009
|
+
});
|
|
3010
|
+
const candidate = remaining[0]?.toLowerCase();
|
|
3011
|
+
const example = candidate && EXAMPLE_KINDS.has(candidate) ? candidate : "research";
|
|
3012
|
+
if (candidate && EXAMPLE_KINDS.has(candidate)) remaining.shift();
|
|
3013
|
+
const question = remaining.join(" ").trim();
|
|
3014
|
+
return { mode, example, ...question ? { question } : {} };
|
|
3015
|
+
}
|
|
3016
|
+
async function resolveKnowledgeStatus(pi, ctx) {
|
|
3017
|
+
if (!process.env.DRONE_KNOWLEDGE_DIR?.trim()) return "unconfigured";
|
|
3018
|
+
const tool = typeof pi?.getAllTools === "function" ? pi.getAllTools().find((candidate) => candidate?.name === "knowledge_status") : void 0;
|
|
3019
|
+
if (typeof tool?.execute !== "function") return "unknown";
|
|
3020
|
+
try {
|
|
3021
|
+
const result = await tool.execute(
|
|
3022
|
+
"drone-example:knowledge-status",
|
|
3023
|
+
{},
|
|
3024
|
+
new AbortController().signal,
|
|
3025
|
+
() => void 0,
|
|
3026
|
+
ctx
|
|
3027
|
+
);
|
|
3028
|
+
const status2 = result?.details?.status ?? result?.status;
|
|
3029
|
+
if (status2 === "unconfigured") return "unconfigured";
|
|
3030
|
+
if (status2 === "configured") return "configured";
|
|
3031
|
+
} catch {
|
|
3032
|
+
}
|
|
3033
|
+
return "unknown";
|
|
3034
|
+
}
|
|
3035
|
+
function emitReport(report, ctx) {
|
|
3036
|
+
const message = JSON.stringify(report);
|
|
3037
|
+
if (ctx.mode === "print" || ctx.mode === "json") console.log(message);
|
|
3038
|
+
else
|
|
3039
|
+
ctx.ui.notify(
|
|
3040
|
+
message,
|
|
3041
|
+
report.status === "blocked" || report.status === "unconfigured" || report.status === "needs-container" || report.status === "incompatible" ? "warning" : "info"
|
|
3042
|
+
);
|
|
3043
|
+
}
|
|
3044
|
+
function registerDroneCommands(pi, options = {}) {
|
|
3045
|
+
pi.registerCommand("drone-doctor", {
|
|
3046
|
+
description: "Check the resolved Pi host, core tools and Drone command contract",
|
|
3047
|
+
handler: async (_args, ctx) => emitReport(buildDoctorReport(pi, options), ctx)
|
|
3048
|
+
});
|
|
3049
|
+
pi.registerCommand("drone-example", {
|
|
3050
|
+
description: "Preview or start a read-only Drone knowledge, research, analysis or evidence example",
|
|
3051
|
+
handler: async (args, ctx) => {
|
|
3052
|
+
const parsed = parseExampleArgs(args);
|
|
3053
|
+
const knowledgeStatus = parsed.example === "knowledge" ? await resolveKnowledgeStatus(pi, ctx) : void 0;
|
|
3054
|
+
const report = buildExampleReport(pi, parsed.mode, parsed.question, {
|
|
3055
|
+
example: parsed.example,
|
|
3056
|
+
knowledgeStatus
|
|
3057
|
+
});
|
|
3058
|
+
if (parsed.mode === "run" && report.status === "started" && typeof pi.sendUserMessage === "function") {
|
|
3059
|
+
await pi.sendUserMessage(
|
|
3060
|
+
`Run a read-only Drone ${report.example} example for this question: ${parsed.question}
|
|
3061
|
+
Use local evidence first, preserve source URIs and hashes, and report blocked/unknown states instead of guessing.`,
|
|
3062
|
+
{ deliverAs: "followUp", expandPromptTemplates: true }
|
|
3063
|
+
);
|
|
3064
|
+
}
|
|
3065
|
+
emitReport(report, ctx);
|
|
3066
|
+
}
|
|
3067
|
+
});
|
|
3068
|
+
}
|
|
3069
|
+
|
|
2821
3070
|
// ../shared/src/analysis-orchestration.ts
|
|
2822
3071
|
var ANALYSIS_STAGES = Object.freeze([
|
|
2823
3072
|
"intake",
|
|
@@ -10685,6 +10934,18 @@ var ComputeHostInputSchema = typebox_exports.Object(
|
|
|
10685
10934
|
},
|
|
10686
10935
|
{ additionalProperties: false }
|
|
10687
10936
|
);
|
|
10937
|
+
var ComputeSshConfigHostSchema = typebox_exports.Object(
|
|
10938
|
+
{
|
|
10939
|
+
alias: typebox_exports.String({ minLength: 1, maxLength: 64, pattern: "^[A-Za-z0-9._-]+$" }),
|
|
10940
|
+
hostname: typebox_exports.Optional(typebox_exports.String({ maxLength: 512 })),
|
|
10941
|
+
port: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, maximum: 65535 })),
|
|
10942
|
+
user: typebox_exports.Optional(typebox_exports.String({ maxLength: 128 })),
|
|
10943
|
+
identityFiles: typebox_exports.Array(typebox_exports.String({ maxLength: 1024 }), { maxItems: 8 }),
|
|
10944
|
+
proxyJump: typebox_exports.Optional(typebox_exports.String({ maxLength: 512 })),
|
|
10945
|
+
source: typebox_exports.Literal("ssh-config")
|
|
10946
|
+
},
|
|
10947
|
+
{ additionalProperties: false }
|
|
10948
|
+
);
|
|
10688
10949
|
var ComputeBudgetSchema = typebox_exports.Object(
|
|
10689
10950
|
{
|
|
10690
10951
|
/** Total CPU core-hours allowed for this task. */
|
|
@@ -11608,6 +11869,61 @@ var GitBranchesSchema = typebox_exports.Object(
|
|
|
11608
11869
|
{ additionalProperties: false }
|
|
11609
11870
|
);
|
|
11610
11871
|
var NullableString = typebox_exports.Union([typebox_exports.String(), typebox_exports.Null()]);
|
|
11872
|
+
var SkillRepositoryAddInputSchema = typebox_exports.Unsafe(
|
|
11873
|
+
typebox_exports.Object(
|
|
11874
|
+
{
|
|
11875
|
+
kind: typebox_exports.Union([typebox_exports.Literal("git"), typebox_exports.Literal("local")]),
|
|
11876
|
+
source: typebox_exports.String({ minLength: 1, maxLength: 4096 }),
|
|
11877
|
+
ref: typebox_exports.Optional(typebox_exports.String({ minLength: 1, maxLength: 256 })),
|
|
11878
|
+
subpath: typebox_exports.Optional(typebox_exports.String({ maxLength: 1024 })),
|
|
11879
|
+
license: typebox_exports.String({ minLength: 1, maxLength: 256 }),
|
|
11880
|
+
licenseEvidence: typebox_exports.Optional(typebox_exports.String({ maxLength: 4096 })),
|
|
11881
|
+
name: typebox_exports.Optional(typebox_exports.String({ maxLength: 256 }))
|
|
11882
|
+
},
|
|
11883
|
+
{ additionalProperties: false }
|
|
11884
|
+
)
|
|
11885
|
+
);
|
|
11886
|
+
var SkillRepositoryRecordSchema = typebox_exports.Unsafe(
|
|
11887
|
+
typebox_exports.Object(
|
|
11888
|
+
{
|
|
11889
|
+
id: typebox_exports.String({ minLength: 1, maxLength: 64 }),
|
|
11890
|
+
name: typebox_exports.String({ minLength: 1, maxLength: 256 }),
|
|
11891
|
+
kind: typebox_exports.Union([typebox_exports.Literal("git"), typebox_exports.Literal("local")]),
|
|
11892
|
+
source: typebox_exports.String({ minLength: 1, maxLength: 4096 }),
|
|
11893
|
+
ref: typebox_exports.Optional(typebox_exports.String({ maxLength: 256 })),
|
|
11894
|
+
subpath: typebox_exports.Optional(typebox_exports.String({ maxLength: 1024 })),
|
|
11895
|
+
license: typebox_exports.String({ minLength: 1, maxLength: 256 }),
|
|
11896
|
+
licenseEvidence: typebox_exports.Optional(typebox_exports.String({ maxLength: 4096 })),
|
|
11897
|
+
status: typebox_exports.Union([typebox_exports.Literal("ready"), typebox_exports.Literal("update-available"), typebox_exports.Literal("error")]),
|
|
11898
|
+
skillCount: typebox_exports.Integer({ minimum: 0, maximum: 1e3 }),
|
|
11899
|
+
lastCheckedAt: typebox_exports.Optional(typebox_exports.String({ maxLength: 64 })),
|
|
11900
|
+
lastAppliedAt: typebox_exports.Optional(typebox_exports.String({ maxLength: 64 })),
|
|
11901
|
+
lastError: typebox_exports.Optional(typebox_exports.String({ maxLength: 2e3 })),
|
|
11902
|
+
updateAvailable: typebox_exports.Optional(typebox_exports.Boolean())
|
|
11903
|
+
},
|
|
11904
|
+
{ additionalProperties: false }
|
|
11905
|
+
)
|
|
11906
|
+
);
|
|
11907
|
+
var SkillRepositoryListSchema = typebox_exports.Array(SkillRepositoryRecordSchema, { maxItems: 100 });
|
|
11908
|
+
var SkillRepositoryCheckResultSchema = typebox_exports.Unsafe(
|
|
11909
|
+
typebox_exports.Object(
|
|
11910
|
+
{
|
|
11911
|
+
repository: SkillRepositoryRecordSchema,
|
|
11912
|
+
changedFiles: typebox_exports.Array(typebox_exports.String({ maxLength: 1024 }), { maxItems: 1e3 })
|
|
11913
|
+
},
|
|
11914
|
+
{ additionalProperties: false }
|
|
11915
|
+
)
|
|
11916
|
+
);
|
|
11917
|
+
var SkillRepositoryUpdateResultSchema = typebox_exports.Unsafe(
|
|
11918
|
+
typebox_exports.Object(
|
|
11919
|
+
{
|
|
11920
|
+
repository: SkillRepositoryRecordSchema,
|
|
11921
|
+
changedFiles: typebox_exports.Array(typebox_exports.String({ maxLength: 1024 }), { maxItems: 1e3 }),
|
|
11922
|
+
restartedRequired: typebox_exports.Literal(true)
|
|
11923
|
+
},
|
|
11924
|
+
{ additionalProperties: false }
|
|
11925
|
+
)
|
|
11926
|
+
);
|
|
11611
11927
|
var AppContract = defineDomain("app", {
|
|
11612
11928
|
methods: {
|
|
11613
11929
|
getInfo: {
|
|
@@ -11695,8 +12011,26 @@ var AppContract = defineDomain("app", {
|
|
|
11695
12011
|
checkForUpdates: { args: typebox_exports.Tuple([]), result: typebox_exports.Void() },
|
|
11696
12012
|
downloadUpdate: { args: typebox_exports.Tuple([]), result: typebox_exports.Void() },
|
|
11697
12013
|
installUpdate: { args: typebox_exports.Tuple([]), result: typebox_exports.Void() },
|
|
12014
|
+
checkResearchSkills: { args: typebox_exports.Tuple([]), result: typebox_exports.Void() },
|
|
11698
12015
|
updateResearchSkills: { args: typebox_exports.Tuple([]), result: typebox_exports.Void() },
|
|
11699
12016
|
restartForResearchSkills: { args: typebox_exports.Tuple([]), result: typebox_exports.Void() },
|
|
12017
|
+
listSkillRepositories: { args: typebox_exports.Tuple([]), result: SkillRepositoryListSchema },
|
|
12018
|
+
addSkillRepository: {
|
|
12019
|
+
args: typebox_exports.Tuple([SkillRepositoryAddInputSchema]),
|
|
12020
|
+
result: SkillRepositoryRecordSchema
|
|
12021
|
+
},
|
|
12022
|
+
checkSkillRepository: {
|
|
12023
|
+
args: typebox_exports.Tuple([typebox_exports.String({ minLength: 1, maxLength: 64 })]),
|
|
12024
|
+
result: SkillRepositoryCheckResultSchema
|
|
12025
|
+
},
|
|
12026
|
+
updateSkillRepository: {
|
|
12027
|
+
args: typebox_exports.Tuple([typebox_exports.String({ minLength: 1, maxLength: 64 })]),
|
|
12028
|
+
result: SkillRepositoryUpdateResultSchema
|
|
12029
|
+
},
|
|
12030
|
+
removeSkillRepository: {
|
|
12031
|
+
args: typebox_exports.Tuple([typebox_exports.String({ minLength: 1, maxLength: 64 })]),
|
|
12032
|
+
result: typebox_exports.Void()
|
|
12033
|
+
},
|
|
11700
12034
|
saveFileDialog: {
|
|
11701
12035
|
args: typebox_exports.Tuple([typebox_exports.String(), typebox_exports.String()]),
|
|
11702
12036
|
result: NullableString
|
|
@@ -11709,6 +12043,7 @@ var AppContract = defineDomain("app", {
|
|
|
11709
12043
|
result: NullableString
|
|
11710
12044
|
},
|
|
11711
12045
|
pickDirectory: { args: typebox_exports.Tuple([]), result: NullableString },
|
|
12046
|
+
formalKnowledgeVault: { args: typebox_exports.Tuple([]), result: NullableString },
|
|
11712
12047
|
getGitBranch: { args: typebox_exports.Tuple([typebox_exports.String()]), result: NullableString },
|
|
11713
12048
|
listGitBranches: { args: typebox_exports.Tuple([typebox_exports.String()]), result: GitBranchesSchema },
|
|
11714
12049
|
checkoutBranch: { args: typebox_exports.Tuple([typebox_exports.String(), typebox_exports.String()]), result: typebox_exports.String() }
|
|
@@ -11786,6 +12121,7 @@ var OnboardingStepArgs = typebox_exports.Tuple([
|
|
|
11786
12121
|
var ComputeContract = defineDomain("compute", {
|
|
11787
12122
|
methods: {
|
|
11788
12123
|
listHosts: { args: EmptyArgs, result: typebox_exports.Array(ComputeHostSchema, { maxItems: 256 }) },
|
|
12124
|
+
listSshConfig: { args: EmptyArgs, result: typebox_exports.Array(ComputeSshConfigHostSchema, { maxItems: 256 }) },
|
|
11789
12125
|
getHost: { args: IdArgs, result: typebox_exports.Union([ComputeHostSchema, typebox_exports.Null()]) },
|
|
11790
12126
|
saveHost: { args: typebox_exports.Tuple([ComputeHostInputSchema]), result: ComputeHostSchema },
|
|
11791
12127
|
removeHost: { args: IdArgs, result: typebox_exports.Void() },
|
|
@@ -12129,9 +12465,10 @@ var SpecialistSettingsInput = typebox_exports.Object(
|
|
|
12129
12465
|
);
|
|
12130
12466
|
var ZoteroStatusSchema = typebox_exports.Object(
|
|
12131
12467
|
{
|
|
12132
|
-
registered: typebox_exports.Boolean(),
|
|
12133
|
-
enabled: typebox_exports.Boolean(),
|
|
12468
|
+
registered: typebox_exports.Optional(typebox_exports.Boolean()),
|
|
12469
|
+
enabled: typebox_exports.Optional(typebox_exports.Boolean()),
|
|
12134
12470
|
command: typebox_exports.Union([typebox_exports.String(), typebox_exports.Null()]),
|
|
12471
|
+
version: typebox_exports.Optional(typebox_exports.Union([typebox_exports.String(), typebox_exports.Null()])),
|
|
12135
12472
|
localApiReachable: typebox_exports.Boolean(),
|
|
12136
12473
|
desktopDetected: typebox_exports.Boolean(),
|
|
12137
12474
|
desktopPath: typebox_exports.Union([typebox_exports.String(), typebox_exports.Null()]),
|
|
@@ -12327,6 +12664,13 @@ var KnowledgeContract = defineDomain("knowledge", {
|
|
|
12327
12664
|
args: OneObject(),
|
|
12328
12665
|
result: typebox_exports.Unknown()
|
|
12329
12666
|
},
|
|
12667
|
+
getMaintenanceSettings: { args: typebox_exports.Tuple([]), result: ResultObject() },
|
|
12668
|
+
saveMaintenanceSettings: {
|
|
12669
|
+
args: OneObject(),
|
|
12670
|
+
result: ResultObject()
|
|
12671
|
+
},
|
|
12672
|
+
runMaintenance: { args: OneObject(), result: ResultObject() },
|
|
12673
|
+
getMaintenanceRuns: { args: typebox_exports.Tuple([]), result: typebox_exports.Array(ResultObject()) },
|
|
12330
12674
|
getZoteroStatus: {
|
|
12331
12675
|
args: typebox_exports.Tuple([]),
|
|
12332
12676
|
result: ZoteroStatusSchema
|
|
@@ -12558,6 +12902,60 @@ var ConfiguredPackageInfoSchema = typebox_exports.Object(
|
|
|
12558
12902
|
},
|
|
12559
12903
|
{ additionalProperties: false }
|
|
12560
12904
|
);
|
|
12905
|
+
var PackageLifecycleEventSchema = typebox_exports.Object(
|
|
12906
|
+
{
|
|
12907
|
+
type: typebox_exports.Union([
|
|
12908
|
+
typebox_exports.Literal("staged"),
|
|
12909
|
+
typebox_exports.Literal("verified"),
|
|
12910
|
+
typebox_exports.Literal("enabled"),
|
|
12911
|
+
typebox_exports.Literal("disabled"),
|
|
12912
|
+
typebox_exports.Literal("drained"),
|
|
12913
|
+
typebox_exports.Literal("reloaded"),
|
|
12914
|
+
typebox_exports.Literal("reload_deferred"),
|
|
12915
|
+
typebox_exports.Literal("rolled_back"),
|
|
12916
|
+
typebox_exports.Literal("failed")
|
|
12917
|
+
]),
|
|
12918
|
+
at: typebox_exports.Number({ minimum: 0 }),
|
|
12919
|
+
sessionId: typebox_exports.Optional(typebox_exports.String({ minLength: 1 })),
|
|
12920
|
+
detail: typebox_exports.Optional(typebox_exports.String())
|
|
12921
|
+
},
|
|
12922
|
+
{ additionalProperties: false }
|
|
12923
|
+
);
|
|
12924
|
+
var PackageLifecycleErrorSchema = typebox_exports.Object(
|
|
12925
|
+
{
|
|
12926
|
+
code: typebox_exports.Union([
|
|
12927
|
+
typebox_exports.Literal("invalid-source"),
|
|
12928
|
+
typebox_exports.Literal("builtin"),
|
|
12929
|
+
typebox_exports.Literal("not-installed"),
|
|
12930
|
+
typebox_exports.Literal("unavailable"),
|
|
12931
|
+
typebox_exports.Literal("operation-failed")
|
|
12932
|
+
]),
|
|
12933
|
+
message: typebox_exports.String({ minLength: 1 }),
|
|
12934
|
+
retryable: typebox_exports.Boolean()
|
|
12935
|
+
},
|
|
12936
|
+
{ additionalProperties: false }
|
|
12937
|
+
);
|
|
12938
|
+
var PackageLifecycleReceiptSchema = typebox_exports.Object(
|
|
12939
|
+
{
|
|
12940
|
+
operation: typebox_exports.Union([typebox_exports.Literal("install"), typebox_exports.Literal("update"), typebox_exports.Literal("remove")]),
|
|
12941
|
+
packageName: typebox_exports.String({ minLength: 1 }),
|
|
12942
|
+
source: typebox_exports.String({ minLength: 1 }),
|
|
12943
|
+
scope: typebox_exports.Union([typebox_exports.Literal("user"), typebox_exports.Literal("project")]),
|
|
12944
|
+
status: typebox_exports.Union([typebox_exports.Literal("succeeded"), typebox_exports.Literal("failed")]),
|
|
12945
|
+
effect: typebox_exports.Union([
|
|
12946
|
+
typebox_exports.Literal("current-session"),
|
|
12947
|
+
typebox_exports.Literal("next-session"),
|
|
12948
|
+
typebox_exports.Literal("app-restart")
|
|
12949
|
+
]),
|
|
12950
|
+
version: typebox_exports.Optional(typebox_exports.String({ minLength: 1 })),
|
|
12951
|
+
previousVersion: typebox_exports.Optional(typebox_exports.String({ minLength: 1 })),
|
|
12952
|
+
events: typebox_exports.Array(PackageLifecycleEventSchema),
|
|
12953
|
+
error: typebox_exports.Optional(PackageLifecycleErrorSchema),
|
|
12954
|
+
reloadedSessionIds: typebox_exports.Optional(typebox_exports.Array(typebox_exports.String({ minLength: 1 }))),
|
|
12955
|
+
deferredSessionIds: typebox_exports.Optional(typebox_exports.Array(typebox_exports.String({ minLength: 1 })))
|
|
12956
|
+
},
|
|
12957
|
+
{ additionalProperties: false }
|
|
12958
|
+
);
|
|
12561
12959
|
var PackagesContract = defineDomain("packages", {
|
|
12562
12960
|
methods: {
|
|
12563
12961
|
searchCatalog: {
|
|
@@ -12566,16 +12964,25 @@ var PackagesContract = defineDomain("packages", {
|
|
|
12566
12964
|
args: SearchCatalogArgsSchema,
|
|
12567
12965
|
result: typebox_exports.Unsafe(CatalogSearchResultSchema)
|
|
12568
12966
|
},
|
|
12967
|
+
/** Latest published npm version per package name (null when unknown/offline). */
|
|
12968
|
+
latestPackageVersions: {
|
|
12969
|
+
args: typebox_exports.Tuple([typebox_exports.Array(typebox_exports.String({ minLength: 1 }), { maxItems: 50 })]),
|
|
12970
|
+
result: typebox_exports.Record(typebox_exports.String(), typebox_exports.Union([typebox_exports.String(), typebox_exports.Null()]))
|
|
12971
|
+
},
|
|
12569
12972
|
installPackage: {
|
|
12570
12973
|
args: typebox_exports.Tuple([typebox_exports.String({ minLength: 1 })]),
|
|
12571
|
-
result: typebox_exports.
|
|
12974
|
+
result: typebox_exports.Unsafe(PackageLifecycleReceiptSchema)
|
|
12975
|
+
},
|
|
12976
|
+
updatePackage: {
|
|
12977
|
+
args: typebox_exports.Tuple([typebox_exports.String({ minLength: 1 })]),
|
|
12978
|
+
result: typebox_exports.Unsafe(PackageLifecycleReceiptSchema)
|
|
12572
12979
|
},
|
|
12573
12980
|
removePackage: {
|
|
12574
12981
|
args: typebox_exports.Tuple([
|
|
12575
12982
|
typebox_exports.String({ minLength: 1 }),
|
|
12576
12983
|
typebox_exports.Union([typebox_exports.Literal("user"), typebox_exports.Literal("project")])
|
|
12577
12984
|
]),
|
|
12578
|
-
result: typebox_exports.
|
|
12985
|
+
result: typebox_exports.Unsafe(PackageLifecycleReceiptSchema)
|
|
12579
12986
|
},
|
|
12580
12987
|
listConfiguredPackages: {
|
|
12581
12988
|
args: typebox_exports.Tuple([]),
|
|
@@ -12892,6 +13299,10 @@ var SessionsContract = defineDomain("sessions", {
|
|
|
12892
13299
|
{ additionalProperties: false }
|
|
12893
13300
|
)
|
|
12894
13301
|
},
|
|
13302
|
+
setSkillNamesEnabled: {
|
|
13303
|
+
args: typebox_exports.Tuple([Id2, typebox_exports.Array(typebox_exports.String()), typebox_exports.Boolean()]),
|
|
13304
|
+
result: typebox_exports.Object({ disabled: typebox_exports.Array(typebox_exports.String()) }, { additionalProperties: false })
|
|
13305
|
+
},
|
|
12895
13306
|
compact: {
|
|
12896
13307
|
args: typebox_exports.Union([typebox_exports.Tuple([Id2]), typebox_exports.Tuple([Id2, typebox_exports.String()])]),
|
|
12897
13308
|
result: typebox_exports.Void()
|
|
@@ -16954,12 +17365,12 @@ import { stat as stat2 } from "node:fs/promises";
|
|
|
16954
17365
|
|
|
16955
17366
|
// src/path.ts
|
|
16956
17367
|
import { homedir as homedir2 } from "node:os";
|
|
16957
|
-
import { isAbsolute as isAbsolute5, join, resolve as resolve6 } from "node:path";
|
|
17368
|
+
import { isAbsolute as isAbsolute5, join as join2, resolve as resolve6 } from "node:path";
|
|
16958
17369
|
var UNICODE_SPACES = /[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]/g;
|
|
16959
17370
|
function resolveToolPath(rawPath, cwd, home = homedir2()) {
|
|
16960
17371
|
let path = rawPath.replace(UNICODE_SPACES, " ");
|
|
16961
17372
|
if (path === "~") path = home;
|
|
16962
|
-
else if (path.startsWith("~/")) path =
|
|
17373
|
+
else if (path.startsWith("~/")) path = join2(home, path.slice(2));
|
|
16963
17374
|
return isAbsolute5(path) ? path : resolve6(cwd, path);
|
|
16964
17375
|
}
|
|
16965
17376
|
|
|
@@ -17020,13 +17431,13 @@ function makeDeliverFilesTool() {
|
|
|
17020
17431
|
}
|
|
17021
17432
|
|
|
17022
17433
|
// src/memory.ts
|
|
17023
|
-
import { mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
17024
|
-
import { join as
|
|
17434
|
+
import { mkdirSync, readdirSync, readFileSync as readFileSync2, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
17435
|
+
import { join as join3 } from "node:path";
|
|
17025
17436
|
var MEMORY_TYPES = ["user", "feedback", "project", "reference"];
|
|
17026
17437
|
var MEMORY_INDEX = "MEMORY.md";
|
|
17027
17438
|
var MAX_INDEX_LINES = 200;
|
|
17028
17439
|
function memoryDir(cwd) {
|
|
17029
|
-
return
|
|
17440
|
+
return join3(cwd, ".pi", "memory");
|
|
17030
17441
|
}
|
|
17031
17442
|
function memorySlug(name) {
|
|
17032
17443
|
const slug = name.trim().toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "").slice(0, 64);
|
|
@@ -17079,7 +17490,7 @@ function listMemories(cwd) {
|
|
|
17079
17490
|
}
|
|
17080
17491
|
const out = [];
|
|
17081
17492
|
for (const file of files) {
|
|
17082
|
-
const entry = parseMemory(
|
|
17493
|
+
const entry = parseMemory(readFileSync2(join3(dir, file), "utf8"));
|
|
17083
17494
|
if (entry) out.push({ ...entry, file });
|
|
17084
17495
|
}
|
|
17085
17496
|
return out;
|
|
@@ -17088,14 +17499,14 @@ function writeMemory(cwd, entry) {
|
|
|
17088
17499
|
const dir = memoryDir(cwd);
|
|
17089
17500
|
mkdirSync(dir, { recursive: true });
|
|
17090
17501
|
const file = `${entry.type}_${memorySlug(entry.name)}.md`;
|
|
17091
|
-
atomicWrite(
|
|
17092
|
-
atomicWrite(
|
|
17502
|
+
atomicWrite(join3(dir, file), serializeMemory(entry));
|
|
17503
|
+
atomicWrite(join3(dir, MEMORY_INDEX), renderMemoryIndex(listMemories(cwd)));
|
|
17093
17504
|
return file;
|
|
17094
17505
|
}
|
|
17095
17506
|
function memoryIndexPrompt(cwd) {
|
|
17096
17507
|
let index;
|
|
17097
17508
|
try {
|
|
17098
|
-
index =
|
|
17509
|
+
index = readFileSync2(join3(memoryDir(cwd), MEMORY_INDEX), "utf8");
|
|
17099
17510
|
} catch {
|
|
17100
17511
|
return [];
|
|
17101
17512
|
}
|
|
@@ -17111,8 +17522,8 @@ ${shown.join("\n")}${lines.length > shown.length ? `
|
|
|
17111
17522
|
function forgetMemory(cwd, file) {
|
|
17112
17523
|
if (!/^[^\\/]+\.md$/.test(file) || file === MEMORY_INDEX) return false;
|
|
17113
17524
|
if (!listMemories(cwd).some((e) => e.file === file)) return false;
|
|
17114
|
-
rmSync(
|
|
17115
|
-
atomicWrite(
|
|
17525
|
+
rmSync(join3(memoryDir(cwd), file));
|
|
17526
|
+
atomicWrite(join3(memoryDir(cwd), MEMORY_INDEX), renderMemoryIndex(listMemories(cwd)));
|
|
17116
17527
|
return true;
|
|
17117
17528
|
}
|
|
17118
17529
|
|
|
@@ -17309,136 +17720,6 @@ ${formatTodoList(todos)}`;
|
|
|
17309
17720
|
};
|
|
17310
17721
|
}
|
|
17311
17722
|
|
|
17312
|
-
// src/drone-commands.ts
|
|
17313
|
-
import { readFileSync as readFileSync2 } from "node:fs";
|
|
17314
|
-
import { createRequire } from "node:module";
|
|
17315
|
-
import { dirname, join as join3 } from "node:path";
|
|
17316
|
-
var DRONE_COMMAND_SCHEMA_VERSION = 1;
|
|
17317
|
-
var PI_CORE_PACKAGE_VERSION = "0.1.1";
|
|
17318
|
-
var PI_HOST_RANGE = ">=1.1.0 <2.0.0";
|
|
17319
|
-
var CORE_TOOLS = [
|
|
17320
|
-
"ask_user",
|
|
17321
|
-
"set_status",
|
|
17322
|
-
"todo",
|
|
17323
|
-
"deliver_files",
|
|
17324
|
-
"memory_save",
|
|
17325
|
-
"task_plan",
|
|
17326
|
-
"task_status",
|
|
17327
|
-
"task_wait",
|
|
17328
|
-
"task_reconcile",
|
|
17329
|
-
"task_evidence_restore"
|
|
17330
|
-
];
|
|
17331
|
-
var EXAMPLE_TOOLS = [
|
|
17332
|
-
"knowledge_status",
|
|
17333
|
-
"knowledge_search",
|
|
17334
|
-
"research_search_sources",
|
|
17335
|
-
"research_read_source",
|
|
17336
|
-
"research_answer_sources"
|
|
17337
|
-
];
|
|
17338
|
-
function packageVersion() {
|
|
17339
|
-
const configured = process.env.PI_VERSION?.trim();
|
|
17340
|
-
if (configured) return { version: configured, source: "PI_VERSION" };
|
|
17341
|
-
try {
|
|
17342
|
-
const require2 = createRequire(import.meta.url);
|
|
17343
|
-
const entry = require2.resolve("@earendil-works/pi-coding-agent");
|
|
17344
|
-
const packagePath = join3(dirname(entry), "..", "package.json");
|
|
17345
|
-
const metadata = JSON.parse(readFileSync2(packagePath, "utf8"));
|
|
17346
|
-
if (typeof metadata.version === "string" && metadata.version.length > 0)
|
|
17347
|
-
return { version: metadata.version, source: "resolved-package" };
|
|
17348
|
-
} catch {
|
|
17349
|
-
}
|
|
17350
|
-
return { version: null, source: "unavailable" };
|
|
17351
|
-
}
|
|
17352
|
-
function snapshot(pi) {
|
|
17353
|
-
const tools = typeof pi?.getAllTools === "function" ? pi.getAllTools().map((tool) => String(tool?.name || "")).filter(Boolean) : typeof pi?.getActiveTools === "function" ? pi.getActiveTools().map((name) => String(name)).filter(Boolean) : [];
|
|
17354
|
-
const commands = typeof pi?.getCommands === "function" ? pi.getCommands().map((command) => String(command?.name || "")).filter(Boolean) : [];
|
|
17355
|
-
return { tools: [...new Set(tools)].sort(), commands: [...new Set(commands)].sort() };
|
|
17356
|
-
}
|
|
17357
|
-
function buildDoctorReport(pi, options = {}) {
|
|
17358
|
-
const current = snapshot(pi);
|
|
17359
|
-
const missingTools = CORE_TOOLS.filter((name) => !current.tools.includes(name));
|
|
17360
|
-
const missingCommands = ["drone-doctor", "drone-example"].filter((name) => !current.commands.includes(name));
|
|
17361
|
-
const resolved = options.hostVersion === void 0 ? packageVersion() : { version: options.hostVersion, source: "host-contract" };
|
|
17362
|
-
const hostKind = options.hostKind || "native-pi";
|
|
17363
|
-
const checks = [
|
|
17364
|
-
{
|
|
17365
|
-
id: "core-tools",
|
|
17366
|
-
status: missingTools.length ? "blocked" : "pass",
|
|
17367
|
-
detail: missingTools.length ? "pi-core tools are missing" : "all pi-core tools are registered",
|
|
17368
|
-
...missingTools.length ? { missing: missingTools } : {}
|
|
17369
|
-
},
|
|
17370
|
-
{
|
|
17371
|
-
id: "drone-commands",
|
|
17372
|
-
status: missingCommands.length ? "blocked" : "pass",
|
|
17373
|
-
detail: missingCommands.length ? "Drone onboarding commands are missing" : "doctor and example commands are registered",
|
|
17374
|
-
...missingCommands.length ? { missing: missingCommands } : {}
|
|
17375
|
-
},
|
|
17376
|
-
{
|
|
17377
|
-
id: "pi-host-version",
|
|
17378
|
-
status: resolved.version ? "pass" : "unknown",
|
|
17379
|
-
detail: resolved.version ? `resolved Pi host ${resolved.version}` : "Pi host version is not exposed by this host"
|
|
17380
|
-
}
|
|
17381
|
-
];
|
|
17382
|
-
const blocked = checks.some((check) => check.status === "blocked");
|
|
17383
|
-
return {
|
|
17384
|
-
schemaVersion: DRONE_COMMAND_SCHEMA_VERSION,
|
|
17385
|
-
command: "drone-doctor",
|
|
17386
|
-
status: blocked ? "blocked" : resolved.version ? "pass" : "unknown",
|
|
17387
|
-
plugin: { name: "@gyoungwe/pi-core", version: PI_CORE_PACKAGE_VERSION, piRange: PI_HOST_RANGE },
|
|
17388
|
-
host: { kind: hostKind, version: resolved.version || null, source: resolved.source },
|
|
17389
|
-
checks,
|
|
17390
|
-
commands: current.commands,
|
|
17391
|
-
tools: current.tools,
|
|
17392
|
-
next: blocked ? "\u5B89\u88C5\u6216\u91CD\u65B0\u52A0\u8F7D\u7F3A\u5931\u7684 Drone \u63D2\u4EF6\u540E\u91CD\u8BD5 /drone-doctor" : null
|
|
17393
|
-
};
|
|
17394
|
-
}
|
|
17395
|
-
function buildExampleReport(pi, mode = "preview", question) {
|
|
17396
|
-
const current = snapshot(pi);
|
|
17397
|
-
const missingTools = EXAMPLE_TOOLS.filter((name) => !current.tools.includes(name));
|
|
17398
|
-
const hasQuestion = Boolean(question?.trim());
|
|
17399
|
-
const status2 = missingTools.length ? "blocked" : mode === "run" && hasQuestion ? "started" : hasQuestion ? "ready" : "needs-data";
|
|
17400
|
-
return {
|
|
17401
|
-
schemaVersion: DRONE_COMMAND_SCHEMA_VERSION,
|
|
17402
|
-
command: "drone-example",
|
|
17403
|
-
status: status2,
|
|
17404
|
-
mode,
|
|
17405
|
-
title: "Evidence-gated local research example",
|
|
17406
|
-
steps: ["inspect local knowledge", "read at least two sources", "answer with source receipts"],
|
|
17407
|
-
requiredTools: [...EXAMPLE_TOOLS],
|
|
17408
|
-
missingTools: [...missingTools],
|
|
17409
|
-
next: missingTools.length ? "\u5B89\u88C5\u5E76\u542F\u7528 pi-knowledge \u4E0E pi-research \u540E\u91CD\u8BD5 /drone-example" : hasQuestion ? mode === "run" ? "\u7814\u7A76\u56DE\u5408\u5DF2\u6392\u961F\uFF1B\u7B49\u5F85\u771F\u5B9E\u6765\u6E90\u56DE\u6267" : "\u8FD0\u884C /drone-example --run <\u7814\u7A76\u95EE\u9898> \u5F00\u59CB\u53EA\u8BFB\u793A\u4F8B" : "\u63D0\u4F9B\u4E00\u4E2A\u7814\u7A76\u95EE\u9898\uFF1A/drone-example --run <\u7814\u7A76\u95EE\u9898>",
|
|
17410
|
-
...hasQuestion ? { question: question?.trim() } : {}
|
|
17411
|
-
};
|
|
17412
|
-
}
|
|
17413
|
-
function emitReport(report, ctx) {
|
|
17414
|
-
const message = JSON.stringify(report);
|
|
17415
|
-
if (ctx.mode === "print" || ctx.mode === "json") console.log(message);
|
|
17416
|
-
else ctx.ui.notify(message, report.status === "blocked" ? "warning" : "info");
|
|
17417
|
-
}
|
|
17418
|
-
function registerDroneCommands(pi, options = {}) {
|
|
17419
|
-
pi.registerCommand("drone-doctor", {
|
|
17420
|
-
description: "Check the resolved Pi host, core tools and Drone command contract",
|
|
17421
|
-
handler: async (_args, ctx) => emitReport(buildDoctorReport(pi, options), ctx)
|
|
17422
|
-
});
|
|
17423
|
-
pi.registerCommand("drone-example", {
|
|
17424
|
-
description: "Preview or start a read-only evidence-gated research example",
|
|
17425
|
-
handler: async (args, ctx) => {
|
|
17426
|
-
const trimmed = args.trim();
|
|
17427
|
-
const run = trimmed.startsWith("--run");
|
|
17428
|
-
const question = run ? trimmed.slice("--run".length).trim() : trimmed;
|
|
17429
|
-
const report = buildExampleReport(pi, run ? "run" : "preview", question || void 0);
|
|
17430
|
-
if (run && report.status === "started" && typeof pi.sendUserMessage === "function") {
|
|
17431
|
-
await pi.sendUserMessage(
|
|
17432
|
-
`Run a read-only Drone research example for this question: ${question}
|
|
17433
|
-
Use local evidence first, read at least two sources, preserve source URIs and hashes, and report blocked/unknown states instead of guessing.`,
|
|
17434
|
-
{ deliverAs: "followUp", expandPromptTemplates: true }
|
|
17435
|
-
);
|
|
17436
|
-
}
|
|
17437
|
-
emitReport(report, ctx);
|
|
17438
|
-
}
|
|
17439
|
-
});
|
|
17440
|
-
}
|
|
17441
|
-
|
|
17442
17723
|
// src/index.ts
|
|
17443
17724
|
var DEFAULT_HOST_VERSION = "1.1.0";
|
|
17444
17725
|
function createNativePiHostPort(ctx, hostVersion = DEFAULT_HOST_VERSION) {
|
|
@@ -17511,7 +17792,9 @@ function registerPiCore(pi, options = {}) {
|
|
|
17511
17792
|
activeContext = void 0;
|
|
17512
17793
|
});
|
|
17513
17794
|
registerTaskRuntime(pi);
|
|
17514
|
-
registerDroneCommands(pi, {
|
|
17795
|
+
registerDroneCommands(pi, {
|
|
17796
|
+
hostKind: options.host?.host === "drone-desktop" ? "drone-desktop" : "native-pi"
|
|
17797
|
+
});
|
|
17515
17798
|
const ask = options.ask || ((request, signal, context) => askWithNativeUi(request, signal, context || activeContext));
|
|
17516
17799
|
pi.registerTool(makeAskUserTool({ ask }));
|
|
17517
17800
|
pi.registerTool(makeStatusTool());
|
|
@@ -17543,6 +17826,7 @@ export {
|
|
|
17543
17826
|
makeTodoTool,
|
|
17544
17827
|
memoryIndexPrompt,
|
|
17545
17828
|
normalizeTodos,
|
|
17829
|
+
parseExampleArgs,
|
|
17546
17830
|
registerDroneCommands,
|
|
17547
17831
|
registerPiCore,
|
|
17548
17832
|
writeMemory
|