@cstack-protocol/pingala 1.0.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/.agent/CSD.md +39 -0
- package/.agent/MANIFEST.md +4 -0
- package/.agent/MANIFEST.md.template +4 -0
- package/.agent/agent-contractor.md +45 -0
- package/.agent/architecture/consent-model-fsm.md +77 -0
- package/.agent/architecture/governor-maturity-fsm.md +101 -0
- package/.agent/architecture/governor-validation-fsm.md +106 -0
- package/.agent/architecture/humanized-audit-fsm.md +76 -0
- package/.agent/architecture/pingala-csi-fsm.md +81 -0
- package/.agent/architecture.md +34 -0
- package/.agent/behavior.md +29 -0
- package/.agent/compute.md +32 -0
- package/.agent/consent-prompts.md +41 -0
- package/.agent/governance.yaml +5 -0
- package/.agent/identity.md +29 -0
- package/.agent/knowledge-lattice.json +96 -0
- package/.agent/knowledge-lattice.md +53 -0
- package/.agent/lattice-viz.html +157 -0
- package/.agent/mission.md +37 -0
- package/.agent/pairing-protocol.md +89 -0
- package/.agent/pairing.csp +108 -0
- package/.agent/personas/reflective-operator.md +67 -0
- package/.agent/personas/research.md +62 -0
- package/.agent/pingala.md +47 -0
- package/.agent/roadmap.md +56 -0
- package/.agent/scripts/lattice-extract.py +100 -0
- package/.agent/scripts/sync-agents.sh +82 -0
- package/.agent/scripts/vault-ingest.py +80 -0
- package/.agent/seo-strategy.md +71 -0
- package/.agent/skills/agent-orchestrator/SKILL.md +22 -0
- package/.agent/skills/agent-orchestrator/scripts/sync-agents.sh +61 -0
- package/.agent/skills/knowledge-lattice/SKILL.md +23 -0
- package/.agent/skills/knowledge-lattice/scripts/lattice-extract.py +107 -0
- package/.agent/skills/resource-vault/SKILL.md +30 -0
- package/.agent/skills/resource-vault/scripts/vault-ingest.py +80 -0
- package/.agent/skills/sites-integrity/SKILL.md +28 -0
- package/.agent/skills/stack-auditor/SKILL.md +25 -0
- package/.agent/sources.md +20 -0
- package/.agent/stack-auditor.md +47 -0
- package/.agent/standards.md +36 -0
- package/.agent/strategy.md +65 -0
- package/.agent/vault-schema.md +53 -0
- package/.agent/voice.md +27 -0
- package/.agent/workflows/sync-agents.md +14 -0
- package/.env.example +5 -0
- package/.env.production +3 -0
- package/DISTRIBUTION-PLAN.md +33 -0
- package/HOSTED_SETUP.md +54 -0
- package/LANDING_PAGE_DESIGN.md +46 -0
- package/MANUAL_VERCEL_STEPS.md +39 -0
- package/PRODUCT-ROADMAP.md +241 -0
- package/PROVISIONING_GUIDE.md +39 -0
- package/README.md +38 -0
- package/ROADMAP.md +21 -0
- package/SYNC-ENGINE-SPEC.md +257 -0
- package/build/core/531-protocol.d.ts +26 -0
- package/build/core/531-protocol.js +87 -0
- package/build/core/531-protocol.js.map +1 -0
- package/build/core/531-rule.d.ts +26 -0
- package/build/core/531-rule.js +106 -0
- package/build/core/531-rule.js.map +1 -0
- package/build/core/auth.d.ts +1 -0
- package/build/core/auth.js +24 -0
- package/build/core/auth.js.map +1 -0
- package/build/core/consent-manager.d.ts +17 -0
- package/build/core/consent-manager.js +104 -0
- package/build/core/consent-manager.js.map +1 -0
- package/build/core/csp.d.ts +12 -0
- package/build/core/csp.js +20 -0
- package/build/core/csp.js.map +1 -0
- package/build/core/engagement-analyzer.d.ts +42 -0
- package/build/core/engagement-analyzer.js +71 -0
- package/build/core/engagement-analyzer.js.map +1 -0
- package/build/core/governor.d.ts +106 -0
- package/build/core/governor.js +405 -0
- package/build/core/governor.js.map +1 -0
- package/build/core/life-area-mapper.d.ts +39 -0
- package/build/core/life-area-mapper.js +73 -0
- package/build/core/life-area-mapper.js.map +1 -0
- package/build/core/methodology.d.ts +39 -0
- package/build/core/methodology.js +164 -0
- package/build/core/methodology.js.map +1 -0
- package/build/core/pingala.d.ts +31 -0
- package/build/core/pingala.js +56 -0
- package/build/core/pingala.js.map +1 -0
- package/build/core/sdk-adapter.d.ts +6 -0
- package/build/core/sdk-adapter.js +33 -0
- package/build/core/sdk-adapter.js.map +1 -0
- package/build/cs-agent-core/sdk/index.d.ts +6 -0
- package/build/cs-agent-core/sdk/index.js +18 -0
- package/build/cs-agent-core/sdk/index.js.map +1 -0
- package/build/cs-agent-core/sdk/patterns/index.d.ts +3 -0
- package/build/cs-agent-core/sdk/patterns/index.js +37 -0
- package/build/cs-agent-core/sdk/patterns/index.js.map +1 -0
- package/build/cs-agent-core/sdk/patterns/registry.d.ts +4 -0
- package/build/cs-agent-core/sdk/patterns/registry.js +80 -0
- package/build/cs-agent-core/sdk/patterns/registry.js.map +1 -0
- package/build/cs-agent-core/sdk/telemetry/buffer.d.ts +9 -0
- package/build/cs-agent-core/sdk/telemetry/buffer.js +47 -0
- package/build/cs-agent-core/sdk/telemetry/buffer.js.map +1 -0
- package/build/cs-agent-core/sdk/telemetry/scrubber.d.ts +3 -0
- package/build/cs-agent-core/sdk/telemetry/scrubber.js +13 -0
- package/build/cs-agent-core/sdk/telemetry/scrubber.js.map +1 -0
- package/build/cs-agent-core/sdk/telemetry/types.d.ts +50 -0
- package/build/cs-agent-core/sdk/telemetry/types.js +2 -0
- package/build/cs-agent-core/sdk/telemetry/types.js.map +1 -0
- package/build/cs-agent-core/sdk/types/decision.d.ts +18 -0
- package/build/cs-agent-core/sdk/types/decision.js +2 -0
- package/build/cs-agent-core/sdk/types/decision.js.map +1 -0
- package/build/cs-agent-core/sdk/types/index.d.ts +4 -0
- package/build/cs-agent-core/sdk/types/index.js +5 -0
- package/build/cs-agent-core/sdk/types/index.js.map +1 -0
- package/build/cs-agent-core/sdk/types/pattern.d.ts +17 -0
- package/build/cs-agent-core/sdk/types/pattern.js +2 -0
- package/build/cs-agent-core/sdk/types/pattern.js.map +1 -0
- package/build/cs-agent-core/sdk/types/stack.d.ts +8 -0
- package/build/cs-agent-core/sdk/types/stack.js +2 -0
- package/build/cs-agent-core/sdk/types/stack.js.map +1 -0
- package/build/cs-agent-core/sdk/types/tool.d.ts +9 -0
- package/build/cs-agent-core/sdk/types/tool.js +2 -0
- package/build/cs-agent-core/sdk/types/tool.js.map +1 -0
- package/build/cs-agent-core/sdk/validator/csi.d.ts +2 -0
- package/build/cs-agent-core/sdk/validator/csi.js +24 -0
- package/build/cs-agent-core/sdk/validator/csi.js.map +1 -0
- package/build/cs-agent-core/sdk/validator/index.d.ts +2 -0
- package/build/cs-agent-core/sdk/validator/index.js +3 -0
- package/build/cs-agent-core/sdk/validator/index.js.map +1 -0
- package/build/cs-agent-core/sdk/validator/rules/geometry.d.ts +11 -0
- package/build/cs-agent-core/sdk/validator/rules/geometry.js +22 -0
- package/build/cs-agent-core/sdk/validator/rules/geometry.js.map +1 -0
- package/build/cs-agent-core/sdk/validator/validate.d.ts +2 -0
- package/build/cs-agent-core/sdk/validator/validate.js +46 -0
- package/build/cs-agent-core/sdk/validator/validate.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +444 -0
- package/build/index.js.map +1 -0
- package/build/pingala-mcp/src/core/531-rule.d.ts +26 -0
- package/build/pingala-mcp/src/core/531-rule.js +96 -0
- package/build/pingala-mcp/src/core/531-rule.js.map +1 -0
- package/build/pingala-mcp/src/core/auth.d.ts +1 -0
- package/build/pingala-mcp/src/core/auth.js +15 -0
- package/build/pingala-mcp/src/core/auth.js.map +1 -0
- package/build/pingala-mcp/src/core/consent-manager.d.ts +17 -0
- package/build/pingala-mcp/src/core/consent-manager.js +104 -0
- package/build/pingala-mcp/src/core/consent-manager.js.map +1 -0
- package/build/pingala-mcp/src/core/csp.d.ts +12 -0
- package/build/pingala-mcp/src/core/csp.js +20 -0
- package/build/pingala-mcp/src/core/csp.js.map +1 -0
- package/build/pingala-mcp/src/core/engagement-analyzer.d.ts +42 -0
- package/build/pingala-mcp/src/core/engagement-analyzer.js +71 -0
- package/build/pingala-mcp/src/core/engagement-analyzer.js.map +1 -0
- package/build/pingala-mcp/src/core/governor.d.ts +104 -0
- package/build/pingala-mcp/src/core/governor.js +359 -0
- package/build/pingala-mcp/src/core/governor.js.map +1 -0
- package/build/pingala-mcp/src/core/life-area-mapper.d.ts +39 -0
- package/build/pingala-mcp/src/core/life-area-mapper.js +73 -0
- package/build/pingala-mcp/src/core/life-area-mapper.js.map +1 -0
- package/build/pingala-mcp/src/core/methodology.d.ts +39 -0
- package/build/pingala-mcp/src/core/methodology.js +164 -0
- package/build/pingala-mcp/src/core/methodology.js.map +1 -0
- package/build/pingala-mcp/src/core/pingala.d.ts +25 -0
- package/build/pingala-mcp/src/core/pingala.js +56 -0
- package/build/pingala-mcp/src/core/pingala.js.map +1 -0
- package/build/pingala-mcp/src/core/sdk-adapter.d.ts +6 -0
- package/build/pingala-mcp/src/core/sdk-adapter.js +33 -0
- package/build/pingala-mcp/src/core/sdk-adapter.js.map +1 -0
- package/build/pingala-mcp/src/index.d.ts +1 -0
- package/build/pingala-mcp/src/index.js +221 -0
- package/build/pingala-mcp/src/index.js.map +1 -0
- package/build/pingala-mcp/src/test-l3.d.ts +1 -0
- package/build/pingala-mcp/src/test-l3.js +35 -0
- package/build/pingala-mcp/src/test-l3.js.map +1 -0
- package/build/pingala-mcp/src/tools/audit-workspace.d.ts +16 -0
- package/build/pingala-mcp/src/tools/audit-workspace.js +39 -0
- package/build/pingala-mcp/src/tools/audit-workspace.js.map +1 -0
- package/build/pingala-mcp/src/tools/calculate-csi.d.ts +24 -0
- package/build/pingala-mcp/src/tools/calculate-csi.js +29 -0
- package/build/pingala-mcp/src/tools/calculate-csi.js.map +1 -0
- package/build/pingala-mcp/src/tools/cs-audit.d.ts +54 -0
- package/build/pingala-mcp/src/tools/cs-audit.js +310 -0
- package/build/pingala-mcp/src/tools/cs-audit.js.map +1 -0
- package/build/pingala-mcp/src/tools/get-governance-context.d.ts +11 -0
- package/build/pingala-mcp/src/tools/get-governance-context.js +16 -0
- package/build/pingala-mcp/src/tools/get-governance-context.js.map +1 -0
- package/build/pingala-mcp/src/tools/validate-stack-change.d.ts +41 -0
- package/build/pingala-mcp/src/tools/validate-stack-change.js +35 -0
- package/build/pingala-mcp/src/tools/validate-stack-change.js.map +1 -0
- package/build/sdk/index.d.ts +6 -0
- package/build/sdk/index.js +18 -0
- package/build/sdk/index.js.map +1 -0
- package/build/sdk/patterns/index.d.ts +3 -0
- package/build/sdk/patterns/index.js +37 -0
- package/build/sdk/patterns/index.js.map +1 -0
- package/build/sdk/patterns/registry.d.ts +4 -0
- package/build/sdk/patterns/registry.js +80 -0
- package/build/sdk/patterns/registry.js.map +1 -0
- package/build/sdk/telemetry/buffer.d.ts +9 -0
- package/build/sdk/telemetry/buffer.js +47 -0
- package/build/sdk/telemetry/buffer.js.map +1 -0
- package/build/sdk/telemetry/scrubber.d.ts +3 -0
- package/build/sdk/telemetry/scrubber.js +13 -0
- package/build/sdk/telemetry/scrubber.js.map +1 -0
- package/build/sdk/telemetry/types.d.ts +50 -0
- package/build/sdk/telemetry/types.js +2 -0
- package/build/sdk/telemetry/types.js.map +1 -0
- package/build/sdk/types/decision.d.ts +18 -0
- package/build/sdk/types/decision.js +2 -0
- package/build/sdk/types/decision.js.map +1 -0
- package/build/sdk/types/index.d.ts +4 -0
- package/build/sdk/types/index.js +5 -0
- package/build/sdk/types/index.js.map +1 -0
- package/build/sdk/types/pattern.d.ts +17 -0
- package/build/sdk/types/pattern.js +2 -0
- package/build/sdk/types/pattern.js.map +1 -0
- package/build/sdk/types/stack.d.ts +8 -0
- package/build/sdk/types/stack.js +2 -0
- package/build/sdk/types/stack.js.map +1 -0
- package/build/sdk/types/tool.d.ts +9 -0
- package/build/sdk/types/tool.js +2 -0
- package/build/sdk/types/tool.js.map +1 -0
- package/build/sdk/validator/csi.d.ts +2 -0
- package/build/sdk/validator/csi.js +24 -0
- package/build/sdk/validator/csi.js.map +1 -0
- package/build/sdk/validator/index.d.ts +2 -0
- package/build/sdk/validator/index.js +3 -0
- package/build/sdk/validator/index.js.map +1 -0
- package/build/sdk/validator/rules/geometry.d.ts +11 -0
- package/build/sdk/validator/rules/geometry.js +22 -0
- package/build/sdk/validator/rules/geometry.js.map +1 -0
- package/build/sdk/validator/validate.d.ts +2 -0
- package/build/sdk/validator/validate.js +46 -0
- package/build/sdk/validator/validate.js.map +1 -0
- package/build/src/core/531-rule.d.ts +26 -0
- package/build/src/core/531-rule.js +96 -0
- package/build/src/core/531-rule.js.map +1 -0
- package/build/src/core/auth.d.ts +1 -0
- package/build/src/core/auth.js +15 -0
- package/build/src/core/auth.js.map +1 -0
- package/build/src/core/consent-manager.d.ts +17 -0
- package/build/src/core/consent-manager.js +104 -0
- package/build/src/core/consent-manager.js.map +1 -0
- package/build/src/core/csp.d.ts +12 -0
- package/build/src/core/csp.js +20 -0
- package/build/src/core/csp.js.map +1 -0
- package/build/src/core/engagement-analyzer.d.ts +42 -0
- package/build/src/core/engagement-analyzer.js +71 -0
- package/build/src/core/engagement-analyzer.js.map +1 -0
- package/build/src/core/governor.d.ts +104 -0
- package/build/src/core/governor.js +371 -0
- package/build/src/core/governor.js.map +1 -0
- package/build/src/core/life-area-mapper.d.ts +39 -0
- package/build/src/core/life-area-mapper.js +73 -0
- package/build/src/core/life-area-mapper.js.map +1 -0
- package/build/src/core/methodology.d.ts +39 -0
- package/build/src/core/methodology.js +164 -0
- package/build/src/core/methodology.js.map +1 -0
- package/build/src/core/pingala.d.ts +25 -0
- package/build/src/core/pingala.js +56 -0
- package/build/src/core/pingala.js.map +1 -0
- package/build/src/core/sdk-adapter.d.ts +8 -0
- package/build/src/core/sdk-adapter.js +34 -0
- package/build/src/core/sdk-adapter.js.map +1 -0
- package/build/src/index.d.ts +2 -0
- package/build/src/index.js +333 -0
- package/build/src/index.js.map +1 -0
- package/build/src/test-l3.d.ts +1 -0
- package/build/src/test-l3.js +35 -0
- package/build/src/test-l3.js.map +1 -0
- package/build/src/tools/audit-workspace.d.ts +16 -0
- package/build/src/tools/audit-workspace.js +39 -0
- package/build/src/tools/audit-workspace.js.map +1 -0
- package/build/src/tools/calculate-csi.d.ts +24 -0
- package/build/src/tools/calculate-csi.js +29 -0
- package/build/src/tools/calculate-csi.js.map +1 -0
- package/build/src/tools/cs-audit.d.ts +54 -0
- package/build/src/tools/cs-audit.js +310 -0
- package/build/src/tools/cs-audit.js.map +1 -0
- package/build/src/tools/get-governance-context.d.ts +11 -0
- package/build/src/tools/get-governance-context.js +16 -0
- package/build/src/tools/get-governance-context.js.map +1 -0
- package/build/src/tools/validate-stack-change.d.ts +41 -0
- package/build/src/tools/validate-stack-change.js +35 -0
- package/build/src/tools/validate-stack-change.js.map +1 -0
- package/build/test-l3.d.ts +1 -0
- package/build/test-l3.js +35 -0
- package/build/test-l3.js.map +1 -0
- package/build/tools/analyze-stack.d.ts +40 -0
- package/build/tools/analyze-stack.js +121 -0
- package/build/tools/analyze-stack.js.map +1 -0
- package/build/tools/audit-workspace.d.ts +16 -0
- package/build/tools/audit-workspace.js +39 -0
- package/build/tools/audit-workspace.js.map +1 -0
- package/build/tools/calculate-csi.d.ts +26 -0
- package/build/tools/calculate-csi.js +30 -0
- package/build/tools/calculate-csi.js.map +1 -0
- package/build/tools/cs-audit.d.ts +43 -0
- package/build/tools/cs-audit.js +330 -0
- package/build/tools/cs-audit.js.map +1 -0
- package/build/tools/get-governance-context.d.ts +11 -0
- package/build/tools/get-governance-context.js +61 -0
- package/build/tools/get-governance-context.js.map +1 -0
- package/build/tools/validate-stack-change.d.ts +41 -0
- package/build/tools/validate-stack-change.js +54 -0
- package/build/tools/validate-stack-change.js.map +1 -0
- package/package.json +34 -0
- package/scripts/cloud-bridge.js +62 -0
- package/scripts/generate-token.js +13 -0
- package/src/core/531-rule.ts +148 -0
- package/src/core/auth.ts +42 -0
- package/src/core/consent-manager.ts +134 -0
- package/src/core/csp.ts +40 -0
- package/src/core/engagement-analyzer.ts +122 -0
- package/src/core/governor.ts +522 -0
- package/src/core/life-area-mapper.ts +138 -0
- package/src/core/methodology.ts +256 -0
- package/src/core/pingala.ts +77 -0
- package/src/core/sdk-adapter.ts +52 -0
- package/src/index.ts +562 -0
- package/src/test-l3.ts +45 -0
- package/src/tools/analyze-stack.ts +153 -0
- package/src/tools/audit-workspace.ts +50 -0
- package/src/tools/calculate-csi.ts +38 -0
- package/src/tools/cs-audit.ts +384 -0
- package/src/tools/get-governance-context.ts +69 -0
- package/src/tools/validate-stack-change.ts +71 -0
- package/src/types.d.ts +2 -0
- package/tsconfig.json +40 -0
- package/vercel.json +15 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
|
3
|
+
import { csAuditTool } from "./tools/cs-audit.js";
|
|
4
|
+
import { validateStackChangeTool } from "./tools/validate-stack-change.js";
|
|
5
|
+
import { getGovernanceContextTool } from "./tools/get-governance-context.js";
|
|
6
|
+
import { calculateCsiTool } from "./tools/calculate-csi.js";
|
|
7
|
+
import { analyzeStackTool } from "./tools/analyze-stack.js";
|
|
8
|
+
import { MethodologyLoader } from "./core/methodology.js";
|
|
9
|
+
import { Governor } from "./core/governor.js";
|
|
10
|
+
import { PingalaEngine } from "./core/pingala.js";
|
|
11
|
+
import { initPingalaTelemetry, getRegistryMode } from "./core/sdk-adapter.js";
|
|
12
|
+
import process from "node:process";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
import express from "express";
|
|
15
|
+
import cors from "cors";
|
|
16
|
+
|
|
17
|
+
// Load .env variables natively if available (Node v20.6+)
|
|
18
|
+
try {
|
|
19
|
+
(process as any).loadEnvFile();
|
|
20
|
+
} catch (e) {
|
|
21
|
+
// .env file missing or not supported, move on
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* CSTACK MCP Server (Powered by Pingala)
|
|
26
|
+
*
|
|
27
|
+
* The governance layer for the Conscious Stack ecosystem.
|
|
28
|
+
* Enforces the 5:3:1 Protocol and provides diagnostic tools.
|
|
29
|
+
*/
|
|
30
|
+
const server = new McpServer({
|
|
31
|
+
name: "cstack-mcp",
|
|
32
|
+
version: "0.4.5-cloud",
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Initialize Telemetry for Cloud Mode
|
|
36
|
+
try {
|
|
37
|
+
initPingalaTelemetry('contributor');
|
|
38
|
+
} catch (e) {
|
|
39
|
+
console.error("[Pingala] Telemetry initialization failed (likely missing SDK)", e);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Load methodology for dynamic description
|
|
43
|
+
const rules = MethodologyLoader.load531Rules();
|
|
44
|
+
const protocolDesc = rules.rawDescription || "1 Anchor, 3 Active, 5 Supporting";
|
|
45
|
+
|
|
46
|
+
// Register Tools
|
|
47
|
+
server.tool(
|
|
48
|
+
csAuditTool.name,
|
|
49
|
+
`${csAuditTool.description} (Protocol Rule: ${protocolDesc})`,
|
|
50
|
+
csAuditTool.schema,
|
|
51
|
+
csAuditTool.handler
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
server.tool(
|
|
55
|
+
validateStackChangeTool.name,
|
|
56
|
+
validateStackChangeTool.description,
|
|
57
|
+
validateStackChangeTool.schema as any,
|
|
58
|
+
validateStackChangeTool.handler
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
server.tool(
|
|
62
|
+
getGovernanceContextTool.name,
|
|
63
|
+
getGovernanceContextTool.description,
|
|
64
|
+
getGovernanceContextTool.schema,
|
|
65
|
+
getGovernanceContextTool.handler
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
server.tool(
|
|
69
|
+
calculateCsiTool.name,
|
|
70
|
+
calculateCsiTool.description,
|
|
71
|
+
calculateCsiTool.schema as any,
|
|
72
|
+
calculateCsiTool.handler
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
server.tool(
|
|
76
|
+
analyzeStackTool.name,
|
|
77
|
+
analyzeStackTool.description,
|
|
78
|
+
analyzeStackTool.schema as any,
|
|
79
|
+
analyzeStackTool.handler
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// Register Resources
|
|
83
|
+
server.resource(
|
|
84
|
+
"current-stack",
|
|
85
|
+
"cstack://stack-map/current",
|
|
86
|
+
{
|
|
87
|
+
description: "The current 5:3:1 hierarchy of tools",
|
|
88
|
+
mimeType: "application/json"
|
|
89
|
+
},
|
|
90
|
+
async (uri: URL) => {
|
|
91
|
+
const stack = Governor.getStack();
|
|
92
|
+
return {
|
|
93
|
+
contents: [{
|
|
94
|
+
uri: uri.href,
|
|
95
|
+
text: JSON.stringify({
|
|
96
|
+
anchor: stack.find(t => t.role === 'Anchor') || null,
|
|
97
|
+
active: stack.filter(t => t.role === 'Active'),
|
|
98
|
+
supporting: stack.filter(t => t.role === 'Supporting')
|
|
99
|
+
}, null, 2)
|
|
100
|
+
}]
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
server.resource(
|
|
106
|
+
"maturity-status",
|
|
107
|
+
"cstack://maturity/status",
|
|
108
|
+
{
|
|
109
|
+
description: "Current maturity level and days of stability",
|
|
110
|
+
mimeType: "application/json"
|
|
111
|
+
},
|
|
112
|
+
async (uri: URL) => {
|
|
113
|
+
const state = Governor.getMaturityState();
|
|
114
|
+
return {
|
|
115
|
+
contents: [{
|
|
116
|
+
uri: uri.href,
|
|
117
|
+
text: JSON.stringify(state, null, 2)
|
|
118
|
+
}]
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
server.resource(
|
|
124
|
+
"latest-csi",
|
|
125
|
+
"cstack://csi/latest",
|
|
126
|
+
{
|
|
127
|
+
description: "Current Conscious Stack Index (CSI) with component breakdown",
|
|
128
|
+
mimeType: "application/json"
|
|
129
|
+
},
|
|
130
|
+
async (uri: URL) => {
|
|
131
|
+
const stack = Governor.getStack();
|
|
132
|
+
const diagnosis = await PingalaEngine.diagnose({ tools: stack });
|
|
133
|
+
return {
|
|
134
|
+
contents: [{
|
|
135
|
+
uri: uri.href,
|
|
136
|
+
text: JSON.stringify(diagnosis, null, 2)
|
|
137
|
+
}]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
server.resource(
|
|
143
|
+
"stack-drift",
|
|
144
|
+
"cstack://drift/current",
|
|
145
|
+
{
|
|
146
|
+
description: "Current architectural drift signals and score",
|
|
147
|
+
mimeType: "application/json"
|
|
148
|
+
},
|
|
149
|
+
async (uri: URL) => {
|
|
150
|
+
const drift = Governor.getStackDriftScore();
|
|
151
|
+
return {
|
|
152
|
+
contents: [{
|
|
153
|
+
uri: uri.href,
|
|
154
|
+
text: JSON.stringify(drift, null, 2)
|
|
155
|
+
}]
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
// Register Prompts
|
|
161
|
+
server.prompt(
|
|
162
|
+
"inject-constraints",
|
|
163
|
+
{
|
|
164
|
+
base_prompt: z.string().describe("The user's original request")
|
|
165
|
+
},
|
|
166
|
+
async (args) => {
|
|
167
|
+
const stack = Governor.getStack();
|
|
168
|
+
const state = Governor.getMaturityState();
|
|
169
|
+
const diagnosis = await PingalaEngine.diagnose({ tools: stack });
|
|
170
|
+
const context = Governor.getGovernanceContext();
|
|
171
|
+
const mode = getRegistryMode();
|
|
172
|
+
|
|
173
|
+
const modeFlag = mode === 'Authorized' ? 'COLLECTIVE MODE (Authorized)' : 'SOVEREIGN MODE (Local-First)';
|
|
174
|
+
const connectionDetails = mode === 'Authorized'
|
|
175
|
+
? 'Connected to patterns.consciousstack.com (Live Registry)'
|
|
176
|
+
: 'Using local patterns and public registry fallback.';
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
messages: [{
|
|
180
|
+
role: "user",
|
|
181
|
+
content: {
|
|
182
|
+
type: "text",
|
|
183
|
+
text: `GOVERNANCE CONTEXT [${modeFlag}]:
|
|
184
|
+
- Functional Nodes: ${JSON.stringify(context.functional_nodes)}
|
|
185
|
+
- Maturity Level: ${state.level} (${state.level_name}) - ${state.stability_days} days stable
|
|
186
|
+
- CSI Score: ${diagnosis.csi_score} [${diagnosis.risk_band}] (Blended: SDK Logic + Fragmentation)
|
|
187
|
+
- CSI Delta: ${context.progression.csi_delta > 0 ? '+' : ''}${context.progression.csi_delta}
|
|
188
|
+
- SDK Violations: ${diagnosis.protocol_analysis.violations.length > 0 ? diagnosis.protocol_analysis.violations.join('; ') : 'None'}
|
|
189
|
+
- Allowed Actions: ${context.allowed_actions.join(", ")}
|
|
190
|
+
- Blocked Actions: ${context.blocked_actions.join(", ")}
|
|
191
|
+
|
|
192
|
+
REGISTRY & MOAT:
|
|
193
|
+
- Status: ${connectionDetails}
|
|
194
|
+
- Data Moat: ${mode === 'Authorized' ? 'ACTIVE (Contributing anonymized signals)' : 'PENDING (Key required for contribution)'}
|
|
195
|
+
- Privacy Guard: Tool names are NEVER captured, only Categories (e.g., 'Productivity').
|
|
196
|
+
|
|
197
|
+
CONSTRAINTS (Horizon 1.5 - Functional Scaling):
|
|
198
|
+
- 5:3:1 Protocol: Max 1 Anchor Node, 3 Active Nodes, 5 Supporting Nodes (9 Functional Slots Total).
|
|
199
|
+
- Subtraction over addition: Always explore removal before addition.
|
|
200
|
+
- CSI threshold: No destabilizing changes if CSI < 70.
|
|
201
|
+
- Maturity gate: Level ${state.level} requires specific stability before expansion (${context.progression.days_remaining} days remaining).
|
|
202
|
+
|
|
203
|
+
INSTRUCTIONS:
|
|
204
|
+
1. Review 'SDK Violations' first. These represent specific Failure Patterns (e.g., 'Anchor Void') from the registry.
|
|
205
|
+
2. If tool changes are requested, call validate_stack_change() immediately.
|
|
206
|
+
3. ADAPTER RECOGNITION (Horizon 1.5): If a user provides a flat list of apps, identify if any serve the same function across different devices (e.g., 'Chrome (mobile)' and 'Chrome (desktop)').
|
|
207
|
+
- Cluster these into a single 'functionId' (e.g., 'browser').
|
|
208
|
+
- Tag device-specific versions with 'contexts' and 'isAdapter: true'.
|
|
209
|
+
- The MCP now auto-detects these, but your hints improve precision.
|
|
210
|
+
4. PROTOCOL HANDSHAKE: If in COLLECTIVE MODE and you detect a significant CSI shift or a novel pattern match, inform the user: "Significant stack shift detected. Signal buffered for collective intelligence."
|
|
211
|
+
5. Your goal: High Resonance (CSI > 85). Minimize Fragmentation and maximize Decision Provenance.
|
|
212
|
+
|
|
213
|
+
USER REQUEST:
|
|
214
|
+
${args.base_prompt}`
|
|
215
|
+
}
|
|
216
|
+
}]
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
server.prompt(
|
|
222
|
+
"canonical-output",
|
|
223
|
+
{
|
|
224
|
+
analysis_type: z.enum(["audit", "mirror", "zoning"]).describe("Type of analysis being performed")
|
|
225
|
+
},
|
|
226
|
+
async (args) => {
|
|
227
|
+
return {
|
|
228
|
+
messages: [{
|
|
229
|
+
role: "user",
|
|
230
|
+
content: {
|
|
231
|
+
type: "text",
|
|
232
|
+
text: `Respond using the Pingala canonical structure for ${args.analysis_type}:
|
|
233
|
+
|
|
234
|
+
## 1. Target State
|
|
235
|
+
[Define desired operating condition with specific metrics]
|
|
236
|
+
|
|
237
|
+
## 2. Current State
|
|
238
|
+
[Summarize present signals from stack, CSI, telemetry]
|
|
239
|
+
|
|
240
|
+
## 3. Recommendations
|
|
241
|
+
[3-5 actionable changes tied to Target State]
|
|
242
|
+
|
|
243
|
+
## 4. Guardrails
|
|
244
|
+
[Rules that prevent erosion]
|
|
245
|
+
|
|
246
|
+
## 5. Workflow Improvements
|
|
247
|
+
[Concrete protocol changes]
|
|
248
|
+
|
|
249
|
+
## 6. Crystalline Geometry
|
|
250
|
+
[Identify hex/cubic patterns and evolution path]
|
|
251
|
+
|
|
252
|
+
## 7. Additional Info
|
|
253
|
+
[Assumptions, caveats, telemetry notes]`
|
|
254
|
+
}
|
|
255
|
+
}]
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
server.prompt(
|
|
261
|
+
"augmentation-only",
|
|
262
|
+
{
|
|
263
|
+
decision_context: z.string().describe("What decision needs to be made")
|
|
264
|
+
},
|
|
265
|
+
async (args) => {
|
|
266
|
+
return {
|
|
267
|
+
messages: [{
|
|
268
|
+
role: "user",
|
|
269
|
+
content: {
|
|
270
|
+
type: "text",
|
|
271
|
+
text: `AUGMENTATION MODE ACTIVE
|
|
272
|
+
|
|
273
|
+
Your role: Provide analysis and options
|
|
274
|
+
Human's role: Make final decision and own the outcome
|
|
275
|
+
|
|
276
|
+
Decision context: ${args.decision_context}
|
|
277
|
+
|
|
278
|
+
Provide:
|
|
279
|
+
1. Key factors to consider
|
|
280
|
+
2. 2-3 options with tradeoffs
|
|
281
|
+
3. Data/evidence supporting each option
|
|
282
|
+
4. Potential risks and mitigations
|
|
283
|
+
|
|
284
|
+
Do NOT:
|
|
285
|
+
- Make the decision for the human
|
|
286
|
+
- Use language like 'you should' or 'I recommend'
|
|
287
|
+
- Provide a single answer without alternatives
|
|
288
|
+
|
|
289
|
+
End with: 'What do you decide?'`
|
|
290
|
+
}
|
|
291
|
+
}]
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
import { validateToken } from "./core/auth.js";
|
|
297
|
+
|
|
298
|
+
const app = express();
|
|
299
|
+
app.use(cors());
|
|
300
|
+
|
|
301
|
+
let transport: SSEServerTransport | null = null;
|
|
302
|
+
|
|
303
|
+
// Apply auth only to MCP endpoints (keep / public for landing page)
|
|
304
|
+
app.use("/sse", validateToken);
|
|
305
|
+
app.use("/messages", validateToken);
|
|
306
|
+
|
|
307
|
+
app.get("/", (req: any, res: any) => {
|
|
308
|
+
res.send(`
|
|
309
|
+
<!DOCTYPE html>
|
|
310
|
+
<html lang="en">
|
|
311
|
+
<head>
|
|
312
|
+
<meta charset="UTF-8">
|
|
313
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
314
|
+
<title>Pingala MCP | Conscious Stack</title>
|
|
315
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
316
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
317
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&family=Outfit:wght@300;600&display=swap" rel="stylesheet">
|
|
318
|
+
<style>
|
|
319
|
+
:root {
|
|
320
|
+
--bg: #0a0a0c;
|
|
321
|
+
--fg: #e2e2e4;
|
|
322
|
+
--accent: #9a86fd;
|
|
323
|
+
--glass: rgba(255, 255, 255, 0.05);
|
|
324
|
+
}
|
|
325
|
+
body {
|
|
326
|
+
margin: 0;
|
|
327
|
+
padding: 0;
|
|
328
|
+
background: var(--bg);
|
|
329
|
+
color: var(--fg);
|
|
330
|
+
font-family: 'Inter', sans-serif;
|
|
331
|
+
display: flex;
|
|
332
|
+
flex-direction: column;
|
|
333
|
+
align-items: center;
|
|
334
|
+
justify-content: center;
|
|
335
|
+
min-height: 100vh;
|
|
336
|
+
overflow: hidden;
|
|
337
|
+
}
|
|
338
|
+
.container {
|
|
339
|
+
text-align: center;
|
|
340
|
+
z-index: 10;
|
|
341
|
+
padding: 2rem;
|
|
342
|
+
background: var(--glass);
|
|
343
|
+
backdrop-filter: blur(20px);
|
|
344
|
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
345
|
+
border-radius: 24px;
|
|
346
|
+
max-width: 600px;
|
|
347
|
+
}
|
|
348
|
+
h1 {
|
|
349
|
+
font-family: 'Outfit', sans-serif;
|
|
350
|
+
font-size: 3rem;
|
|
351
|
+
margin: 0;
|
|
352
|
+
background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
|
|
353
|
+
-webkit-background-clip: text;
|
|
354
|
+
-webkit-text-fill-color: transparent;
|
|
355
|
+
}
|
|
356
|
+
p {
|
|
357
|
+
color: #a1a1aa;
|
|
358
|
+
line-height: 1.6;
|
|
359
|
+
margin: 1.5rem 0;
|
|
360
|
+
}
|
|
361
|
+
.details {
|
|
362
|
+
text-align: left;
|
|
363
|
+
background: rgba(0,0,0,0.3);
|
|
364
|
+
padding: 1.5rem;
|
|
365
|
+
border-radius: 12px;
|
|
366
|
+
margin-top: 2rem;
|
|
367
|
+
font-family: monospace;
|
|
368
|
+
font-size: 0.9rem;
|
|
369
|
+
border-left: 4px solid var(--accent);
|
|
370
|
+
}
|
|
371
|
+
.glow {
|
|
372
|
+
position: absolute;
|
|
373
|
+
width: 600px;
|
|
374
|
+
height: 600px;
|
|
375
|
+
background: radial-gradient(circle, rgba(154, 134, 253, 0.15) 0%, transparent 70%);
|
|
376
|
+
top: 50%;
|
|
377
|
+
left: 50%;
|
|
378
|
+
transform: translate(-50%, -50%);
|
|
379
|
+
z-index: 1;
|
|
380
|
+
}
|
|
381
|
+
</style>
|
|
382
|
+
</head>
|
|
383
|
+
<body>
|
|
384
|
+
<div class="glow"></div>
|
|
385
|
+
<div class="container">
|
|
386
|
+
<h1>Pingala MCP</h1>
|
|
387
|
+
<p>Architectural Guardrails for AI Autonomy.<br>The first AI<>Human Co-Governance Layer.</p>
|
|
388
|
+
<div class="details">
|
|
389
|
+
<strong>Endpoint:</strong> mcp.consciousstack.com/sse<br>
|
|
390
|
+
<strong>Transport:</strong> SSE (Server-Sent Events)<br>
|
|
391
|
+
<strong>Auth:</strong> Bearer Token Required
|
|
392
|
+
</div>
|
|
393
|
+
<p style="font-size: 0.8rem; opacity: 0.5; margin-top: 2rem;">© 2026 Conscious Stack Protocol</p>
|
|
394
|
+
</div>
|
|
395
|
+
</body>
|
|
396
|
+
</html>
|
|
397
|
+
`);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
app.get("/sse", async (req: any, res: any) => {
|
|
401
|
+
// Thread the token into the message endpoint so POSTs are automatically authorized
|
|
402
|
+
const token = req.query.token || (req.headers.authorization?.startsWith("Bearer ") ? req.headers.authorization.split(" ")[1] : null);
|
|
403
|
+
const messageEndpoint = token ? `/messages?token=${token}` : "/messages";
|
|
404
|
+
|
|
405
|
+
transport = new SSEServerTransport(messageEndpoint as any, res);
|
|
406
|
+
await server.connect(transport);
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
app.post("/messages", async (req: any, res: any) => {
|
|
410
|
+
if (transport) {
|
|
411
|
+
try {
|
|
412
|
+
await transport.handlePostMessage(req, res);
|
|
413
|
+
} catch (e: any) {
|
|
414
|
+
console.error("[SSE] Post message error:", e.message);
|
|
415
|
+
res.status(500).send(e.message);
|
|
416
|
+
}
|
|
417
|
+
} else {
|
|
418
|
+
console.warn("[SSE] Message received but no active transport found. Vercel lambda likely recycled.");
|
|
419
|
+
res.status(400).send("No active SSE connection. Please reconnect.");
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
const PORT = process.env.PORT || 3000;
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
// CLI COMMANDS
|
|
427
|
+
// Only run these if arguments are provided
|
|
428
|
+
const args = process.argv.slice(2);
|
|
429
|
+
const command = args[0];
|
|
430
|
+
|
|
431
|
+
if (command) {
|
|
432
|
+
handleCliCommand(command, args.slice(1));
|
|
433
|
+
} else {
|
|
434
|
+
// Only listen if not running as a Vercel serverless function AND no CLI command
|
|
435
|
+
if (process.env.NODE_ENV !== 'production' || !process.env.VERCEL) {
|
|
436
|
+
app.listen(PORT, () => {
|
|
437
|
+
console.log(`Pingala MCP Cloud Server running on port ${PORT}`);
|
|
438
|
+
console.log(`SSE endpoint: /sse`);
|
|
439
|
+
console.log(`Messages endpoint: /messages`);
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
async function handleCliCommand(cmd: string, opts: string[]) {
|
|
445
|
+
try {
|
|
446
|
+
switch (cmd) {
|
|
447
|
+
case 'audit':
|
|
448
|
+
await runAudit();
|
|
449
|
+
break;
|
|
450
|
+
case 'setup-claude':
|
|
451
|
+
await runSetupClaude();
|
|
452
|
+
break;
|
|
453
|
+
case 'config':
|
|
454
|
+
await runConfig(opts);
|
|
455
|
+
break;
|
|
456
|
+
default:
|
|
457
|
+
console.error(`Unknown command: ${cmd}`);
|
|
458
|
+
console.log(`Available commands: audit, setup-claude, config`);
|
|
459
|
+
process.exit(1);
|
|
460
|
+
}
|
|
461
|
+
} catch (error) {
|
|
462
|
+
console.error("Error executing command:", error);
|
|
463
|
+
process.exit(1);
|
|
464
|
+
}
|
|
465
|
+
// Explicit exit after CLI command
|
|
466
|
+
process.exit(0);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
async function runAudit() {
|
|
470
|
+
console.log("š Pingala: Starting local sovereignty audit...");
|
|
471
|
+
|
|
472
|
+
// Force local detection
|
|
473
|
+
const stack = Governor.getStack();
|
|
474
|
+
const result = (await csAuditTool.handler({ path: process.cwd() } as any)) as any;
|
|
475
|
+
|
|
476
|
+
// Parse result from tool output
|
|
477
|
+
const content = result.content[0].text;
|
|
478
|
+
console.log("\n" + content);
|
|
479
|
+
|
|
480
|
+
// Add "Next Steps" hook
|
|
481
|
+
console.log("\n---------------------------------------------------------");
|
|
482
|
+
console.log("š Want to track this over time and get pattern matching?");
|
|
483
|
+
console.log(" Run: npx @cstack-protocol/pingala config set-key <YOUR_CSTACK_API_KEY>");
|
|
484
|
+
console.log(" Get a key at: https://api.consciousstack.com");
|
|
485
|
+
console.log("---------------------------------------------------------");
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
async function runSetupClaude() {
|
|
489
|
+
const fs = await import('fs');
|
|
490
|
+
const path = await import('path');
|
|
491
|
+
const os = await import('os');
|
|
492
|
+
|
|
493
|
+
console.log("š¤ Pingala: Configuring Claude Desktop...");
|
|
494
|
+
|
|
495
|
+
const configPath = path.join(os.homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
|
|
496
|
+
let config: any = { mcpServers: {} };
|
|
497
|
+
|
|
498
|
+
if (fs.existsSync(configPath)) {
|
|
499
|
+
try {
|
|
500
|
+
config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
501
|
+
} catch (e) {
|
|
502
|
+
console.warn("Could not parse existing config, creating new.");
|
|
503
|
+
}
|
|
504
|
+
} else {
|
|
505
|
+
// Ensure directory exists
|
|
506
|
+
const dir = path.dirname(configPath);
|
|
507
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// Try to find API Key
|
|
511
|
+
let apiKey = process.env.CSTACK_API_KEY;
|
|
512
|
+
if (!apiKey) {
|
|
513
|
+
const homeConfig = path.join(os.homedir(), '.cstackrc');
|
|
514
|
+
if (fs.existsSync(homeConfig)) {
|
|
515
|
+
const content = fs.readFileSync(homeConfig, 'utf8');
|
|
516
|
+
const match = content.match(/CSTACK_API_KEY=(.*)/);
|
|
517
|
+
if (match) apiKey = match[1].trim();
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// Add Pingala
|
|
522
|
+
config.mcpServers["pingala"] = {
|
|
523
|
+
command: "npx",
|
|
524
|
+
args: ["-y", "@cstack-protocol/pingala@latest"],
|
|
525
|
+
env: {
|
|
526
|
+
"CSTACK_API_KEY": apiKey || ""
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
531
|
+
console.log(`ā
Successfully updated ${configPath}`);
|
|
532
|
+
|
|
533
|
+
if (!apiKey) {
|
|
534
|
+
console.warn("\nā ļø No API Key found. Your Pingala agent will run in local-only mode.");
|
|
535
|
+
console.log(" To enable cloud patterns: npx @cstack-protocol/pingala config set-key <KEY> && npx @cstack-protocol/pingala setup-claude");
|
|
536
|
+
} else {
|
|
537
|
+
console.log(" API Key injected successfully.");
|
|
538
|
+
}
|
|
539
|
+
console.log(" Please restart Claude Desktop to enable Pingala.");
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
async function runConfig(opts: string[]) {
|
|
543
|
+
if (opts[0] === 'set-key' && opts[1]) {
|
|
544
|
+
console.log(`š Setting API Key: ${opts[1].substring(0, 8)}...`);
|
|
545
|
+
// In a real CLI, we might write to a local .env or config file in home dir
|
|
546
|
+
// For now, let's guide them to export it
|
|
547
|
+
console.log("To persist this, please add it to your environment variables:");
|
|
548
|
+
console.log(`export CSTACK_API_KEY=${opts[1]}`);
|
|
549
|
+
|
|
550
|
+
// Setup rudimentary dotfile persistence for the brave
|
|
551
|
+
const fs = await import('fs');
|
|
552
|
+
const path = await import('path');
|
|
553
|
+
const os = await import('os');
|
|
554
|
+
const homeConfig = path.join(os.homedir(), '.cstackrc');
|
|
555
|
+
fs.writeFileSync(homeConfig, `CSTACK_API_KEY=${opts[1]}`);
|
|
556
|
+
console.log(` (Saved to ${homeConfig} for local tools)`);
|
|
557
|
+
} else {
|
|
558
|
+
console.log("Usage: config set-key <key>");
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
export default app;
|
package/src/test-l3.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { csAuditTool } from "./tools/cs-audit.js";
|
|
2
|
+
import { MethodologyLoader } from "./core/methodology.js";
|
|
3
|
+
import { ConsentManager } from "./core/consent-manager.js";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
|
|
6
|
+
async function test_l3_audit() {
|
|
7
|
+
process.env.CSTACK_AGENT_CORE_PATH = "/Users/georgesiosi/Documents/GitHub/conscious-stack/_active/cs-agent-core";
|
|
8
|
+
MethodologyLoader.init();
|
|
9
|
+
|
|
10
|
+
// Set workspace to the current active directory
|
|
11
|
+
const workspacePath = "/Users/georgesiosi/Documents/GitHub/conscious-stack/_active/cs-mcp-core";
|
|
12
|
+
ConsentManager.setWorkspace(workspacePath);
|
|
13
|
+
|
|
14
|
+
// Mock tool stack
|
|
15
|
+
const tools = [
|
|
16
|
+
{ name: "FocusMonitor", role: "Anchor", functionId: "Tai Ji", category: "OS" },
|
|
17
|
+
{ name: "Cursor", role: "Active", functionId: "Gen", category: "Development" },
|
|
18
|
+
{ name: "Notion", role: "Active", functionId: "Qian", category: "Knowledge" },
|
|
19
|
+
{ name: "Obsidian", role: "Active", functionId: "Dui", category: "Knowledge" },
|
|
20
|
+
{ name: "Slack", role: "Supporting", functionId: "Li", category: "Communication" },
|
|
21
|
+
{ name: "Linear", role: "Supporting", functionId: "Kan", category: "Task" }
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
console.log("--- TEST 1: L3 Audit Without Consent ---");
|
|
25
|
+
const result1 = await csAuditTool.handler({
|
|
26
|
+
tools,
|
|
27
|
+
path: workspacePath,
|
|
28
|
+
depth_level: "L3"
|
|
29
|
+
});
|
|
30
|
+
console.log(JSON.stringify(result1, null, 2));
|
|
31
|
+
|
|
32
|
+
console.log("\n--- TEST 2: L3 Audit WITH CONSENT ---");
|
|
33
|
+
// Simulate user granting consent in the workspace
|
|
34
|
+
ConsentManager.setConsent("L2", true);
|
|
35
|
+
ConsentManager.setConsent("L3", true);
|
|
36
|
+
|
|
37
|
+
const result2 = await csAuditTool.handler({
|
|
38
|
+
tools,
|
|
39
|
+
path: workspacePath,
|
|
40
|
+
depth_level: "L3"
|
|
41
|
+
});
|
|
42
|
+
console.log(JSON.stringify(result2, null, 2));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
test_l3_audit().catch(console.error);
|