diffcat-cli 0.2.1

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 (49) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/README.md +135 -0
  3. package/connectors/workbuddy/cli.json +11 -0
  4. package/connectors/workbuddy/connector-meta.json +22 -0
  5. package/connectors/workbuddy/icon.svg +11 -0
  6. package/connectors/workbuddy/skills/diffcat/SKILL.md +94 -0
  7. package/connectors/workbuddy/skills/diffcat/references/operations.md +64 -0
  8. package/connectors/workbuddy/skills/diffcat/references/safety.md +37 -0
  9. package/dist/client.d.ts +38 -0
  10. package/dist/client.js +199 -0
  11. package/dist/client.js.map +1 -0
  12. package/dist/config-store.d.ts +8 -0
  13. package/dist/config-store.js +100 -0
  14. package/dist/config-store.js.map +1 -0
  15. package/dist/credential-store.d.ts +4 -0
  16. package/dist/credential-store.js +37 -0
  17. package/dist/credential-store.js.map +1 -0
  18. package/dist/deployment.d.ts +5 -0
  19. package/dist/deployment.js +6 -0
  20. package/dist/deployment.js.map +1 -0
  21. package/dist/device-login.d.ts +6 -0
  22. package/dist/device-login.js +93 -0
  23. package/dist/device-login.js.map +1 -0
  24. package/dist/dpop.d.ts +12 -0
  25. package/dist/dpop.js +25 -0
  26. package/dist/dpop.js.map +1 -0
  27. package/dist/index.d.ts +2 -0
  28. package/dist/index.js +296 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/json-input.d.ts +1 -0
  31. package/dist/json-input.js +28 -0
  32. package/dist/json-input.js.map +1 -0
  33. package/dist/output.d.ts +2 -0
  34. package/dist/output.js +7 -0
  35. package/dist/output.js.map +1 -0
  36. package/dist/types.d.ts +37 -0
  37. package/dist/types.js +2 -0
  38. package/dist/types.js.map +1 -0
  39. package/package.json +42 -0
  40. package/plugins/diffcat/.codex-plugin/plugin.json +24 -0
  41. package/plugins/diffcat/README.md +45 -0
  42. package/plugins/diffcat/skills/diffcat/SKILL.md +41 -0
  43. package/plugins/diffcat/skills/diffcat/agents/openai.yaml +6 -0
  44. package/plugins/diffcat/skills/diffcat/references/authentication.md +75 -0
  45. package/plugins/diffcat/skills/diffcat/references/capabilities.md +75 -0
  46. package/plugins/diffcat/skills/diffcat/references/drafts-and-approvals.md +58 -0
  47. package/plugins/diffcat/skills/diffcat/references/querying.md +74 -0
  48. package/plugins/diffcat/skills/diffcat/references/recovery.md +44 -0
  49. package/scripts/codex-plugin.mjs +116 -0
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from 'node:child_process';
3
+ import { dirname, resolve } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ const PLUGIN = 'diffcat';
7
+ const MARKETPLACE = 'diffcat-cli';
8
+ const mode = process.argv[2];
9
+ const automatic = process.argv.includes('--automatic');
10
+ const json = process.argv.includes('--json');
11
+ const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
12
+
13
+ function commandCandidates() {
14
+ const override = process.env.DIFFCAT_CODEX_COMMAND?.trim();
15
+ if (override) return [override];
16
+ return process.platform === 'win32' ? ['codex.exe', 'codex.cmd', 'codex'] : ['codex'];
17
+ }
18
+
19
+ function runCodex(args) {
20
+ let missing = null;
21
+ for (const command of commandCandidates()) {
22
+ const result = spawnSync(command, args, {
23
+ encoding: 'utf8',
24
+ windowsHide: true,
25
+ });
26
+ if (result.error?.code === 'ENOENT') {
27
+ missing = result.error;
28
+ continue;
29
+ }
30
+ return result;
31
+ }
32
+ return { status: null, stdout: '', stderr: '', error: missing };
33
+ }
34
+
35
+ function detail(result) {
36
+ return String(result.stderr || result.stdout || result.error?.message || '')
37
+ .trim()
38
+ .slice(0, 1000);
39
+ }
40
+
41
+ function emit(result, exitCode = result.success ? 0 : 1) {
42
+ if (automatic) {
43
+ const line = result.success
44
+ ? `[diffcat] Codex Plugin ${mode === 'install' ? 'installed' : 'removed'} (${PLUGIN}@${MARKETPLACE}).`
45
+ : `[diffcat] Codex Plugin ${mode} skipped: ${result.message}. Run \`diffcat setup codex\` after Codex is available.`;
46
+ (result.success ? console.log : console.warn)(line);
47
+ process.exitCode = 0;
48
+ return;
49
+ }
50
+ if (json) console.log(JSON.stringify(result));
51
+ else (result.success ? console.log : console.error)(result.message);
52
+ process.exitCode = exitCode;
53
+ }
54
+
55
+ function failure(message, step, result) {
56
+ emit({
57
+ success: false,
58
+ integration: 'codex',
59
+ plugin: PLUGIN,
60
+ marketplace: MARKETPLACE,
61
+ step,
62
+ message,
63
+ detail: detail(result),
64
+ });
65
+ }
66
+
67
+ function install() {
68
+ const marketplace = runCodex(['plugin', 'marketplace', 'add', packageRoot, '--json']);
69
+ if (marketplace.error || marketplace.status !== 0) {
70
+ failure('无法登记 npm 包内的 Codex marketplace', 'marketplace_add', marketplace);
71
+ return;
72
+ }
73
+
74
+ const plugin = runCodex(['plugin', 'add', `${PLUGIN}@${MARKETPLACE}`]);
75
+ if (plugin.error || plugin.status !== 0) {
76
+ failure('marketplace 已登记,但 Codex Plugin 安装失败', 'plugin_add', plugin);
77
+ return;
78
+ }
79
+
80
+ emit({
81
+ success: true,
82
+ integration: 'codex',
83
+ plugin: PLUGIN,
84
+ marketplace: MARKETPLACE,
85
+ packageRoot,
86
+ message: 'DiffCat Codex Plugin 与 Companion Skill 已安装;请新建会话加载。',
87
+ });
88
+ }
89
+
90
+ function uninstall() {
91
+ const plugin = runCodex(['plugin', 'remove', `${PLUGIN}@${MARKETPLACE}`, '--json']);
92
+ const marketplace = runCodex(['plugin', 'marketplace', 'remove', MARKETPLACE]);
93
+ if (plugin.error || plugin.status !== 0 || marketplace.error || marketplace.status !== 0) {
94
+ const failed = plugin.error || plugin.status !== 0 ? plugin : marketplace;
95
+ failure('Codex Plugin 卸载清理未完整完成', 'uninstall', failed);
96
+ return;
97
+ }
98
+ emit({
99
+ success: true,
100
+ integration: 'codex',
101
+ plugin: PLUGIN,
102
+ marketplace: MARKETPLACE,
103
+ message: 'DiffCat Codex Plugin 登记已清理。',
104
+ });
105
+ }
106
+
107
+ if (mode === 'install') install();
108
+ else if (mode === 'uninstall') uninstall();
109
+ else
110
+ emit({
111
+ success: false,
112
+ integration: 'codex',
113
+ plugin: PLUGIN,
114
+ marketplace: MARKETPLACE,
115
+ message: '用法:codex-plugin.mjs <install|uninstall> [--automatic|--json]',
116
+ });