claudecode-omc 5.6.0 → 5.6.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.
package/src/cli/source.js CHANGED
@@ -74,8 +74,8 @@ async function syncRemoteSource(sourceName, sourceConfig, root) {
74
74
  const srcPath = path.join(tmpDir, srcSubdir);
75
75
  const destPath = getSyncTargetDir(sourceName, artifactType, root);
76
76
 
77
+ await fsp.rm(destPath, { recursive: true, force: true });
77
78
  if (fs.existsSync(srcPath)) {
78
- await fsp.rm(destPath, { recursive: true, force: true });
79
79
  if (fs.statSync(srcPath).isDirectory()) {
80
80
  await copyDirRecursive(srcPath, destPath);
81
81
  } else {
@@ -213,6 +213,23 @@ function getInstallTarget(artifactType) {
213
213
  return type.installTarget;
214
214
  }
215
215
 
216
+ function getScopedInstallTarget(artifactType, scope = 'user', cwd = process.cwd()) {
217
+ if (scope !== 'project') {
218
+ return getInstallTarget(artifactType);
219
+ }
220
+
221
+ if (artifactType === 'guidelines' || artifactType === 'claude-md') {
222
+ return path.join(cwd, '.claude', 'CLAUDE.md');
223
+ }
224
+ if (artifactType === 'settings') {
225
+ return path.join(cwd, '.claude', 'settings.json');
226
+ }
227
+
228
+ const type = ARTIFACT_TYPES[artifactType];
229
+ if (!type) throw new Error(`Unknown artifact type: ${artifactType}`);
230
+ return path.join(cwd, '.claude', type.sourceSubdir);
231
+ }
232
+
216
233
  // Backward-compatible aliases
217
234
  function getLocalSkillsDir(root) {
218
235
  return getSourceArtifactDir('local', 'skills', root);
@@ -257,6 +274,7 @@ module.exports = {
257
274
  getSyncTargetDir,
258
275
  getSyncTempDir,
259
276
  getInstallTarget,
277
+ getScopedInstallTarget,
260
278
  USER_DATA_DIR,
261
279
  // Backward-compatible
262
280
  getLocalSkillsDir,
@@ -0,0 +1,92 @@
1
+ const fs = require('fs');
2
+ const { getProjectRoot, getSourceArtifactDir } = require('../config/paths');
3
+ const { readConfig, filterItemsByAllowlist } = require('../config/sources');
4
+ const { loadSkillsFromSource } = require('./skill-merger');
5
+ const { loadAgentsFromSource } = require('./agent-merger');
6
+ const { loadCommandsFromSource } = require('./command-merger');
7
+ const { loadHookFilesFromSource } = require('./hook-merger');
8
+ const { loadFilesFromSource } = require('./file-merger');
9
+ const { loadClaudeMd } = require('./claude-md-merger');
10
+
11
+ function loadSectionDocumentFromSource(sourceDir) {
12
+ const content = loadClaudeMd(sourceDir);
13
+ if (!content) return [];
14
+ return [{
15
+ name: 'CLAUDE.md',
16
+ path: sourceDir,
17
+ metadata: {
18
+ description: `${content.length} chars of prompt guidelines`,
19
+ },
20
+ }];
21
+ }
22
+
23
+ function getArtifactLoader(artifactType, options = {}) {
24
+ switch (artifactType) {
25
+ case 'skills': return loadSkillsFromSource;
26
+ case 'agents': return loadAgentsFromSource;
27
+ case 'commands': return loadCommandsFromSource;
28
+ case 'hooks': return loadHookFilesFromSource;
29
+ case 'hud': return loadFilesFromSource;
30
+ case 'guidelines':
31
+ case 'claude-md':
32
+ return options.includeSectionDocuments ? loadSectionDocumentFromSource : null;
33
+ default: return null;
34
+ }
35
+ }
36
+
37
+ function getOrderedInstallableSources(config) {
38
+ return Object.entries(config.sources || {})
39
+ .sort(([, a], [, b]) => a.priority - b.priority)
40
+ .filter(([, src]) => src.role !== 'reference')
41
+ .filter(([, src]) => !src.installMode || src.installMode === 'auto');
42
+ }
43
+
44
+ function collectSourceDirsForType(artifactType, root = getProjectRoot(), config = readConfig()) {
45
+ const sourcesForType = [];
46
+
47
+ for (const [name, src] of getOrderedInstallableSources(config)) {
48
+ if (!(src.artifacts || []).includes(artifactType)) continue;
49
+
50
+ const dir = getSourceArtifactDir(name, artifactType, root);
51
+ if (fs.existsSync(dir)) {
52
+ sourcesForType.push({ name, dir, priority: src.priority, config: src });
53
+ }
54
+ }
55
+
56
+ if (sourcesForType.length === 0 && artifactType === 'claude-md') {
57
+ return collectSourceDirsForType('guidelines', root, config);
58
+ }
59
+
60
+ return sourcesForType;
61
+ }
62
+
63
+ function loadSourcesForType(artifactType, root = getProjectRoot(), options = {}) {
64
+ const config = options.config || readConfig();
65
+ const loader = getArtifactLoader(artifactType, { includeSectionDocuments: true });
66
+ if (!loader) return [];
67
+
68
+ const sources = [];
69
+ for (const source of collectSourceDirsForType(artifactType, root, config)) {
70
+ const items = filterItemsByAllowlist(
71
+ source.config,
72
+ artifactType,
73
+ loader(source.dir, source.name),
74
+ );
75
+ if (items.length > 0) {
76
+ sources.push({ name: source.name, items });
77
+ }
78
+ }
79
+
80
+ if (sources.length === 0 && artifactType === 'claude-md') {
81
+ return loadSourcesForType('guidelines', root, options);
82
+ }
83
+
84
+ return sources;
85
+ }
86
+
87
+ module.exports = {
88
+ collectSourceDirsForType,
89
+ getArtifactLoader,
90
+ loadSectionDocumentFromSource,
91
+ loadSourcesForType,
92
+ };