ostacky 0.10.3 → 0.11.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 +16 -3
- package/assets/agents/ostacky.md +11 -5
- package/assets/commands/install-stack.md +1 -1
- package/assets/docs/ostacky-reference.md +1 -0
- package/assets/mcp/ostacky-controller/controller-core.js +30 -0
- package/assets/mcp/ostacky-controller/index.js +216 -18
- package/assets/mcp/ostacky-controller/session-slots.js +110 -0
- package/assets/mcp/ostacky-controller/session-store.js +290 -0
- package/assets/plugins/ostacky-controller/compaction-threshold.ts +274 -0
- package/assets/plugins/ostacky-controller/controller-core.ts +30 -0
- package/assets/plugins/ostacky-controller/index.ts +306 -80
- package/assets/plugins/ostacky-controller/session-slots.ts +167 -0
- package/assets/plugins/ostacky-controller/session-store.ts +394 -0
- package/assets/plugins/ostacky-controller/tiered.ts +29 -0
- package/dist/cli.js +362 -129
- package/dist/mcp/ostacky-controller/index.js +655 -108
- package/manifest.json +29 -29
- package/package.json +4 -3
package/dist/cli.js
CHANGED
|
@@ -205,7 +205,19 @@ function verifyChecksum(content, expectedHash, label) {
|
|
|
205
205
|
recibido: ${actual}`);
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
var
|
|
208
|
+
var SENSITIVE_DEFAULT;
|
|
209
|
+
var init_security = __esm(() => {
|
|
210
|
+
SENSITIVE_DEFAULT = [
|
|
211
|
+
"**/.env*",
|
|
212
|
+
"**/.secrets/**",
|
|
213
|
+
"**/*.pem",
|
|
214
|
+
"**/*.key",
|
|
215
|
+
"**/.aws/**",
|
|
216
|
+
"**/.ssh/**",
|
|
217
|
+
"**/credentials.json",
|
|
218
|
+
"**/.npmrc"
|
|
219
|
+
];
|
|
220
|
+
});
|
|
209
221
|
|
|
210
222
|
// src/fs.ts
|
|
211
223
|
import {
|
|
@@ -638,31 +650,31 @@ var init_fs = __esm(() => {
|
|
|
638
650
|
var manifest_default;
|
|
639
651
|
var init_manifest = __esm(() => {
|
|
640
652
|
manifest_default = {
|
|
641
|
-
version: "0.
|
|
653
|
+
version: "0.11.0",
|
|
642
654
|
repo: "JaimeHoracio/Ostacky",
|
|
643
|
-
tag: "v0.
|
|
655
|
+
tag: "v0.11.0",
|
|
644
656
|
agents: [
|
|
645
657
|
{
|
|
646
658
|
name: "ostacky",
|
|
647
659
|
file: "assets/agents/ostacky.md",
|
|
648
|
-
description: "Orquestador con recuperación automática (nunca se congela), ruteo por nivel de impacto, controller MCP con SDK oficial, edición segura con fallback inline, y delegación en OpenSpec + Superpowers. v0.
|
|
649
|
-
version: "0.
|
|
650
|
-
sha256: "
|
|
660
|
+
description: "Orquestador con recuperación automática (nunca se congela), ruteo por nivel de impacto, controller MCP con SDK oficial, edición segura con fallback inline, y delegación en OpenSpec + Superpowers. v0.11.0: prune de skills obsoletas, lastHandoff, getAvailableTransitions, consecutiveFailures real, mem_session_summary automático al cierre.",
|
|
661
|
+
version: "0.11.0",
|
|
662
|
+
sha256: "6b1b19ce2b2ce174394281cb40e39f74db9db17e78ad8dd3c6eb5dc24dbb7812"
|
|
651
663
|
}
|
|
652
664
|
],
|
|
653
665
|
commands: [
|
|
654
666
|
{
|
|
655
667
|
name: "install-stack",
|
|
656
668
|
file: "assets/commands/install-stack.md",
|
|
657
|
-
description: "Instala el stack tecnológico del proyecto (CodeGraph, skills, OpenSpec, Engram, controller plugin). v0.
|
|
658
|
-
version: "0.
|
|
659
|
-
sha256: "
|
|
669
|
+
description: "Instala el stack tecnológico del proyecto (CodeGraph, skills, OpenSpec, Engram, controller plugin). v0.11.0: controller plugin como alma hard-gate, Context7 removido del stack.",
|
|
670
|
+
version: "0.11.0",
|
|
671
|
+
sha256: "87c9908455a1c976b616ac0da257cae98e20e5b8c631c6d6e4770a2f3c87ed4f"
|
|
660
672
|
},
|
|
661
673
|
{
|
|
662
674
|
name: "opsx-sync",
|
|
663
675
|
file: "assets/commands/opsx-sync.md",
|
|
664
676
|
description: "Sincroniza delta specs del change activo sin inicializar CodeGraph si ya existe índice",
|
|
665
|
-
version: "0.
|
|
677
|
+
version: "0.11.0",
|
|
666
678
|
sha256: "f883f9ad96f7d75778631d5cc13d8a1a9c3e6ec41396bbce8ce13cff2e66fca2"
|
|
667
679
|
}
|
|
668
680
|
],
|
|
@@ -670,16 +682,16 @@ var init_manifest = __esm(() => {
|
|
|
670
682
|
{
|
|
671
683
|
name: "ostacky-controller",
|
|
672
684
|
file: "assets/mcp/ostacky-controller/",
|
|
673
|
-
description: "Máquina de estados persistida con @modelcontextprotocol/server SDK. v0.
|
|
674
|
-
version: "0.
|
|
675
|
-
sha256: "
|
|
676
|
-
sourceSha256: "
|
|
685
|
+
description: "Máquina de estados persistida con @modelcontextprotocol/server SDK. v0.11.0: 22 tools (incluye set_handoff, get_handoff, clear_handoff, get_available_transitions funcional). Bugfixes: consecutiveFailures real, lastHandoff state, defaultChoice persistido. Robustez: degraded mode automático tras 3 fallos, persistence condicional para Nivel 0, prune de skills obsoletas.",
|
|
686
|
+
version: "0.11.0",
|
|
687
|
+
sha256: "8a013be07c8751f044c25860bf8846bbda12bd470d1ebf0d68b354c73117d53f",
|
|
688
|
+
sourceSha256: "330c85c8c9ed3a6c8733e1fe7287bf61b9256138675b0b95949635e89697c975"
|
|
677
689
|
},
|
|
678
690
|
{
|
|
679
691
|
name: "openspec",
|
|
680
692
|
file: "assets/mcp/openspec/",
|
|
681
693
|
description: "MCP server local para OpenSpec - proposal, apply, archive, sync de cambios",
|
|
682
|
-
version: "0.
|
|
694
|
+
version: "0.11.0",
|
|
683
695
|
sha256: "038ef43eaa1816251626610522f874a6c932528c00237f94f5354f18ed59ef53",
|
|
684
696
|
sourceSha256: "bdb283fe8ec2dfcba2ec4f38191f4039e58cd7ae12e44e66310783b42c827638"
|
|
685
697
|
}
|
|
@@ -689,105 +701,105 @@ var init_manifest = __esm(() => {
|
|
|
689
701
|
name: "brainstorming",
|
|
690
702
|
file: "assets/skills/brainstorming/SKILL.md",
|
|
691
703
|
description: "Skill unificado de pensamiento con dos modos: creative-design (producción de diseño → transición a implementación directa o openspec-propose) y open-exploration (exploración libre)",
|
|
692
|
-
version: "0.
|
|
704
|
+
version: "0.11.0",
|
|
693
705
|
sha256: "ba76eff6fb5bea08d3b26622089ea4739b7b542b3677a46071b2576f3f2001c7"
|
|
694
706
|
},
|
|
695
707
|
{
|
|
696
708
|
name: "execution-mode-evaluation",
|
|
697
709
|
file: "assets/skills/execution-mode-evaluation/SKILL.md",
|
|
698
710
|
description: "Skill de análisis de modo de ejecución — output reconciliado con controller snapshot contract (recommendation field)",
|
|
699
|
-
version: "0.
|
|
711
|
+
version: "0.11.0",
|
|
700
712
|
sha256: "9090132ccfe31dcf34b6d5f399c1135dcb1044c504d4beb026e0c7d9e09e7c0d"
|
|
701
713
|
},
|
|
702
714
|
{
|
|
703
715
|
name: "tdd",
|
|
704
716
|
file: "assets/skills/tdd/SKILL.md",
|
|
705
717
|
description: "Skill de test-driven development (Superpowers)",
|
|
706
|
-
version: "0.
|
|
718
|
+
version: "0.11.0",
|
|
707
719
|
sha256: "cce54e81cce46ba973066f9b43e74994a7dbf21aa756146c27689241cf62704d"
|
|
708
720
|
},
|
|
709
721
|
{
|
|
710
722
|
name: "subagent-driven-development",
|
|
711
723
|
file: "assets/skills/subagent-driven-development/SKILL.md",
|
|
712
724
|
description: "Skill de ejecución con subagentes (Superpowers) — ejecuta solo después de confirmación del coordinador Ostacky",
|
|
713
|
-
version: "0.
|
|
725
|
+
version: "0.11.0",
|
|
714
726
|
sha256: "1a42d714a9a13faf05f0bf7b580e8d837c2e77a5633839542ccce603023419e8"
|
|
715
727
|
},
|
|
716
728
|
{
|
|
717
729
|
name: "dispatching-parallel-agents",
|
|
718
730
|
file: "assets/skills/dispatching-parallel-agents/SKILL.md",
|
|
719
731
|
description: "Skill de dispatch paralelo de agentes (Superpowers)",
|
|
720
|
-
version: "0.
|
|
732
|
+
version: "0.11.0",
|
|
721
733
|
sha256: "7e7b712ef742d5631e302e6a71583e2bbbd33094da9281abfb84b43505fc3ef1"
|
|
722
734
|
},
|
|
723
735
|
{
|
|
724
736
|
name: "review",
|
|
725
737
|
file: "assets/skills/review/SKILL.md",
|
|
726
738
|
description: "Skill de revisión de código (Superpowers)",
|
|
727
|
-
version: "0.
|
|
739
|
+
version: "0.11.0",
|
|
728
740
|
sha256: "b19650ed4d1d4d9857a4dd5b7e08e91328a1a1fc9c45bcc2fb600fa9d0213279"
|
|
729
741
|
},
|
|
730
742
|
{
|
|
731
743
|
name: "receiving-code-review",
|
|
732
744
|
file: "assets/skills/receiving-code-review/SKILL.md",
|
|
733
745
|
description: "Skill de recibir y procesar feedback de code review",
|
|
734
|
-
version: "0.
|
|
746
|
+
version: "0.11.0",
|
|
735
747
|
sha256: "d761e884e71d8d3476ac734d287cae403a4024506a7d12e7361a448217c0a831"
|
|
736
748
|
},
|
|
737
749
|
{
|
|
738
750
|
name: "openspec-propose",
|
|
739
751
|
file: "assets/skills/openspec-propose/SKILL.md",
|
|
740
752
|
description: "Skill de generación de proposal (OpenSpec)",
|
|
741
|
-
version: "0.
|
|
753
|
+
version: "0.11.0",
|
|
742
754
|
sha256: "9049b944cea88a5428fd5d77b411a0ed32d169ad68acda911b68365fac08f38f"
|
|
743
755
|
},
|
|
744
756
|
{
|
|
745
757
|
name: "openspec-apply-change",
|
|
746
758
|
file: "assets/skills/openspec-apply-change/SKILL.md",
|
|
747
759
|
description: "Skill de aplicación de change (OpenSpec)",
|
|
748
|
-
version: "0.
|
|
760
|
+
version: "0.11.0",
|
|
749
761
|
sha256: "dfc823bf89fc7505e91ab6dee9c1f004be38a410bd3d88fb67b211b1b6cbb1d0"
|
|
750
762
|
},
|
|
751
763
|
{
|
|
752
764
|
name: "openspec-archive-change",
|
|
753
765
|
file: "assets/skills/openspec-archive-change/SKILL.md",
|
|
754
766
|
description: "Skill de archivo de change (OpenSpec)",
|
|
755
|
-
version: "0.
|
|
767
|
+
version: "0.11.0",
|
|
756
768
|
sha256: "16e4b561de7747283663fed602e506abf502452c49a8d4b86d7a5539c40f0195"
|
|
757
769
|
},
|
|
758
770
|
{
|
|
759
771
|
name: "openspec-explore",
|
|
760
772
|
file: "assets/skills/openspec-explore/SKILL.md",
|
|
761
773
|
description: "Modo explore para OpenSpec — thinking partner para explorar ideas, investigar problemas y clarificar requisitos antes/durante un cambio",
|
|
762
|
-
version: "0.
|
|
774
|
+
version: "0.11.0",
|
|
763
775
|
sha256: "9eafc3a8c693b8d9916867ef764d49e5222da717fde501c957bb3f6c312d2415"
|
|
764
776
|
},
|
|
765
777
|
{
|
|
766
778
|
name: "using-git-worktrees",
|
|
767
779
|
file: "assets/skills/using-git-worktrees/SKILL.md",
|
|
768
780
|
description: "Skill de uso de git worktrees para aislamiento de trabajo",
|
|
769
|
-
version: "0.
|
|
781
|
+
version: "0.11.0",
|
|
770
782
|
sha256: "93341bc1b7c053618a8b6dc07e3615b77990d7b549a0201f5835d95fef67ce13"
|
|
771
783
|
},
|
|
772
784
|
{
|
|
773
785
|
name: "using-superpowers",
|
|
774
786
|
file: "assets/skills/using-superpowers/SKILL.md",
|
|
775
787
|
description: "Skill de orquestación de Superpowers skills",
|
|
776
|
-
version: "0.
|
|
788
|
+
version: "0.11.0",
|
|
777
789
|
sha256: "7e54536f96d2a379185a10bfc1e970850caa2561b6d8aca7080f0defea0381a4"
|
|
778
790
|
},
|
|
779
791
|
{
|
|
780
792
|
name: "writing-skills",
|
|
781
793
|
file: "assets/skills/writing-skills/SKILL.md",
|
|
782
794
|
description: "Skill de creación y edición de skills",
|
|
783
|
-
version: "0.
|
|
795
|
+
version: "0.11.0",
|
|
784
796
|
sha256: "3d76b906cee518a2b809febb70db95697a35b9f368986bb504b4120c3bfb437a"
|
|
785
797
|
},
|
|
786
798
|
{
|
|
787
799
|
name: "graceful-degradation",
|
|
788
800
|
file: "assets/skills/graceful-degradation/SKILL.md",
|
|
789
801
|
description: "Skill de degradación graceful cuando múltiples tools están indisponibles",
|
|
790
|
-
version: "0.
|
|
802
|
+
version: "0.11.0",
|
|
791
803
|
sha256: "363449bd9e6f800a0a3168667cf78f767fb105d86e4a4adadcc649d418139303"
|
|
792
804
|
}
|
|
793
805
|
]
|
|
@@ -1214,7 +1226,7 @@ function copyOstackyControllerPlugin(projectRoot) {
|
|
|
1214
1226
|
throw new Error(`Plugin bundleado de OstackyController no encontrado: ${packageSource}`);
|
|
1215
1227
|
}
|
|
1216
1228
|
mkdirSync4(packageDest, { recursive: true });
|
|
1217
|
-
for (const f of ["index.ts", "controller-core.ts", "security.ts", "tiered.ts"]) {
|
|
1229
|
+
for (const f of ["index.ts", "controller-core.ts", "security.ts", "tiered.ts", "session-slots.ts", "session-store.ts", "compaction-threshold.ts"]) {
|
|
1218
1230
|
const src = join7(packageSource, f);
|
|
1219
1231
|
if (existsSync6(src))
|
|
1220
1232
|
copyFileSync3(src, join7(packageDest, f));
|
|
@@ -1577,29 +1589,222 @@ var init_stack = __esm(() => {
|
|
|
1577
1589
|
init_github();
|
|
1578
1590
|
});
|
|
1579
1591
|
|
|
1592
|
+
// src/session-slots.ts
|
|
1593
|
+
function parsePoolConfig(env = process.env) {
|
|
1594
|
+
const num = (raw, fallback) => {
|
|
1595
|
+
const n = Number(raw);
|
|
1596
|
+
return Number.isFinite(n) && n > 0 ? n : fallback;
|
|
1597
|
+
};
|
|
1598
|
+
return {
|
|
1599
|
+
poolMax: Math.floor(num(env.OSTACKY_SESSION_POOL_MAX, POOL_DEFAULTS.poolMax)),
|
|
1600
|
+
overflowMax: Math.floor(num(env.OSTACKY_SESSION_OVERFLOW_MAX, POOL_DEFAULTS.overflowMax)),
|
|
1601
|
+
activeMs: num(env.OSTACKY_SESSION_ACTIVE_MIN, POOL_DEFAULTS.activeMinutes) * 60000,
|
|
1602
|
+
recycleMs: num(env.OSTACKY_SESSION_RECYCLE_DAYS, POOL_DEFAULTS.recycleDays) * 86400000
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
function isActiveSlot(s, now, cfg) {
|
|
1606
|
+
if (!s.sessionId || !s.requestId || s.quarantined)
|
|
1607
|
+
return false;
|
|
1608
|
+
if (s.state && TERMINAL_REQUEST_STATES.includes(s.state))
|
|
1609
|
+
return false;
|
|
1610
|
+
return s.ownerHeartbeat > 0 && now - s.ownerHeartbeat <= cfg.activeMs;
|
|
1611
|
+
}
|
|
1612
|
+
var TERMINAL_REQUEST_STATES, POOL_DEFAULTS;
|
|
1613
|
+
var init_session_slots = __esm(() => {
|
|
1614
|
+
TERMINAL_REQUEST_STATES = ["DONE", "ABANDONED"];
|
|
1615
|
+
POOL_DEFAULTS = {
|
|
1616
|
+
poolMax: 10,
|
|
1617
|
+
overflowMax: 5,
|
|
1618
|
+
activeMinutes: 15,
|
|
1619
|
+
recycleDays: 7
|
|
1620
|
+
};
|
|
1621
|
+
});
|
|
1622
|
+
|
|
1623
|
+
// src/compaction-threshold.ts
|
|
1624
|
+
function num(raw, fallback) {
|
|
1625
|
+
const n = Number(raw);
|
|
1626
|
+
return Number.isFinite(n) && n > 0 ? n : fallback;
|
|
1627
|
+
}
|
|
1628
|
+
function parseCompactConfig(env = process.env) {
|
|
1629
|
+
const enabledRaw = env.OSTACKY_COMPACT_ENABLED;
|
|
1630
|
+
const enabled = enabledRaw === undefined ? COMPACT_DEFAULTS.enabled : enabledRaw.trim().toLowerCase() !== "false";
|
|
1631
|
+
const modeRaw = (env.OSTACKY_COMPACT_MODE ?? COMPACT_DEFAULTS.mode).trim().toLowerCase();
|
|
1632
|
+
const mode = modeRaw === "off" || modeRaw === "warn" || modeRaw === "auto" ? modeRaw : COMPACT_DEFAULTS.mode;
|
|
1633
|
+
const threshold = Math.floor(num(env.OSTACKY_COMPACT_THRESHOLD, DEFAULT_THRESHOLD));
|
|
1634
|
+
const model = env.OSTACKY_COMPACT_MODEL?.trim() || undefined;
|
|
1635
|
+
return { enabled, mode: enabled ? mode : "off", threshold, model };
|
|
1636
|
+
}
|
|
1637
|
+
var COMPACT_DEFAULTS, DEFAULT_THRESHOLD, WARN_AT_FOR_DEFAULT;
|
|
1638
|
+
var init_compaction_threshold = __esm(() => {
|
|
1639
|
+
COMPACT_DEFAULTS = {
|
|
1640
|
+
enabled: true,
|
|
1641
|
+
mode: "warn",
|
|
1642
|
+
threshold: 120000,
|
|
1643
|
+
warnAt: 1e5,
|
|
1644
|
+
model: undefined,
|
|
1645
|
+
cooldownMs: 10 * 60 * 1000
|
|
1646
|
+
};
|
|
1647
|
+
DEFAULT_THRESHOLD = COMPACT_DEFAULTS.threshold;
|
|
1648
|
+
WARN_AT_FOR_DEFAULT = COMPACT_DEFAULTS.warnAt;
|
|
1649
|
+
});
|
|
1650
|
+
|
|
1651
|
+
// src/controller-core.ts
|
|
1652
|
+
var MAX_SNAPSHOT_JSON_LENGTH, MAX_STATE_FILE_SIZE, STATES, TERMINAL_STATES, DEFAULT_STATE;
|
|
1653
|
+
var init_controller_core = __esm(() => {
|
|
1654
|
+
init_security();
|
|
1655
|
+
MAX_SNAPSHOT_JSON_LENGTH = 50 * 1024;
|
|
1656
|
+
MAX_STATE_FILE_SIZE = 2 * 1024 * 1024;
|
|
1657
|
+
STATES = Object.freeze({
|
|
1658
|
+
INTERPRETATION_PENDING: "INTERPRETATION_PENDING",
|
|
1659
|
+
CLARIFICATION_PENDING: "CLARIFICATION_PENDING",
|
|
1660
|
+
DISCOVERY: "DISCOVERY",
|
|
1661
|
+
ROUTE_DECISION_PENDING: "ROUTE_DECISION_PENDING",
|
|
1662
|
+
SPECIFICATION: "SPECIFICATION",
|
|
1663
|
+
EXECUTION_ANALYSIS: "EXECUTION_ANALYSIS",
|
|
1664
|
+
EXECUTION_DECISION_PENDING: "EXECUTION_DECISION_PENDING",
|
|
1665
|
+
EXECUTING_INLINE: "EXECUTING_INLINE",
|
|
1666
|
+
EXECUTING_SUBAGENTS: "EXECUTING_SUBAGENTS",
|
|
1667
|
+
SYNC: "SYNC",
|
|
1668
|
+
DONE: "DONE",
|
|
1669
|
+
BLOCKED: "BLOCKED"
|
|
1670
|
+
});
|
|
1671
|
+
TERMINAL_STATES = Object.freeze([
|
|
1672
|
+
STATES.INTERPRETATION_PENDING,
|
|
1673
|
+
STATES.CLARIFICATION_PENDING,
|
|
1674
|
+
STATES.BLOCKED,
|
|
1675
|
+
STATES.DONE
|
|
1676
|
+
]);
|
|
1677
|
+
DEFAULT_STATE = {
|
|
1678
|
+
state: STATES.INTERPRETATION_PENDING,
|
|
1679
|
+
revision: 0,
|
|
1680
|
+
requestId: null,
|
|
1681
|
+
changeId: null,
|
|
1682
|
+
routeDecisionId: null,
|
|
1683
|
+
routeChoice: null,
|
|
1684
|
+
level: null,
|
|
1685
|
+
executionDecisionId: null,
|
|
1686
|
+
executionMode: null,
|
|
1687
|
+
snapshots: { codegraph: null, execution: null },
|
|
1688
|
+
tasks: {},
|
|
1689
|
+
fileFingerprints: {},
|
|
1690
|
+
error: null,
|
|
1691
|
+
lastHandoff: null,
|
|
1692
|
+
expectedTasks: null,
|
|
1693
|
+
expectedTaskCount: null,
|
|
1694
|
+
taskVerifications: null,
|
|
1695
|
+
taskVerificationResults: {},
|
|
1696
|
+
auditSeq: 0,
|
|
1697
|
+
degraded: false,
|
|
1698
|
+
schemaVersion: 2,
|
|
1699
|
+
stateOversizedCount: 0,
|
|
1700
|
+
codegraphBypassCount: 0,
|
|
1701
|
+
degradedEditsCount: 0,
|
|
1702
|
+
cacheHitCount: 0,
|
|
1703
|
+
cacheMissCount: 0,
|
|
1704
|
+
tokenSavingEstimate: 0,
|
|
1705
|
+
discoveryCacheHitCount: 0,
|
|
1706
|
+
redundantCallCount: 0,
|
|
1707
|
+
cacheMissWithoutPutCount: 0,
|
|
1708
|
+
stateCheckCount: 0,
|
|
1709
|
+
toolCallCount: 0,
|
|
1710
|
+
lastProposal: null,
|
|
1711
|
+
allowedFiles: {},
|
|
1712
|
+
deniedFiles: {},
|
|
1713
|
+
sensitivePatterns: [...SENSITIVE_DEFAULT],
|
|
1714
|
+
sensitiveAccess: { allowed: 0, denied: 0, blockedAttempts: 0 },
|
|
1715
|
+
staleContentAttempts: 0,
|
|
1716
|
+
completeWithoutValidateCount: 0,
|
|
1717
|
+
toolTimeoutCount: 0,
|
|
1718
|
+
lastToolDurationMs: 0,
|
|
1719
|
+
stateDurationMs: 0,
|
|
1720
|
+
subagentFailedCount: 0,
|
|
1721
|
+
lastValidated: null,
|
|
1722
|
+
pendingFileAccess: {},
|
|
1723
|
+
lastHeartbeat: 0,
|
|
1724
|
+
watchdogEnabled: true,
|
|
1725
|
+
ownerSessionId: null,
|
|
1726
|
+
ownerHeartbeat: 0,
|
|
1727
|
+
ts: Date.now(),
|
|
1728
|
+
specNotInSync: false,
|
|
1729
|
+
engramBypassCount: 0
|
|
1730
|
+
};
|
|
1731
|
+
});
|
|
1732
|
+
|
|
1733
|
+
// src/session-store.ts
|
|
1734
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync5, readFileSync as readFileSync6, renameSync as renameSync3, rmSync as rmSync5, statSync as statSync3, writeFileSync as writeFileSync6 } from "node:fs";
|
|
1735
|
+
import { join as join10 } from "node:path";
|
|
1736
|
+
function sessionsDir(opencodeDir) {
|
|
1737
|
+
return join10(opencodeDir, "sessions");
|
|
1738
|
+
}
|
|
1739
|
+
function indexPath(opencodeDir) {
|
|
1740
|
+
return join10(sessionsDir(opencodeDir), "index.json");
|
|
1741
|
+
}
|
|
1742
|
+
function emptyIndex() {
|
|
1743
|
+
return { version: 1, revision: 0, migrated: false, slots: {} };
|
|
1744
|
+
}
|
|
1745
|
+
function readIndex(opencodeDir) {
|
|
1746
|
+
try {
|
|
1747
|
+
const parsed = JSON.parse(readFileSync6(indexPath(opencodeDir), "utf-8"));
|
|
1748
|
+
if (parsed && typeof parsed === "object" && parsed.slots && typeof parsed.slots === "object")
|
|
1749
|
+
return parsed;
|
|
1750
|
+
} catch {}
|
|
1751
|
+
return emptyIndex();
|
|
1752
|
+
}
|
|
1753
|
+
function toInfo(slot, r) {
|
|
1754
|
+
return {
|
|
1755
|
+
slot,
|
|
1756
|
+
overflow: r.overflow,
|
|
1757
|
+
quarantined: r.quarantined,
|
|
1758
|
+
sessionId: r.sessionId,
|
|
1759
|
+
requestId: r.requestId,
|
|
1760
|
+
state: r.state,
|
|
1761
|
+
ownerHeartbeat: r.ownerHeartbeat,
|
|
1762
|
+
lastUsedAt: r.lastUsedAt
|
|
1763
|
+
};
|
|
1764
|
+
}
|
|
1765
|
+
function poolReport(opencodeDir, now, cfg) {
|
|
1766
|
+
const idx = readIndex(opencodeDir);
|
|
1767
|
+
const entries = Object.entries(idx.slots);
|
|
1768
|
+
const infos = entries.map(([s, r]) => toInfo(s, r));
|
|
1769
|
+
const active = infos.filter((i) => i.sessionId && i.requestId && i.ownerHeartbeat > 0 && now - i.ownerHeartbeat <= cfg.activeMs && !["DONE", "ABANDONED"].includes(i.state ?? "")).length;
|
|
1770
|
+
return {
|
|
1771
|
+
base: entries.filter(([, r]) => !r.overflow).length,
|
|
1772
|
+
overflow: entries.filter(([, r]) => r.overflow).length,
|
|
1773
|
+
active,
|
|
1774
|
+
quarantined: entries.filter(([, r]) => r.quarantined).map(([s, r]) => `${s}: ${r.quarantineReason ?? "motivo desconocido"}`),
|
|
1775
|
+
occupied: infos.filter((i) => i.sessionId).sort((a, b) => a.lastUsedAt - b.lastUsedAt).map((i) => ({ ...i, sessionName: idx.slots[i.slot].sessionName, active: isActiveSlot(i, now, cfg) }))
|
|
1776
|
+
};
|
|
1777
|
+
}
|
|
1778
|
+
var FILE_ACTIVITY_RETENTION_MS;
|
|
1779
|
+
var init_session_store = __esm(() => {
|
|
1780
|
+
init_controller_core();
|
|
1781
|
+
init_session_slots();
|
|
1782
|
+
FILE_ACTIVITY_RETENTION_MS = 24 * 60 * 60 * 1000;
|
|
1783
|
+
});
|
|
1784
|
+
|
|
1580
1785
|
// src/doctor-v2.ts
|
|
1581
|
-
import { existsSync as
|
|
1582
|
-
import { join as
|
|
1786
|
+
import { existsSync as existsSync9, readFileSync as readFileSync7, readdirSync as readdirSync3 } from "fs";
|
|
1787
|
+
import { join as join11, delimiter, isAbsolute } from "path";
|
|
1583
1788
|
function globalOstackyArtifacts(globalDir = getGlobalOpenCodeDir()) {
|
|
1584
1789
|
const found = [];
|
|
1585
1790
|
const candidates = [
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1791
|
+
join11(globalDir, "agent", "ostacky.md"),
|
|
1792
|
+
join11(globalDir, "plugins", "ostacky-controller", "index.ts"),
|
|
1793
|
+
join11(globalDir, "plugin", "ostacky-controller", "index.ts"),
|
|
1794
|
+
join11(globalDir, "command", "ostacky.md")
|
|
1590
1795
|
];
|
|
1591
1796
|
for (const p of candidates) {
|
|
1592
1797
|
try {
|
|
1593
|
-
if (
|
|
1798
|
+
if (existsSync9(p))
|
|
1594
1799
|
found.push(p);
|
|
1595
1800
|
} catch {}
|
|
1596
1801
|
}
|
|
1597
1802
|
for (const cfgName of ["opencode.json", "opencode.jsonc"]) {
|
|
1598
|
-
const cfg =
|
|
1803
|
+
const cfg = join11(globalDir, cfgName);
|
|
1599
1804
|
try {
|
|
1600
|
-
if (!
|
|
1805
|
+
if (!existsSync9(cfg))
|
|
1601
1806
|
continue;
|
|
1602
|
-
const raw =
|
|
1807
|
+
const raw = readFileSync7(cfg, "utf-8");
|
|
1603
1808
|
const json = JSON.parse(raw.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, ""));
|
|
1604
1809
|
const servers = json?.mcp?.servers ?? json?.mcp ?? {};
|
|
1605
1810
|
if (servers && servers["ostacky-controller"])
|
|
@@ -1610,22 +1815,43 @@ function globalOstackyArtifacts(globalDir = getGlobalOpenCodeDir()) {
|
|
|
1610
1815
|
}
|
|
1611
1816
|
function globalPluginScopeAware(globalDir = getGlobalOpenCodeDir()) {
|
|
1612
1817
|
const candidates = [
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1818
|
+
join11(globalDir, "plugins", "ostacky-controller", "index.ts"),
|
|
1819
|
+
join11(globalDir, "plugin", "ostacky-controller", "index.ts"),
|
|
1820
|
+
join11(globalDir, "plugins", "ostacky-controller", "index.js"),
|
|
1821
|
+
join11(globalDir, "plugin", "ostacky-controller", "index.js")
|
|
1617
1822
|
];
|
|
1618
1823
|
for (const p of candidates) {
|
|
1619
1824
|
try {
|
|
1620
|
-
if (!
|
|
1825
|
+
if (!existsSync9(p))
|
|
1621
1826
|
continue;
|
|
1622
|
-
return
|
|
1827
|
+
return readFileSync7(p, "utf-8").includes("ostacky-controller-global");
|
|
1623
1828
|
} catch {}
|
|
1624
1829
|
}
|
|
1625
1830
|
return null;
|
|
1626
1831
|
}
|
|
1627
1832
|
function checkDoctorV2(projectRoot) {
|
|
1628
1833
|
const lines = [];
|
|
1834
|
+
try {
|
|
1835
|
+
const cfg = parseCompactConfig(process.env);
|
|
1836
|
+
lines.push(`ℹ️ compactación: enabled=${cfg.enabled}, mode=${cfg.mode}, threshold=${cfg.threshold}${cfg.model ? `, model=${cfg.model}` : ""}`);
|
|
1837
|
+
} catch (err) {
|
|
1838
|
+
lines.push(`⚠️ compactación: no se pudo leer config (${String(err?.message ?? err)})`);
|
|
1839
|
+
}
|
|
1840
|
+
try {
|
|
1841
|
+
const opencodeDir = join11(projectRoot, ".opencode");
|
|
1842
|
+
if (existsSync9(join11(opencodeDir, "sessions", "index.json"))) {
|
|
1843
|
+
const cfg = parsePoolConfig(process.env);
|
|
1844
|
+
const rep = poolReport(opencodeDir, Date.now(), cfg);
|
|
1845
|
+
lines.push(`ℹ️ sesiones: base ${rep.base}/${cfg.poolMax}, extensión ${rep.overflow}/${cfg.overflowMax}, activas ${rep.active}`);
|
|
1846
|
+
for (const q of rep.quarantined)
|
|
1847
|
+
lines.push(`⚠️ sesiones: slot en cuarentena — ${q}`);
|
|
1848
|
+
for (const o of rep.occupied.filter((x) => !x.active && x.state && !["DONE", "ABANDONED"].includes(x.state))) {
|
|
1849
|
+
lines.push(`ℹ️ sesiones: ${o.slot} "${o.sessionName || o.requestId || "sin nombre"}" con request no terminal (${o.state}) sin actividad reciente`);
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
} catch (err) {
|
|
1853
|
+
lines.push(`⚠️ sesiones: no se pudo leer el pool (${String(err?.message ?? err)})`);
|
|
1854
|
+
}
|
|
1629
1855
|
const globalArtifacts = globalOstackyArtifacts();
|
|
1630
1856
|
if (globalArtifacts.length > 0) {
|
|
1631
1857
|
if (globalPluginScopeAware() === false) {
|
|
@@ -1635,18 +1861,18 @@ function checkDoctorV2(projectRoot) {
|
|
|
1635
1861
|
}
|
|
1636
1862
|
}
|
|
1637
1863
|
const cwd = projectRoot;
|
|
1638
|
-
const opencodeDir = findOpenCodeDir(cwd) ||
|
|
1864
|
+
const opencodeDir = findOpenCodeDir(cwd) || join11(cwd, ".opencode");
|
|
1639
1865
|
const pluginPaths = [
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1866
|
+
join11(opencodeDir, "plugins", "ostacky-controller", "index.ts"),
|
|
1867
|
+
join11(cwd, ".opencode", "plugins", "ostacky-controller", "index.ts"),
|
|
1868
|
+
join11(opencodeDir, "plugins", "ostacky-plugin.ts"),
|
|
1869
|
+
join11(cwd, ".opencode", "plugins", "ostacky-plugin.ts"),
|
|
1870
|
+
join11(cwd, "assets", "plugins", "ostacky-plugin.ts")
|
|
1645
1871
|
];
|
|
1646
|
-
const found = pluginPaths.find((p) =>
|
|
1872
|
+
const found = pluginPaths.find((p) => existsSync9(p));
|
|
1647
1873
|
if (found) {
|
|
1648
1874
|
try {
|
|
1649
|
-
const src =
|
|
1875
|
+
const src = readFileSync7(found, "utf-8");
|
|
1650
1876
|
const hasDefault = /export\s+default/.test(src);
|
|
1651
1877
|
const hasLegacyPkg = src.includes("@opencode-ai/");
|
|
1652
1878
|
if (hasDefault && !hasLegacyPkg)
|
|
@@ -1657,18 +1883,18 @@ function checkDoctorV2(projectRoot) {
|
|
|
1657
1883
|
lines.push(`⚠️ controller: no se pudo leer ${found}`);
|
|
1658
1884
|
}
|
|
1659
1885
|
}
|
|
1660
|
-
const pluginsDir =
|
|
1886
|
+
const pluginsDir = join11(opencodeDir, "plugins");
|
|
1661
1887
|
for (const f of ["controller-core.ts", "security.ts", "tiered.ts"]) {
|
|
1662
1888
|
try {
|
|
1663
|
-
const p =
|
|
1664
|
-
if (
|
|
1889
|
+
const p = join11(pluginsDir, f);
|
|
1890
|
+
if (existsSync9(p) && !readFileSync7(p, "utf-8").includes("export default")) {
|
|
1665
1891
|
lines.push(`⚠️ plugins/${f} suelto sin default — el server lo carga como plugin y falla; mové a plugins/ostacky-controller/ o re-corré install (doctor no lo modifica)`);
|
|
1666
1892
|
}
|
|
1667
1893
|
} catch {}
|
|
1668
1894
|
}
|
|
1669
1895
|
try {
|
|
1670
1896
|
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
1671
|
-
const globalPlugins = home ?
|
|
1897
|
+
const globalPlugins = home ? join11(home, ".config", "opencode", "plugins") : "";
|
|
1672
1898
|
if (globalPlugins) {
|
|
1673
1899
|
let entries = [];
|
|
1674
1900
|
try {
|
|
@@ -1676,7 +1902,7 @@ function checkDoctorV2(projectRoot) {
|
|
|
1676
1902
|
} catch {}
|
|
1677
1903
|
for (const e of entries) {
|
|
1678
1904
|
try {
|
|
1679
|
-
const src =
|
|
1905
|
+
const src = readFileSync7(join11(globalPlugins, e), "utf-8");
|
|
1680
1906
|
if (src.includes("@opencode-ai/") || !src.includes("export default")) {
|
|
1681
1907
|
lines.push(`⚠️ global ${e} con formato V1 (@opencode-ai/* o sin default) — no corre en server V2; actualizalo o borralo a mano (doctor no lo modifica)`);
|
|
1682
1908
|
}
|
|
@@ -1746,7 +1972,7 @@ function checkDoctorV2(projectRoot) {
|
|
|
1746
1972
|
lines.push(`⚠️ mcp.servers.${name} local sin command array — V2 requiere command: [bin, ...args]`);
|
|
1747
1973
|
} else {
|
|
1748
1974
|
const bin = cmd[0];
|
|
1749
|
-
const ok = isAbsolute(bin) ?
|
|
1975
|
+
const ok = isAbsolute(bin) ? existsSync9(bin) : lookupOnPath(bin) !== null;
|
|
1750
1976
|
if (!ok)
|
|
1751
1977
|
lines.push(`⚠️ mcp.servers.${name} command no existe (${bin}) — ¿proyecto movido? re-corré install`);
|
|
1752
1978
|
}
|
|
@@ -1775,23 +2001,26 @@ function lookupOnPath(name) {
|
|
|
1775
2001
|
if (!dir)
|
|
1776
2002
|
continue;
|
|
1777
2003
|
try {
|
|
1778
|
-
if (
|
|
1779
|
-
return
|
|
1780
|
-
if (suffix &&
|
|
1781
|
-
return
|
|
2004
|
+
if (existsSync9(join11(dir, name + suffix)))
|
|
2005
|
+
return join11(dir, name + suffix);
|
|
2006
|
+
if (suffix && existsSync9(join11(dir, name)))
|
|
2007
|
+
return join11(dir, name);
|
|
1782
2008
|
} catch {}
|
|
1783
2009
|
}
|
|
1784
2010
|
} catch {}
|
|
1785
2011
|
return null;
|
|
1786
2012
|
}
|
|
1787
2013
|
var init_doctor_v2 = __esm(() => {
|
|
2014
|
+
init_session_slots();
|
|
2015
|
+
init_compaction_threshold();
|
|
2016
|
+
init_session_store();
|
|
1788
2017
|
init_config();
|
|
1789
2018
|
init_fs();
|
|
1790
2019
|
});
|
|
1791
2020
|
// package.json
|
|
1792
2021
|
var package_default = {
|
|
1793
2022
|
name: "ostacky",
|
|
1794
|
-
version: "0.
|
|
2023
|
+
version: "0.11.0",
|
|
1795
2024
|
description: "Instalador interactivo de agentes y comandos para OpenCode",
|
|
1796
2025
|
type: "module",
|
|
1797
2026
|
bin: {
|
|
@@ -1800,9 +2029,9 @@ var package_default = {
|
|
|
1800
2029
|
scripts: {
|
|
1801
2030
|
prebuild: "bun run scripts/sync-version.ts && bun run scripts/sync-controller-core.ts",
|
|
1802
2031
|
dev: "bun run src/cli.ts",
|
|
1803
|
-
build: "bun run build:cli && bun run build:mcp",
|
|
1804
2032
|
"build:cli": "bun build src/cli.ts --target=node --format=esm --outfile dist/cli.js && bun scripts/add-shebang.ts",
|
|
1805
2033
|
"build:mcp": "bun run scripts/build-mcp-bundles.ts",
|
|
2034
|
+
build: "bun run build:cli && bun run build:mcp && tsc --noEmit",
|
|
1806
2035
|
start: "node dist/cli.js",
|
|
1807
2036
|
test: "bun test --isolate",
|
|
1808
2037
|
"test:safe": "bun run scripts/run-tests-isolated.ts",
|
|
@@ -1831,7 +2060,8 @@ var package_default = {
|
|
|
1831
2060
|
devDependencies: {
|
|
1832
2061
|
"@types/bun": "latest",
|
|
1833
2062
|
openspec: "^0.0.0",
|
|
1834
|
-
typescript: "^5.
|
|
2063
|
+
typescript: "^5.9.3",
|
|
2064
|
+
"vite-plugin-checker": "^1.0.0"
|
|
1835
2065
|
},
|
|
1836
2066
|
publishConfig: {
|
|
1837
2067
|
access: "public"
|
|
@@ -2973,7 +3203,7 @@ async function probeMcpServer(nodeExecutable, serverPath, cwd, statePath, option
|
|
|
2973
3203
|
params: {
|
|
2974
3204
|
protocolVersion: "2025-03-26",
|
|
2975
3205
|
capabilities: {},
|
|
2976
|
-
clientInfo: { name: "ostacky-installer", version: "0.
|
|
3206
|
+
clientInfo: { name: "ostacky-installer", version: "0.11.0" }
|
|
2977
3207
|
}
|
|
2978
3208
|
});
|
|
2979
3209
|
});
|
|
@@ -3318,7 +3548,10 @@ function uninstallAll(paths) {
|
|
|
3318
3548
|
"ostacky-controller.ts",
|
|
3319
3549
|
"controller-core.ts",
|
|
3320
3550
|
"security.ts",
|
|
3321
|
-
"tiered.ts"
|
|
3551
|
+
"tiered.ts",
|
|
3552
|
+
"session-slots.ts",
|
|
3553
|
+
"session-store.ts",
|
|
3554
|
+
"compaction-threshold.ts"
|
|
3322
3555
|
];
|
|
3323
3556
|
for (const file of ostackyPlugins) {
|
|
3324
3557
|
const fp = join6(paths.plugins, file);
|
|
@@ -4675,8 +4908,8 @@ async function runUninstallMcpCommand(name, scope) {
|
|
|
4675
4908
|
}
|
|
4676
4909
|
|
|
4677
4910
|
// src/cli.ts
|
|
4678
|
-
import { existsSync as
|
|
4679
|
-
import { join as
|
|
4911
|
+
import { existsSync as existsSync10, statSync as statSync4, readFileSync as readFileSync8, readdirSync as readdirSync4 } from "node:fs";
|
|
4912
|
+
import { join as join12, dirname as dirname8 } from "node:path";
|
|
4680
4913
|
import { spawnSync } from "node:child_process";
|
|
4681
4914
|
init_fs();
|
|
4682
4915
|
init_github();
|
|
@@ -4837,8 +5070,8 @@ var noStack = process.argv.includes("--no-stack");
|
|
|
4837
5070
|
var [, , cmd, subcmd] = argvNoScope;
|
|
4838
5071
|
async function runDoctorCommand() {
|
|
4839
5072
|
const cwd = process.cwd();
|
|
4840
|
-
const opencodeDir = findOpenCodeDir(cwd) ||
|
|
4841
|
-
const statePath =
|
|
5073
|
+
const opencodeDir = findOpenCodeDir(cwd) || join12(cwd, ".opencode");
|
|
5074
|
+
const statePath = join12(opencodeDir, "ostacky-state.json");
|
|
4842
5075
|
let hasError = false;
|
|
4843
5076
|
let hasWarn = false;
|
|
4844
5077
|
const check = (label, ok, warn = false) => {
|
|
@@ -4853,26 +5086,26 @@ async function runDoctorCommand() {
|
|
|
4853
5086
|
}
|
|
4854
5087
|
};
|
|
4855
5088
|
const pluginPaths = [
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
5089
|
+
join12(cwd, "assets", "plugins", "ostacky-controller", "index.ts"),
|
|
5090
|
+
join12(opencodeDir, "plugins", "ostacky-controller", "index.ts"),
|
|
5091
|
+
join12(cwd, ".opencode", "plugins", "ostacky-controller", "index.ts"),
|
|
5092
|
+
join12(cwd, "assets", "plugins", "ostacky-plugin.ts"),
|
|
5093
|
+
join12(opencodeDir, "plugins", "ostacky-plugin.ts"),
|
|
5094
|
+
join12(cwd, ".opencode", "plugins", "ostacky-plugin.ts"),
|
|
5095
|
+
join12(cwd, "assets", "plugins", "ostacky-controller.ts"),
|
|
5096
|
+
join12(opencodeDir, "plugins", "ostacky-controller.ts"),
|
|
5097
|
+
join12(cwd, ".opencode", "plugins", "ostacky-controller.ts")
|
|
4865
5098
|
];
|
|
4866
|
-
const pluginActive = pluginPaths.some((p) =>
|
|
5099
|
+
const pluginActive = pluginPaths.some((p) => existsSync10(p));
|
|
4867
5100
|
try {
|
|
4868
|
-
if (!
|
|
5101
|
+
if (!existsSync10(statePath)) {
|
|
4869
5102
|
if (pluginActive)
|
|
4870
5103
|
console.log(`✅ controller: plugin active (no state yet)`);
|
|
4871
5104
|
else
|
|
4872
5105
|
check("controller: state file missing", false, true);
|
|
4873
5106
|
} else {
|
|
4874
|
-
const stat =
|
|
4875
|
-
const raw =
|
|
5107
|
+
const stat = statSync4(statePath);
|
|
5108
|
+
const raw = readFileSync8(statePath, "utf-8");
|
|
4876
5109
|
const parsed = JSON.parse(raw);
|
|
4877
5110
|
if (pluginActive) {
|
|
4878
5111
|
console.log(`✅ controller: plugin active (rev ${parsed.revision || 0} state ${parsed.state || "unknown"})`);
|
|
@@ -4936,15 +5169,15 @@ async function runDoctorCommand() {
|
|
|
4936
5169
|
check(`controller: ${e.message}`, false);
|
|
4937
5170
|
}
|
|
4938
5171
|
try {
|
|
4939
|
-
const lockPid =
|
|
4940
|
-
const lockTs =
|
|
4941
|
-
if (
|
|
5172
|
+
const lockPid = join12(opencodeDir, "ostacky-state.json.lock.pid");
|
|
5173
|
+
const lockTs = join12(opencodeDir, "ostacky-state.json.lock.timestamp");
|
|
5174
|
+
if (existsSync10(lockPid) || existsSync10(lockTs)) {
|
|
4942
5175
|
let ageStr = "";
|
|
4943
5176
|
try {
|
|
4944
|
-
const ts = parseInt(
|
|
5177
|
+
const ts = parseInt(readFileSync8(lockTs, "utf-8"), 10);
|
|
4945
5178
|
const age = Date.now() - ts;
|
|
4946
5179
|
ageStr = `${Math.floor(age / 1000)}s`;
|
|
4947
|
-
const pid =
|
|
5180
|
+
const pid = readFileSync8(lockPid, "utf-8").trim();
|
|
4948
5181
|
let alive = false;
|
|
4949
5182
|
try {
|
|
4950
5183
|
process.kill(parseInt(pid, 10), 0);
|
|
@@ -4962,9 +5195,9 @@ async function runDoctorCommand() {
|
|
|
4962
5195
|
}
|
|
4963
5196
|
const tools = ["codegraph", "engram"];
|
|
4964
5197
|
for (const t of tools) {
|
|
4965
|
-
const p =
|
|
5198
|
+
const p = join12(opencodeDir, "tools", t, "bin", t);
|
|
4966
5199
|
const pExe = p + ".exe";
|
|
4967
|
-
check(`tool ${t}: ${
|
|
5200
|
+
check(`tool ${t}: ${existsSync10(p) || existsSync10(pExe) ? "found" : "missing"}`, existsSync10(p) || existsSync10(pExe), true);
|
|
4968
5201
|
}
|
|
4969
5202
|
try {
|
|
4970
5203
|
const name = "ostacky-controller";
|
|
@@ -4990,22 +5223,22 @@ async function runDoctorCommand() {
|
|
|
4990
5223
|
} catch {
|
|
4991
5224
|
check("doctor-v2: check failed", false, true);
|
|
4992
5225
|
}
|
|
4993
|
-
if (
|
|
5226
|
+
if (existsSync10(statePath)) {
|
|
4994
5227
|
try {
|
|
4995
|
-
const s = JSON.parse(
|
|
5228
|
+
const s = JSON.parse(readFileSync8(statePath, "utf-8"));
|
|
4996
5229
|
if (s.allowedFiles || s.deniedFiles) {}
|
|
4997
5230
|
} catch {}
|
|
4998
5231
|
}
|
|
4999
5232
|
try {
|
|
5000
|
-
const cacheDir =
|
|
5001
|
-
if (!
|
|
5233
|
+
const cacheDir = join12(opencodeDir, "cache", "codegraph");
|
|
5234
|
+
if (!existsSync10(cacheDir)) {
|
|
5002
5235
|
console.log("ℹ️ cache: no cache dir yet (ok)");
|
|
5003
5236
|
} else {
|
|
5004
5237
|
const files = readdirSync4(cacheDir);
|
|
5005
5238
|
let total = 0;
|
|
5006
5239
|
for (const f of files) {
|
|
5007
5240
|
try {
|
|
5008
|
-
total +=
|
|
5241
|
+
total += statSync4(join12(cacheDir, f)).size;
|
|
5009
5242
|
} catch {}
|
|
5010
5243
|
}
|
|
5011
5244
|
const totalMB = (total / 1048576).toFixed(2);
|
|
@@ -5016,7 +5249,7 @@ async function runDoctorCommand() {
|
|
|
5016
5249
|
console.log(`✅ cache: OK (${files.length} files, ${totalMB}MB)`);
|
|
5017
5250
|
}
|
|
5018
5251
|
try {
|
|
5019
|
-
const s = JSON.parse(
|
|
5252
|
+
const s = JSON.parse(readFileSync8(statePath, "utf-8"));
|
|
5020
5253
|
if (s.cacheHitCount !== undefined) {
|
|
5021
5254
|
console.log(`ℹ️ cacheHitCount=${s.cacheHitCount} cacheMissCount=${s.cacheMissCount || 0} tokenSavingEstimate=${s.tokenSavingEstimate || 0}`);
|
|
5022
5255
|
}
|
|
@@ -5026,29 +5259,29 @@ async function runDoctorCommand() {
|
|
|
5026
5259
|
console.log(`⚠️ cache: check failed ${e.message}`);
|
|
5027
5260
|
}
|
|
5028
5261
|
try {
|
|
5029
|
-
const coreSrc =
|
|
5030
|
-
const coreMcp =
|
|
5031
|
-
const corePlugin =
|
|
5032
|
-
const coreSync =
|
|
5262
|
+
const coreSrc = join12(cwd, "src", "controller-core.ts");
|
|
5263
|
+
const coreMcp = join12(cwd, "assets", "mcp", "ostacky-controller", "controller-core.js");
|
|
5264
|
+
const corePlugin = join12(cwd, "assets", "plugins", "controller-core.ts");
|
|
5265
|
+
const coreSync = existsSync10(coreSrc) && existsSync10(coreMcp) && existsSync10(corePlugin);
|
|
5033
5266
|
if (coreSync) {
|
|
5034
|
-
const srcHash =
|
|
5035
|
-
const mcpHash =
|
|
5036
|
-
const ok =
|
|
5267
|
+
const srcHash = readFileSync8(coreSrc, "utf-8").slice(0, 100);
|
|
5268
|
+
const mcpHash = readFileSync8(coreMcp, "utf-8").slice(0, 100);
|
|
5269
|
+
const ok = readFileSync8(coreMcp, "utf-8").includes("STATES") && readFileSync8(corePlugin, "utf-8").includes("STATES");
|
|
5037
5270
|
check(`controller-core: synced (${ok ? "STATES present" : "mismatch"})`, ok);
|
|
5038
5271
|
if (!ok)
|
|
5039
5272
|
console.log(" Run: bun run scripts/sync-controller-core.ts (if exists) or copy src/controller-core.ts");
|
|
5040
5273
|
} else {
|
|
5041
5274
|
check("controller-core: synced", false, true);
|
|
5042
5275
|
}
|
|
5043
|
-
const auditPath =
|
|
5044
|
-
if (
|
|
5045
|
-
const sz =
|
|
5046
|
-
const lines =
|
|
5276
|
+
const auditPath = join12(opencodeDir, "ostacky-audit.jsonl");
|
|
5277
|
+
if (existsSync10(auditPath)) {
|
|
5278
|
+
const sz = statSync4(auditPath).size;
|
|
5279
|
+
const lines = readFileSync8(auditPath, "utf-8").split(`
|
|
5047
5280
|
`).filter(Boolean).length;
|
|
5048
5281
|
check(`audit: jsonl ${lines} entries, ${(sz / 1024).toFixed(1)}KB`, sz < 512000);
|
|
5049
|
-
if (
|
|
5050
|
-
const s = JSON.parse(
|
|
5051
|
-
const stateSize =
|
|
5282
|
+
if (existsSync10(statePath)) {
|
|
5283
|
+
const s = JSON.parse(readFileSync8(statePath, "utf-8"));
|
|
5284
|
+
const stateSize = statSync4(statePath).size;
|
|
5052
5285
|
check(`state size <50KB (${(stateSize / 1024).toFixed(1)}KB)`, stateSize < 51200);
|
|
5053
5286
|
if (s.audit && s.audit.length > 20)
|
|
5054
5287
|
console.log(`⚠️ state.audit large: ${s.audit.length} (should be tail only, full in jsonl)`);
|
|
@@ -5058,16 +5291,16 @@ async function runDoctorCommand() {
|
|
|
5058
5291
|
} else {
|
|
5059
5292
|
console.log("ℹ️ audit: jsonl not yet created (will be created on next audit)");
|
|
5060
5293
|
}
|
|
5061
|
-
const ostackyMd =
|
|
5294
|
+
const ostackyMd = readFileSync8(join12(cwd, "assets", "agents", "ostacky.md"), "utf-8");
|
|
5062
5295
|
const hasLevels = ostackyMd.includes("LEVEL_THRESHOLDS") || ostackyMd.includes("classifyLevel");
|
|
5063
5296
|
check("levels: unified via tiered.ts", hasLevels, true);
|
|
5064
5297
|
const hasHonesty = ostackyMd.includes("Principios de honestidad");
|
|
5065
5298
|
check("honesty: 7 SHALL", hasHonesty);
|
|
5066
5299
|
if (!hasHonesty)
|
|
5067
5300
|
console.log(" Expected: ## Principios de honestidad (SHALL) in ostacky.md");
|
|
5068
|
-
const pluginPath =
|
|
5069
|
-
if (
|
|
5070
|
-
const plugin =
|
|
5301
|
+
const pluginPath = join12(cwd, "assets", "plugins", "ostacky-controller", "index.ts");
|
|
5302
|
+
if (existsSync10(pluginPath)) {
|
|
5303
|
+
const plugin = readFileSync8(pluginPath, "utf-8");
|
|
5071
5304
|
const hasNoOverwrite = plugin.includes("shouldBlockCodeRead") && plugin.includes("isCodeReadGated") && plugin.includes("isTaskTracked") && plugin.includes("isShellPathExempt");
|
|
5072
5305
|
check("spec/tracked read-guard (shouldBlockCodeRead + exemptions)", hasNoOverwrite, true);
|
|
5073
5306
|
}
|
|
@@ -5077,12 +5310,12 @@ async function runDoctorCommand() {
|
|
|
5077
5310
|
console.log(`⚠️ honesty/spec checks failed: ${e.message}`);
|
|
5078
5311
|
}
|
|
5079
5312
|
try {
|
|
5080
|
-
const giPath =
|
|
5081
|
-
if (!
|
|
5313
|
+
const giPath = join12(cwd, ".gitignore");
|
|
5314
|
+
if (!existsSync10(giPath)) {
|
|
5082
5315
|
console.log("⚠️ .gitignore: missing (run npx ostacky install --scope local to create)");
|
|
5083
5316
|
hasWarn = true;
|
|
5084
5317
|
} else {
|
|
5085
|
-
const gi =
|
|
5318
|
+
const gi = readFileSync8(giPath, "utf-8");
|
|
5086
5319
|
const needed = [
|
|
5087
5320
|
".opencode/tools/",
|
|
5088
5321
|
".opencode/cache/",
|
|
@@ -5102,12 +5335,12 @@ async function runDoctorCommand() {
|
|
|
5102
5335
|
}
|
|
5103
5336
|
} catch {}
|
|
5104
5337
|
try {
|
|
5105
|
-
const secPath =
|
|
5106
|
-
if (!
|
|
5338
|
+
const secPath = join12(cwd, "src", "security.ts");
|
|
5339
|
+
if (!existsSync10(secPath)) {
|
|
5107
5340
|
console.log("⚠️ src/security.ts: missing (source-of-truth)");
|
|
5108
5341
|
hasWarn = true;
|
|
5109
5342
|
} else {
|
|
5110
|
-
const sec =
|
|
5343
|
+
const sec = readFileSync8(secPath, "utf-8");
|
|
5111
5344
|
const hasSensitiveDefault = sec.includes("SENSITIVE_DEFAULT");
|
|
5112
5345
|
const hasBashRe = sec.includes("BASH_SENSITIVE_RE");
|
|
5113
5346
|
const hasIsSensitive = sec.includes("function isSensitive");
|
|
@@ -5121,7 +5354,7 @@ async function runDoctorCommand() {
|
|
|
5121
5354
|
}
|
|
5122
5355
|
} catch {}
|
|
5123
5356
|
try {
|
|
5124
|
-
const s = JSON.parse(
|
|
5357
|
+
const s = JSON.parse(readFileSync8(statePath, "utf-8"));
|
|
5125
5358
|
if (s.sensitiveAccess?.blockedAttempts > 0) {
|
|
5126
5359
|
console.log(`ℹ️ sensitiveAccess: blockedAttempts includes bash (${s.sensitiveAccess.blockedAttempts})`);
|
|
5127
5360
|
}
|
|
@@ -5134,14 +5367,14 @@ async function runDoctorCommand() {
|
|
|
5134
5367
|
async function runStatusCommand(args) {
|
|
5135
5368
|
const isJson = args.includes("--json");
|
|
5136
5369
|
const cwd = process.cwd();
|
|
5137
|
-
const opencodeDir = findOpenCodeDir(cwd) ||
|
|
5138
|
-
const statePath =
|
|
5139
|
-
if (!
|
|
5370
|
+
const opencodeDir = findOpenCodeDir(cwd) || join12(cwd, ".opencode");
|
|
5371
|
+
const statePath = join12(opencodeDir, "ostacky-state.json");
|
|
5372
|
+
if (!existsSync10(statePath)) {
|
|
5140
5373
|
console.log(isJson ? JSON.stringify({ error: "no state" }) : "No state file");
|
|
5141
5374
|
return;
|
|
5142
5375
|
}
|
|
5143
5376
|
try {
|
|
5144
|
-
const parsed = JSON.parse(
|
|
5377
|
+
const parsed = JSON.parse(readFileSync8(statePath, "utf-8"));
|
|
5145
5378
|
const completed = Object.values(parsed.tasks || {}).filter((t) => t.status === "COMPLETED").length;
|
|
5146
5379
|
const expected = parsed.expectedTaskCount ?? parsed.expectedTasks?.length ?? Object.keys(parsed.tasks || {}).length;
|
|
5147
5380
|
const degraded = parsed.degraded ? " degraded" : "";
|