@clickminded/coauthor-cli 0.0.21 → 0.0.23
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/README.md +61 -175
- package/dist/commands.js +278 -87
- package/dist/parser.js +1 -0
- package/package.json +1 -1
- package/scripts/build-cursor-rule.mjs +58 -0
- package/scripts/postinstall.mjs +60 -48
- package/scripts/verify-skill-sync.mjs +50 -42
- package/skills/coauthor/SKILL.md +62 -0
- package/skills/coauthor/references/brief-and-contract.md +151 -0
- package/skills/coauthor/references/credits-and-plans.md +26 -0
- package/skills/coauthor/references/editing-drafts.md +59 -0
- package/skills/coauthor/references/images-and-social.md +28 -0
- package/skills/coauthor/references/publishing-and-export.md +37 -0
- package/skills/coauthor/references/troubleshooting.md +45 -0
- package/skills/cursor/coauthor-cli.mdc +322 -139
- package/skills/agents/SKILL.md +0 -274
- package/skills/claude/SKILL.md +0 -274
- package/skills/codex/SKILL.md +0 -274
package/dist/commands.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { setTimeout as sleep } from 'node:timers/promises';
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
3
|
import { createHash } from 'node:crypto';
|
|
4
|
-
import {
|
|
4
|
+
import { existsSync } from 'node:fs';
|
|
5
|
+
import { mkdir, readFile, readdir, writeFile } from 'node:fs/promises';
|
|
5
6
|
import { homedir } from 'node:os';
|
|
6
7
|
import { dirname, join, resolve } from 'node:path';
|
|
7
8
|
import { fileURLToPath } from 'node:url';
|
|
@@ -527,7 +528,15 @@ async function runDraftReviseCommand(projectId, input, context) {
|
|
|
527
528
|
};
|
|
528
529
|
}
|
|
529
530
|
if (getResponseValue(revision, 'awaiting_review') !== true) {
|
|
530
|
-
|
|
531
|
+
// No changes usually means CoAuthor asked a question or explained why it
|
|
532
|
+
// did not edit. Show its reply so the caller can answer or rephrase.
|
|
533
|
+
const reply = getResponseString(revision, 'assistant_message');
|
|
534
|
+
return {
|
|
535
|
+
ok: true,
|
|
536
|
+
status: 'no_changes',
|
|
537
|
+
message: `Revision ${revisionId} finished as ${getResponseString(revision, 'state') ?? 'unknown'} with no changes to review.${reply ? `\nCoAuthor replied: ${reply}` : ''}`,
|
|
538
|
+
data: revision,
|
|
539
|
+
};
|
|
531
540
|
}
|
|
532
541
|
if (getBoolean(input.values, 'apply')) {
|
|
533
542
|
const applied = await applyRevision(context.client, projectId, revisionId, input);
|
|
@@ -690,98 +699,208 @@ async function runOperationCommand(action, input, client) {
|
|
|
690
699
|
}
|
|
691
700
|
throw new Error('Usage: coauthor operation <list|show|status>');
|
|
692
701
|
}
|
|
693
|
-
const SKILL_NAMES = ['
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
702
|
+
const SKILL_NAMES = ['claude', 'codex', 'agents', 'cursor'];
|
|
703
|
+
const AGENT_LABELS = {
|
|
704
|
+
claude: 'Claude Code',
|
|
705
|
+
codex: 'Codex',
|
|
706
|
+
agents: 'Agents (.agents/skills)',
|
|
707
|
+
cursor: 'Cursor',
|
|
699
708
|
};
|
|
709
|
+
// Relative to dist/commands.js (and src/commands.ts) inside the package.
|
|
710
|
+
const SKILL_TEMPLATE_DIR = '../skills/coauthor';
|
|
711
|
+
const CURSOR_TEMPLATE = '../skills/cursor/coauthor-cli.mdc';
|
|
700
712
|
async function runSkillsCommand(action, input) {
|
|
713
|
+
const cwd = resolve(getString(input.values, 'cwd') ?? process.cwd());
|
|
714
|
+
const scope = parseSkillScope(getString(input.values, 'scope'));
|
|
701
715
|
if (!action || action === 'list') {
|
|
702
|
-
const
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
})),
|
|
710
|
-
},
|
|
711
|
-
};
|
|
716
|
+
const skills = [];
|
|
717
|
+
for (const skill of SKILL_NAMES) {
|
|
718
|
+
const target = skillTarget(skill, skill === 'cursor' ? 'project' : scope ?? 'user', cwd);
|
|
719
|
+
skills.push({ skill, agent: AGENT_LABELS[skill], scope: target.scope, path: target.path, status: await skillStatus(skill, target.path) });
|
|
720
|
+
}
|
|
721
|
+
const legacy = await legacyProjectCopies(cwd);
|
|
722
|
+
return { ok: true, data: { skills, ...(legacy.length > 0 ? { project_copies: legacy } : {}) } };
|
|
712
723
|
}
|
|
713
724
|
if (action === 'install') {
|
|
714
|
-
const
|
|
715
|
-
const skills = resolveRequestedSkills(requested);
|
|
716
|
-
const cwd = resolve(getString(input.values, 'cwd') ?? process.cwd());
|
|
725
|
+
const skills = resolveRequestedSkills(input.positionals[0]);
|
|
717
726
|
const force = getBoolean(input.values, 'force');
|
|
718
727
|
const dryRun = getBoolean(input.values, 'dry-run');
|
|
719
728
|
const results = [];
|
|
720
729
|
for (const skill of skills) {
|
|
721
|
-
results.push(await installSkill({ skill, cwd, force, dryRun }));
|
|
730
|
+
results.push(await installSkill({ skill, scope: scope ?? 'user', cwd, force, dryRun }));
|
|
722
731
|
}
|
|
732
|
+
const warnings = (scope ?? 'user') === 'user'
|
|
733
|
+
? (await legacyProjectCopies(cwd)).map((copy) => `An older project-level copy is at ${copy.path}. Your agent may load both; delete it, or update it with \`coauthor skills install ${copy.skill} --scope project\`.`)
|
|
734
|
+
: [];
|
|
723
735
|
return {
|
|
724
736
|
ok: true,
|
|
725
|
-
message:
|
|
726
|
-
data: { results },
|
|
737
|
+
message: formatSkillInstallMessage(results, warnings, dryRun),
|
|
738
|
+
data: { results, ...(warnings.length > 0 ? { warnings } : {}) },
|
|
727
739
|
};
|
|
728
740
|
}
|
|
729
|
-
throw new Error('Usage: coauthor skills <list|install> [codex|
|
|
741
|
+
throw new Error('Usage: coauthor skills <list|install> [claude|codex|agents|cursor|all] [--scope user|project]');
|
|
742
|
+
}
|
|
743
|
+
function parseSkillScope(value) {
|
|
744
|
+
if (value === undefined)
|
|
745
|
+
return null;
|
|
746
|
+
if (value === 'user' || value === 'project')
|
|
747
|
+
return value;
|
|
748
|
+
throw new Error('--scope must be user or project');
|
|
730
749
|
}
|
|
750
|
+
// No target: install for the agents this machine has (Claude Code, Codex),
|
|
751
|
+
// falling back to Claude Code. Cursor and .agents are opt-in.
|
|
731
752
|
function resolveRequestedSkills(value) {
|
|
732
|
-
if (!value
|
|
733
|
-
|
|
734
|
-
|
|
753
|
+
if (!value) {
|
|
754
|
+
const detected = ['claude', 'codex'].filter((skill) => existsSync(join(homedir(), `.${skill}`)));
|
|
755
|
+
return detected.length > 0 ? [...detected] : ['claude'];
|
|
756
|
+
}
|
|
757
|
+
if (value === 'all')
|
|
758
|
+
return ['claude', 'codex', 'agents'];
|
|
759
|
+
if (SKILL_NAMES.includes(value))
|
|
735
760
|
return [value];
|
|
736
|
-
throw new Error('Usage: coauthor skills install
|
|
761
|
+
throw new Error('Usage: coauthor skills install [claude|codex|agents|cursor|all] [--scope user|project]');
|
|
762
|
+
}
|
|
763
|
+
function skillTarget(skill, scope, cwd) {
|
|
764
|
+
if (skill === 'cursor')
|
|
765
|
+
return { path: join(cwd, '.cursor', 'rules', 'coauthor-cli.mdc'), scope: 'project' };
|
|
766
|
+
if (skill === 'codex') {
|
|
767
|
+
if (scope === 'project')
|
|
768
|
+
throw new Error('Codex skills install per user. Run `coauthor skills install codex` without --scope project.');
|
|
769
|
+
return { path: join(homedir(), '.codex', 'skills', 'coauthor'), scope: 'user' };
|
|
770
|
+
}
|
|
771
|
+
const base = scope === 'project' ? cwd : homedir();
|
|
772
|
+
return { path: join(base, skill === 'claude' ? '.claude' : '.agents', 'skills', 'coauthor'), scope };
|
|
773
|
+
}
|
|
774
|
+
async function skillTemplates(skill) {
|
|
775
|
+
if (skill === 'cursor')
|
|
776
|
+
return [{ template: CURSOR_TEMPLATE, relative: '' }];
|
|
777
|
+
const root = templatePath(SKILL_TEMPLATE_DIR);
|
|
778
|
+
return (await listFiles(root)).map((file) => ({ template: `${SKILL_TEMPLATE_DIR}/${file}`, relative: file }));
|
|
779
|
+
}
|
|
780
|
+
async function listFiles(dir, prefix = '') {
|
|
781
|
+
const files = [];
|
|
782
|
+
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
783
|
+
const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
784
|
+
if (entry.isDirectory())
|
|
785
|
+
files.push(...await listFiles(join(dir, entry.name), relativePath));
|
|
786
|
+
else
|
|
787
|
+
files.push(relativePath);
|
|
788
|
+
}
|
|
789
|
+
return files.sort();
|
|
737
790
|
}
|
|
738
|
-
function
|
|
739
|
-
return
|
|
791
|
+
function templatePath(template) {
|
|
792
|
+
return fileURLToPath(new URL(template, import.meta.url));
|
|
740
793
|
}
|
|
741
794
|
async function installSkill(params) {
|
|
742
|
-
const
|
|
743
|
-
const
|
|
744
|
-
const
|
|
745
|
-
const
|
|
746
|
-
|
|
747
|
-
const
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
795
|
+
const target = skillTarget(params.skill, params.scope, params.cwd);
|
|
796
|
+
const registry = await readManagedSkillRegistry();
|
|
797
|
+
const files = [];
|
|
798
|
+
for (const { template, relative } of await skillTemplates(params.skill)) {
|
|
799
|
+
const path = relative ? join(target.path, ...relative.split('/')) : target.path;
|
|
800
|
+
const contents = await readFile(templatePath(template), 'utf8');
|
|
801
|
+
const templateHash = sha256(contents);
|
|
802
|
+
const current = await readFile(path, 'utf8').catch((error) => isMissingFileError(error) ? null : Promise.reject(error));
|
|
803
|
+
const currentHash = current === null ? null : sha256(current);
|
|
804
|
+
const managed = registry.skills.find((entry) => entry.path === path);
|
|
805
|
+
let status;
|
|
806
|
+
if (currentHash === templateHash)
|
|
807
|
+
status = 'unchanged';
|
|
808
|
+
else if (current === null)
|
|
809
|
+
status = 'installed';
|
|
810
|
+
// Overwrite a file only when it is the copy we wrote earlier (or --force),
|
|
811
|
+
// so local edits survive upgrades.
|
|
812
|
+
else if (params.force || managed?.templateHash === currentHash)
|
|
813
|
+
status = 'updated';
|
|
814
|
+
else
|
|
815
|
+
status = 'skipped';
|
|
816
|
+
if (params.dryRun) {
|
|
817
|
+
files.push({ path, status: status === 'unchanged' || status === 'skipped' ? status : 'dry_run' });
|
|
818
|
+
continue;
|
|
755
819
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
820
|
+
if (status === 'installed' || status === 'updated') {
|
|
821
|
+
await mkdir(dirname(path), { recursive: true });
|
|
822
|
+
await writeFile(path, contents, { mode: 0o644 });
|
|
823
|
+
}
|
|
824
|
+
if (status !== 'skipped')
|
|
825
|
+
await recordManagedSkill({ skill: params.skill, path, template, templateHash });
|
|
826
|
+
files.push({ path, status });
|
|
760
827
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
828
|
+
const statuses = new Set(files.map((file) => file.status));
|
|
829
|
+
const status = statuses.has('skipped')
|
|
830
|
+
? 'skipped'
|
|
831
|
+
: statuses.has('dry_run')
|
|
832
|
+
? 'dry_run'
|
|
833
|
+
: statuses.has('updated')
|
|
834
|
+
? 'updated'
|
|
835
|
+
: statuses.has('installed')
|
|
836
|
+
? 'installed'
|
|
837
|
+
: 'unchanged';
|
|
838
|
+
return {
|
|
764
839
|
skill: params.skill,
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
}
|
|
771
|
-
function getSkillTemplatePath(skill) {
|
|
772
|
-
return fileURLToPath(new URL(getSkillTemplateRelativePath(skill), import.meta.url));
|
|
773
|
-
}
|
|
774
|
-
function getSkillTemplateRelativePath(skill) {
|
|
775
|
-
return SKILL_TEMPLATE_PATHS[skill];
|
|
840
|
+
scope: target.scope,
|
|
841
|
+
path: target.path,
|
|
842
|
+
status,
|
|
843
|
+
files,
|
|
844
|
+
...(status === 'skipped' ? { note: 'Some files have local changes and were left alone. Re-run with --force to overwrite them.' } : {}),
|
|
845
|
+
};
|
|
776
846
|
}
|
|
777
|
-
function
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
847
|
+
async function skillStatus(skill, root) {
|
|
848
|
+
const registry = await readManagedSkillRegistry();
|
|
849
|
+
let present = 0;
|
|
850
|
+
let outdated = false;
|
|
851
|
+
let modified = false;
|
|
852
|
+
for (const { template, relative } of await skillTemplates(skill)) {
|
|
853
|
+
const path = relative ? join(root, ...relative.split('/')) : root;
|
|
854
|
+
const current = await readFile(path, 'utf8').catch(() => null);
|
|
855
|
+
if (current === null) {
|
|
856
|
+
outdated = true;
|
|
857
|
+
continue;
|
|
858
|
+
}
|
|
859
|
+
present += 1;
|
|
860
|
+
const currentHash = sha256(current);
|
|
861
|
+
if (currentHash === sha256(await readFile(templatePath(template), 'utf8')))
|
|
862
|
+
continue;
|
|
863
|
+
if (registry.skills.some((entry) => entry.path === path && entry.templateHash === currentHash))
|
|
864
|
+
outdated = true;
|
|
865
|
+
else
|
|
866
|
+
modified = true;
|
|
867
|
+
}
|
|
868
|
+
if (present === 0)
|
|
869
|
+
return 'missing';
|
|
870
|
+
if (modified)
|
|
871
|
+
return 'modified';
|
|
872
|
+
return outdated ? 'outdated' : 'current';
|
|
873
|
+
}
|
|
874
|
+
// Older CLI versions installed into the current repo. A user-level install
|
|
875
|
+
// next to one of those means the agent may load two different versions.
|
|
876
|
+
async function legacyProjectCopies(cwd) {
|
|
877
|
+
if (resolve(cwd) === resolve(homedir()))
|
|
878
|
+
return [];
|
|
879
|
+
const copies = [];
|
|
880
|
+
for (const skill of ['claude', 'agents']) {
|
|
881
|
+
const path = join(cwd, skill === 'claude' ? '.claude' : '.agents', 'skills', 'coauthor');
|
|
882
|
+
if (existsSync(join(path, 'SKILL.md')))
|
|
883
|
+
copies.push({ skill, path });
|
|
884
|
+
}
|
|
885
|
+
return copies;
|
|
886
|
+
}
|
|
887
|
+
function formatSkillInstallMessage(results, warnings, dryRun) {
|
|
888
|
+
const lines = results.map((result) => {
|
|
889
|
+
const verb = {
|
|
890
|
+
installed: 'installed at',
|
|
891
|
+
updated: 'updated at',
|
|
892
|
+
unchanged: 'already up to date at',
|
|
893
|
+
skipped: 'left unchanged (local edits) at',
|
|
894
|
+
dry_run: 'would be written to',
|
|
895
|
+
}[result.status];
|
|
896
|
+
return `${AGENT_LABELS[result.skill]}: CoAuthor skill ${verb} ${result.path}${result.note ? `\n ${result.note}` : ''}`;
|
|
897
|
+
});
|
|
898
|
+
if (!dryRun && results.some((result) => result.status === 'installed' || result.status === 'updated')) {
|
|
899
|
+
lines.push('', 'Next steps:', '1. Start a new agent session so it loads the skill.', '2. Sign in once with `coauthor auth login` if you have not already.', '3. Ask your agent: "Use CoAuthor to write a blog post about <your topic>."');
|
|
900
|
+
}
|
|
901
|
+
if (warnings.length > 0)
|
|
902
|
+
lines.push('', ...warnings);
|
|
903
|
+
return lines.join('\n');
|
|
785
904
|
}
|
|
786
905
|
async function recordManagedSkill(entry) {
|
|
787
906
|
const registry = await readManagedSkillRegistry();
|
|
@@ -811,7 +930,7 @@ async function readManagedSkillRegistry() {
|
|
|
811
930
|
version: 1,
|
|
812
931
|
skills: parsed.skills.filter((skill) => {
|
|
813
932
|
return Boolean(skill)
|
|
814
|
-
&&
|
|
933
|
+
&& SKILL_NAMES.includes(skill.skill)
|
|
815
934
|
&& typeof skill.path === 'string'
|
|
816
935
|
&& typeof skill.template === 'string'
|
|
817
936
|
&& typeof skill.templateHash === 'string';
|
|
@@ -832,17 +951,6 @@ function getManagedSkillRegistryPath() {
|
|
|
832
951
|
? resolve(process.env.COAUTHOR_MANAGED_SKILLS_REGISTRY)
|
|
833
952
|
: join(homedir(), '.config', 'coauthor', 'managed-skills.json');
|
|
834
953
|
}
|
|
835
|
-
async function fileExists(path) {
|
|
836
|
-
try {
|
|
837
|
-
await readFile(path);
|
|
838
|
-
return true;
|
|
839
|
-
}
|
|
840
|
-
catch (error) {
|
|
841
|
-
return isMissingFileError(error)
|
|
842
|
-
? false
|
|
843
|
-
: Promise.reject(error);
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
954
|
function isMissingFileError(error) {
|
|
847
955
|
return typeof error === 'object'
|
|
848
956
|
&& error !== null
|
|
@@ -1380,13 +1488,13 @@ export function helpResult(command = []) {
|
|
|
1380
1488
|
' thread list|show|create|generate|save',
|
|
1381
1489
|
' slideshow show|save',
|
|
1382
1490
|
' publish thread',
|
|
1383
|
-
' export list|
|
|
1491
|
+
' export list|wordpress',
|
|
1384
1492
|
' operation list|show|status',
|
|
1385
1493
|
' credits',
|
|
1386
1494
|
' share <project-id>',
|
|
1387
1495
|
' models list|preferences show|preferences set',
|
|
1388
1496
|
' skills list|install',
|
|
1389
|
-
' skills install
|
|
1497
|
+
' skills install [claude|codex|agents|cursor|all] [--scope user|project] (default: the agents on this machine, per user)',
|
|
1390
1498
|
].join('\n'),
|
|
1391
1499
|
};
|
|
1392
1500
|
}
|
|
@@ -1442,11 +1550,94 @@ function commandHelp(command) {
|
|
|
1442
1550
|
'Fails with 409 if the draft changed since you read it (re-read and reapply), or if the user edited it in the browser in the last 90 seconds (--force overrides).',
|
|
1443
1551
|
DRAFT_SAVE_SHAPE,
|
|
1444
1552
|
].join('\n'),
|
|
1553
|
+
project: [
|
|
1554
|
+
'Usage: coauthor project <create|list|show> [<project-id>] [--json]',
|
|
1555
|
+
'',
|
|
1556
|
+
'create: --title, --topic, --audience, --contract <json|@file>. list: --limit. show: one project.',
|
|
1557
|
+
].join('\n'),
|
|
1558
|
+
contract: [
|
|
1559
|
+
'Usage: coauthor contract <show|save|approve> <project-id> [--data <json|@file>] [--json]',
|
|
1560
|
+
'',
|
|
1561
|
+
'save replaces the brief ({"contract":{...}}); approve approves the saved brief. To have CoAuthor review it: coauthor workflow run <project-id> --target contract --briefing-mode strict --json',
|
|
1562
|
+
].join('\n'),
|
|
1563
|
+
outline: [
|
|
1564
|
+
'Usage: coauthor outline <show|generate|save|approve> <project-id> [--data <json|@file>] [--planning-model <id>] [--json]',
|
|
1565
|
+
'',
|
|
1566
|
+
'generate creates an outline without approving it (data.sections). show returns the saved outline (data.artifact).',
|
|
1567
|
+
'save replaces it with the complete list {"sections":[...]}; omitted sections are removed. approve approves the saved outline.',
|
|
1568
|
+
].join('\n'),
|
|
1569
|
+
'research-plan': [
|
|
1570
|
+
'Usage: coauthor research-plan <show|generate|save|approve> <project-id> [--data <json|@file>] [--planning-model <id>] [--json]',
|
|
1571
|
+
'',
|
|
1572
|
+
'generate requires an approved outline (data.research_tasks). show returns the saved plan (data.artifact).',
|
|
1573
|
+
'save replaces it with {"research_tasks":[...]}; approve approves the saved plan.',
|
|
1574
|
+
].join('\n'),
|
|
1575
|
+
research: [
|
|
1576
|
+
'Usage: coauthor research <run|status|structured> <project-id> [--wait] [--json]',
|
|
1577
|
+
].join('\n'),
|
|
1578
|
+
workflow: [
|
|
1579
|
+
'Usage: coauthor workflow <status|run|resume|rewind|approve> <project-id> [--target <contract|outline|research-plan|research|draft>] [--wait] [--json]',
|
|
1580
|
+
'',
|
|
1581
|
+
'run --target draft --wait runs every remaining step to a finished draft. resume continues research or draft after a timeout or pause.',
|
|
1582
|
+
].join('\n'),
|
|
1583
|
+
chat: [
|
|
1584
|
+
'Usage: coauthor chat <project-id> --message "..." [--stage <contract|outline|research-plan|draft>] [--json]',
|
|
1585
|
+
' coauthor chat show <project-id> [--json]',
|
|
1586
|
+
'',
|
|
1587
|
+
"Talk to CoAuthor about the project. The reply text is in data.text. Re-read the artifact afterwards: CoAuthor's summary can differ from what was saved.",
|
|
1588
|
+
].join('\n'),
|
|
1589
|
+
image: [
|
|
1590
|
+
'Usage: coauthor image <list|status|show|generate|edit|metadata> <project-id> [...] [--json]',
|
|
1591
|
+
'',
|
|
1592
|
+
'list: planned placeholders (use each id). generate/edit: --placeholder-id <id> [--edit-prompt "..."]. status: generation progress.',
|
|
1593
|
+
'metadata <project-id> <placeholder id>: --alt-text, --description, --file-slug.',
|
|
1594
|
+
].join('\n'),
|
|
1595
|
+
thread: [
|
|
1596
|
+
'Usage: coauthor thread <show|generate|save> <project-id> [--data <json|@file>] [--writing-model <id>] [--json]',
|
|
1597
|
+
'',
|
|
1598
|
+
'generate writes an X thread from the draft. show returns data.thread.posts and connected X accounts (data.social_accounts).',
|
|
1599
|
+
'save takes {"posts":[...], "destination_url"?, "selected_social_account_id"?}. Publish with: coauthor publish thread <project-id> --yes',
|
|
1600
|
+
].join('\n'),
|
|
1601
|
+
publish: [
|
|
1602
|
+
'Usage: coauthor publish thread <project-id> --yes [--json]',
|
|
1603
|
+
'',
|
|
1604
|
+
'Posts the X thread now. Needs a login with publish permission: coauthor auth login --with-publish',
|
|
1605
|
+
].join('\n'),
|
|
1606
|
+
export: [
|
|
1607
|
+
'Usage: coauthor export list <project-id> [--json]',
|
|
1608
|
+
' coauthor export wordpress <project-id> --yes --slug <slug> [--connection-id <id>] [--json]',
|
|
1609
|
+
'',
|
|
1610
|
+
'wordpress creates a draft post on the connected WordPress site and returns wordpress_edit_url.',
|
|
1611
|
+
'Needs a login with publish permission (coauthor auth login --with-publish). With several sites connected, the error lists their ids for --connection-id.',
|
|
1612
|
+
].join('\n'),
|
|
1613
|
+
share: [
|
|
1614
|
+
'Usage: coauthor share <project-id> [--json]',
|
|
1615
|
+
'',
|
|
1616
|
+
'Returns the public read-only link (data.share_url), creating it if needed. Anyone with the link can read the draft.',
|
|
1617
|
+
].join('\n'),
|
|
1618
|
+
credits: [
|
|
1619
|
+
'Usage: coauthor credits <project-id> [--json]',
|
|
1620
|
+
'',
|
|
1621
|
+
'Shows the plan, credits used and remaining this period, and the reset date.',
|
|
1622
|
+
].join('\n'),
|
|
1623
|
+
'skills install': [
|
|
1624
|
+
'Usage: coauthor skills install [claude|codex|agents|cursor|all] [--scope user|project] [--force] [--dry-run] [--json]',
|
|
1625
|
+
'',
|
|
1626
|
+
'With no target, installs the CoAuthor skill for the agents on this machine (Claude Code, Codex) in your user folder.',
|
|
1627
|
+
'--scope project installs Claude or .agents skills into the current repo instead. Cursor rules are always per project.',
|
|
1628
|
+
'Files you edited are left alone unless you pass --force.',
|
|
1629
|
+
].join('\n'),
|
|
1630
|
+
'skills list': [
|
|
1631
|
+
'Usage: coauthor skills list [--scope user|project] [--json]',
|
|
1632
|
+
'',
|
|
1633
|
+
'Shows where the skill is installed for each agent and whether it is current, outdated, modified, or missing.',
|
|
1634
|
+
].join('\n'),
|
|
1445
1635
|
'draft revise': [
|
|
1446
|
-
'Usage: coauthor draft revise <project-id> --instruction "..." [--wait] [--apply] [--
|
|
1636
|
+
'Usage: coauthor draft revise <project-id> --instruction "..." [--wait] [--apply] [--json]',
|
|
1447
1637
|
'',
|
|
1448
1638
|
"CoAuthor's editor rewrites the draft from your instruction. With --wait the command returns the proposed changes as groups (before/after markdown) for you to review.",
|
|
1449
|
-
'Then: coauthor draft revision apply <project-id> <revision-id> [--accept
|
|
1639
|
+
'Then: coauthor draft revision apply <project-id> <revision-id> [--accept <group ids> | --reject <group ids>], or coauthor draft revision discard <project-id> <revision-id>.',
|
|
1640
|
+
'Group ids are the data.groups[].id values (review_...), comma-separated.',
|
|
1450
1641
|
'--apply applies every group as soon as the revision is ready. Only one revision can be open on a draft at a time.',
|
|
1451
1642
|
].join('\n'),
|
|
1452
1643
|
'draft revision': [
|
|
@@ -1481,5 +1672,5 @@ function commandHelp(command) {
|
|
|
1481
1672
|
'Generates a social thread from the saved draft.',
|
|
1482
1673
|
].join('\n'),
|
|
1483
1674
|
};
|
|
1484
|
-
return help[key] ?? help[command.slice(0, 2).join(' ')] ?? null;
|
|
1675
|
+
return help[key] ?? help[command.slice(0, 2).join(' ')] ?? help[command[0] ?? ''] ?? null;
|
|
1485
1676
|
}
|
package/dist/parser.js
CHANGED
|
@@ -65,6 +65,7 @@ const OPTIONS = {
|
|
|
65
65
|
'grounding-mode': { type: 'string' },
|
|
66
66
|
'image-generation-model': { type: 'string' },
|
|
67
67
|
instruction: { type: 'string' },
|
|
68
|
+
scope: { type: 'string' },
|
|
68
69
|
apply: { type: 'boolean', default: false },
|
|
69
70
|
accept: { type: 'string' },
|
|
70
71
|
reject: { type: 'string' },
|
package/package.json
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Builds the Cursor rule from the canonical skill (skills/coauthor). Cursor
|
|
3
|
+
// rules cannot load reference files on demand, so the references are appended
|
|
4
|
+
// as sections. `--check` exits non-zero when the committed rule is out of date.
|
|
5
|
+
|
|
6
|
+
import { readFile, readdir, writeFile } from 'node:fs/promises'
|
|
7
|
+
import { dirname, join } from 'node:path'
|
|
8
|
+
import { fileURLToPath } from 'node:url'
|
|
9
|
+
|
|
10
|
+
const packageRoot = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
11
|
+
const skillDir = join(packageRoot, 'skills', 'coauthor')
|
|
12
|
+
export const cursorRulePath = join(packageRoot, 'skills', 'cursor', 'coauthor-cli.mdc')
|
|
13
|
+
|
|
14
|
+
export async function buildCursorRule() {
|
|
15
|
+
const skill = await readFile(join(skillDir, 'SKILL.md'), 'utf8')
|
|
16
|
+
const match = /^---\n([\s\S]*?)\n---\n/.exec(skill)
|
|
17
|
+
if (!match) throw new Error('skills/coauthor/SKILL.md is missing its frontmatter')
|
|
18
|
+
const description = /^description: (.*)$/m.exec(match[1])?.[1]
|
|
19
|
+
if (!description) throw new Error('skills/coauthor/SKILL.md frontmatter has no description')
|
|
20
|
+
const body = skill.slice(match[0].length).trim()
|
|
21
|
+
const referenceNames = (await readdir(join(skillDir, 'references'))).filter((name) => name.endsWith('.md')).sort()
|
|
22
|
+
const references = await Promise.all(referenceNames.map(async (name) => {
|
|
23
|
+
const text = (await readFile(join(skillDir, 'references', name), 'utf8')).trim()
|
|
24
|
+
// Demote headings one level so each reference nests under its own section.
|
|
25
|
+
return `## references/${name}\n\n${text.replace(/^(#+) /gm, '#$1 ')}`
|
|
26
|
+
}))
|
|
27
|
+
return [
|
|
28
|
+
'---',
|
|
29
|
+
`description: ${description}`,
|
|
30
|
+
'alwaysApply: false',
|
|
31
|
+
'---',
|
|
32
|
+
'',
|
|
33
|
+
'<!-- Generated from skills/coauthor by scripts/build-cursor-rule.mjs. Do not edit by hand. -->',
|
|
34
|
+
'',
|
|
35
|
+
body,
|
|
36
|
+
'',
|
|
37
|
+
'# Reference sections',
|
|
38
|
+
'',
|
|
39
|
+
'The `references/*.md` files mentioned above are included below.',
|
|
40
|
+
'',
|
|
41
|
+
references.join('\n\n'),
|
|
42
|
+
'',
|
|
43
|
+
].join('\n')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
47
|
+
const rule = await buildCursorRule()
|
|
48
|
+
if (process.argv.includes('--check')) {
|
|
49
|
+
const current = await readFile(cursorRulePath, 'utf8').catch(() => '')
|
|
50
|
+
if (current !== rule) {
|
|
51
|
+
console.error('skills/cursor/coauthor-cli.mdc is out of date. Run: node scripts/build-cursor-rule.mjs')
|
|
52
|
+
process.exit(1)
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
await writeFile(cursorRulePath, rule)
|
|
56
|
+
console.log('Wrote skills/cursor/coauthor-cli.mdc')
|
|
57
|
+
}
|
|
58
|
+
}
|