@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.
- package/CHANGELOG.md +169 -0
- package/LICENSE +21 -0
- package/README.md +83 -0
- package/bin/bitrix-skills.js +3 -0
- package/dist/cli.js +1510 -0
- package/dist/features/bx-task/install.js +111 -0
- package/dist/features/task-sync/index.js +1053 -0
- package/package.json +69 -0
- package/src/features/bx/assets/SKILL.md +34 -0
- package/src/features/bx/feature.json +8 -0
- package/src/features/bx-calendar/assets/SKILL.md +61 -0
- package/src/features/bx-calendar/assets/availability.md +65 -0
- package/src/features/bx-calendar/assets/meeting.md +87 -0
- package/src/features/bx-calendar/assets/reminder.md +71 -0
- package/src/features/bx-calendar/assets/sync.md +70 -0
- package/src/features/bx-calendar/feature.json +10 -0
- package/src/features/bx-crm/assets/SKILL.md +59 -0
- package/src/features/bx-crm/assets/commerce.md +96 -0
- package/src/features/bx-crm/assets/onboard.md +127 -0
- package/src/features/bx-crm/assets/report.md +98 -0
- package/src/features/bx-crm/assets/research.md +71 -0
- package/src/features/bx-crm/feature.json +10 -0
- package/src/features/bx-task/assets/SKILL.md +148 -0
- package/src/features/bx-task/assets/lib/bx-api.sh +39 -0
- package/src/features/bx-task/assets/lib/bx-checklist.sh +127 -0
- package/src/features/bx-task/assets/lib/bx-resolve-task.sh +41 -0
- package/src/features/bx-task/assets/lib/bx-state.sh +131 -0
- package/src/features/bx-task/assets/lib/bx-tasks.sh +109 -0
- package/src/features/bx-task/assets/references/bootstrap.md +184 -0
- package/src/features/bx-task/assets/references/feature.md +97 -0
- package/src/features/bx-task/assets/references/init-templates/cli-tool.md +47 -0
- package/src/features/bx-task/assets/references/init-templates/generic.md +31 -0
- package/src/features/bx-task/assets/references/init-templates/library.md +45 -0
- package/src/features/bx-task/assets/references/init-templates/monorepo.md +38 -0
- package/src/features/bx-task/assets/references/init-templates/npm-package.md +40 -0
- package/src/features/bx-task/assets/references/init-templates/web-app.md +46 -0
- package/src/features/bx-task/assets/references/init.md +107 -0
- package/src/features/bx-task/assets/references/roadmap.md +93 -0
- package/src/features/bx-task/assets/references/summary.md +269 -0
- package/src/features/bx-task/assets/references/sync.md +104 -0
- package/src/features/bx-task/assets/references/time-log.md +214 -0
- package/src/features/bx-task/feature.json +10 -0
- package/src/features/bx-task/install.ts +117 -0
- package/src/features/task-sync/assets/docs/bitrix-task-reference.md +318 -0
- package/src/features/task-sync/assets/docs/bitrix-task-sync.md +254 -0
- package/src/features/task-sync/assets/githooks/commit-msg +44 -0
- package/src/features/task-sync/assets/githooks/install.sh +15 -0
- package/src/features/task-sync/assets/manifest.json +108 -0
- package/src/features/task-sync/assets/rules/00-bitrix-task-sync.md +161 -0
- package/src/features/task-sync/assets/scripts/bitrix-attach-files.sh +55 -0
- package/src/features/task-sync/assets/scripts/bitrix-lib.sh +540 -0
- package/src/features/task-sync/assets/scripts/bitrix-render-digest.sh +116 -0
- package/src/features/task-sync/assets/scripts/bitrix-session-check.sh +51 -0
- package/src/features/task-sync/assets/scripts/bitrix-session-sync.sh +89 -0
- package/src/features/task-sync/assets/scripts/bitrix-skill-end.sh +165 -0
- package/src/features/task-sync/assets/scripts/bitrix-skill-start.sh +58 -0
- package/src/features/task-sync/assets/scripts/lib/bb-formatter.sh +110 -0
- package/src/features/task-sync/assets/scripts/lib/bitrix-lib.sh +540 -0
- package/src/features/task-sync/assets/scripts/lib/time-helpers.sh +57 -0
- package/src/features/task-sync/assets/workflows/bitrix-sync.yml +85 -0
- package/src/features/task-sync/commands/install.ts +296 -0
- package/src/features/task-sync/commands/uninstall.ts +189 -0
- package/src/features/task-sync/commands/update.ts +11 -0
- package/src/features/task-sync/commands/verify.ts +141 -0
- package/src/features/task-sync/feature.json +12 -0
- package/src/features/task-sync/index.ts +121 -0
- package/src/features/task-sync/lib/dest-map.ts +96 -0
- package/src/features/task-sync/lib/drift-check.ts +47 -0
- package/src/features/task-sync/lib/file-ops.ts +36 -0
- package/src/features/task-sync/lib/manifest.ts +66 -0
- package/src/features/task-sync/lib/project-root.ts +38 -0
- package/src/features/task-sync/lib/settings-merge.ts +112 -0
- package/src/features/task-sync/lib/skill-refs.ts +106 -0
- package/src/features/task-sync/lib/task-id-finder.ts +31 -0
- package/src/features/task-sync/lib/token-extractor.ts +52 -0
- package/src/features/task-sync/lib/version.ts +36 -0
- 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
|
+
}
|