@bcelep/capint 0.4.2

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.
Files changed (69) hide show
  1. package/AGENT.md +28 -0
  2. package/CHANGELOG.md +58 -0
  3. package/README.md +94 -0
  4. package/bin/capint.js +90 -0
  5. package/design.md +23 -0
  6. package/docs/architecture-decisions.md +95 -0
  7. package/docs/execution-intent-contract.md +81 -0
  8. package/docs/manifest-schema.md +36 -0
  9. package/docs/release-checklist.md +31 -0
  10. package/package.json +33 -0
  11. package/projections/session-start.md +32 -0
  12. package/registry.json +12 -0
  13. package/scripts/release-check.mjs +40 -0
  14. package/scripts/validate-matrix.mjs +83 -0
  15. package/skill-routing-matrix.json +150 -0
  16. package/skills/capability-router/SKILL.md +3 -0
  17. package/skills/context-memory-bridge/SKILL.md +17 -0
  18. package/skills/localization-hub/SKILL.md +17 -0
  19. package/skills/refactor/SKILL.md +17 -0
  20. package/skills/systematic-debugging/SKILL.md +19 -0
  21. package/src/commands/audit.js +32 -0
  22. package/src/commands/consult.js +64 -0
  23. package/src/commands/doctor.js +36 -0
  24. package/src/commands/ide.js +62 -0
  25. package/src/commands/init.js +50 -0
  26. package/src/commands/memory.js +60 -0
  27. package/src/commands/route.js +30 -0
  28. package/src/commands/scaffold.js +37 -0
  29. package/src/commands/status.js +22 -0
  30. package/src/commands/uninstall.js +46 -0
  31. package/src/commands/upgrade.js +69 -0
  32. package/src/lib/audit.js +107 -0
  33. package/src/lib/capability-router.js +118 -0
  34. package/src/lib/context-memory-bridge.js +87 -0
  35. package/src/lib/context-pack.js +39 -0
  36. package/src/lib/contract.js +71 -0
  37. package/src/lib/doctor.js +115 -0
  38. package/src/lib/event-log.js +40 -0
  39. package/src/lib/execution-policy.js +168 -0
  40. package/src/lib/ide-sync.js +277 -0
  41. package/src/lib/intent-parser.js +116 -0
  42. package/src/lib/orchestration.js +25 -0
  43. package/src/lib/providers/activation-policy.js +93 -0
  44. package/src/lib/providers/graph-provider.js +35 -0
  45. package/src/lib/providers/local-graph-adapter.js +40 -0
  46. package/src/lib/providers/local-memory-adapter.js +41 -0
  47. package/src/lib/providers/memory-provider.js +35 -0
  48. package/src/lib/route-engine.js +191 -0
  49. package/src/lib/scaffold/file-policy.js +92 -0
  50. package/src/lib/scaffold/index.js +29 -0
  51. package/src/lib/scaffold/manifest-schema.js +116 -0
  52. package/src/lib/scaffold/manifest.js +34 -0
  53. package/src/lib/scaffold/presets.js +132 -0
  54. package/src/lib/uninstall.js +126 -0
  55. package/src/lib/upgrade-matrix.js +120 -0
  56. package/templates/bundle/skills/capability-router/SKILL.md +12 -0
  57. package/templates/bundle/skills/context-memory-bridge/SKILL.md +17 -0
  58. package/templates/bundle/skills/localization-hub/SKILL.md +17 -0
  59. package/templates/bundle/skills/refactor/SKILL.md +17 -0
  60. package/templates/bundle/skills/systematic-debugging/SKILL.md +19 -0
  61. package/templates/bundle/workflows/forge.md +51 -0
  62. package/templates/minimal/.capint/rules/core.md +18 -0
  63. package/templates/minimal/AGENT.md +26 -0
  64. package/templates/minimal/AGENTS.md +9 -0
  65. package/templates/minimal/design.md +25 -0
  66. package/templates/minimal/registry.json +7 -0
  67. package/templates/prismx-compatible/.capint/context.json +8 -0
  68. package/templates/prismx-compatible/HANDOFF.md +19 -0
  69. package/workflows/forge.md +51 -0
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import { fileURLToPath } from "url";
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
+ const root = path.join(__dirname, "..");
8
+
9
+ const REQUIRED_TOP = [
10
+ "schema_version",
11
+ "resolver_order",
12
+ "fallback_policy",
13
+ "execution_policy_defaults",
14
+ "clarification_policy",
15
+ "classification",
16
+ "task_types"
17
+ ];
18
+
19
+ const MEMORY_LEVELS = new Set(["none", "optional", "required"]);
20
+ const WEIGHTS = new Set(["light", "medium", "heavy"]);
21
+ const PLANS = new Set(["auto", "confirm", "override"]);
22
+
23
+ function fail(msg) {
24
+ console.error(`matrix validation error: ${msg}`);
25
+ process.exit(1);
26
+ }
27
+
28
+ function validateMatrix(matrix) {
29
+ if (!matrix || typeof matrix !== "object") fail("root must be object");
30
+
31
+ for (const key of REQUIRED_TOP) {
32
+ if (!(key in matrix)) fail(`missing top-level key: ${key}`);
33
+ }
34
+
35
+ const semver = String(matrix.schema_version || "");
36
+ if (!/^\d+\.\d+$/.test(semver)) fail("schema_version must be major.minor (e.g. 1.1)");
37
+
38
+ const ids = new Set();
39
+ for (const tt of matrix.task_types) {
40
+ if (!tt.id) fail("task_types entry missing id");
41
+ if (ids.has(tt.id)) fail(`duplicate task_type id: ${tt.id}`);
42
+ ids.add(tt.id);
43
+ if (!tt.capability) fail(`task_type ${tt.id} missing capability`);
44
+ if (!Array.isArray(tt.keywords)) fail(`task_type ${tt.id} keywords must be array`);
45
+ if (tt.requires_memory && !MEMORY_LEVELS.has(tt.requires_memory)) {
46
+ fail(`task_type ${tt.id} invalid requires_memory`);
47
+ }
48
+ if (tt.weight_default && !WEIGHTS.has(tt.weight_default)) {
49
+ fail(`task_type ${tt.id} invalid weight_default`);
50
+ }
51
+ if (tt.default_execution_policy && !PLANS.has(tt.default_execution_policy)) {
52
+ fail(`task_type ${tt.id} invalid default_execution_policy`);
53
+ }
54
+ for (const p of tt.providers || []) {
55
+ if (!p.name || !p.type || !p.resource) {
56
+ fail(`task_type ${tt.id} provider missing name/type/resource`);
57
+ }
58
+ }
59
+ }
60
+
61
+ const policy = matrix.provider_activation_policy;
62
+ if (policy) {
63
+ for (const kind of ["memory_providers", "graph_providers"]) {
64
+ const block = policy[kind];
65
+ if (!block) continue;
66
+ if (block.default !== "off" && block.default !== "on") {
67
+ fail(`${kind}.default must be off|on`);
68
+ }
69
+ }
70
+ }
71
+
72
+ for (const chain of matrix.capability_chains || []) {
73
+ if (!chain.from_capability || !chain.then_capability) {
74
+ fail("capability_chains entry needs from_capability and then_capability");
75
+ }
76
+ }
77
+
78
+ console.log(`matrix valid (schema_version ${matrix.schema_version}, ${matrix.task_types.length} task_types)`);
79
+ }
80
+
81
+ const matrixPath = process.argv[2] || path.join(root, "skill-routing-matrix.json");
82
+ if (!fs.existsSync(matrixPath)) fail(`file not found: ${matrixPath}`);
83
+ validateMatrix(JSON.parse(fs.readFileSync(matrixPath, "utf-8")));
@@ -0,0 +1,150 @@
1
+ {
2
+ "schema_version": "1.2",
3
+ "updated_at": "2026-05-30",
4
+ "resolver_order": ["exact_keyword", "domain_rules", "classification_default"],
5
+ "fallback_policy": {
6
+ "ambiguous_default_capability": "request-clarification",
7
+ "override_hint": "/workflow"
8
+ },
9
+ "execution_policy_defaults": {
10
+ "light": "auto",
11
+ "medium": "confirm",
12
+ "heavy": "confirm"
13
+ },
14
+ "clarification_policy": {
15
+ "mode": "always_confirm",
16
+ "max_options": 3,
17
+ "default_option": "plan_first"
18
+ },
19
+ "verification_defaults": {
20
+ "require_on_light": false,
21
+ "profile": "standard"
22
+ },
23
+ "provider_activation_policy": {
24
+ "memory_providers": {
25
+ "default": "off",
26
+ "require_doctor_pass": true,
27
+ "allow_on_light": false,
28
+ "high_risk_capabilities": ["incident-response", "threat-modeling", "memory-retrieval"]
29
+ },
30
+ "graph_providers": {
31
+ "default": "off",
32
+ "require_doctor_pass": true,
33
+ "allow_on_light": false,
34
+ "high_risk_capabilities": ["memory-retrieval"]
35
+ }
36
+ },
37
+ "capability_chains": [
38
+ {
39
+ "from_capability": "systematic-debugging",
40
+ "then_capability": "refactor-simplify",
41
+ "when": "plan_first"
42
+ },
43
+ {
44
+ "from_capability": "refactor-simplify",
45
+ "then_capability": "verification",
46
+ "when": "after_apply"
47
+ }
48
+ ],
49
+ "classification": {
50
+ "security_override_min": "medium",
51
+ "ambiguous_default": "medium",
52
+ "multi_item_bundle_min": "medium",
53
+ "file_thresholds": { "medium": 3, "heavy": 10 },
54
+ "security_keywords": ["auth", "login", "session", "payment", "secret", "credential", ".env"],
55
+ "heavy_keywords": ["new module", "architecture", "mimari", "schema design", "from scratch"],
56
+ "medium_keywords": ["migration", "endpoint", "refactor", "unit test", "todo", "api"]
57
+ },
58
+ "rules_domain_map": {
59
+ "rules/security.md": {
60
+ "skills": ["security-hardening"],
61
+ "weight_min": "medium"
62
+ },
63
+ "rules/testing.md": {
64
+ "skills": ["test-driven-development"],
65
+ "weight_min": "medium"
66
+ }
67
+ },
68
+ "task_types": [
69
+ {
70
+ "id": "debug",
71
+ "capability": "systematic-debugging",
72
+ "phase": "build",
73
+ "orchestration_pattern": "producer_reviewer",
74
+ "keywords": ["bug", "error", "broken", "fix", "hata", "çalışmıyor"],
75
+ "weight_default": "medium",
76
+ "requires_memory": "optional",
77
+ "default_execution_policy": "confirm",
78
+ "verification_profile": "debug",
79
+ "providers": [
80
+ { "name": "workflow", "type": "workflow", "resource": "forge", "confidence_base": 0.84 },
81
+ { "name": "skill", "type": "skill", "resource": "systematic-debugging", "confidence_base": 0.8 }
82
+ ],
83
+ "skills": ["systematic-debugging"],
84
+ "workflow": "/forge"
85
+ },
86
+ {
87
+ "id": "i18n",
88
+ "capability": "localization-hub",
89
+ "phase": "build",
90
+ "orchestration_pattern": "expert_pool",
91
+ "keywords": ["i18n", "localization", "çeviri", "lang file", "translation hub"],
92
+ "weight_default": "medium",
93
+ "requires_memory": "optional",
94
+ "default_execution_policy": "confirm",
95
+ "providers": [
96
+ { "name": "skill", "type": "skill", "resource": "localization-hub", "confidence_base": 0.9 }
97
+ ],
98
+ "skills": ["localization-hub"],
99
+ "workflow": null
100
+ },
101
+ {
102
+ "id": "refactor",
103
+ "capability": "refactor-simplify",
104
+ "phase": "build",
105
+ "orchestration_pattern": "pipeline",
106
+ "keywords": ["refactor", "clean up", "simplify", "code smell"],
107
+ "weight_default": "medium",
108
+ "requires_memory": "optional",
109
+ "default_execution_policy": "confirm",
110
+ "verification_profile": "refactor",
111
+ "providers": [
112
+ { "name": "workflow", "type": "workflow", "resource": "forge", "confidence_base": 0.79 },
113
+ { "name": "skill", "type": "skill", "resource": "refactor", "confidence_base": 0.77 }
114
+ ],
115
+ "skills": ["refactor"],
116
+ "workflow": "/forge"
117
+ },
118
+ {
119
+ "id": "memory_lookup",
120
+ "capability": "memory-retrieval",
121
+ "phase": "analyze",
122
+ "orchestration_pattern": "expert_pool",
123
+ "keywords": ["memory lookup", "what did we decide", "geçen karar", "history"],
124
+ "weight_default": "light",
125
+ "requires_memory": "required",
126
+ "default_execution_policy": "confirm",
127
+ "verification_required": true,
128
+ "providers": [
129
+ { "name": "skill", "type": "skill", "resource": "context-memory-bridge", "confidence_base": 0.86 }
130
+ ],
131
+ "skills": ["context-memory-bridge"],
132
+ "workflow": null
133
+ },
134
+ {
135
+ "id": "workflow_override",
136
+ "capability": "workflow-override",
137
+ "phase": "meta",
138
+ "orchestration_pattern": "supervisor",
139
+ "keywords": ["/workflow", "/skill", "override"],
140
+ "weight_default": "light",
141
+ "requires_memory": "none",
142
+ "default_execution_policy": "override",
143
+ "providers": [
144
+ { "name": "skill", "type": "skill", "resource": "capability-router", "confidence_base": 0.88 }
145
+ ],
146
+ "skills": ["capability-router"],
147
+ "workflow": null
148
+ }
149
+ ]
150
+ }
@@ -0,0 +1,3 @@
1
+ # capability-router
2
+
3
+ Routes normalized intent to capabilities/providers using `skill-routing-matrix.json`.
@@ -0,0 +1,17 @@
1
+ # context-memory-bridge
2
+
3
+ Use when the task requires prior decisions, handoff context, or session history lookup.
4
+
5
+ ## When
6
+
7
+ - memory lookup, what did we decide, geçen karar, history
8
+
9
+ ## Steps
10
+
11
+ 1. Read HANDOFF.md, AGENT.md, design.md when present
12
+ 2. Summarize relevant prior decisions
13
+ 3. Do not invent history; cite file paths
14
+
15
+ ## CapInt
16
+
17
+ Matrix capability: `memory-retrieval` · Memory: required
@@ -0,0 +1,17 @@
1
+ # localization-hub
2
+
3
+ Use for i18n, translation files, locale keys, and language hub tasks.
4
+
5
+ ## When
6
+
7
+ - User mentions i18n, localization, çeviri, lang file, translation hub
8
+
9
+ ## Steps
10
+
11
+ 1. Identify target locales and key namespaces
12
+ 2. Check existing translation patterns in the repo
13
+ 3. Apply consistent key naming; avoid hardcoded strings
14
+
15
+ ## CapInt
16
+
17
+ Matrix capability: `localization-hub`
@@ -0,0 +1,17 @@
1
+ # refactor
2
+
3
+ Use when simplifying code, reducing smell, or cleaning structure without changing behavior.
4
+
5
+ ## When
6
+
7
+ - refactor, clean up, simplify, code smell
8
+
9
+ ## Steps
10
+
11
+ 1. Ensure tests exist or add minimal coverage
12
+ 2. Make smallest structural change
13
+ 3. Re-run tests; no behavior change unless intended
14
+
15
+ ## CapInt
16
+
17
+ Matrix capability: `refactor-simplify` · Workflow: `/forge`
@@ -0,0 +1,19 @@
1
+ # systematic-debugging
2
+
3
+ Use when fixing bugs, errors, or unexpected behavior before proposing fixes.
4
+
5
+ ## When
6
+
7
+ - User reports broken behavior, test failures, or regressions
8
+ - Keywords: bug, error, fix, hata, çalışmıyor
9
+
10
+ ## Steps
11
+
12
+ 1. Reproduce the issue with minimal steps
13
+ 2. Gather evidence (logs, stack traces)
14
+ 3. Form hypothesis; test one change at a time
15
+ 4. Verify fix with targeted test
16
+
17
+ ## CapInt
18
+
19
+ Matrix capability: `systematic-debugging` · Workflow: `/forge`
@@ -0,0 +1,32 @@
1
+ const { runAudit } = require("../lib/audit");
2
+
3
+ module.exports = async function audit(_args, flags) {
4
+ const rootDir = process.cwd();
5
+ const report = runAudit(rootDir);
6
+
7
+ if (flags.json) {
8
+ console.log(JSON.stringify(report, null, 2));
9
+ if (!report.pass) process.exit(report.exit_code);
10
+ return;
11
+ }
12
+
13
+ console.log("\n## CapInt Audit (read-only)\n");
14
+ console.log(`Result: ${report.pass ? "PASS" : "FAIL"}`);
15
+ console.log(`Doctor: ${report.doctor_pass ? "pass" : "fail"}`);
16
+ console.log(`Findings: ${report.summary.issues} issues, ${report.summary.warnings} warnings, ${report.summary.info} info\n`);
17
+
18
+ if (report.findings.length) {
19
+ for (const f of report.findings) {
20
+ console.log(` [${f.level}] ${f.message}`);
21
+ }
22
+ console.log("");
23
+ }
24
+
25
+ if (report.recommendations.length) {
26
+ console.log("Recommendations:");
27
+ for (const r of report.recommendations) console.log(` - ${r}`);
28
+ console.log("");
29
+ }
30
+
31
+ if (!report.pass) process.exit(report.exit_code);
32
+ };
@@ -0,0 +1,64 @@
1
+ const { routeTask } = require("../lib/route-engine");
2
+ const { validateExecutionIntent } = require("../lib/contract");
3
+
4
+ module.exports = async function consult(args, flags) {
5
+ const rootDir = process.cwd();
6
+ const text = args.filter((a) => !a.startsWith("--")).join(" ").trim();
7
+ if (!text) {
8
+ console.error('Provide task text: capint consult "fix i18n bug"');
9
+ process.exit(1);
10
+ }
11
+
12
+ const result = routeTask(text, rootDir);
13
+ if (result.error) {
14
+ console.error(result.error);
15
+ process.exit(1);
16
+ }
17
+
18
+ const contract = validateExecutionIntent(result.execution_intent);
19
+ const payload = {
20
+ mode: "dry_run",
21
+ side_effects: false,
22
+ request: text,
23
+ recommendation: {
24
+ capability: result.execution_intent.capability,
25
+ resolution: result.execution_intent.resolution,
26
+ memory: result.execution_intent.memory,
27
+ plan: result.execution_intent.plan,
28
+ confirm_default: result.execution_intent.confirm_default_option,
29
+ verification_required: result.execution_intent.verification_required,
30
+ provider_activation: result.execution_intent.provider_activation
31
+ },
32
+ weight: result.overall_weight,
33
+ contract_valid: contract.valid,
34
+ contract_errors: contract.errors,
35
+ next_commands: [
36
+ `capint route --json "${text.replace(/"/g, '\\"')}"`,
37
+ "capint doctor",
38
+ "capint status --json"
39
+ ]
40
+ };
41
+
42
+ if (flags.json) {
43
+ console.log(JSON.stringify(payload, null, 2));
44
+ return;
45
+ }
46
+
47
+ console.log("\n## CapInt Consult (dry-run, no side effects)\n");
48
+ console.log(`Task: ${text}`);
49
+ console.log(`Capability: ${payload.recommendation.capability}`);
50
+ console.log(`Resolution: ${payload.recommendation.resolution}`);
51
+ console.log(`Memory: ${payload.recommendation.memory}`);
52
+ console.log(`Plan: ${payload.recommendation.plan}`);
53
+ console.log(`Weight: ${payload.weight}`);
54
+ console.log(`Verification: ${payload.recommendation.verification_required ? "required" : "optional"}`);
55
+ if (payload.recommendation.provider_activation) {
56
+ const pa = payload.recommendation.provider_activation;
57
+ console.log(
58
+ `Providers: memory=${pa.memory?.activated ? "on" : "off"}, graph=${pa.graph?.activated ? "on" : "off"}`
59
+ );
60
+ }
61
+ console.log("\nSuggested next:");
62
+ for (const c of payload.next_commands) console.log(` ${c}`);
63
+ console.log("");
64
+ };
@@ -0,0 +1,36 @@
1
+ const { runDoctor } = require("../lib/doctor");
2
+
3
+ module.exports = async function doctor(_args, flags) {
4
+ const rootDir = process.cwd();
5
+ const report = runDoctor(rootDir);
6
+
7
+ if (flags.json) {
8
+ console.log(JSON.stringify(report, null, 2));
9
+ if (!report.pass) process.exit(report.exit_code);
10
+ return;
11
+ }
12
+
13
+ console.log("\n## CapInt Doctor\n");
14
+ console.log(`Result: ${report.pass ? "PASS" : "FAIL"}`);
15
+ console.log(`Auto-fix: ${report.auto_fix ? "yes" : "no"}\n`);
16
+
17
+ if (report.ok.length) {
18
+ console.log("OK:");
19
+ for (const o of report.ok) console.log(` + ${o}`);
20
+ console.log("");
21
+ }
22
+ if (report.warnings.length) {
23
+ console.log("Warnings:");
24
+ for (const w of report.warnings) console.log(` ! ${w}`);
25
+ console.log("");
26
+ }
27
+ if (report.issues.length) {
28
+ console.log("Issues:");
29
+ for (const i of report.issues) console.log(` x ${i}`);
30
+ console.log("");
31
+ }
32
+ console.log(report.hint);
33
+ console.log("");
34
+
35
+ if (!report.pass) process.exit(report.exit_code);
36
+ };
@@ -0,0 +1,62 @@
1
+ const path = require("path");
2
+ const {
3
+ syncIdeProjections,
4
+ checkIdeProjection,
5
+ appendIdeManifestEntries,
6
+ DEFAULT_TARGETS,
7
+ CAPINT_SYNC_MARKER
8
+ } = require("../lib/ide-sync");
9
+
10
+ module.exports = async function ide(args, flags) {
11
+ const sub = args[0];
12
+ const rootDir = process.cwd();
13
+ const dryRun = Boolean(flags["dry-run"]);
14
+
15
+ if (sub === "check") {
16
+ const checks = checkIdeProjection(rootDir);
17
+ if (flags.json) {
18
+ console.log(JSON.stringify({ marker: CAPINT_SYNC_MARKER, checks }, null, 2));
19
+ return;
20
+ }
21
+ console.log("\n## CapInt IDE check\n");
22
+ for (const c of checks) {
23
+ console.log(` ${c.ok ? "✓" : "✗"} ${c.name} (${c.path})`);
24
+ }
25
+ console.log("");
26
+ return;
27
+ }
28
+
29
+ if (sub !== "sync") {
30
+ console.error("Usage: capint ide sync|check [--dry-run] [--json] [--targets cursor,claude,...]");
31
+ process.exit(1);
32
+ }
33
+
34
+ const targets = flags.targets
35
+ ? flags.targets.split(",").map((t) => t.trim())
36
+ : DEFAULT_TARGETS;
37
+
38
+ const result = syncIdeProjections(rootDir, { targets, dryRun });
39
+ if (result.errors.length) {
40
+ console.error(result.errors.join("; "));
41
+ process.exit(1);
42
+ }
43
+
44
+ if (!dryRun) {
45
+ appendIdeManifestEntries(rootDir, result, dryRun);
46
+ }
47
+
48
+ if (flags.json) {
49
+ console.log(JSON.stringify(result, null, 2));
50
+ return;
51
+ }
52
+
53
+ console.log("\n## CapInt IDE sync\n");
54
+ if (dryRun) console.log("(dry-run — no files written)\n");
55
+ for (const w of result.written) {
56
+ console.log(` wrote ${path.relative(rootDir, w) || w}`);
57
+ }
58
+ for (const s of result.skipped) {
59
+ console.log(` skipped: ${s}`);
60
+ }
61
+ console.log("");
62
+ };
@@ -0,0 +1,50 @@
1
+ const path = require("path");
2
+ const { runScaffold, PRESET_MANIFEST } = require("../lib/scaffold");
3
+ const { syncIdeProjections, appendIdeManifestEntries } = require("../lib/ide-sync");
4
+
5
+ module.exports = async function init(args, flags) {
6
+ const rootDir = process.cwd();
7
+ const preset = flags.preset || "minimal";
8
+ const projectName = flags.name || path.basename(rootDir);
9
+ const force = Boolean(flags.force);
10
+ const ideSync = !flags["no-ide-sync"];
11
+
12
+ const report = runScaffold({ rootDir, preset, projectName, force });
13
+ if (report.error) {
14
+ console.error(report.error);
15
+ process.exit(1);
16
+ }
17
+
18
+ let ideResult = null;
19
+ if (ideSync) {
20
+ ideResult = syncIdeProjections(rootDir, { dryRun: false });
21
+ if (ideResult.errors.length === 0) {
22
+ appendIdeManifestEntries(rootDir, ideResult, false);
23
+ }
24
+ }
25
+
26
+ if (flags.json) {
27
+ console.log(JSON.stringify({ ...report, ide_sync: ideResult }, null, 2));
28
+ return;
29
+ }
30
+
31
+ console.log("\n## CapInt Init\n");
32
+ console.log(`Preset: ${preset}`);
33
+ console.log(`Project: ${projectName}`);
34
+ console.log(`Created: ${report.summary.created}, Updated: ${report.summary.updated}, Skipped: ${report.summary.skipped}, Conflicts: ${report.summary.conflict}\n`);
35
+ for (const r of report.results) {
36
+ const extra = r.sidecar ? ` -> see ${r.sidecar}` : r.reason ? ` (${r.reason})` : "";
37
+ console.log(` [${r.action}] ${r.path}${extra}`);
38
+ }
39
+ if (ideSync && ideResult) {
40
+ if (ideResult.errors.length) {
41
+ console.log(`\nIDE sync skipped: ${ideResult.errors.join("; ")}`);
42
+ } else {
43
+ console.log(`\nIDE sync: ${ideResult.written.length} projection(s) written`);
44
+ }
45
+ } else if (!ideSync) {
46
+ console.log("\nIDE sync skipped (--no-ide-sync). Run: capint ide sync");
47
+ }
48
+ console.log("\nNext: capint route \"i18n\"");
49
+ console.log("Conflict policy: existing files without capint managed blocks are never overwritten.\n");
50
+ };
@@ -0,0 +1,60 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const { loadProvidersConfig, DEFAULT_PATHS, search } = require("../lib/providers/local-memory-adapter");
4
+ const { loadProvidersConfig: loadGraphCfg, DEFAULT_PATHS: GRAPH_PATHS, query } = require("../lib/providers/local-graph-adapter");
5
+ const { localContextEnabled } = require("../lib/context-memory-bridge");
6
+
7
+ function fileStatus(rootDir, rel) {
8
+ const abs = path.join(rootDir, rel);
9
+ return { path: rel, exists: fs.existsSync(abs) };
10
+ }
11
+
12
+ module.exports = async function memory(args, flags) {
13
+ const sub = args[0];
14
+ const rootDir = process.cwd();
15
+
16
+ if (sub !== "status") {
17
+ console.error("Usage: capint memory status [--json]");
18
+ process.exit(1);
19
+ }
20
+
21
+ const memCfg = loadProvidersConfig(rootDir);
22
+ const graphCfg = loadGraphCfg(rootDir);
23
+ const memPaths = memCfg?.memory?.paths || DEFAULT_PATHS;
24
+ const graphPaths = graphCfg?.graph?.paths || GRAPH_PATHS;
25
+
26
+ const report = {
27
+ mode: "read_only",
28
+ local_context_flag: localContextEnabled({}),
29
+ env_CAPINT_LOCAL_CONTEXT: process.env.CAPINT_LOCAL_CONTEXT || null,
30
+ providers_config: fs.existsSync(path.join(rootDir, ".capint", "providers.json")),
31
+ memory: {
32
+ driver: memCfg?.memory?.driver || "local (default)",
33
+ paths: memPaths.map((p) => fileStatus(rootDir, p))
34
+ },
35
+ graph: {
36
+ driver: graphCfg?.graph?.driver || "local (default)",
37
+ paths: graphPaths.map((p) => fileStatus(rootDir, p))
38
+ },
39
+ sample_memory_search: search(rootDir, "", { config: memCfg }).hits.length,
40
+ sample_graph_query: query(rootDir, null, { config: graphCfg }).excerpts.length
41
+ };
42
+
43
+ if (flags.json) {
44
+ console.log(JSON.stringify(report, null, 2));
45
+ return;
46
+ }
47
+
48
+ console.log("\n## CapInt memory status\n");
49
+ console.log(`Local context hot-path: ${report.local_context_flag ? "enabled" : "off (set CAPINT_LOCAL_CONTEXT=1)"}`);
50
+ console.log(`providers.json: ${report.providers_config ? "yes" : "no (optional)"}\n`);
51
+ console.log("Memory paths:");
52
+ for (const p of report.memory.paths) {
53
+ console.log(` ${p.exists ? "✓" : "✗"} ${p.path}`);
54
+ }
55
+ console.log("\nGraph paths:");
56
+ for (const p of report.graph.paths) {
57
+ console.log(` ${p.exists ? "✓" : "✗"} ${p.path}`);
58
+ }
59
+ console.log("");
60
+ };
@@ -0,0 +1,30 @@
1
+ const path = require("path");
2
+ const { routeTask, formatTextReport, listCheatsheet, loadMatrix } = require("../lib/route-engine");
3
+
4
+ module.exports = async function route(args, flags) {
5
+ const rootDir = process.cwd();
6
+
7
+ if (flags.list) {
8
+ const matrix = loadMatrix(rootDir);
9
+ if (!matrix) {
10
+ console.error("No skill-routing-matrix.json found");
11
+ process.exit(1);
12
+ }
13
+ console.log("\n" + listCheatsheet(matrix));
14
+ return;
15
+ }
16
+
17
+ const text = args.filter((a) => !a.startsWith("--")).join(" ").trim();
18
+ if (!text) {
19
+ console.error('Provide task text: capint route "fix i18n bug"');
20
+ process.exit(1);
21
+ }
22
+
23
+ const result = routeTask(text, rootDir);
24
+ if (flags.json) {
25
+ console.log(JSON.stringify(result, null, 2));
26
+ return;
27
+ }
28
+
29
+ console.log(formatTextReport(result, { verbose: Boolean(flags.verbose || flags.v) }));
30
+ };