@rely-ai/caliber 1.25.0 → 1.25.1-dev.1773933794
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/dist/bin.js +130 -38
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -27,6 +27,8 @@ __export(constants_exports, {
|
|
|
27
27
|
BACKUPS_DIR: () => BACKUPS_DIR,
|
|
28
28
|
CALIBER_DIR: () => CALIBER_DIR,
|
|
29
29
|
LEARNING_DIR: () => LEARNING_DIR,
|
|
30
|
+
LEARNING_FINALIZE_LOG: () => LEARNING_FINALIZE_LOG,
|
|
31
|
+
LEARNING_LAST_ERROR_FILE: () => LEARNING_LAST_ERROR_FILE,
|
|
30
32
|
LEARNING_MAX_EVENTS: () => LEARNING_MAX_EVENTS,
|
|
31
33
|
LEARNING_ROI_FILE: () => LEARNING_ROI_FILE,
|
|
32
34
|
LEARNING_SESSION_FILE: () => LEARNING_SESSION_FILE,
|
|
@@ -37,7 +39,7 @@ __export(constants_exports, {
|
|
|
37
39
|
});
|
|
38
40
|
import path2 from "path";
|
|
39
41
|
import os from "os";
|
|
40
|
-
var AUTH_DIR, CALIBER_DIR, MANIFEST_FILE, BACKUPS_DIR, LEARNING_DIR, LEARNING_SESSION_FILE, LEARNING_STATE_FILE, LEARNING_MAX_EVENTS, LEARNING_ROI_FILE, PERSONAL_LEARNINGS_FILE, MIN_SESSIONS_FOR_COMPARISON;
|
|
42
|
+
var AUTH_DIR, CALIBER_DIR, MANIFEST_FILE, BACKUPS_DIR, LEARNING_DIR, LEARNING_SESSION_FILE, LEARNING_STATE_FILE, LEARNING_MAX_EVENTS, LEARNING_ROI_FILE, PERSONAL_LEARNINGS_FILE, LEARNING_FINALIZE_LOG, LEARNING_LAST_ERROR_FILE, MIN_SESSIONS_FOR_COMPARISON;
|
|
41
43
|
var init_constants = __esm({
|
|
42
44
|
"src/constants.ts"() {
|
|
43
45
|
"use strict";
|
|
@@ -51,6 +53,8 @@ var init_constants = __esm({
|
|
|
51
53
|
LEARNING_MAX_EVENTS = 500;
|
|
52
54
|
LEARNING_ROI_FILE = "roi-stats.json";
|
|
53
55
|
PERSONAL_LEARNINGS_FILE = path2.join(AUTH_DIR, "personal-learnings.md");
|
|
56
|
+
LEARNING_FINALIZE_LOG = "finalize.log";
|
|
57
|
+
LEARNING_LAST_ERROR_FILE = "last-error.json";
|
|
54
58
|
MIN_SESSIONS_FOR_COMPARISON = 3;
|
|
55
59
|
}
|
|
56
60
|
});
|
|
@@ -586,7 +590,7 @@ var init_lock = __esm({
|
|
|
586
590
|
// src/cli.ts
|
|
587
591
|
import { Command } from "commander";
|
|
588
592
|
import fs45 from "fs";
|
|
589
|
-
import
|
|
593
|
+
import path36 from "path";
|
|
590
594
|
import { fileURLToPath } from "url";
|
|
591
595
|
|
|
592
596
|
// src/commands/init.ts
|
|
@@ -2648,6 +2652,11 @@ DO NOT extract:
|
|
|
2648
2652
|
- General programming best practices everyone already knows
|
|
2649
2653
|
- Summaries of successful routine operations that need no special handling
|
|
2650
2654
|
- Anything already covered in the existing CLAUDE.md
|
|
2655
|
+
- **One-time debugging artifacts** \u2014 fixes for a specific bug that was resolved in this session and won't recur (e.g. "fixed the stream parser by adding a null check at line 42"). Only extract if the pattern will help future sessions avoid the same trap.
|
|
2656
|
+
- **Session-specific file paths, worktree locations, or branch names** \u2014 these are ephemeral and won't apply to future sessions
|
|
2657
|
+
- **Implementation details of a feature being built** \u2014 the learning should be about HOW to work in this project, not WHAT was built
|
|
2658
|
+
|
|
2659
|
+
The litmus test for every learning: "Would a different developer, working on a DIFFERENT task in this same repo next week, benefit from knowing this?" If the answer is no \u2014 if it only matters for the exact problem being debugged today \u2014 do NOT include it.
|
|
2651
2660
|
|
|
2652
2661
|
From these observations, produce:
|
|
2653
2662
|
|
|
@@ -2681,6 +2690,9 @@ Bad examples (do NOT produce these):
|
|
|
2681
2690
|
- "The codebase uses TypeScript with strict mode" (describes code, not actionable)
|
|
2682
2691
|
- "Components follow a pattern of X" (describes architecture, not operational)
|
|
2683
2692
|
- "The project has a scoring module" (summarizes code structure)
|
|
2693
|
+
- "Cursor provider with \`--print --output-format stream-json\` outputs multiple events" (implementation detail of a specific feature, not a reusable pattern)
|
|
2694
|
+
- "When merging to \`next\`, use the worktree at \`/path/to/worktree\`" (session-specific path, won't apply next week)
|
|
2695
|
+
- "Fixed the lock bug by adding \`process.kill(pid, 0)\`" (one-time bug fix, not a reusable lesson)
|
|
2684
2696
|
- Any bullet without a **[type]** prefix
|
|
2685
2697
|
|
|
2686
2698
|
Rules for the learned section:
|
|
@@ -3412,15 +3424,15 @@ init_config();
|
|
|
3412
3424
|
// src/utils/dependencies.ts
|
|
3413
3425
|
import { readFileSync as readFileSync2 } from "fs";
|
|
3414
3426
|
import { join as join2 } from "path";
|
|
3415
|
-
function readFileOrNull2(
|
|
3427
|
+
function readFileOrNull2(path38) {
|
|
3416
3428
|
try {
|
|
3417
|
-
return readFileSync2(
|
|
3429
|
+
return readFileSync2(path38, "utf-8");
|
|
3418
3430
|
} catch {
|
|
3419
3431
|
return null;
|
|
3420
3432
|
}
|
|
3421
3433
|
}
|
|
3422
|
-
function readJsonOrNull(
|
|
3423
|
-
const content = readFileOrNull2(
|
|
3434
|
+
function readJsonOrNull(path38) {
|
|
3435
|
+
const content = readFileOrNull2(path38);
|
|
3424
3436
|
if (!content) return null;
|
|
3425
3437
|
try {
|
|
3426
3438
|
return JSON.parse(content);
|
|
@@ -4046,11 +4058,38 @@ function appendPreCommitBlock(content) {
|
|
|
4046
4058
|
function getCursorPreCommitRule() {
|
|
4047
4059
|
return { filename: CURSOR_RULE_FILENAME, content: CURSOR_RULE_CONTENT };
|
|
4048
4060
|
}
|
|
4061
|
+
var LEARNINGS_BLOCK_START = "<!-- caliber:managed:learnings -->";
|
|
4062
|
+
var LEARNINGS_BLOCK_END = "<!-- /caliber:managed:learnings -->";
|
|
4063
|
+
var LEARNINGS_BLOCK = `${LEARNINGS_BLOCK_START}
|
|
4064
|
+
## Session Learnings
|
|
4065
|
+
|
|
4066
|
+
Read \`CALIBER_LEARNINGS.md\` for patterns and anti-patterns learned from previous sessions.
|
|
4067
|
+
These are auto-extracted from real tool usage \u2014 treat them as project-specific rules.
|
|
4068
|
+
${LEARNINGS_BLOCK_END}`;
|
|
4069
|
+
var CURSOR_LEARNINGS_FILENAME = "caliber-learnings.mdc";
|
|
4070
|
+
var CURSOR_LEARNINGS_CONTENT = `---
|
|
4071
|
+
description: Reference session-learned patterns from CALIBER_LEARNINGS.md
|
|
4072
|
+
alwaysApply: true
|
|
4073
|
+
---
|
|
4074
|
+
Read \`CALIBER_LEARNINGS.md\` for patterns and anti-patterns learned from previous sessions.
|
|
4075
|
+
These are auto-extracted from real tool usage \u2014 treat them as project-specific rules.
|
|
4076
|
+
`;
|
|
4077
|
+
function hasLearningsBlock(content) {
|
|
4078
|
+
return content.includes(LEARNINGS_BLOCK_START);
|
|
4079
|
+
}
|
|
4080
|
+
function appendLearningsBlock(content) {
|
|
4081
|
+
if (hasLearningsBlock(content)) return content;
|
|
4082
|
+
const trimmed = content.trimEnd();
|
|
4083
|
+
return trimmed + "\n\n" + LEARNINGS_BLOCK + "\n";
|
|
4084
|
+
}
|
|
4085
|
+
function getCursorLearningsRule() {
|
|
4086
|
+
return { filename: CURSOR_LEARNINGS_FILENAME, content: CURSOR_LEARNINGS_CONTENT };
|
|
4087
|
+
}
|
|
4049
4088
|
|
|
4050
4089
|
// src/writers/claude/index.ts
|
|
4051
4090
|
function writeClaudeConfig(config) {
|
|
4052
4091
|
const written = [];
|
|
4053
|
-
fs9.writeFileSync("CLAUDE.md", appendPreCommitBlock(config.claudeMd));
|
|
4092
|
+
fs9.writeFileSync("CLAUDE.md", appendLearningsBlock(appendPreCommitBlock(config.claudeMd)));
|
|
4054
4093
|
written.push("CLAUDE.md");
|
|
4055
4094
|
if (config.skills?.length) {
|
|
4056
4095
|
for (const skill of config.skills) {
|
|
@@ -4094,7 +4133,8 @@ function writeCursorConfig(config) {
|
|
|
4094
4133
|
written.push(".cursorrules");
|
|
4095
4134
|
}
|
|
4096
4135
|
const preCommitRule = getCursorPreCommitRule();
|
|
4097
|
-
const
|
|
4136
|
+
const learningsRule = getCursorLearningsRule();
|
|
4137
|
+
const allRules = [...config.rules || [], preCommitRule, learningsRule];
|
|
4098
4138
|
const rulesDir = path10.join(".cursor", "rules");
|
|
4099
4139
|
if (!fs10.existsSync(rulesDir)) fs10.mkdirSync(rulesDir, { recursive: true });
|
|
4100
4140
|
for (const rule of allRules) {
|
|
@@ -4142,7 +4182,7 @@ import fs11 from "fs";
|
|
|
4142
4182
|
import path11 from "path";
|
|
4143
4183
|
function writeCodexConfig(config) {
|
|
4144
4184
|
const written = [];
|
|
4145
|
-
fs11.writeFileSync("AGENTS.md", appendPreCommitBlock(config.agentsMd));
|
|
4185
|
+
fs11.writeFileSync("AGENTS.md", appendLearningsBlock(appendPreCommitBlock(config.agentsMd)));
|
|
4146
4186
|
written.push("AGENTS.md");
|
|
4147
4187
|
if (config.skills?.length) {
|
|
4148
4188
|
for (const skill of config.skills) {
|
|
@@ -4170,7 +4210,7 @@ function writeGithubCopilotConfig(config) {
|
|
|
4170
4210
|
const written = [];
|
|
4171
4211
|
if (config.instructions) {
|
|
4172
4212
|
fs12.mkdirSync(".github", { recursive: true });
|
|
4173
|
-
fs12.writeFileSync(path12.join(".github", "copilot-instructions.md"), appendPreCommitBlock(config.instructions));
|
|
4213
|
+
fs12.writeFileSync(path12.join(".github", "copilot-instructions.md"), appendLearningsBlock(appendPreCommitBlock(config.instructions)));
|
|
4174
4214
|
written.push(".github/copilot-instructions.md");
|
|
4175
4215
|
}
|
|
4176
4216
|
if (config.instructionFiles?.length) {
|
|
@@ -7105,11 +7145,11 @@ function countIssuePoints(issues) {
|
|
|
7105
7145
|
}
|
|
7106
7146
|
async function scoreAndRefine(setup, dir, sessionHistory, callbacks) {
|
|
7107
7147
|
const existsCache = /* @__PURE__ */ new Map();
|
|
7108
|
-
const cachedExists = (
|
|
7109
|
-
const cached = existsCache.get(
|
|
7148
|
+
const cachedExists = (path38) => {
|
|
7149
|
+
const cached = existsCache.get(path38);
|
|
7110
7150
|
if (cached !== void 0) return cached;
|
|
7111
|
-
const result = existsSync9(
|
|
7112
|
-
existsCache.set(
|
|
7151
|
+
const result = existsSync9(path38);
|
|
7152
|
+
existsCache.set(path38, result);
|
|
7113
7153
|
return result;
|
|
7114
7154
|
};
|
|
7115
7155
|
const projectStructure = collectProjectStructure(dir);
|
|
@@ -9222,7 +9262,7 @@ import path25 from "path";
|
|
|
9222
9262
|
function writeRefreshDocs(docs) {
|
|
9223
9263
|
const written = [];
|
|
9224
9264
|
if (docs.claudeMd) {
|
|
9225
|
-
fs33.writeFileSync("CLAUDE.md", appendPreCommitBlock(docs.claudeMd));
|
|
9265
|
+
fs33.writeFileSync("CLAUDE.md", appendLearningsBlock(appendPreCommitBlock(docs.claudeMd)));
|
|
9226
9266
|
written.push("CLAUDE.md");
|
|
9227
9267
|
}
|
|
9228
9268
|
if (docs.readmeMd) {
|
|
@@ -9251,7 +9291,7 @@ function writeRefreshDocs(docs) {
|
|
|
9251
9291
|
}
|
|
9252
9292
|
if (docs.copilotInstructions) {
|
|
9253
9293
|
fs33.mkdirSync(".github", { recursive: true });
|
|
9254
|
-
fs33.writeFileSync(path25.join(".github", "copilot-instructions.md"), appendPreCommitBlock(docs.copilotInstructions));
|
|
9294
|
+
fs33.writeFileSync(path25.join(".github", "copilot-instructions.md"), appendLearningsBlock(appendPreCommitBlock(docs.copilotInstructions)));
|
|
9255
9295
|
written.push(".github/copilot-instructions.md");
|
|
9256
9296
|
}
|
|
9257
9297
|
if (docs.copilotInstructionFiles) {
|
|
@@ -10020,6 +10060,7 @@ async function configCommand() {
|
|
|
10020
10060
|
|
|
10021
10061
|
// src/commands/learn.ts
|
|
10022
10062
|
import fs42 from "fs";
|
|
10063
|
+
import path33 from "path";
|
|
10023
10064
|
import chalk23 from "chalk";
|
|
10024
10065
|
|
|
10025
10066
|
// src/learner/stdin.ts
|
|
@@ -10150,10 +10191,17 @@ function acquireFinalizeLock() {
|
|
|
10150
10191
|
try {
|
|
10151
10192
|
const stat = fs39.statSync(lockPath);
|
|
10152
10193
|
if (Date.now() - stat.mtimeMs < LOCK_STALE_MS) {
|
|
10153
|
-
|
|
10194
|
+
const pid = parseInt(fs39.readFileSync(lockPath, "utf-8").trim(), 10);
|
|
10195
|
+
if (!isNaN(pid) && isProcessAlive(pid)) {
|
|
10196
|
+
return false;
|
|
10197
|
+
}
|
|
10154
10198
|
}
|
|
10155
10199
|
} catch {
|
|
10156
10200
|
}
|
|
10201
|
+
try {
|
|
10202
|
+
fs39.unlinkSync(lockPath);
|
|
10203
|
+
} catch {
|
|
10204
|
+
}
|
|
10157
10205
|
}
|
|
10158
10206
|
try {
|
|
10159
10207
|
fs39.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
|
|
@@ -10162,6 +10210,14 @@ function acquireFinalizeLock() {
|
|
|
10162
10210
|
return false;
|
|
10163
10211
|
}
|
|
10164
10212
|
}
|
|
10213
|
+
function isProcessAlive(pid) {
|
|
10214
|
+
try {
|
|
10215
|
+
process.kill(pid, 0);
|
|
10216
|
+
return true;
|
|
10217
|
+
} catch {
|
|
10218
|
+
return false;
|
|
10219
|
+
}
|
|
10220
|
+
}
|
|
10165
10221
|
function releaseFinalizeLock() {
|
|
10166
10222
|
const lockPath = lockFilePath();
|
|
10167
10223
|
try {
|
|
@@ -10621,6 +10677,27 @@ var MIN_EVENTS_FOR_ANALYSIS = 25;
|
|
|
10621
10677
|
var MIN_EVENTS_AUTO = 10;
|
|
10622
10678
|
var AUTO_SETTLE_MS = 200;
|
|
10623
10679
|
var INCREMENTAL_INTERVAL = 50;
|
|
10680
|
+
function writeFinalizeError(message) {
|
|
10681
|
+
try {
|
|
10682
|
+
const errorPath = path33.join(LEARNING_DIR, LEARNING_LAST_ERROR_FILE);
|
|
10683
|
+
if (!fs42.existsSync(LEARNING_DIR)) fs42.mkdirSync(LEARNING_DIR, { recursive: true });
|
|
10684
|
+
fs42.writeFileSync(errorPath, JSON.stringify({
|
|
10685
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10686
|
+
error: message,
|
|
10687
|
+
pid: process.pid
|
|
10688
|
+
}, null, 2));
|
|
10689
|
+
} catch {
|
|
10690
|
+
}
|
|
10691
|
+
}
|
|
10692
|
+
function readFinalizeError() {
|
|
10693
|
+
try {
|
|
10694
|
+
const errorPath = path33.join(LEARNING_DIR, LEARNING_LAST_ERROR_FILE);
|
|
10695
|
+
if (!fs42.existsSync(errorPath)) return null;
|
|
10696
|
+
return JSON.parse(fs42.readFileSync(errorPath, "utf-8"));
|
|
10697
|
+
} catch {
|
|
10698
|
+
return null;
|
|
10699
|
+
}
|
|
10700
|
+
}
|
|
10624
10701
|
async function learnObserveCommand(options) {
|
|
10625
10702
|
try {
|
|
10626
10703
|
const raw = await readStdin();
|
|
@@ -10663,10 +10740,14 @@ async function learnObserveCommand(options) {
|
|
|
10663
10740
|
const { resolveCaliber: resolveCaliber2 } = await Promise.resolve().then(() => (init_resolve_caliber(), resolve_caliber_exports));
|
|
10664
10741
|
const bin = resolveCaliber2();
|
|
10665
10742
|
const { spawn: spawn4 } = await import("child_process");
|
|
10743
|
+
const logPath = path33.join(LEARNING_DIR, LEARNING_FINALIZE_LOG);
|
|
10744
|
+
if (!fs42.existsSync(LEARNING_DIR)) fs42.mkdirSync(LEARNING_DIR, { recursive: true });
|
|
10745
|
+
const logFd = fs42.openSync(logPath, "a");
|
|
10666
10746
|
spawn4(bin, ["learn", "finalize", "--auto", "--incremental"], {
|
|
10667
10747
|
detached: true,
|
|
10668
|
-
stdio: "ignore"
|
|
10748
|
+
stdio: ["ignore", logFd, logFd]
|
|
10669
10749
|
}).unref();
|
|
10750
|
+
fs42.closeSync(logFd);
|
|
10670
10751
|
} catch {
|
|
10671
10752
|
}
|
|
10672
10753
|
}
|
|
@@ -10851,9 +10932,11 @@ async function learnFinalizeCommand(options) {
|
|
|
10851
10932
|
console.log(chalk23.dim(`caliber: ${totalLearnings} learnings active \u2014 est. ~${t.estimatedSavingsTokens.toLocaleString()} tokens saved across ${t.totalSessionsWithLearnings} sessions`));
|
|
10852
10933
|
}
|
|
10853
10934
|
} catch (err) {
|
|
10935
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
10854
10936
|
if (options?.force && !isAuto) {
|
|
10855
|
-
console.error(chalk23.red("caliber: finalize failed \u2014"),
|
|
10937
|
+
console.error(chalk23.red("caliber: finalize failed \u2014"), errorMsg);
|
|
10856
10938
|
}
|
|
10939
|
+
writeFinalizeError(errorMsg);
|
|
10857
10940
|
} finally {
|
|
10858
10941
|
if (analyzed) {
|
|
10859
10942
|
if (isIncremental) {
|
|
@@ -10943,6 +11026,15 @@ async function learnStatusCommand() {
|
|
|
10943
11026
|
} else {
|
|
10944
11027
|
console.log(`Last analysis: ${chalk23.dim("none")}`);
|
|
10945
11028
|
}
|
|
11029
|
+
const lastError = readFinalizeError();
|
|
11030
|
+
if (lastError) {
|
|
11031
|
+
console.log(`Last error: ${chalk23.red(lastError.error)}`);
|
|
11032
|
+
console.log(chalk23.dim(` at ${lastError.timestamp}`));
|
|
11033
|
+
const logPath = path33.join(LEARNING_DIR, LEARNING_FINALIZE_LOG);
|
|
11034
|
+
if (fs42.existsSync(logPath)) {
|
|
11035
|
+
console.log(chalk23.dim(` Full log: ${logPath}`));
|
|
11036
|
+
}
|
|
11037
|
+
}
|
|
10946
11038
|
const learnedSection = readLearnedSection();
|
|
10947
11039
|
if (learnedSection) {
|
|
10948
11040
|
const lineCount = learnedSection.split("\n").filter(Boolean).length;
|
|
@@ -11194,7 +11286,7 @@ async function insightsCommand(options) {
|
|
|
11194
11286
|
|
|
11195
11287
|
// src/commands/sources.ts
|
|
11196
11288
|
import fs43 from "fs";
|
|
11197
|
-
import
|
|
11289
|
+
import path34 from "path";
|
|
11198
11290
|
import chalk25 from "chalk";
|
|
11199
11291
|
async function sourcesListCommand() {
|
|
11200
11292
|
const dir = process.cwd();
|
|
@@ -11210,9 +11302,9 @@ async function sourcesListCommand() {
|
|
|
11210
11302
|
if (configSources.length > 0) {
|
|
11211
11303
|
for (const source of configSources) {
|
|
11212
11304
|
const sourcePath = source.path || source.url || "";
|
|
11213
|
-
const exists = source.path ? fs43.existsSync(
|
|
11305
|
+
const exists = source.path ? fs43.existsSync(path34.resolve(dir, source.path)) : false;
|
|
11214
11306
|
const status = exists ? chalk25.green("reachable") : chalk25.red("not found");
|
|
11215
|
-
const hasSummary = source.path && fs43.existsSync(
|
|
11307
|
+
const hasSummary = source.path && fs43.existsSync(path34.join(path34.resolve(dir, source.path), ".caliber", "summary.json"));
|
|
11216
11308
|
console.log(` ${chalk25.bold(source.role || source.type)} ${chalk25.dim(sourcePath)}`);
|
|
11217
11309
|
console.log(` Type: ${source.type} Status: ${status}${hasSummary ? " " + chalk25.cyan("has summary.json") : ""}`);
|
|
11218
11310
|
if (source.description) console.log(` ${chalk25.dim(source.description)}`);
|
|
@@ -11222,7 +11314,7 @@ async function sourcesListCommand() {
|
|
|
11222
11314
|
if (workspaces.length > 0) {
|
|
11223
11315
|
console.log(chalk25.dim(" Auto-detected workspaces:"));
|
|
11224
11316
|
for (const ws of workspaces) {
|
|
11225
|
-
const exists = fs43.existsSync(
|
|
11317
|
+
const exists = fs43.existsSync(path34.resolve(dir, ws));
|
|
11226
11318
|
console.log(` ${exists ? chalk25.green("\u25CF") : chalk25.red("\u25CF")} ${ws}`);
|
|
11227
11319
|
}
|
|
11228
11320
|
console.log("");
|
|
@@ -11230,7 +11322,7 @@ async function sourcesListCommand() {
|
|
|
11230
11322
|
}
|
|
11231
11323
|
async function sourcesAddCommand(sourcePath) {
|
|
11232
11324
|
const dir = process.cwd();
|
|
11233
|
-
const absPath =
|
|
11325
|
+
const absPath = path34.resolve(dir, sourcePath);
|
|
11234
11326
|
if (!fs43.existsSync(absPath)) {
|
|
11235
11327
|
console.log(chalk25.red(`
|
|
11236
11328
|
Path not found: ${sourcePath}
|
|
@@ -11246,7 +11338,7 @@ async function sourcesAddCommand(sourcePath) {
|
|
|
11246
11338
|
}
|
|
11247
11339
|
const existing = loadSourcesConfig(dir);
|
|
11248
11340
|
const alreadyConfigured = existing.some(
|
|
11249
|
-
(s) => s.path &&
|
|
11341
|
+
(s) => s.path && path34.resolve(dir, s.path) === absPath
|
|
11250
11342
|
);
|
|
11251
11343
|
if (alreadyConfigured) {
|
|
11252
11344
|
console.log(chalk25.yellow(`
|
|
@@ -11295,7 +11387,7 @@ async function sourcesRemoveCommand(name) {
|
|
|
11295
11387
|
|
|
11296
11388
|
// src/commands/publish.ts
|
|
11297
11389
|
import fs44 from "fs";
|
|
11298
|
-
import
|
|
11390
|
+
import path35 from "path";
|
|
11299
11391
|
import chalk26 from "chalk";
|
|
11300
11392
|
import ora7 from "ora";
|
|
11301
11393
|
init_config();
|
|
@@ -11309,10 +11401,10 @@ async function publishCommand() {
|
|
|
11309
11401
|
const spinner = ora7("Generating project summary...").start();
|
|
11310
11402
|
try {
|
|
11311
11403
|
const fingerprint = await collectFingerprint(dir);
|
|
11312
|
-
const claudeMd = readFileOrNull(
|
|
11404
|
+
const claudeMd = readFileOrNull(path35.join(dir, "CLAUDE.md"));
|
|
11313
11405
|
const topLevelDirs = fingerprint.fileTree.filter((f) => f.endsWith("/") && !f.includes("/")).map((f) => f.replace(/\/$/, ""));
|
|
11314
11406
|
const summary = {
|
|
11315
|
-
name: fingerprint.packageName ||
|
|
11407
|
+
name: fingerprint.packageName || path35.basename(dir),
|
|
11316
11408
|
version: "1.0.0",
|
|
11317
11409
|
description: fingerprint.description || "",
|
|
11318
11410
|
languages: fingerprint.languages,
|
|
@@ -11324,7 +11416,7 @@ async function publishCommand() {
|
|
|
11324
11416
|
summary.conventions = claudeMd.slice(0, 2e3);
|
|
11325
11417
|
}
|
|
11326
11418
|
try {
|
|
11327
|
-
const pkgContent = readFileOrNull(
|
|
11419
|
+
const pkgContent = readFileOrNull(path35.join(dir, "package.json"));
|
|
11328
11420
|
if (pkgContent) {
|
|
11329
11421
|
const pkg3 = JSON.parse(pkgContent);
|
|
11330
11422
|
if (pkg3.scripts) {
|
|
@@ -11337,14 +11429,14 @@ async function publishCommand() {
|
|
|
11337
11429
|
}
|
|
11338
11430
|
} catch {
|
|
11339
11431
|
}
|
|
11340
|
-
const outputDir =
|
|
11432
|
+
const outputDir = path35.join(dir, ".caliber");
|
|
11341
11433
|
if (!fs44.existsSync(outputDir)) {
|
|
11342
11434
|
fs44.mkdirSync(outputDir, { recursive: true });
|
|
11343
11435
|
}
|
|
11344
|
-
const outputPath =
|
|
11436
|
+
const outputPath = path35.join(outputDir, "summary.json");
|
|
11345
11437
|
fs44.writeFileSync(outputPath, JSON.stringify(summary, null, 2) + "\n", "utf-8");
|
|
11346
11438
|
spinner.succeed("Project summary published");
|
|
11347
|
-
console.log(` ${chalk26.green("\u2713")} ${
|
|
11439
|
+
console.log(` ${chalk26.green("\u2713")} ${path35.relative(dir, outputPath)}`);
|
|
11348
11440
|
console.log(chalk26.dim("\n Other projects can now reference this repo as a source."));
|
|
11349
11441
|
console.log(chalk26.dim(" When they run `caliber init`, they'll read this summary automatically.\n"));
|
|
11350
11442
|
} catch (err) {
|
|
@@ -11356,9 +11448,9 @@ async function publishCommand() {
|
|
|
11356
11448
|
}
|
|
11357
11449
|
|
|
11358
11450
|
// src/cli.ts
|
|
11359
|
-
var __dirname =
|
|
11451
|
+
var __dirname = path36.dirname(fileURLToPath(import.meta.url));
|
|
11360
11452
|
var pkg = JSON.parse(
|
|
11361
|
-
fs45.readFileSync(
|
|
11453
|
+
fs45.readFileSync(path36.resolve(__dirname, "..", "package.json"), "utf-8")
|
|
11362
11454
|
);
|
|
11363
11455
|
var program = new Command();
|
|
11364
11456
|
var displayVersion = process.env.CALIBER_LOCAL ? `${pkg.version}-local` : pkg.version;
|
|
@@ -11445,15 +11537,15 @@ learn.command("delete <index>").description("Delete a learning by its index numb
|
|
|
11445
11537
|
|
|
11446
11538
|
// src/utils/version-check.ts
|
|
11447
11539
|
import fs46 from "fs";
|
|
11448
|
-
import
|
|
11540
|
+
import path37 from "path";
|
|
11449
11541
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
11450
11542
|
import { execSync as execSync15 } from "child_process";
|
|
11451
11543
|
import chalk27 from "chalk";
|
|
11452
11544
|
import ora8 from "ora";
|
|
11453
11545
|
import confirm2 from "@inquirer/confirm";
|
|
11454
|
-
var __dirname_vc =
|
|
11546
|
+
var __dirname_vc = path37.dirname(fileURLToPath2(import.meta.url));
|
|
11455
11547
|
var pkg2 = JSON.parse(
|
|
11456
|
-
fs46.readFileSync(
|
|
11548
|
+
fs46.readFileSync(path37.resolve(__dirname_vc, "..", "package.json"), "utf-8")
|
|
11457
11549
|
);
|
|
11458
11550
|
function getChannel(version) {
|
|
11459
11551
|
const match = version.match(/-(dev|next)\./);
|
|
@@ -11478,7 +11570,7 @@ function isNewer(registry, current) {
|
|
|
11478
11570
|
function getInstalledVersion() {
|
|
11479
11571
|
try {
|
|
11480
11572
|
const globalRoot = execSync15("npm root -g", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
11481
|
-
const pkgPath =
|
|
11573
|
+
const pkgPath = path37.join(globalRoot, "@rely-ai", "caliber", "package.json");
|
|
11482
11574
|
return JSON.parse(fs46.readFileSync(pkgPath, "utf-8")).version;
|
|
11483
11575
|
} catch {
|
|
11484
11576
|
return null;
|
package/package.json
CHANGED