@context-forge/cli 0.8.5 → 0.9.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/dist/commands/arch.d.ts +7 -0
- package/dist/commands/arch.d.ts.map +1 -0
- package/dist/commands/arch.js +169 -0
- package/dist/commands/arch.js.map +1 -0
- package/dist/commands/backup.d.ts +3 -0
- package/dist/commands/backup.d.ts.map +1 -0
- package/dist/commands/backup.js +27 -0
- package/dist/commands/backup.js.map +1 -0
- package/dist/commands/build.d.ts +24 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +146 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/check.d.ts +3 -0
- package/dist/commands/check.d.ts.map +1 -0
- package/dist/commands/check.js +250 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/commandInstaller.d.ts +28 -0
- package/dist/commands/commandInstaller.d.ts.map +1 -0
- package/dist/commands/commandInstaller.js +136 -0
- package/dist/commands/commandInstaller.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +116 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/future.d.ts +3 -0
- package/dist/commands/future.d.ts.map +1 -0
- package/dist/commands/future.js +96 -0
- package/dist/commands/future.js.map +1 -0
- package/dist/commands/guides.d.ts +9 -0
- package/dist/commands/guides.d.ts.map +1 -0
- package/dist/commands/guides.js +156 -0
- package/dist/commands/guides.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +124 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +97 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/next.d.ts +3 -0
- package/dist/commands/next.d.ts.map +1 -0
- package/dist/commands/next.js +52 -0
- package/dist/commands/next.js.map +1 -0
- package/dist/commands/plan.d.ts +7 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +102 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/project.d.ts +25 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +550 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/commands/prompt.d.ts +3 -0
- package/dist/commands/prompt.d.ts.map +1 -0
- package/dist/commands/prompt.js +112 -0
- package/dist/commands/prompt.js.map +1 -0
- package/dist/commands/setup-ide.d.ts +15 -0
- package/dist/commands/setup-ide.d.ts.map +1 -0
- package/dist/commands/setup-ide.js +250 -0
- package/dist/commands/setup-ide.js.map +1 -0
- package/dist/commands/slice.d.ts +7 -0
- package/dist/commands/slice.d.ts.map +1 -0
- package/dist/commands/slice.js +151 -0
- package/dist/commands/slice.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +210 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/task.d.ts +13 -0
- package/dist/commands/task.d.ts.map +1 -0
- package/dist/commands/task.js +207 -0
- package/dist/commands/task.js.map +1 -0
- package/dist/commands/update.d.ts +27 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +172 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/workflow.d.ts +3 -0
- package/dist/commands/workflow.d.ts.map +1 -0
- package/dist/commands/workflow.js +204 -0
- package/dist/commands/workflow.js.map +1 -0
- package/dist/commands/worktree.d.ts +3 -0
- package/dist/commands/worktree.d.ts.map +1 -0
- package/dist/commands/worktree.js +371 -0
- package/dist/commands/worktree.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +167 -0
- package/dist/index.js.map +1 -0
- package/dist/options.d.ts +16 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +29 -0
- package/dist/options.js.map +1 -0
- package/dist/output/entryStatusDisplay.d.ts +12 -0
- package/dist/output/entryStatusDisplay.d.ts.map +1 -0
- package/dist/output/entryStatusDisplay.js +24 -0
- package/dist/output/entryStatusDisplay.js.map +1 -0
- package/dist/output/formatter.d.ts +6 -0
- package/dist/output/formatter.d.ts.map +1 -0
- package/dist/output/formatter.js +9 -0
- package/dist/output/formatter.js.map +1 -0
- package/dist/output/styles.d.ts +15 -0
- package/dist/output/styles.d.ts.map +1 -0
- package/dist/output/styles.js +16 -0
- package/dist/output/styles.js.map +1 -0
- package/dist/output/tables.d.ts +6 -0
- package/dist/output/tables.d.ts.map +1 -0
- package/dist/output/tables.js +45 -0
- package/dist/output/tables.js.map +1 -0
- package/dist/utils/archIndex.d.ts +7 -0
- package/dist/utils/archIndex.d.ts.map +1 -0
- package/dist/utils/archIndex.js +14 -0
- package/dist/utils/archIndex.js.map +1 -0
- package/dist/utils/breaking-changes.d.ts +14 -0
- package/dist/utils/breaking-changes.d.ts.map +1 -0
- package/dist/utils/breaking-changes.js +11 -0
- package/dist/utils/breaking-changes.js.map +1 -0
- package/dist/utils/commandCatalog.d.ts +25 -0
- package/dist/utils/commandCatalog.d.ts.map +1 -0
- package/dist/utils/commandCatalog.js +32 -0
- package/dist/utils/commandCatalog.js.map +1 -0
- package/dist/utils/confirm.d.ts +3 -0
- package/dist/utils/confirm.d.ts.map +1 -0
- package/dist/utils/confirm.js +12 -0
- package/dist/utils/confirm.js.map +1 -0
- package/dist/utils/errors.d.ts +22 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +63 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/phaseShorthand.d.ts +23 -0
- package/dist/utils/phaseShorthand.d.ts.map +1 -0
- package/dist/utils/phaseShorthand.js +68 -0
- package/dist/utils/phaseShorthand.js.map +1 -0
- package/dist/utils/project.d.ts +60 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +140 -0
- package/dist/utils/project.js.map +1 -0
- package/dist/utils/worktree-overlay.d.ts +31 -0
- package/dist/utils/worktree-overlay.d.ts.map +1 -0
- package/dist/utils/worktree-overlay.js +63 -0
- package/dist/utils/worktree-overlay.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { GitWorktreeDiscovery } from '@context-forge/core/node';
|
|
2
|
+
import { UserError } from './errors.js';
|
|
3
|
+
/**
|
|
4
|
+
* Find a project by exact ID or case-insensitive name.
|
|
5
|
+
* ID match takes priority over name match.
|
|
6
|
+
*/
|
|
7
|
+
export async function findByNameOrId(nameOrId, store) {
|
|
8
|
+
const projects = await store.getAll();
|
|
9
|
+
// Exact ID match first
|
|
10
|
+
const byId = projects.find((p) => p.id === nameOrId);
|
|
11
|
+
if (byId)
|
|
12
|
+
return byId;
|
|
13
|
+
// Case-insensitive name match
|
|
14
|
+
const lower = nameOrId.toLowerCase();
|
|
15
|
+
const byName = projects.find((p) => p.name?.toLowerCase() === lower);
|
|
16
|
+
return byName ?? null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Find the project whose projectPath or worktreePath best matches the current
|
|
20
|
+
* working directory. When multiple paths match (nested paths), the longest wins.
|
|
21
|
+
* Projects without a projectPath are skipped; worktrees without a worktreePath
|
|
22
|
+
* are also skipped.
|
|
23
|
+
*/
|
|
24
|
+
export async function findProjectByCwd(store) {
|
|
25
|
+
const projects = await store.getAll();
|
|
26
|
+
const cwd = process.cwd();
|
|
27
|
+
const candidates = [];
|
|
28
|
+
for (const p of projects) {
|
|
29
|
+
// Existing: project root path
|
|
30
|
+
if (p.projectPath) {
|
|
31
|
+
candidates.push({ project: p, path: p.projectPath });
|
|
32
|
+
}
|
|
33
|
+
// New: worktree paths
|
|
34
|
+
for (const wt of p.worktrees ?? []) {
|
|
35
|
+
if (wt.worktreePath) {
|
|
36
|
+
candidates.push({ project: p, path: wt.worktreePath, worktreeId: wt.id });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const matches = candidates
|
|
41
|
+
.filter((c) => {
|
|
42
|
+
const path = c.path.endsWith('/') ? c.path.slice(0, -1) : c.path;
|
|
43
|
+
return cwd === path || cwd.startsWith(path + '/');
|
|
44
|
+
})
|
|
45
|
+
.sort((a, b) => {
|
|
46
|
+
// Longest path wins; on tie, prefer worktree match over project root
|
|
47
|
+
const lenDiff = b.path.length - a.path.length;
|
|
48
|
+
if (lenDiff !== 0)
|
|
49
|
+
return lenDiff;
|
|
50
|
+
if (a.worktreeId && !b.worktreeId)
|
|
51
|
+
return -1;
|
|
52
|
+
if (!a.worktreeId && b.worktreeId)
|
|
53
|
+
return 1;
|
|
54
|
+
return 0;
|
|
55
|
+
});
|
|
56
|
+
if (matches.length === 0)
|
|
57
|
+
return null;
|
|
58
|
+
return { project: matches[0].project, worktreeId: matches[0].worktreeId };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Resolves which project and (optionally) worktree to use via a three-step chain:
|
|
62
|
+
*
|
|
63
|
+
* 1. explicit --project flag → findByNameOrId
|
|
64
|
+
* 2. CWD detection → findProjectByCwd (worktree-aware)
|
|
65
|
+
* 3. Throw UserError with guidance
|
|
66
|
+
*
|
|
67
|
+
* When opts.worktree is provided and a project was resolved, also resolves the
|
|
68
|
+
* worktreeId via findWorktreeByNameOrId.
|
|
69
|
+
*/
|
|
70
|
+
export async function resolveProjectWorktree(opts, store) {
|
|
71
|
+
const explicit = opts.project;
|
|
72
|
+
// Step 1: explicit --project flag
|
|
73
|
+
if (explicit) {
|
|
74
|
+
const project = await findByNameOrId(explicit, store);
|
|
75
|
+
if (!project) {
|
|
76
|
+
throw new UserError(`Project '${explicit}' not found.`, 'PROJECT_NOT_FOUND', `Check the spelling, or run cf project list to see available projects.`);
|
|
77
|
+
}
|
|
78
|
+
const resolved = { id: project.id, source: 'flag' };
|
|
79
|
+
if (opts.worktree) {
|
|
80
|
+
const wt = await findWorktreeByNameOrId(project.id, opts.worktree, store);
|
|
81
|
+
if (wt)
|
|
82
|
+
resolved.worktreeId = wt.id;
|
|
83
|
+
}
|
|
84
|
+
return resolved;
|
|
85
|
+
}
|
|
86
|
+
// Step 2: CWD detection (worktree-aware)
|
|
87
|
+
const cwdMatch = await findProjectByCwd(store);
|
|
88
|
+
if (cwdMatch) {
|
|
89
|
+
if (cwdMatch.worktreeId) {
|
|
90
|
+
return { id: cwdMatch.project.id, worktreeId: cwdMatch.worktreeId, source: 'worktree' };
|
|
91
|
+
}
|
|
92
|
+
return { id: cwdMatch.project.id, source: 'cwd' };
|
|
93
|
+
}
|
|
94
|
+
// Step 2b: CWD is a git worktree of a known project (not yet registered as a cf worktree)
|
|
95
|
+
try {
|
|
96
|
+
const discovery = new GitWorktreeDiscovery();
|
|
97
|
+
const gitWorktrees = await discovery.listWorktrees(process.cwd());
|
|
98
|
+
if (gitWorktrees.length > 0) {
|
|
99
|
+
const mainWorktreePath = gitWorktrees[0].path;
|
|
100
|
+
const projects = await store.getAll();
|
|
101
|
+
const matchingProject = projects.find((p) => p.projectPath === mainWorktreePath);
|
|
102
|
+
if (matchingProject) {
|
|
103
|
+
return { id: matchingProject.id, source: 'cwd' };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// Git unavailable or not a git repo — fall through
|
|
109
|
+
}
|
|
110
|
+
// Step 3: no resolution
|
|
111
|
+
throw new UserError('No project specified and no registered project found at current path.', 'PROJECT_NOT_FOUND', `cf init # register current directory as a project\n` +
|
|
112
|
+
` --project <name> # specify a project explicitly\n` +
|
|
113
|
+
` cf project list # see registered projects`);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Resolves which project to use via a three-step chain.
|
|
117
|
+
* Backwards-compatible wrapper around resolveProjectWorktree — drops worktreeId.
|
|
118
|
+
*/
|
|
119
|
+
export async function resolveProjectId(explicit, store) {
|
|
120
|
+
const result = await resolveProjectWorktree({ project: explicit }, store);
|
|
121
|
+
return { id: result.id, source: result.source };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Find a worktree within a project by exact ID or case-insensitive name.
|
|
125
|
+
* ID match takes priority over name match. Returns undefined if not found.
|
|
126
|
+
*/
|
|
127
|
+
export async function findWorktreeByNameOrId(projectId, nameOrId, store) {
|
|
128
|
+
const project = await store.getById(projectId);
|
|
129
|
+
if (!project)
|
|
130
|
+
return undefined;
|
|
131
|
+
const worktrees = project.worktrees ?? [];
|
|
132
|
+
// Exact ID match first
|
|
133
|
+
const byId = worktrees.find((wt) => wt.id === nameOrId);
|
|
134
|
+
if (byId)
|
|
135
|
+
return byId;
|
|
136
|
+
// Case-insensitive name match
|
|
137
|
+
const lower = nameOrId.toLowerCase();
|
|
138
|
+
return worktrees.find((wt) => wt.name.toLowerCase() === lower);
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/utils/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAElF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAAgB,EAChB,KAAuB;IAEvB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC;IAEtC,uBAAuB;IACvB,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;IACrD,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAEtB,8BAA8B;IAC9B,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,KAA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|
|
4
|
+
* Resolve the filesystem path for file operations.
|
|
5
|
+
* Returns worktreePath when a worktree is resolved and has a path,
|
|
6
|
+
* otherwise returns projectPath.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveOperationPath(project: ProjectData, worktreeId?: string): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Get the index range for filtering, if applicable.
|
|
11
|
+
* Returns the worktree's indexRange for ALL worktrees (including default).
|
|
12
|
+
* Returns undefined only when no worktreeId, no worktrees array, or
|
|
13
|
+
* worktree not found (projects without worktrees — no filtering).
|
|
14
|
+
*/
|
|
15
|
+
export declare function getWorktreeIndexRange(project: ProjectData, worktreeId?: string): [number, number] | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Get all unique filesystem paths for cross-worktree aggregation (--all mode).
|
|
18
|
+
* Collects projectPath + all worktreePath values into a deduplicated set.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveAllOperationPaths(project: ProjectData): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Check if a worktree has rangeOverride enabled.
|
|
23
|
+
* Returns false when no worktreeId, no worktrees, or worktree not found.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getWorktreeRangeOverride(project: ProjectData, worktreeId?: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a numeric index falls within an optional range.
|
|
28
|
+
* Returns true if no range is specified (no filtering).
|
|
29
|
+
*/
|
|
30
|
+
export declare function isInIndexRange(index: number, range?: [number, number]): boolean;
|
|
31
|
+
//# sourceMappingURL=worktree-overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-overlay.d.ts","sourceRoot":"","sources":["../../src/utils/worktree-overlay.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,WAAW,EACpB,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CAMpB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,WAAW,EACpB,UAAU,CAAC,EAAE,MAAM,GAClB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAK9B;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,WAAW,GACnB,MAAM,EAAE,CAOV;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,WAAW,EACpB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAIT;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GACvB,OAAO,CAGT"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Re-export from core — canonical implementation lives in @context-forge/core
|
|
2
|
+
export { applyWorktreeOverlay } from '@context-forge/core';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the filesystem path for file operations.
|
|
5
|
+
* Returns worktreePath when a worktree is resolved and has a path,
|
|
6
|
+
* otherwise returns projectPath.
|
|
7
|
+
*/
|
|
8
|
+
export function resolveOperationPath(project, worktreeId) {
|
|
9
|
+
if (worktreeId && project.worktrees) {
|
|
10
|
+
const wt = project.worktrees.find((w) => w.id === worktreeId);
|
|
11
|
+
if (wt?.worktreePath)
|
|
12
|
+
return wt.worktreePath;
|
|
13
|
+
}
|
|
14
|
+
return project.projectPath;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get the index range for filtering, if applicable.
|
|
18
|
+
* Returns the worktree's indexRange for ALL worktrees (including default).
|
|
19
|
+
* Returns undefined only when no worktreeId, no worktrees array, or
|
|
20
|
+
* worktree not found (projects without worktrees — no filtering).
|
|
21
|
+
*/
|
|
22
|
+
export function getWorktreeIndexRange(project, worktreeId) {
|
|
23
|
+
if (!worktreeId || !project.worktrees)
|
|
24
|
+
return undefined;
|
|
25
|
+
const wt = project.worktrees.find((w) => w.id === worktreeId);
|
|
26
|
+
if (!wt)
|
|
27
|
+
return undefined;
|
|
28
|
+
return wt.indexRange;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get all unique filesystem paths for cross-worktree aggregation (--all mode).
|
|
32
|
+
* Collects projectPath + all worktreePath values into a deduplicated set.
|
|
33
|
+
*/
|
|
34
|
+
export function resolveAllOperationPaths(project) {
|
|
35
|
+
const paths = new Set();
|
|
36
|
+
if (project.projectPath)
|
|
37
|
+
paths.add(project.projectPath);
|
|
38
|
+
for (const wt of project.worktrees ?? []) {
|
|
39
|
+
if (wt.worktreePath)
|
|
40
|
+
paths.add(wt.worktreePath);
|
|
41
|
+
}
|
|
42
|
+
return [...paths];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Check if a worktree has rangeOverride enabled.
|
|
46
|
+
* Returns false when no worktreeId, no worktrees, or worktree not found.
|
|
47
|
+
*/
|
|
48
|
+
export function getWorktreeRangeOverride(project, worktreeId) {
|
|
49
|
+
if (!worktreeId || !project.worktrees)
|
|
50
|
+
return false;
|
|
51
|
+
const wt = project.worktrees.find((w) => w.id === worktreeId);
|
|
52
|
+
return wt?.rangeOverride === true;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Check if a numeric index falls within an optional range.
|
|
56
|
+
* Returns true if no range is specified (no filtering).
|
|
57
|
+
*/
|
|
58
|
+
export function isInIndexRange(index, range) {
|
|
59
|
+
if (!range)
|
|
60
|
+
return true;
|
|
61
|
+
return index >= range[0] && index <= range[1];
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=worktree-overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-overlay.js","sourceRoot":"","sources":["../../src/utils/worktree-overlay.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,EA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;AACH,MAAM,UAAU,wBAAwB,CACtC,OAAoB,EACpB,UAAmB;IAEnB,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IACpD,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,CAAC;IAC9D,OAAO,EAAE,EAAE,aAAa,KAAK,IAAI,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAa,EACb,KAAwB;IAExB,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@context-forge/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "CLI for Context Forge — terminal access to context assembly, project management, workflow navigation, and configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"chalk": "^5.4.1",
|
|
34
34
|
"commander": "^13.1.0",
|
|
35
|
-
"@context-forge/core": "0.
|
|
35
|
+
"@context-forge/core": "0.9.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^25.3.0",
|