musubix2 0.5.9 → 0.5.10
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/.claude/.musubix-managed +1 -1
- package/dist/assets/skills-manifest.json +1 -1
- package/dist/cli.js +138 -73
- package/dist/index.js +138 -73
- package/package.json +1 -1
package/.claude/.musubix-managed
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"generator":"musubix2","version":"0.5.
|
|
1
|
+
{"generator":"musubix2","version":"0.5.10","timestamp":"2026-07-09T10:42:36.515Z"}
|
package/dist/cli.js
CHANGED
|
@@ -14431,93 +14431,129 @@ function researchTools() {
|
|
|
14431
14431
|
param("depth", "string", "Research depth: shallow | medium | deep", false, "medium")
|
|
14432
14432
|
], async (params) => {
|
|
14433
14433
|
try {
|
|
14434
|
-
const
|
|
14435
|
-
const
|
|
14436
|
-
|
|
14434
|
+
const { createResearchEngine: createResearchEngine2 } = await Promise.resolve().then(() => (init_dist10(), dist_exports10));
|
|
14435
|
+
const sources = normalizeSources(params["sources"]);
|
|
14436
|
+
const result = createResearchEngine2().research({ topic: params["topic"] ?? "", depth: params["depth"] ?? "medium" }, sources);
|
|
14437
|
+
return ok(result);
|
|
14437
14438
|
} catch {
|
|
14438
|
-
return
|
|
14439
|
+
return fail("Deep-research package not available");
|
|
14439
14440
|
}
|
|
14440
14441
|
}),
|
|
14441
|
-
tool("research.iterative", "Perform iterative
|
|
14442
|
+
tool("research.iterative", "Perform iterative research with progressive refinement over provided sources", "research", [
|
|
14442
14443
|
param("topic", "string", "Research topic"),
|
|
14443
|
-
param("
|
|
14444
|
+
param("depth", "string", "Depth: shallow | medium | deep", false, "medium"),
|
|
14445
|
+
param("sources", "array", "Sources as {title,type,relevance,content} objects")
|
|
14444
14446
|
], async (params) => {
|
|
14445
14447
|
try {
|
|
14446
|
-
const
|
|
14447
|
-
const
|
|
14448
|
-
|
|
14448
|
+
const { createResearchEngine: createResearchEngine2 } = await Promise.resolve().then(() => (init_dist10(), dist_exports10));
|
|
14449
|
+
const sources = normalizeSources(params["sources"]);
|
|
14450
|
+
const result = createResearchEngine2().researchIterative({ topic: params["topic"] ?? "", depth: params["depth"] ?? "medium" }, () => sources);
|
|
14451
|
+
return ok(result);
|
|
14449
14452
|
} catch {
|
|
14450
|
-
return
|
|
14453
|
+
return fail("Deep-research package not available");
|
|
14451
14454
|
}
|
|
14452
14455
|
}),
|
|
14453
|
-
tool("research.evidence", "
|
|
14454
|
-
param("
|
|
14455
|
-
param("sources", "array", "
|
|
14456
|
+
tool("research.evidence", "Accumulate research results and retrieve evidence for a topic", "research", [
|
|
14457
|
+
param("topic", "string", "Topic to gather evidence for"),
|
|
14458
|
+
param("sources", "array", "Sources as {title,type,relevance,content} objects")
|
|
14456
14459
|
], async (params) => {
|
|
14457
14460
|
try {
|
|
14458
|
-
const
|
|
14459
|
-
const
|
|
14460
|
-
|
|
14461
|
+
const { createResearchEngine: createResearchEngine2, createKnowledgeAccumulator: createKnowledgeAccumulator2 } = await Promise.resolve().then(() => (init_dist10(), dist_exports10));
|
|
14462
|
+
const sources = normalizeSources(params["sources"]);
|
|
14463
|
+
const topic = params["topic"] ?? "";
|
|
14464
|
+
const result = createResearchEngine2().research({ topic, depth: "medium" }, sources);
|
|
14465
|
+
const acc = createKnowledgeAccumulator2();
|
|
14466
|
+
acc.accumulate(result);
|
|
14467
|
+
return ok({ evidence: acc.query(topic), summary: result.summary, confidence: result.confidence });
|
|
14461
14468
|
} catch {
|
|
14462
|
-
return
|
|
14469
|
+
return fail("Deep-research package not available");
|
|
14463
14470
|
}
|
|
14464
14471
|
})
|
|
14465
14472
|
];
|
|
14466
14473
|
}
|
|
14474
|
+
function normalizeSources(raw) {
|
|
14475
|
+
const valid = /* @__PURE__ */ new Set(["code", "documentation", "article", "api-reference"]);
|
|
14476
|
+
const arr = Array.isArray(raw) ? raw : [];
|
|
14477
|
+
return arr.map((s, i) => {
|
|
14478
|
+
const o = s ?? {};
|
|
14479
|
+
const t = String(o["type"] ?? "documentation");
|
|
14480
|
+
return {
|
|
14481
|
+
title: String(o["title"] ?? `source-${i + 1}`),
|
|
14482
|
+
type: valid.has(t) ? t : "documentation",
|
|
14483
|
+
relevance: typeof o["relevance"] === "number" ? o["relevance"] : 0.5,
|
|
14484
|
+
content: String(o["content"] ?? (typeof s === "string" ? s : ""))
|
|
14485
|
+
};
|
|
14486
|
+
});
|
|
14487
|
+
}
|
|
14467
14488
|
function neuralTools() {
|
|
14468
14489
|
return [
|
|
14469
|
-
tool("neural.search", "Neural similarity search
|
|
14490
|
+
tool("neural.search", "Neural (TF-IDF) similarity search over provided documents", "neural", [
|
|
14470
14491
|
param("query", "string", "Search query"),
|
|
14492
|
+
param("documents", "array", "Documents to index: strings or {id,text} objects"),
|
|
14471
14493
|
param("topK", "number", "Number of results", false, 10)
|
|
14472
14494
|
], async (params) => {
|
|
14473
14495
|
try {
|
|
14474
|
-
const
|
|
14475
|
-
const
|
|
14476
|
-
|
|
14496
|
+
const { createNeuralSearchEngine: createNeuralSearchEngine2, createTfIdfEmbeddingModel: createTfIdfEmbeddingModel2 } = await Promise.resolve().then(() => (init_dist14(), dist_exports14));
|
|
14497
|
+
const model = createTfIdfEmbeddingModel2();
|
|
14498
|
+
const engine = createNeuralSearchEngine2();
|
|
14499
|
+
const docs = params["documents"] ?? [];
|
|
14500
|
+
const texts = docs.map((d) => typeof d === "string" ? d : d.text ?? "");
|
|
14501
|
+
const model2 = createTfIdfEmbeddingModel2();
|
|
14502
|
+
if (typeof model2.fit === "function") {
|
|
14503
|
+
model2.fit(texts);
|
|
14504
|
+
}
|
|
14505
|
+
const embedder = typeof model2.fit === "function" ? model2 : model;
|
|
14506
|
+
for (let i = 0; i < docs.length; i++) {
|
|
14507
|
+
const d = docs[i];
|
|
14508
|
+
const id = typeof d === "string" ? `doc-${i}` : d.id ?? `doc-${i}`;
|
|
14509
|
+
engine.addDocument(id, await embedder.embed(texts[i]), { text: texts[i] });
|
|
14510
|
+
}
|
|
14511
|
+
const hits = engine.search(await embedder.embed(params["query"] ?? ""), params["topK"] ?? 10);
|
|
14512
|
+
return ok({ query: params["query"], hits });
|
|
14477
14513
|
} catch {
|
|
14478
|
-
return
|
|
14514
|
+
return fail("Neural-search package not available");
|
|
14479
14515
|
}
|
|
14480
14516
|
}),
|
|
14481
|
-
tool("neural.embed", "Generate
|
|
14517
|
+
tool("neural.embed", "Generate a TF-IDF embedding vector for text", "neural", [param("text", "string", "Text to embed")], async (params) => {
|
|
14482
14518
|
try {
|
|
14483
|
-
const
|
|
14484
|
-
const
|
|
14485
|
-
|
|
14519
|
+
const { createTfIdfEmbeddingModel: createTfIdfEmbeddingModel2 } = await Promise.resolve().then(() => (init_dist14(), dist_exports14));
|
|
14520
|
+
const model = createTfIdfEmbeddingModel2();
|
|
14521
|
+
const text = params["text"] ?? "";
|
|
14522
|
+
if (typeof model.fit === "function") {
|
|
14523
|
+
model.fit([text]);
|
|
14524
|
+
}
|
|
14525
|
+
const vector = await model.embed(text);
|
|
14526
|
+
return ok({ vector, dimensions: Array.isArray(vector) ? vector.length : vector.values?.length ?? 0 });
|
|
14486
14527
|
} catch {
|
|
14487
|
-
return
|
|
14528
|
+
return fail("Neural-search package not available");
|
|
14488
14529
|
}
|
|
14489
14530
|
}),
|
|
14490
|
-
tool("neural.patterns.extract", "Wake phase: extract patterns from
|
|
14491
|
-
param("source", "string", "Source code or data to extract patterns from"),
|
|
14492
|
-
param("type", "string", "Pattern type: structural | behavioral | api", false, "structural")
|
|
14493
|
-
], async (params) => {
|
|
14531
|
+
tool("neural.patterns.extract", "Wake phase: extract patterns from a list of items", "neural", [param("items", "array", "Items (strings) to process for pattern extraction")], async (params) => {
|
|
14494
14532
|
try {
|
|
14495
|
-
const
|
|
14496
|
-
const
|
|
14497
|
-
return ok(
|
|
14533
|
+
const { createWakePhase: createWakePhase2 } = await Promise.resolve().then(() => (init_dist15(), dist_exports15));
|
|
14534
|
+
const items = (params["items"] ?? []).map(String);
|
|
14535
|
+
return ok(createWakePhase2().process(items));
|
|
14498
14536
|
} catch {
|
|
14499
|
-
return
|
|
14537
|
+
return fail("Wake-sleep package not available");
|
|
14500
14538
|
}
|
|
14501
14539
|
}),
|
|
14502
|
-
tool("neural.patterns.consolidate", "Sleep phase: consolidate and compress learned patterns", "neural", [param("patterns", "array", "
|
|
14540
|
+
tool("neural.patterns.consolidate", "Sleep phase: consolidate and compress learned patterns", "neural", [param("patterns", "array", "Pattern strings to consolidate")], async (params) => {
|
|
14503
14541
|
try {
|
|
14504
|
-
const
|
|
14505
|
-
const
|
|
14506
|
-
return ok(
|
|
14542
|
+
const { createSleepPhase: createSleepPhase2 } = await Promise.resolve().then(() => (init_dist15(), dist_exports15));
|
|
14543
|
+
const patterns = (params["patterns"] ?? []).map(String);
|
|
14544
|
+
return ok(createSleepPhase2().consolidate(patterns));
|
|
14507
14545
|
} catch {
|
|
14508
|
-
return
|
|
14546
|
+
return fail("Wake-sleep package not available");
|
|
14509
14547
|
}
|
|
14510
14548
|
}),
|
|
14511
|
-
tool("neural.library.learn", "Learn patterns from
|
|
14512
|
-
param("library", "string", "Library name or path"),
|
|
14513
|
-
param("depth", "string", "Analysis depth: api | usage | deep", false, "api")
|
|
14514
|
-
], async (params) => {
|
|
14549
|
+
tool("neural.library.learn", "Learn reusable patterns from code snippets (E-graph library learning)", "neural", [param("snippets", "array", "Array of code snippet strings to learn from")], async (params) => {
|
|
14515
14550
|
try {
|
|
14516
|
-
const
|
|
14517
|
-
const
|
|
14518
|
-
|
|
14551
|
+
const { createLibraryLearner: createLibraryLearner2 } = await Promise.resolve().then(() => (init_dist11(), dist_exports11));
|
|
14552
|
+
const snippets = (params["snippets"] ?? []).map(String);
|
|
14553
|
+
const patterns = createLibraryLearner2().learn(snippets);
|
|
14554
|
+
return ok({ patterns, count: patterns.length });
|
|
14519
14555
|
} catch {
|
|
14520
|
-
return
|
|
14556
|
+
return fail("Library-learner package not available");
|
|
14521
14557
|
}
|
|
14522
14558
|
})
|
|
14523
14559
|
];
|
|
@@ -14671,52 +14707,81 @@ function formalVerifyTools() {
|
|
|
14671
14707
|
})
|
|
14672
14708
|
];
|
|
14673
14709
|
}
|
|
14710
|
+
async function loadTracker(basePath) {
|
|
14711
|
+
const { createStateTracker: createStateTracker2 } = await Promise.resolve().then(() => (init_dist6(), dist_exports6));
|
|
14712
|
+
const { existsSync: existsSync12, readFileSync: readFileSync7 } = await import("node:fs");
|
|
14713
|
+
const { join: join8 } = await import("node:path");
|
|
14714
|
+
const tracker = createStateTracker2();
|
|
14715
|
+
const file = join8(basePath, ".musubix", "workflow-state.json");
|
|
14716
|
+
try {
|
|
14717
|
+
if (existsSync12(file))
|
|
14718
|
+
tracker.restore(JSON.parse(readFileSync7(file, "utf-8")));
|
|
14719
|
+
} catch {
|
|
14720
|
+
}
|
|
14721
|
+
return { tracker, file };
|
|
14722
|
+
}
|
|
14723
|
+
async function saveTracker(tracker, file) {
|
|
14724
|
+
const { writeFileSync: writeFileSync4, mkdirSync: mkdirSync4 } = await import("node:fs");
|
|
14725
|
+
const { dirname: dirname4 } = await import("node:path");
|
|
14726
|
+
mkdirSync4(dirname4(file), { recursive: true });
|
|
14727
|
+
writeFileSync4(file, JSON.stringify(tracker.toJSON(), null, 2), "utf-8");
|
|
14728
|
+
}
|
|
14674
14729
|
function workflowTools() {
|
|
14675
14730
|
return [
|
|
14676
|
-
tool("workflow.phase.current", "Get the current SDD workflow phase", "workflow", [param("basePath", "string", "Project base path", false, ".")], async (params) => {
|
|
14731
|
+
tool("workflow.phase.current", "Get the current SDD workflow phase and approvals", "workflow", [param("basePath", "string", "Project base path", false, ".")], async (params) => {
|
|
14677
14732
|
try {
|
|
14678
|
-
const
|
|
14679
|
-
const
|
|
14680
|
-
const
|
|
14681
|
-
return ok(
|
|
14733
|
+
const { PHASE_ORDER: PHASE_ORDER2 } = await Promise.resolve().then(() => (init_dist6(), dist_exports6));
|
|
14734
|
+
const { tracker } = await loadTracker(params["basePath"] ?? ".");
|
|
14735
|
+
const state = tracker.getState();
|
|
14736
|
+
return ok({
|
|
14737
|
+
currentPhase: state.currentPhase,
|
|
14738
|
+
approvals: PHASE_ORDER2.map((p) => ({ phase: p, approved: tracker.isApproved(p) }))
|
|
14739
|
+
});
|
|
14682
14740
|
} catch {
|
|
14683
|
-
return
|
|
14741
|
+
return fail("Workflow-engine package not available");
|
|
14684
14742
|
}
|
|
14685
14743
|
}),
|
|
14686
|
-
tool("workflow.phase.transition", "Transition to
|
|
14744
|
+
tool("workflow.phase.transition", "Transition to a target SDD workflow phase (persisted)", "workflow", [
|
|
14687
14745
|
param("targetPhase", "string", "Target phase to transition to"),
|
|
14688
14746
|
param("basePath", "string", "Project base path", false, ".")
|
|
14689
14747
|
], async (params) => {
|
|
14690
14748
|
try {
|
|
14691
|
-
const
|
|
14692
|
-
const
|
|
14693
|
-
const result =
|
|
14694
|
-
|
|
14749
|
+
const { createPhaseController: createPhaseController2 } = await Promise.resolve().then(() => (init_dist6(), dist_exports6));
|
|
14750
|
+
const { tracker, file } = await loadTracker(params["basePath"] ?? ".");
|
|
14751
|
+
const result = await createPhaseController2(tracker).transitionTo(params["targetPhase"]);
|
|
14752
|
+
if (result.success)
|
|
14753
|
+
await saveTracker(tracker, file);
|
|
14754
|
+
return ok(result);
|
|
14695
14755
|
} catch {
|
|
14696
|
-
return
|
|
14756
|
+
return fail("Workflow-engine package not available");
|
|
14697
14757
|
}
|
|
14698
14758
|
}),
|
|
14699
|
-
tool("workflow.gate.check", "Check
|
|
14700
|
-
param("
|
|
14759
|
+
tool("workflow.gate.check", "Check whether the workflow can transition to a target phase (quality gates)", "workflow", [
|
|
14760
|
+
param("targetPhase", "string", "Target phase to check"),
|
|
14701
14761
|
param("basePath", "string", "Project base path", false, ".")
|
|
14702
14762
|
], async (params) => {
|
|
14703
14763
|
try {
|
|
14704
|
-
const
|
|
14705
|
-
const
|
|
14706
|
-
const
|
|
14707
|
-
|
|
14764
|
+
const { createPhaseController: createPhaseController2 } = await Promise.resolve().then(() => (init_dist6(), dist_exports6));
|
|
14765
|
+
const { tracker } = await loadTracker(params["basePath"] ?? ".");
|
|
14766
|
+
const target = params["targetPhase"] ?? params["gate"];
|
|
14767
|
+
const canTransition = await createPhaseController2(tracker).canTransition(target);
|
|
14768
|
+
return ok({ targetPhase: target, canTransition });
|
|
14708
14769
|
} catch {
|
|
14709
|
-
return
|
|
14770
|
+
return fail("Workflow-engine package not available");
|
|
14710
14771
|
}
|
|
14711
14772
|
}),
|
|
14712
|
-
tool("workflow.
|
|
14773
|
+
tool("workflow.approve", "Approve the current (or a named) SDD phase (persisted)", "workflow", [
|
|
14774
|
+
param("phase", "string", "Phase to approve"),
|
|
14775
|
+
param("basePath", "string", "Project base path", false, ".")
|
|
14776
|
+
], async (params) => {
|
|
14713
14777
|
try {
|
|
14714
|
-
const
|
|
14715
|
-
const
|
|
14716
|
-
|
|
14717
|
-
|
|
14778
|
+
const { tracker, file } = await loadTracker(params["basePath"] ?? ".");
|
|
14779
|
+
const phase = params["phase"] ?? tracker.getState().currentPhase;
|
|
14780
|
+
tracker.approve(phase);
|
|
14781
|
+
await saveTracker(tracker, file);
|
|
14782
|
+
return ok({ phase, approved: true });
|
|
14718
14783
|
} catch {
|
|
14719
|
-
return
|
|
14784
|
+
return fail("Workflow-engine package not available");
|
|
14720
14785
|
}
|
|
14721
14786
|
})
|
|
14722
14787
|
];
|
package/dist/index.js
CHANGED
|
@@ -14431,93 +14431,129 @@ function researchTools() {
|
|
|
14431
14431
|
param("depth", "string", "Research depth: shallow | medium | deep", false, "medium")
|
|
14432
14432
|
], async (params) => {
|
|
14433
14433
|
try {
|
|
14434
|
-
const
|
|
14435
|
-
const
|
|
14436
|
-
|
|
14434
|
+
const { createResearchEngine: createResearchEngine2 } = await Promise.resolve().then(() => (init_dist10(), dist_exports10));
|
|
14435
|
+
const sources = normalizeSources(params["sources"]);
|
|
14436
|
+
const result = createResearchEngine2().research({ topic: params["topic"] ?? "", depth: params["depth"] ?? "medium" }, sources);
|
|
14437
|
+
return ok(result);
|
|
14437
14438
|
} catch {
|
|
14438
|
-
return
|
|
14439
|
+
return fail("Deep-research package not available");
|
|
14439
14440
|
}
|
|
14440
14441
|
}),
|
|
14441
|
-
tool("research.iterative", "Perform iterative
|
|
14442
|
+
tool("research.iterative", "Perform iterative research with progressive refinement over provided sources", "research", [
|
|
14442
14443
|
param("topic", "string", "Research topic"),
|
|
14443
|
-
param("
|
|
14444
|
+
param("depth", "string", "Depth: shallow | medium | deep", false, "medium"),
|
|
14445
|
+
param("sources", "array", "Sources as {title,type,relevance,content} objects")
|
|
14444
14446
|
], async (params) => {
|
|
14445
14447
|
try {
|
|
14446
|
-
const
|
|
14447
|
-
const
|
|
14448
|
-
|
|
14448
|
+
const { createResearchEngine: createResearchEngine2 } = await Promise.resolve().then(() => (init_dist10(), dist_exports10));
|
|
14449
|
+
const sources = normalizeSources(params["sources"]);
|
|
14450
|
+
const result = createResearchEngine2().researchIterative({ topic: params["topic"] ?? "", depth: params["depth"] ?? "medium" }, () => sources);
|
|
14451
|
+
return ok(result);
|
|
14449
14452
|
} catch {
|
|
14450
|
-
return
|
|
14453
|
+
return fail("Deep-research package not available");
|
|
14451
14454
|
}
|
|
14452
14455
|
}),
|
|
14453
|
-
tool("research.evidence", "
|
|
14454
|
-
param("
|
|
14455
|
-
param("sources", "array", "
|
|
14456
|
+
tool("research.evidence", "Accumulate research results and retrieve evidence for a topic", "research", [
|
|
14457
|
+
param("topic", "string", "Topic to gather evidence for"),
|
|
14458
|
+
param("sources", "array", "Sources as {title,type,relevance,content} objects")
|
|
14456
14459
|
], async (params) => {
|
|
14457
14460
|
try {
|
|
14458
|
-
const
|
|
14459
|
-
const
|
|
14460
|
-
|
|
14461
|
+
const { createResearchEngine: createResearchEngine2, createKnowledgeAccumulator: createKnowledgeAccumulator2 } = await Promise.resolve().then(() => (init_dist10(), dist_exports10));
|
|
14462
|
+
const sources = normalizeSources(params["sources"]);
|
|
14463
|
+
const topic = params["topic"] ?? "";
|
|
14464
|
+
const result = createResearchEngine2().research({ topic, depth: "medium" }, sources);
|
|
14465
|
+
const acc = createKnowledgeAccumulator2();
|
|
14466
|
+
acc.accumulate(result);
|
|
14467
|
+
return ok({ evidence: acc.query(topic), summary: result.summary, confidence: result.confidence });
|
|
14461
14468
|
} catch {
|
|
14462
|
-
return
|
|
14469
|
+
return fail("Deep-research package not available");
|
|
14463
14470
|
}
|
|
14464
14471
|
})
|
|
14465
14472
|
];
|
|
14466
14473
|
}
|
|
14474
|
+
function normalizeSources(raw) {
|
|
14475
|
+
const valid = /* @__PURE__ */ new Set(["code", "documentation", "article", "api-reference"]);
|
|
14476
|
+
const arr = Array.isArray(raw) ? raw : [];
|
|
14477
|
+
return arr.map((s, i) => {
|
|
14478
|
+
const o = s ?? {};
|
|
14479
|
+
const t = String(o["type"] ?? "documentation");
|
|
14480
|
+
return {
|
|
14481
|
+
title: String(o["title"] ?? `source-${i + 1}`),
|
|
14482
|
+
type: valid.has(t) ? t : "documentation",
|
|
14483
|
+
relevance: typeof o["relevance"] === "number" ? o["relevance"] : 0.5,
|
|
14484
|
+
content: String(o["content"] ?? (typeof s === "string" ? s : ""))
|
|
14485
|
+
};
|
|
14486
|
+
});
|
|
14487
|
+
}
|
|
14467
14488
|
function neuralTools() {
|
|
14468
14489
|
return [
|
|
14469
|
-
tool("neural.search", "Neural similarity search
|
|
14490
|
+
tool("neural.search", "Neural (TF-IDF) similarity search over provided documents", "neural", [
|
|
14470
14491
|
param("query", "string", "Search query"),
|
|
14492
|
+
param("documents", "array", "Documents to index: strings or {id,text} objects"),
|
|
14471
14493
|
param("topK", "number", "Number of results", false, 10)
|
|
14472
14494
|
], async (params) => {
|
|
14473
14495
|
try {
|
|
14474
|
-
const
|
|
14475
|
-
const
|
|
14476
|
-
|
|
14496
|
+
const { createNeuralSearchEngine: createNeuralSearchEngine2, createTfIdfEmbeddingModel: createTfIdfEmbeddingModel2 } = await Promise.resolve().then(() => (init_dist14(), dist_exports14));
|
|
14497
|
+
const model = createTfIdfEmbeddingModel2();
|
|
14498
|
+
const engine = createNeuralSearchEngine2();
|
|
14499
|
+
const docs = params["documents"] ?? [];
|
|
14500
|
+
const texts = docs.map((d) => typeof d === "string" ? d : d.text ?? "");
|
|
14501
|
+
const model2 = createTfIdfEmbeddingModel2();
|
|
14502
|
+
if (typeof model2.fit === "function") {
|
|
14503
|
+
model2.fit(texts);
|
|
14504
|
+
}
|
|
14505
|
+
const embedder = typeof model2.fit === "function" ? model2 : model;
|
|
14506
|
+
for (let i = 0; i < docs.length; i++) {
|
|
14507
|
+
const d = docs[i];
|
|
14508
|
+
const id = typeof d === "string" ? `doc-${i}` : d.id ?? `doc-${i}`;
|
|
14509
|
+
engine.addDocument(id, await embedder.embed(texts[i]), { text: texts[i] });
|
|
14510
|
+
}
|
|
14511
|
+
const hits = engine.search(await embedder.embed(params["query"] ?? ""), params["topK"] ?? 10);
|
|
14512
|
+
return ok({ query: params["query"], hits });
|
|
14477
14513
|
} catch {
|
|
14478
|
-
return
|
|
14514
|
+
return fail("Neural-search package not available");
|
|
14479
14515
|
}
|
|
14480
14516
|
}),
|
|
14481
|
-
tool("neural.embed", "Generate
|
|
14517
|
+
tool("neural.embed", "Generate a TF-IDF embedding vector for text", "neural", [param("text", "string", "Text to embed")], async (params) => {
|
|
14482
14518
|
try {
|
|
14483
|
-
const
|
|
14484
|
-
const
|
|
14485
|
-
|
|
14519
|
+
const { createTfIdfEmbeddingModel: createTfIdfEmbeddingModel2 } = await Promise.resolve().then(() => (init_dist14(), dist_exports14));
|
|
14520
|
+
const model = createTfIdfEmbeddingModel2();
|
|
14521
|
+
const text = params["text"] ?? "";
|
|
14522
|
+
if (typeof model.fit === "function") {
|
|
14523
|
+
model.fit([text]);
|
|
14524
|
+
}
|
|
14525
|
+
const vector = await model.embed(text);
|
|
14526
|
+
return ok({ vector, dimensions: Array.isArray(vector) ? vector.length : vector.values?.length ?? 0 });
|
|
14486
14527
|
} catch {
|
|
14487
|
-
return
|
|
14528
|
+
return fail("Neural-search package not available");
|
|
14488
14529
|
}
|
|
14489
14530
|
}),
|
|
14490
|
-
tool("neural.patterns.extract", "Wake phase: extract patterns from
|
|
14491
|
-
param("source", "string", "Source code or data to extract patterns from"),
|
|
14492
|
-
param("type", "string", "Pattern type: structural | behavioral | api", false, "structural")
|
|
14493
|
-
], async (params) => {
|
|
14531
|
+
tool("neural.patterns.extract", "Wake phase: extract patterns from a list of items", "neural", [param("items", "array", "Items (strings) to process for pattern extraction")], async (params) => {
|
|
14494
14532
|
try {
|
|
14495
|
-
const
|
|
14496
|
-
const
|
|
14497
|
-
return ok(
|
|
14533
|
+
const { createWakePhase: createWakePhase2 } = await Promise.resolve().then(() => (init_dist15(), dist_exports15));
|
|
14534
|
+
const items = (params["items"] ?? []).map(String);
|
|
14535
|
+
return ok(createWakePhase2().process(items));
|
|
14498
14536
|
} catch {
|
|
14499
|
-
return
|
|
14537
|
+
return fail("Wake-sleep package not available");
|
|
14500
14538
|
}
|
|
14501
14539
|
}),
|
|
14502
|
-
tool("neural.patterns.consolidate", "Sleep phase: consolidate and compress learned patterns", "neural", [param("patterns", "array", "
|
|
14540
|
+
tool("neural.patterns.consolidate", "Sleep phase: consolidate and compress learned patterns", "neural", [param("patterns", "array", "Pattern strings to consolidate")], async (params) => {
|
|
14503
14541
|
try {
|
|
14504
|
-
const
|
|
14505
|
-
const
|
|
14506
|
-
return ok(
|
|
14542
|
+
const { createSleepPhase: createSleepPhase2 } = await Promise.resolve().then(() => (init_dist15(), dist_exports15));
|
|
14543
|
+
const patterns = (params["patterns"] ?? []).map(String);
|
|
14544
|
+
return ok(createSleepPhase2().consolidate(patterns));
|
|
14507
14545
|
} catch {
|
|
14508
|
-
return
|
|
14546
|
+
return fail("Wake-sleep package not available");
|
|
14509
14547
|
}
|
|
14510
14548
|
}),
|
|
14511
|
-
tool("neural.library.learn", "Learn patterns from
|
|
14512
|
-
param("library", "string", "Library name or path"),
|
|
14513
|
-
param("depth", "string", "Analysis depth: api | usage | deep", false, "api")
|
|
14514
|
-
], async (params) => {
|
|
14549
|
+
tool("neural.library.learn", "Learn reusable patterns from code snippets (E-graph library learning)", "neural", [param("snippets", "array", "Array of code snippet strings to learn from")], async (params) => {
|
|
14515
14550
|
try {
|
|
14516
|
-
const
|
|
14517
|
-
const
|
|
14518
|
-
|
|
14551
|
+
const { createLibraryLearner: createLibraryLearner2 } = await Promise.resolve().then(() => (init_dist11(), dist_exports11));
|
|
14552
|
+
const snippets = (params["snippets"] ?? []).map(String);
|
|
14553
|
+
const patterns = createLibraryLearner2().learn(snippets);
|
|
14554
|
+
return ok({ patterns, count: patterns.length });
|
|
14519
14555
|
} catch {
|
|
14520
|
-
return
|
|
14556
|
+
return fail("Library-learner package not available");
|
|
14521
14557
|
}
|
|
14522
14558
|
})
|
|
14523
14559
|
];
|
|
@@ -14671,52 +14707,81 @@ function formalVerifyTools() {
|
|
|
14671
14707
|
})
|
|
14672
14708
|
];
|
|
14673
14709
|
}
|
|
14710
|
+
async function loadTracker(basePath) {
|
|
14711
|
+
const { createStateTracker: createStateTracker2 } = await Promise.resolve().then(() => (init_dist6(), dist_exports6));
|
|
14712
|
+
const { existsSync: existsSync12, readFileSync: readFileSync7 } = await import("node:fs");
|
|
14713
|
+
const { join: join8 } = await import("node:path");
|
|
14714
|
+
const tracker = createStateTracker2();
|
|
14715
|
+
const file = join8(basePath, ".musubix", "workflow-state.json");
|
|
14716
|
+
try {
|
|
14717
|
+
if (existsSync12(file))
|
|
14718
|
+
tracker.restore(JSON.parse(readFileSync7(file, "utf-8")));
|
|
14719
|
+
} catch {
|
|
14720
|
+
}
|
|
14721
|
+
return { tracker, file };
|
|
14722
|
+
}
|
|
14723
|
+
async function saveTracker(tracker, file) {
|
|
14724
|
+
const { writeFileSync: writeFileSync4, mkdirSync: mkdirSync4 } = await import("node:fs");
|
|
14725
|
+
const { dirname: dirname4 } = await import("node:path");
|
|
14726
|
+
mkdirSync4(dirname4(file), { recursive: true });
|
|
14727
|
+
writeFileSync4(file, JSON.stringify(tracker.toJSON(), null, 2), "utf-8");
|
|
14728
|
+
}
|
|
14674
14729
|
function workflowTools() {
|
|
14675
14730
|
return [
|
|
14676
|
-
tool("workflow.phase.current", "Get the current SDD workflow phase", "workflow", [param("basePath", "string", "Project base path", false, ".")], async (params) => {
|
|
14731
|
+
tool("workflow.phase.current", "Get the current SDD workflow phase and approvals", "workflow", [param("basePath", "string", "Project base path", false, ".")], async (params) => {
|
|
14677
14732
|
try {
|
|
14678
|
-
const
|
|
14679
|
-
const
|
|
14680
|
-
const
|
|
14681
|
-
return ok(
|
|
14733
|
+
const { PHASE_ORDER: PHASE_ORDER2 } = await Promise.resolve().then(() => (init_dist6(), dist_exports6));
|
|
14734
|
+
const { tracker } = await loadTracker(params["basePath"] ?? ".");
|
|
14735
|
+
const state = tracker.getState();
|
|
14736
|
+
return ok({
|
|
14737
|
+
currentPhase: state.currentPhase,
|
|
14738
|
+
approvals: PHASE_ORDER2.map((p) => ({ phase: p, approved: tracker.isApproved(p) }))
|
|
14739
|
+
});
|
|
14682
14740
|
} catch {
|
|
14683
|
-
return
|
|
14741
|
+
return fail("Workflow-engine package not available");
|
|
14684
14742
|
}
|
|
14685
14743
|
}),
|
|
14686
|
-
tool("workflow.phase.transition", "Transition to
|
|
14744
|
+
tool("workflow.phase.transition", "Transition to a target SDD workflow phase (persisted)", "workflow", [
|
|
14687
14745
|
param("targetPhase", "string", "Target phase to transition to"),
|
|
14688
14746
|
param("basePath", "string", "Project base path", false, ".")
|
|
14689
14747
|
], async (params) => {
|
|
14690
14748
|
try {
|
|
14691
|
-
const
|
|
14692
|
-
const
|
|
14693
|
-
const result =
|
|
14694
|
-
|
|
14749
|
+
const { createPhaseController: createPhaseController2 } = await Promise.resolve().then(() => (init_dist6(), dist_exports6));
|
|
14750
|
+
const { tracker, file } = await loadTracker(params["basePath"] ?? ".");
|
|
14751
|
+
const result = await createPhaseController2(tracker).transitionTo(params["targetPhase"]);
|
|
14752
|
+
if (result.success)
|
|
14753
|
+
await saveTracker(tracker, file);
|
|
14754
|
+
return ok(result);
|
|
14695
14755
|
} catch {
|
|
14696
|
-
return
|
|
14756
|
+
return fail("Workflow-engine package not available");
|
|
14697
14757
|
}
|
|
14698
14758
|
}),
|
|
14699
|
-
tool("workflow.gate.check", "Check
|
|
14700
|
-
param("
|
|
14759
|
+
tool("workflow.gate.check", "Check whether the workflow can transition to a target phase (quality gates)", "workflow", [
|
|
14760
|
+
param("targetPhase", "string", "Target phase to check"),
|
|
14701
14761
|
param("basePath", "string", "Project base path", false, ".")
|
|
14702
14762
|
], async (params) => {
|
|
14703
14763
|
try {
|
|
14704
|
-
const
|
|
14705
|
-
const
|
|
14706
|
-
const
|
|
14707
|
-
|
|
14764
|
+
const { createPhaseController: createPhaseController2 } = await Promise.resolve().then(() => (init_dist6(), dist_exports6));
|
|
14765
|
+
const { tracker } = await loadTracker(params["basePath"] ?? ".");
|
|
14766
|
+
const target = params["targetPhase"] ?? params["gate"];
|
|
14767
|
+
const canTransition = await createPhaseController2(tracker).canTransition(target);
|
|
14768
|
+
return ok({ targetPhase: target, canTransition });
|
|
14708
14769
|
} catch {
|
|
14709
|
-
return
|
|
14770
|
+
return fail("Workflow-engine package not available");
|
|
14710
14771
|
}
|
|
14711
14772
|
}),
|
|
14712
|
-
tool("workflow.
|
|
14773
|
+
tool("workflow.approve", "Approve the current (or a named) SDD phase (persisted)", "workflow", [
|
|
14774
|
+
param("phase", "string", "Phase to approve"),
|
|
14775
|
+
param("basePath", "string", "Project base path", false, ".")
|
|
14776
|
+
], async (params) => {
|
|
14713
14777
|
try {
|
|
14714
|
-
const
|
|
14715
|
-
const
|
|
14716
|
-
|
|
14717
|
-
|
|
14778
|
+
const { tracker, file } = await loadTracker(params["basePath"] ?? ".");
|
|
14779
|
+
const phase = params["phase"] ?? tracker.getState().currentPhase;
|
|
14780
|
+
tracker.approve(phase);
|
|
14781
|
+
await saveTracker(tracker, file);
|
|
14782
|
+
return ok({ phase, approved: true });
|
|
14718
14783
|
} catch {
|
|
14719
|
-
return
|
|
14784
|
+
return fail("Workflow-engine package not available");
|
|
14720
14785
|
}
|
|
14721
14786
|
})
|
|
14722
14787
|
];
|