@synity/bitrix-skills 1.3.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 (77) hide show
  1. package/CHANGELOG.md +169 -0
  2. package/LICENSE +21 -0
  3. package/README.md +83 -0
  4. package/bin/bitrix-skills.js +3 -0
  5. package/dist/cli.js +1510 -0
  6. package/dist/features/bx-task/install.js +111 -0
  7. package/dist/features/task-sync/index.js +1053 -0
  8. package/package.json +69 -0
  9. package/src/features/bx/assets/SKILL.md +34 -0
  10. package/src/features/bx/feature.json +8 -0
  11. package/src/features/bx-calendar/assets/SKILL.md +61 -0
  12. package/src/features/bx-calendar/assets/availability.md +65 -0
  13. package/src/features/bx-calendar/assets/meeting.md +87 -0
  14. package/src/features/bx-calendar/assets/reminder.md +71 -0
  15. package/src/features/bx-calendar/assets/sync.md +70 -0
  16. package/src/features/bx-calendar/feature.json +10 -0
  17. package/src/features/bx-crm/assets/SKILL.md +59 -0
  18. package/src/features/bx-crm/assets/commerce.md +96 -0
  19. package/src/features/bx-crm/assets/onboard.md +127 -0
  20. package/src/features/bx-crm/assets/report.md +98 -0
  21. package/src/features/bx-crm/assets/research.md +71 -0
  22. package/src/features/bx-crm/feature.json +10 -0
  23. package/src/features/bx-task/assets/SKILL.md +148 -0
  24. package/src/features/bx-task/assets/lib/bx-api.sh +39 -0
  25. package/src/features/bx-task/assets/lib/bx-checklist.sh +127 -0
  26. package/src/features/bx-task/assets/lib/bx-resolve-task.sh +41 -0
  27. package/src/features/bx-task/assets/lib/bx-state.sh +131 -0
  28. package/src/features/bx-task/assets/lib/bx-tasks.sh +109 -0
  29. package/src/features/bx-task/assets/references/bootstrap.md +184 -0
  30. package/src/features/bx-task/assets/references/feature.md +97 -0
  31. package/src/features/bx-task/assets/references/init-templates/cli-tool.md +47 -0
  32. package/src/features/bx-task/assets/references/init-templates/generic.md +31 -0
  33. package/src/features/bx-task/assets/references/init-templates/library.md +45 -0
  34. package/src/features/bx-task/assets/references/init-templates/monorepo.md +38 -0
  35. package/src/features/bx-task/assets/references/init-templates/npm-package.md +40 -0
  36. package/src/features/bx-task/assets/references/init-templates/web-app.md +46 -0
  37. package/src/features/bx-task/assets/references/init.md +107 -0
  38. package/src/features/bx-task/assets/references/roadmap.md +93 -0
  39. package/src/features/bx-task/assets/references/summary.md +269 -0
  40. package/src/features/bx-task/assets/references/sync.md +104 -0
  41. package/src/features/bx-task/assets/references/time-log.md +214 -0
  42. package/src/features/bx-task/feature.json +10 -0
  43. package/src/features/bx-task/install.ts +117 -0
  44. package/src/features/task-sync/assets/docs/bitrix-task-reference.md +318 -0
  45. package/src/features/task-sync/assets/docs/bitrix-task-sync.md +254 -0
  46. package/src/features/task-sync/assets/githooks/commit-msg +44 -0
  47. package/src/features/task-sync/assets/githooks/install.sh +15 -0
  48. package/src/features/task-sync/assets/manifest.json +108 -0
  49. package/src/features/task-sync/assets/rules/00-bitrix-task-sync.md +161 -0
  50. package/src/features/task-sync/assets/scripts/bitrix-attach-files.sh +55 -0
  51. package/src/features/task-sync/assets/scripts/bitrix-lib.sh +540 -0
  52. package/src/features/task-sync/assets/scripts/bitrix-render-digest.sh +116 -0
  53. package/src/features/task-sync/assets/scripts/bitrix-session-check.sh +51 -0
  54. package/src/features/task-sync/assets/scripts/bitrix-session-sync.sh +89 -0
  55. package/src/features/task-sync/assets/scripts/bitrix-skill-end.sh +165 -0
  56. package/src/features/task-sync/assets/scripts/bitrix-skill-start.sh +58 -0
  57. package/src/features/task-sync/assets/scripts/lib/bb-formatter.sh +110 -0
  58. package/src/features/task-sync/assets/scripts/lib/bitrix-lib.sh +540 -0
  59. package/src/features/task-sync/assets/scripts/lib/time-helpers.sh +57 -0
  60. package/src/features/task-sync/assets/workflows/bitrix-sync.yml +85 -0
  61. package/src/features/task-sync/commands/install.ts +296 -0
  62. package/src/features/task-sync/commands/uninstall.ts +189 -0
  63. package/src/features/task-sync/commands/update.ts +11 -0
  64. package/src/features/task-sync/commands/verify.ts +141 -0
  65. package/src/features/task-sync/feature.json +12 -0
  66. package/src/features/task-sync/index.ts +121 -0
  67. package/src/features/task-sync/lib/dest-map.ts +96 -0
  68. package/src/features/task-sync/lib/drift-check.ts +47 -0
  69. package/src/features/task-sync/lib/file-ops.ts +36 -0
  70. package/src/features/task-sync/lib/manifest.ts +66 -0
  71. package/src/features/task-sync/lib/project-root.ts +38 -0
  72. package/src/features/task-sync/lib/settings-merge.ts +112 -0
  73. package/src/features/task-sync/lib/skill-refs.ts +106 -0
  74. package/src/features/task-sync/lib/task-id-finder.ts +31 -0
  75. package/src/features/task-sync/lib/token-extractor.ts +52 -0
  76. package/src/features/task-sync/lib/version.ts +36 -0
  77. package/src/features/task-sync/types.ts +40 -0
@@ -0,0 +1,52 @@
1
+ // Parse Claude Code transcript JSONL to extract session token usage.
2
+ // Transcript format: one JSON object per line; assistant turns carry message.usage.
3
+ import { createReadStream } from 'node:fs';
4
+ import { createInterface } from 'node:readline';
5
+
6
+ export interface TokenTotals {
7
+ input: number;
8
+ output: number;
9
+ cacheRead: number;
10
+ cacheCreation: number;
11
+ }
12
+
13
+ export interface SessionTokenSummary extends TokenTotals {
14
+ /** input + output (conservative billable count, excludes cache) */
15
+ billable: number;
16
+ }
17
+
18
+ export async function extractTokensFromTranscript(
19
+ transcriptPath: string,
20
+ ): Promise<SessionTokenSummary> {
21
+ const totals: TokenTotals = { input: 0, output: 0, cacheRead: 0, cacheCreation: 0 };
22
+
23
+ try {
24
+ const rl = createInterface({
25
+ input: createReadStream(transcriptPath),
26
+ crlfDelay: Infinity,
27
+ });
28
+
29
+ for await (const line of rl) {
30
+ if (!line.trim()) continue;
31
+ try {
32
+ const entry = JSON.parse(line) as Record<string, unknown>;
33
+ if (entry['type'] === 'assistant') {
34
+ const msg = entry['message'] as Record<string, unknown> | undefined;
35
+ const usage = msg?.['usage'] as Record<string, number> | undefined;
36
+ if (usage) {
37
+ totals.input += usage['input_tokens'] ?? 0;
38
+ totals.output += usage['output_tokens'] ?? 0;
39
+ totals.cacheRead += usage['cache_read_input_tokens'] ?? 0;
40
+ totals.cacheCreation += usage['cache_creation_input_tokens'] ?? 0;
41
+ }
42
+ }
43
+ } catch {
44
+ // skip malformed lines
45
+ }
46
+ }
47
+ } catch {
48
+ // transcript not found or unreadable — return zeros
49
+ }
50
+
51
+ return { ...totals, billable: totals.input + totals.output };
52
+ }
@@ -0,0 +1,36 @@
1
+ // Read package version at runtime — avoids JSON import attribute issues across Node versions.
2
+ import { readFile } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
+
8
+ let cached: string | null = null;
9
+
10
+ export async function getVersion(): Promise<string> {
11
+ if (cached) return cached;
12
+ // dist/index.js → ../package.json (after tsup bundles to dist/)
13
+ // src/features/task-sync/lib/version.ts → ../../../../package.json (during dev/test)
14
+ const candidates = [
15
+ path.resolve(__dirname, '../package.json'),
16
+ path.resolve(__dirname, '../../package.json'),
17
+ path.resolve(__dirname, '../../../package.json'),
18
+ path.resolve(__dirname, '../../../../package.json'),
19
+ ];
20
+ for (const p of candidates) {
21
+ try {
22
+ const raw = await readFile(p, 'utf8');
23
+ const pkg = JSON.parse(raw);
24
+ if (pkg && typeof pkg.version === 'string' && pkg.name?.includes('bitrix-skills')) {
25
+ const v: string = pkg.version;
26
+ cached = v;
27
+ return v;
28
+ }
29
+ } catch {
30
+ // try next
31
+ }
32
+ }
33
+ const fallback = '0.0.0-unknown';
34
+ cached = fallback;
35
+ return fallback;
36
+ }
@@ -0,0 +1,40 @@
1
+ // Shared type definitions for @synity/bitrix-task-sync CLI.
2
+
3
+ export interface ManifestEntry {
4
+ src: string; // path relative to assets/ (e.g. "scripts/bitrix-lib.sh")
5
+ sha256: string;
6
+ size: number;
7
+ mode: number; // octal file mode (0o755 for .sh, 0o644 for docs)
8
+ }
9
+
10
+ export interface Manifest {
11
+ version: string;
12
+ generatedAt: string;
13
+ files: ManifestEntry[];
14
+ }
15
+
16
+ export interface CliOptions {
17
+ cwd: string;
18
+ dryRun: boolean;
19
+ force: boolean;
20
+ noGithooks: boolean;
21
+ noWorkflow: boolean;
22
+ noSkill: boolean;
23
+ keepDocs: boolean;
24
+ quiet: boolean;
25
+ // Uninstall-only: opt in to deleting the user-scope skill at
26
+ // ~/.claude/skills/bitrix-sync-install/. Default false because the skill is
27
+ // shared across all projects on the machine.
28
+ removeSkill: boolean;
29
+ }
30
+
31
+ export type InstallResult = 'copied' | 'skipped' | 'overwritten' | 'planned';
32
+
33
+ export interface InstallStats {
34
+ copied: number;
35
+ skipped: number;
36
+ overwritten: number;
37
+ planned: number;
38
+ filtered: number; // entries excluded by --no-githooks / --no-workflow / --no-skill
39
+ warnings: string[];
40
+ }