runwork 0.5.0 → 0.6.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.
Files changed (116) hide show
  1. package/dist/agents/__tests__/claude-code-stats.test.d.ts +1 -0
  2. package/dist/agents/__tests__/claude-code-stats.test.js +153 -0
  3. package/dist/agents/__tests__/claude-desktop-stats.test.d.ts +1 -0
  4. package/dist/agents/__tests__/claude-desktop-stats.test.js +280 -0
  5. package/dist/agents/__tests__/codex-stats.test.d.ts +1 -0
  6. package/dist/agents/__tests__/codex-stats.test.js +262 -0
  7. package/dist/agents/__tests__/cursor-stats.test.d.ts +1 -0
  8. package/dist/agents/__tests__/cursor-stats.test.js +183 -0
  9. package/dist/agents/__tests__/graceful-degradation.test.d.ts +1 -0
  10. package/dist/agents/__tests__/graceful-degradation.test.js +123 -0
  11. package/dist/agents/__tests__/instruction-hint.test.d.ts +1 -0
  12. package/dist/agents/__tests__/instruction-hint.test.js +69 -0
  13. package/dist/agents/__tests__/intro-skill.test.d.ts +1 -0
  14. package/dist/agents/__tests__/intro-skill.test.js +135 -0
  15. package/dist/agents/__tests__/schema-validation.test.d.ts +1 -0
  16. package/dist/agents/__tests__/schema-validation.test.js +212 -0
  17. package/dist/agents/claude-code.d.ts +16 -1
  18. package/dist/agents/claude-code.js +344 -21
  19. package/dist/agents/claude-desktop.d.ts +10 -1
  20. package/dist/agents/claude-desktop.js +250 -8
  21. package/dist/agents/cline.d.ts +13 -0
  22. package/dist/agents/cline.js +88 -0
  23. package/dist/agents/codex.d.ts +7 -2
  24. package/dist/agents/codex.js +130 -18
  25. package/dist/agents/cursor.d.ts +6 -1
  26. package/dist/agents/cursor.js +164 -7
  27. package/dist/agents/detect.js +30 -7
  28. package/dist/agents/gemini.d.ts +6 -3
  29. package/dist/agents/gemini.js +57 -20
  30. package/dist/agents/generic-adapter.d.ts +23 -0
  31. package/dist/agents/generic-adapter.js +106 -0
  32. package/dist/agents/intro-skill.d.ts +36 -0
  33. package/dist/agents/intro-skill.js +358 -0
  34. package/dist/agents/registry.d.ts +53 -0
  35. package/dist/agents/registry.js +219 -0
  36. package/dist/agents/types.d.ts +44 -1
  37. package/dist/agents/types.js +11 -4
  38. package/dist/agents/utils/instruction-hint.d.ts +11 -0
  39. package/dist/agents/utils/instruction-hint.js +62 -0
  40. package/dist/agents/utils/json-config.js +3 -3
  41. package/dist/agents/windsurf.d.ts +2 -0
  42. package/dist/agents/windsurf.js +26 -9
  43. package/dist/api/client.d.ts +85 -2
  44. package/dist/api/client.js +40 -10
  45. package/dist/auth/__tests__/login-flow.test.d.ts +1 -0
  46. package/dist/auth/__tests__/login-flow.test.js +125 -0
  47. package/dist/auth/login-flow.d.ts +16 -0
  48. package/dist/auth/login-flow.js +101 -1
  49. package/dist/commands/clone.d.ts +9 -1
  50. package/dist/commands/clone.js +40 -12
  51. package/dist/commands/deploy.js +27 -4
  52. package/dist/commands/dev.js +35 -1
  53. package/dist/commands/doctor.d.ts +2 -0
  54. package/dist/commands/doctor.js +82 -0
  55. package/dist/commands/info.js +6 -2
  56. package/dist/commands/init.d.ts +10 -2
  57. package/dist/commands/init.js +58 -15
  58. package/dist/commands/integrations.js +47 -10
  59. package/dist/commands/login.js +31 -4
  60. package/dist/commands/mcp.js +143 -15
  61. package/dist/commands/setup.js +47 -122
  62. package/dist/commands/skills.js +230 -12
  63. package/dist/commands/sync.d.ts +8 -0
  64. package/dist/commands/sync.js +398 -65
  65. package/dist/commands/welcome.js +6 -3
  66. package/dist/generated/version.d.ts +1 -1
  67. package/dist/generated/version.js +1 -1
  68. package/dist/health/__tests__/checks.test.d.ts +1 -0
  69. package/dist/health/__tests__/checks.test.js +223 -0
  70. package/dist/health/checks.d.ts +20 -0
  71. package/dist/health/checks.js +392 -0
  72. package/dist/health/runner.d.ts +2 -0
  73. package/dist/health/runner.js +26 -0
  74. package/dist/health/types.d.ts +12 -0
  75. package/dist/health/types.js +1 -0
  76. package/dist/index.js +32 -0
  77. package/dist/sync/__tests__/change-detect.test.d.ts +1 -0
  78. package/dist/sync/__tests__/change-detect.test.js +123 -0
  79. package/dist/sync/__tests__/hash.test.d.ts +1 -0
  80. package/dist/sync/__tests__/hash.test.js +18 -0
  81. package/dist/sync/change-detect.d.ts +19 -0
  82. package/dist/sync/change-detect.js +136 -0
  83. package/dist/sync/conflict-ui.d.ts +5 -0
  84. package/dist/sync/conflict-ui.js +78 -0
  85. package/dist/sync/executor.d.ts +21 -0
  86. package/dist/sync/executor.js +98 -0
  87. package/dist/sync/hash.d.ts +1 -0
  88. package/dist/sync/hash.js +4 -0
  89. package/dist/sync/types.d.ts +24 -0
  90. package/dist/sync/types.js +1 -0
  91. package/dist/types.d.ts +12 -0
  92. package/dist/ui/__tests__/banner.test.js +17 -1
  93. package/dist/ui/banner.d.ts +1 -1
  94. package/dist/ui/banner.js +27 -2
  95. package/dist/utils/__tests__/resolve.test.d.ts +1 -0
  96. package/dist/utils/__tests__/resolve.test.js +95 -0
  97. package/dist/utils/__tests__/sqlite.test.d.ts +1 -0
  98. package/dist/utils/__tests__/sqlite.test.js +77 -0
  99. package/dist/utils/agent-guidance.d.ts +32 -0
  100. package/dist/utils/agent-guidance.js +106 -0
  101. package/dist/utils/fs.js +2 -2
  102. package/dist/utils/help-json.d.ts +56 -0
  103. package/dist/utils/help-json.js +85 -0
  104. package/dist/utils/resolve.d.ts +12 -0
  105. package/dist/utils/resolve.js +52 -0
  106. package/dist/utils/setup-state.d.ts +3 -0
  107. package/dist/utils/setup-state.js +19 -0
  108. package/dist/utils/sqlite.d.ts +7 -0
  109. package/dist/utils/sqlite.js +24 -0
  110. package/dist/utils/which.d.ts +6 -0
  111. package/dist/utils/which.js +18 -0
  112. package/package.json +7 -3
  113. package/dist/agents/copilot-cli.d.ts +0 -10
  114. package/dist/agents/copilot-cli.js +0 -46
  115. package/dist/agents/copilot-vscode.d.ts +0 -10
  116. package/dist/agents/copilot-vscode.js +0 -37
package/dist/index.js CHANGED
@@ -23,8 +23,11 @@ import { mcpCommand } from './commands/mcp.js';
23
23
  import { setupCommand } from './commands/setup.js';
24
24
  import { syncCommand } from './commands/sync.js';
25
25
  import { appsCommand } from './commands/apps.js';
26
+ import { doctorCommand } from './commands/doctor.js';
26
27
  import { handleGitCredentialRequest } from './git/credentials.js';
27
28
  import { VERSION } from './generated/version.js';
29
+ import { shouldOutputJson, jsonOut } from './utils/output.js';
30
+ import { buildHelpJson, buildCommandHelpJson } from './utils/help-json.js';
28
31
  const program = new Command();
29
32
  program
30
33
  .name('runwork')
@@ -56,7 +59,32 @@ program.addCommand(mcpCommand);
56
59
  program.addCommand(setupCommand);
57
60
  program.addCommand(syncCommand);
58
61
  program.addCommand(appsCommand);
62
+ program.addCommand(doctorCommand);
59
63
  program.addHelpText('after', '\nFor AI agents: run "runwork info --json" to discover app context and available commands.');
64
+ // JSON help: intercept --help when --json is active or stdout is not a TTY.
65
+ // Outputs the full command tree as structured JSON for AI agents.
66
+ function installJsonHelp(cmd) {
67
+ cmd.on('beforeHelp', () => {
68
+ const jsonFlag = cmd.optsWithGlobals?.().json;
69
+ if (shouldOutputJson(jsonFlag)) {
70
+ if (cmd === program) {
71
+ jsonOut(buildHelpJson(program));
72
+ }
73
+ else {
74
+ jsonOut(buildCommandHelpJson(cmd, VERSION));
75
+ }
76
+ process.exit(0);
77
+ }
78
+ });
79
+ }
80
+ installJsonHelp(program);
81
+ for (const cmd of program.commands) {
82
+ installJsonHelp(cmd);
83
+ // Also install on nested subcommands (e.g. `skills list`)
84
+ for (const sub of cmd.commands) {
85
+ installJsonHelp(sub);
86
+ }
87
+ }
60
88
  const credentialHelper = program
61
89
  .command('git-credential-helper', { hidden: true })
62
90
  .argument('<action>', 'Credential action (get/store/erase)')
@@ -74,6 +102,10 @@ const hasCommand = args.some(arg => !arg.startsWith('-') && knownCommands.includ
74
102
  if (!hasCommand && !isHelpOrVersion && args.length === 0) {
75
103
  const { getCredentials } = await import('./auth/store.js');
76
104
  if (!getCredentials()) {
105
+ if (!process.stdout.isTTY) {
106
+ console.error('Not logged in. Run `runwork login` first.');
107
+ process.exit(1);
108
+ }
77
109
  const { runWelcomeWizard } = await import('./commands/welcome.js');
78
110
  await runWelcomeWizard();
79
111
  process.exit(0);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,123 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { computeSyncPlan } from '../change-detect.js';
3
+ import { contentHash } from '../hash.js';
4
+ // Helper to build a stored state entry
5
+ function stored(localContent, remoteContent, source = 'external', remoteId, appId) {
6
+ return {
7
+ localHash: contentHash(localContent),
8
+ remoteHash: contentHash(remoteContent),
9
+ source,
10
+ remoteId,
11
+ appId,
12
+ };
13
+ }
14
+ describe('computeSyncPlan', () => {
15
+ it('skips when nothing changed', () => {
16
+ const content = 'skill content unchanged';
17
+ const plan = computeSyncPlan({
18
+ storedHashes: { 'my-skill': stored(content, content) },
19
+ localSkills: [{ name: 'my-skill', content }],
20
+ remoteSkills: [{ name: 'my-skill', content, source: 'external' }],
21
+ });
22
+ expect(plan.skips).toHaveLength(1);
23
+ expect(plan.skips[0].name).toBe('my-skill');
24
+ expect(plan.pulls).toHaveLength(0);
25
+ expect(plan.pushes).toHaveLength(0);
26
+ expect(plan.conflicts).toHaveLength(0);
27
+ expect(plan.deletions).toHaveLength(0);
28
+ });
29
+ it('pulls when remote changed but local did not', () => {
30
+ const original = 'original content';
31
+ const remoteNew = 'remote updated content';
32
+ const plan = computeSyncPlan({
33
+ storedHashes: { 'my-skill': stored(original, original) },
34
+ localSkills: [{ name: 'my-skill', content: original }],
35
+ remoteSkills: [{ name: 'my-skill', content: remoteNew, source: 'external' }],
36
+ });
37
+ expect(plan.pulls).toHaveLength(1);
38
+ expect(plan.pulls[0].name).toBe('my-skill');
39
+ expect(plan.pulls[0].action).toBe('pull');
40
+ expect(plan.pulls[0].remoteContent).toBe(remoteNew);
41
+ expect(plan.pushes).toHaveLength(0);
42
+ expect(plan.conflicts).toHaveLength(0);
43
+ });
44
+ it('pushes when local changed but remote did not (external skill)', () => {
45
+ const original = 'original content';
46
+ const localNew = 'locally updated content';
47
+ const plan = computeSyncPlan({
48
+ storedHashes: { 'my-skill': stored(original, original, 'external') },
49
+ localSkills: [{ name: 'my-skill', content: localNew }],
50
+ remoteSkills: [{ name: 'my-skill', content: original, source: 'external' }],
51
+ });
52
+ expect(plan.pushes).toHaveLength(1);
53
+ expect(plan.pushes[0].name).toBe('my-skill');
54
+ expect(plan.pushes[0].action).toBe('push');
55
+ expect(plan.pushes[0].localContent).toBe(localNew);
56
+ expect(plan.pulls).toHaveLength(0);
57
+ expect(plan.conflicts).toHaveLength(0);
58
+ });
59
+ it('conflicts when both changed (external skill)', () => {
60
+ const original = 'original content';
61
+ const localNew = 'locally updated content';
62
+ const remoteNew = 'remotely updated content';
63
+ const plan = computeSyncPlan({
64
+ storedHashes: { 'my-skill': stored(original, original, 'external') },
65
+ localSkills: [{ name: 'my-skill', content: localNew }],
66
+ remoteSkills: [{ name: 'my-skill', content: remoteNew, source: 'external' }],
67
+ });
68
+ expect(plan.conflicts).toHaveLength(1);
69
+ expect(plan.conflicts[0].name).toBe('my-skill');
70
+ expect(plan.conflicts[0].action).toBe('conflict');
71
+ expect(plan.conflicts[0].localContent).toBe(localNew);
72
+ expect(plan.conflicts[0].remoteContent).toBe(remoteNew);
73
+ expect(plan.pulls).toHaveLength(0);
74
+ expect(plan.pushes).toHaveLength(0);
75
+ });
76
+ it('detects new remote skill (not in stored state)', () => {
77
+ const content = 'brand new remote skill';
78
+ const plan = computeSyncPlan({
79
+ storedHashes: {},
80
+ localSkills: [],
81
+ remoteSkills: [{ name: 'new-skill', content, source: 'external', remoteId: 'abc123' }],
82
+ });
83
+ expect(plan.pulls).toHaveLength(1);
84
+ expect(plan.pulls[0].name).toBe('new-skill');
85
+ expect(plan.pulls[0].action).toBe('new-remote');
86
+ expect(plan.pulls[0].remoteContent).toBe(content);
87
+ expect(plan.pulls[0].remoteId).toBe('abc123');
88
+ expect(plan.pushes).toHaveLength(0);
89
+ expect(plan.conflicts).toHaveLength(0);
90
+ expect(plan.deletions).toHaveLength(0);
91
+ });
92
+ it('detects deleted remote skill (in stored state, not on workspace)', () => {
93
+ const content = 'was here before';
94
+ const plan = computeSyncPlan({
95
+ storedHashes: { 'gone-skill': stored(content, content, 'external', 'remote-id-1') },
96
+ localSkills: [{ name: 'gone-skill', content }],
97
+ remoteSkills: [],
98
+ });
99
+ expect(plan.deletions).toHaveLength(1);
100
+ expect(plan.deletions[0].name).toBe('gone-skill');
101
+ expect(plan.deletions[0].action).toBe('deleted-remote');
102
+ expect(plan.pulls).toHaveLength(0);
103
+ expect(plan.pushes).toHaveLength(0);
104
+ expect(plan.conflicts).toHaveLength(0);
105
+ });
106
+ it('never pushes app skills — local edit on app skill results in pull/overwrite', () => {
107
+ const original = 'app skill original';
108
+ const localNew = 'user edited the app skill locally';
109
+ const appId = 'app-xyz';
110
+ const plan = computeSyncPlan({
111
+ storedHashes: { 'app-skill': stored(original, original, 'app', undefined, appId) },
112
+ localSkills: [{ name: 'app-skill', content: localNew }],
113
+ remoteSkills: [{ name: 'app-skill', content: original, source: 'app', appId }],
114
+ });
115
+ expect(plan.pushes).toHaveLength(0);
116
+ expect(plan.conflicts).toHaveLength(0);
117
+ expect(plan.pulls).toHaveLength(1);
118
+ expect(plan.pulls[0].name).toBe('app-skill');
119
+ expect(plan.pulls[0].action).toBe('pull');
120
+ expect(plan.pulls[0].remoteContent).toBe(original);
121
+ expect(plan.pulls[0].source).toBe('app');
122
+ });
123
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { contentHash } from '../hash.js';
3
+ describe('contentHash', () => {
4
+ it('returns sha256-prefixed hash', () => {
5
+ const hash = contentHash('hello world');
6
+ expect(hash).toMatch(/^sha256:[a-f0-9]{64}$/);
7
+ });
8
+ it('returns same hash for same content', () => {
9
+ expect(contentHash('test')).toBe(contentHash('test'));
10
+ });
11
+ it('returns different hash for different content', () => {
12
+ expect(contentHash('a')).not.toBe(contentHash('b'));
13
+ });
14
+ it('handles empty string', () => {
15
+ const hash = contentHash('');
16
+ expect(hash).toMatch(/^sha256:[a-f0-9]{64}$/);
17
+ });
18
+ });
@@ -0,0 +1,19 @@
1
+ import type { SkillHashState, SyncPlan } from './types.js';
2
+ interface LocalSkill {
3
+ name: string;
4
+ content: string;
5
+ }
6
+ interface RemoteSkill {
7
+ name: string;
8
+ content: string;
9
+ source: 'external' | 'app';
10
+ remoteId?: string;
11
+ appId?: string;
12
+ }
13
+ interface ComputeSyncInput {
14
+ storedHashes: Record<string, SkillHashState>;
15
+ localSkills: LocalSkill[];
16
+ remoteSkills: RemoteSkill[];
17
+ }
18
+ export declare function computeSyncPlan(input: ComputeSyncInput): SyncPlan;
19
+ export {};
@@ -0,0 +1,136 @@
1
+ import { contentHash } from './hash.js';
2
+ export function computeSyncPlan(input) {
3
+ const { storedHashes, localSkills, remoteSkills } = input;
4
+ const plan = {
5
+ pulls: [],
6
+ pushes: [],
7
+ conflicts: [],
8
+ skips: [],
9
+ deletions: [],
10
+ };
11
+ const localByName = new Map(localSkills.map((s) => [s.name, s]));
12
+ const remoteByName = new Map(remoteSkills.map((s) => [s.name, s]));
13
+ // Process all remote skills — new-remote or change-detection
14
+ for (const remote of remoteSkills) {
15
+ const stored = storedHashes[remote.name];
16
+ const local = localByName.get(remote.name);
17
+ const remoteHash = contentHash(remote.content);
18
+ if (!stored) {
19
+ // New remote skill — never seen before
20
+ plan.pulls.push({
21
+ name: remote.name,
22
+ action: 'new-remote',
23
+ remoteContent: remote.content,
24
+ source: remote.source,
25
+ remoteId: remote.remoteId,
26
+ appId: remote.appId,
27
+ });
28
+ continue;
29
+ }
30
+ const localHash = local ? contentHash(local.content) : null;
31
+ const localChanged = localHash !== null && localHash !== stored.localHash;
32
+ const remoteChanged = remoteHash !== stored.remoteHash;
33
+ if (!local) {
34
+ // Local file was deleted — restore from remote
35
+ plan.pulls.push({
36
+ name: remote.name,
37
+ action: 'pull',
38
+ remoteContent: remote.content,
39
+ source: remote.source,
40
+ remoteId: remote.remoteId,
41
+ appId: remote.appId,
42
+ });
43
+ continue;
44
+ }
45
+ if (!localChanged && !remoteChanged) {
46
+ // Nothing changed
47
+ plan.skips.push({
48
+ name: remote.name,
49
+ action: 'skip',
50
+ source: remote.source,
51
+ remoteId: remote.remoteId,
52
+ appId: remote.appId,
53
+ });
54
+ continue;
55
+ }
56
+ if (!localChanged && remoteChanged) {
57
+ // Only remote changed
58
+ plan.pulls.push({
59
+ name: remote.name,
60
+ action: 'pull',
61
+ localContent: local.content,
62
+ remoteContent: remote.content,
63
+ source: remote.source,
64
+ remoteId: remote.remoteId,
65
+ appId: remote.appId,
66
+ });
67
+ continue;
68
+ }
69
+ if (localChanged && !remoteChanged) {
70
+ if (remote.source === 'external') {
71
+ // Only local changed and skill is external — push
72
+ plan.pushes.push({
73
+ name: remote.name,
74
+ action: 'push',
75
+ localContent: local.content,
76
+ remoteContent: remote.content,
77
+ source: remote.source,
78
+ remoteId: remote.remoteId,
79
+ appId: remote.appId,
80
+ });
81
+ }
82
+ else {
83
+ // App skill — overwrite local with remote (read-only)
84
+ plan.pulls.push({
85
+ name: remote.name,
86
+ action: 'pull',
87
+ localContent: local.content,
88
+ remoteContent: remote.content,
89
+ source: remote.source,
90
+ remoteId: remote.remoteId,
91
+ appId: remote.appId,
92
+ });
93
+ }
94
+ continue;
95
+ }
96
+ // Both changed
97
+ if (remote.source === 'external') {
98
+ plan.conflicts.push({
99
+ name: remote.name,
100
+ action: 'conflict',
101
+ localContent: local.content,
102
+ remoteContent: remote.content,
103
+ source: remote.source,
104
+ remoteId: remote.remoteId,
105
+ appId: remote.appId,
106
+ });
107
+ }
108
+ else {
109
+ // App skill always wins
110
+ plan.pulls.push({
111
+ name: remote.name,
112
+ action: 'pull',
113
+ localContent: local.content,
114
+ remoteContent: remote.content,
115
+ source: remote.source,
116
+ remoteId: remote.remoteId,
117
+ appId: remote.appId,
118
+ });
119
+ }
120
+ }
121
+ // Process stored skills that no longer exist on remote — deleted remotely
122
+ for (const [name, stored] of Object.entries(storedHashes)) {
123
+ if (!remoteByName.has(name)) {
124
+ const local = localByName.get(name);
125
+ plan.deletions.push({
126
+ name,
127
+ action: 'deleted-remote',
128
+ localContent: local?.content,
129
+ source: stored.source,
130
+ remoteId: stored.remoteId,
131
+ appId: stored.appId,
132
+ });
133
+ }
134
+ }
135
+ return plan;
136
+ }
@@ -0,0 +1,5 @@
1
+ import type { SyncPlan, SkillSyncAction } from './types.js';
2
+ export declare function printSyncSummary(plan: SyncPlan): void;
3
+ export type ConflictResolution = 'local' | 'remote' | 'skip';
4
+ export declare function resolveConflict(action: SkillSyncAction): Promise<ConflictResolution>;
5
+ export declare function resolveConflictNonInteractive(prefer: 'local' | 'remote'): ConflictResolution;
@@ -0,0 +1,78 @@
1
+ import { promptSelect } from '../utils/prompt.js';
2
+ import { bold, dim, cyan, yellow, green } from '../ui/colors.js';
3
+ export function printSyncSummary(plan) {
4
+ const pullCount = plan.pulls.length;
5
+ const pushCount = plan.pushes.length;
6
+ const conflictCount = plan.conflicts.length;
7
+ const deleteCount = plan.deletions.length;
8
+ const skipCount = plan.skips.length;
9
+ console.log('');
10
+ console.log(bold('Sync summary:') + ` ${pullCount} to pull, ${pushCount} to push, ${conflictCount} conflict${conflictCount !== 1 ? 's' : ''}, ${deleteCount} to delete, ${skipCount} up to date`);
11
+ console.log('');
12
+ for (const s of plan.pulls) {
13
+ const label = s.action === 'new-remote' ? 'new' : 'pull';
14
+ console.log(` ${green(`[${label}]`.padEnd(8))} ${s.name.padEnd(28)} ${dim('remote updated')}`);
15
+ }
16
+ for (const s of plan.pushes) {
17
+ console.log(` ${cyan('[push]'.padEnd(8))} ${s.name.padEnd(28)} ${dim('local changes')}`);
18
+ }
19
+ for (const s of plan.conflicts) {
20
+ console.log(` ${yellow('[!!]'.padEnd(8))} ${s.name.padEnd(28)} ${dim('modified both locally and remotely')}`);
21
+ }
22
+ for (const s of plan.deletions) {
23
+ console.log(` ${dim('[del]'.padEnd(8))} ${s.name.padEnd(28)} ${dim('removed from workspace')}`);
24
+ }
25
+ console.log('');
26
+ }
27
+ export async function resolveConflict(action) {
28
+ console.log(`\n${bold(`Conflict: "${action.name}"`)} modified both locally and remotely.\n`);
29
+ if (action.localContent && action.remoteContent) {
30
+ const localLines = action.localContent.split('\n').length;
31
+ const remoteLines = action.remoteContent.split('\n').length;
32
+ console.log(` Local: ${localLines} lines`);
33
+ console.log(` Remote: ${remoteLines} lines`);
34
+ console.log('');
35
+ }
36
+ const choice = await promptSelect('Resolution:', [
37
+ { label: 'Keep local version and push to workspace', value: 'local' },
38
+ { label: 'Keep remote version and overwrite local', value: 'remote' },
39
+ { label: 'Show diff', value: 'diff' },
40
+ { label: 'Skip (resolve later)', value: 'skip' },
41
+ ]);
42
+ if (choice.value === 'diff') {
43
+ printDiff(action.localContent || '', action.remoteContent || '');
44
+ const choice2 = await promptSelect('After reviewing diff:', [
45
+ { label: 'Keep local version and push to workspace', value: 'local' },
46
+ { label: 'Keep remote version and overwrite local', value: 'remote' },
47
+ { label: 'Skip (resolve later)', value: 'skip' },
48
+ ]);
49
+ return choice2.value;
50
+ }
51
+ return choice.value;
52
+ }
53
+ function printDiff(local, remote) {
54
+ const localLines = local.split('\n');
55
+ const remoteLines = remote.split('\n');
56
+ const maxLen = Math.max(localLines.length, remoteLines.length);
57
+ console.log('');
58
+ console.log(bold('--- Local'));
59
+ console.log(bold('+++ Remote'));
60
+ console.log('');
61
+ for (let i = 0; i < maxLen; i++) {
62
+ const l = localLines[i];
63
+ const r = remoteLines[i];
64
+ if (l === r) {
65
+ console.log(dim(` ${l ?? ''}`));
66
+ }
67
+ else {
68
+ if (l !== undefined)
69
+ console.log(cyan(`- ${l}`));
70
+ if (r !== undefined)
71
+ console.log(green(`+ ${r}`));
72
+ }
73
+ }
74
+ console.log('');
75
+ }
76
+ export function resolveConflictNonInteractive(prefer) {
77
+ return prefer;
78
+ }
@@ -0,0 +1,21 @@
1
+ import type { ApiClient } from '../api/client.js';
2
+ import type { AgentAdapter } from '../agents/types.js';
3
+ import type { SyncPlan } from './types.js';
4
+ interface ExecutorContext {
5
+ client: ApiClient;
6
+ workspaceId: string;
7
+ adapters: AgentAdapter[];
8
+ scopes: Array<'project' | 'user'>;
9
+ }
10
+ /**
11
+ * Execute the resolved sync plan: pull remote skills, push local skills,
12
+ * delete removed skills. Returns updated skillHashes for state persistence.
13
+ */
14
+ export declare function executeSyncPlan(plan: SyncPlan, resolvedConflicts: Map<string, 'local' | 'remote'>, ctx: ExecutorContext): Promise<Record<string, {
15
+ localHash: string;
16
+ remoteHash: string;
17
+ source: 'external' | 'app';
18
+ remoteId?: string;
19
+ appId?: string;
20
+ }>>;
21
+ export {};
@@ -0,0 +1,98 @@
1
+ import { contentHash } from './hash.js';
2
+ /**
3
+ * Execute the resolved sync plan: pull remote skills, push local skills,
4
+ * delete removed skills. Returns updated skillHashes for state persistence.
5
+ */
6
+ export async function executeSyncPlan(plan, resolvedConflicts, ctx) {
7
+ const newHashes = {};
8
+ // Process pulls
9
+ for (const action of plan.pulls) {
10
+ if (!action.remoteContent)
11
+ continue;
12
+ const hash = contentHash(action.remoteContent);
13
+ writeSkillToAgents(action.name, action.remoteContent, ctx);
14
+ newHashes[action.name] = {
15
+ localHash: hash,
16
+ remoteHash: hash,
17
+ source: action.source,
18
+ remoteId: action.remoteId,
19
+ appId: action.appId,
20
+ };
21
+ console.log(` Pulled: ${action.name}`);
22
+ }
23
+ // Process pushes
24
+ for (const action of plan.pushes) {
25
+ if (!action.localContent || !action.remoteId)
26
+ continue;
27
+ await ctx.client.updateExternalSkill(ctx.workspaceId, action.remoteId, {
28
+ name: action.name,
29
+ description: extractDescription(action.localContent),
30
+ content: stripFrontmatter(action.localContent),
31
+ });
32
+ const hash = contentHash(action.localContent);
33
+ newHashes[action.name] = {
34
+ localHash: hash,
35
+ remoteHash: hash,
36
+ source: 'external',
37
+ remoteId: action.remoteId,
38
+ };
39
+ console.log(` Pushed: ${action.name}`);
40
+ }
41
+ // Process resolved conflicts
42
+ for (const action of plan.conflicts) {
43
+ const resolution = resolvedConflicts.get(action.name);
44
+ if (!resolution)
45
+ continue;
46
+ if (resolution === 'local' && action.localContent && action.remoteId) {
47
+ await ctx.client.updateExternalSkill(ctx.workspaceId, action.remoteId, {
48
+ name: action.name,
49
+ description: extractDescription(action.localContent),
50
+ content: stripFrontmatter(action.localContent),
51
+ });
52
+ const hash = contentHash(action.localContent);
53
+ newHashes[action.name] = { localHash: hash, remoteHash: hash, source: 'external', remoteId: action.remoteId };
54
+ console.log(` Pushed (conflict resolved): ${action.name}`);
55
+ }
56
+ else if (resolution === 'remote' && action.remoteContent) {
57
+ writeSkillToAgents(action.name, action.remoteContent, ctx);
58
+ const hash = contentHash(action.remoteContent);
59
+ newHashes[action.name] = { localHash: hash, remoteHash: hash, source: 'external', remoteId: action.remoteId };
60
+ console.log(` Pulled (conflict resolved): ${action.name}`);
61
+ }
62
+ }
63
+ // Process skips -- preserve current state
64
+ for (const _action of plan.skips) {
65
+ // Skips don't change hashes -- caller preserves existing state
66
+ }
67
+ // Process deletions -- not added to newHashes = removed from state
68
+ for (const action of plan.deletions) {
69
+ console.log(` Deleted locally: ${action.name}`);
70
+ }
71
+ return newHashes;
72
+ }
73
+ function writeSkillToAgents(name, content, ctx) {
74
+ const skillFile = {
75
+ name,
76
+ filename: name.toLowerCase().replace(/[^a-z0-9]+/g, '-'),
77
+ content,
78
+ description: extractDescription(content),
79
+ };
80
+ for (const adapter of ctx.adapters) {
81
+ for (const scope of ctx.scopes) {
82
+ if (!adapter.supportsSkills())
83
+ continue;
84
+ try {
85
+ adapter.writeSkills([skillFile], scope);
86
+ }
87
+ catch { /* skip failing adapters */ }
88
+ }
89
+ }
90
+ }
91
+ function extractDescription(content) {
92
+ const match = content.match(/^---\n[\s\S]*?description:\s*(.+)\n[\s\S]*?---/);
93
+ return match ? match[1].trim() : '';
94
+ }
95
+ function stripFrontmatter(content) {
96
+ const match = content.match(/^---\n[\s\S]*?\n---\n([\s\S]*)$/);
97
+ return match ? match[1] : content;
98
+ }
@@ -0,0 +1 @@
1
+ export declare function contentHash(content: string): string;
@@ -0,0 +1,4 @@
1
+ import { createHash } from 'crypto';
2
+ export function contentHash(content) {
3
+ return 'sha256:' + createHash('sha256').update(content).digest('hex');
4
+ }
@@ -0,0 +1,24 @@
1
+ export interface SkillHashState {
2
+ localHash: string;
3
+ remoteHash: string;
4
+ source: 'external' | 'app';
5
+ remoteId?: string;
6
+ appId?: string;
7
+ }
8
+ export type SkillSyncActionType = 'pull' | 'push' | 'conflict' | 'skip' | 'new-local' | 'new-remote' | 'deleted-remote';
9
+ export interface SkillSyncAction {
10
+ name: string;
11
+ action: SkillSyncActionType;
12
+ localContent?: string;
13
+ remoteContent?: string;
14
+ source: 'external' | 'app';
15
+ remoteId?: string;
16
+ appId?: string;
17
+ }
18
+ export interface SyncPlan {
19
+ pulls: SkillSyncAction[];
20
+ pushes: SkillSyncAction[];
21
+ conflicts: SkillSyncAction[];
22
+ skips: SkillSyncAction[];
23
+ deletions: SkillSyncAction[];
24
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/types.d.ts CHANGED
@@ -27,6 +27,7 @@ export interface AppInfo {
27
27
  export interface WorkspaceInfo {
28
28
  id: string;
29
29
  name: string;
30
+ slug?: string;
30
31
  }
31
32
  export interface RegistryEntity {
32
33
  entityName: string;
@@ -93,6 +94,7 @@ export interface WorkspaceSkill {
93
94
  type: 'app' | 'external' | 'mcp';
94
95
  appId?: string;
95
96
  mcpServerId?: string;
97
+ content?: string;
96
98
  }
97
99
  export interface ExternalSkillRegistration {
98
100
  id: string;
@@ -122,11 +124,21 @@ export interface McpServerConfig {
122
124
  export interface SetupState {
123
125
  workspaceId: string;
124
126
  workspaceName: string;
127
+ workspaceSlug?: string;
125
128
  configuredAgents: string[];
126
129
  scope: 'project' | 'user' | 'both';
127
130
  lastSyncAt: string;
128
131
  mcpServers: string[];
129
132
  skills: string[];
133
+ skillHashes?: Record<string, {
134
+ localHash: string;
135
+ remoteHash: string;
136
+ source: 'external' | 'app';
137
+ remoteId?: string;
138
+ appId?: string;
139
+ }>;
140
+ reportedAgentSlugs?: string[];
141
+ lastHealthReportAt?: string;
130
142
  }
131
143
  export interface WorkflowInfo {
132
144
  name: string;
@@ -1,4 +1,4 @@
1
- import { describe, it, expect } from 'vitest';
1
+ import { describe, it, expect, vi } from 'vitest';
2
2
  import { getAgentCommand, SUPPORTED_AGENTS, getDevBanner, getKeyboardHints, getWelcomeBanner, getInfoPanel } from '../banner.js';
3
3
  import { stripAnsi } from '../colors.js';
4
4
  describe('getAgentCommand', () => {
@@ -80,3 +80,19 @@ describe('getWelcomeBanner', () => {
80
80
  expect(text).toContain('Claude');
81
81
  });
82
82
  });
83
+ describe('runAgentWizard', () => {
84
+ it('prints guidance text without prompting in non-TTY', async () => {
85
+ const { runAgentWizard } = await import('../banner.js');
86
+ const originalIsTTY = process.stdout.isTTY;
87
+ Object.defineProperty(process.stdout, 'isTTY', { value: false, writable: true });
88
+ const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
89
+ await runAgentWizard('/test/dir');
90
+ const output = consoleSpy.mock.calls.map(c => c[0]).join('\n');
91
+ const plain = stripAnsi(output);
92
+ expect(plain).toContain('Claude Code');
93
+ expect(plain).toContain('Cursor');
94
+ expect(plain).toContain('/test/dir');
95
+ consoleSpy.mockRestore();
96
+ Object.defineProperty(process.stdout, 'isTTY', { value: originalIsTTY, writable: true });
97
+ });
98
+ });