create-ledgit-repo 0.1.1 → 0.2.2

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 (2) hide show
  1. package/dist/index.js +58 -45
  2. package/package.json +6 -5
package/dist/index.js CHANGED
@@ -15385,6 +15385,11 @@ var require_axios = __commonJS((exports, module) => {
15385
15385
  // src/index.ts
15386
15386
  import { Command } from "commander";
15387
15387
 
15388
+ // ../../node_modules/@inquirer/core/dist/esm/lib/errors.js
15389
+ class ExitPromptError extends Error {
15390
+ name = "ExitPromptError";
15391
+ }
15392
+
15388
15393
  // src/commands/create.ts
15389
15394
  import { select, input, password, confirm, checkbox } from "@inquirer/prompts";
15390
15395
  import ora from "ora";
@@ -15392,6 +15397,7 @@ import * as path8 from "node:path";
15392
15397
  import * as fs11 from "node:fs/promises";
15393
15398
  import * as os2 from "node:os";
15394
15399
  import { fileURLToPath as fileURLToPath2 } from "node:url";
15400
+ import { createRequire as createRequire2 } from "node:module";
15395
15401
 
15396
15402
  // ../bokio-client/dist/config.js
15397
15403
  var BOKIO_CONFIG = {
@@ -17010,8 +17016,9 @@ var DEFAULT_GITIGNORE = `# Environment files with secrets
17010
17016
  .env
17011
17017
  .env.*
17012
17018
 
17013
- # CLI cache
17014
- .kvitton/
17019
+ # Tokens and cache (sensitive data)
17020
+ .ledgit/tokens/
17021
+ .ledgit/cache/
17015
17022
 
17016
17023
  # OS files
17017
17024
  .DS_Store
@@ -17054,14 +17061,9 @@ This is an accounting data repository for {{COMPANY_NAME}} (Swedish company), st
17054
17061
  │ ├── entry.yaml
17055
17062
  │ └── *.pdf # Supporting documents
17056
17063
 
17057
- ├── inbox/ # Raw incoming documents (no entry yet)
17058
- └── [DATE]-[NAME]/
17059
- │ ├── documents.yaml
17060
- │ └── *.pdf
17061
- └── drafts/ # Documents with entries, ready to post
17062
- └── [DATE]-[NAME]/ # e.g., "2025-12-24-anthropic"
17064
+ └── inbox/ # Raw incoming documents (no entry yet)
17065
+ └── [DATE]-[NAME]/
17063
17066
  ├── documents.yaml
17064
- ├── entry.yaml
17065
17067
  └── *.pdf
17066
17068
  \`\`\`
17067
17069
 
@@ -17075,10 +17077,10 @@ npx ledgit-cli sync-journal # Sync journal entries from accounting prov
17075
17077
  npx ledgit-cli sync-inbox # Download inbox files from accounting provider
17076
17078
  npx ledgit-cli company-info # Display company information
17077
17079
 
17078
- # Create journal entries
17080
+ # Create journal entries (entry number auto-detected, git branch created if on main)
17079
17081
  npx ledgit-cli create-entry --path <inbox-dir-or-file> \\
17080
17082
  --tax-code <code> --base-account <acc> --balancing-account <acc> \\
17081
- --series <A-K> --entry-number <num>
17083
+ --series <A-K>
17082
17084
 
17083
17085
  # For raw files (not from inbox), also provide:
17084
17086
  # --description "Vendor name" --document-date 2025-01-15 --amount 1234.50
@@ -17109,26 +17111,36 @@ npx ledgit-cli update # Update AGENTS.md to latest version
17109
17111
  ## Workflow Overview
17110
17112
 
17111
17113
  \`\`\`
17112
- inbox/ → (create-entry) → drafts/ → (user confirms) journal-entries/ → (sync-journal) → Provider
17114
+ inbox/ → (create-entry) → journal-entries/ → (git review & commit) → (sync-journal) → Provider
17113
17115
  \`\`\`
17114
17116
 
17115
- ## Bookkeeping New Entries
17117
+ When you run \`create-entry\` on main branch, a new git branch is automatically created (e.g., \`book/V-189-2025-10-15-anthropic\`). Review changes with \`git diff\`, commit, and sync to provider.
17116
17118
 
17117
- **Important:** Always ask the user for clarification if anything is unclear about the transaction before creating an entry.
17119
+ ## Bookkeeping New Entries
17118
17120
 
17119
17121
  To create a journal entry from an inbox document:
17120
17122
 
17121
- 1. **Read the document** - Use \`npx ledgit-cli parse-pdf\` for PDFs to understand the content
17122
- 2. **Update documents.yaml** - After parsing, populate missing metadata in \`documents.yaml\`:
17123
+ 1. **Read the document** - You can read PDFs directly, or use \`npx ledgit-cli parse-pdf\` to extract text
17124
+ 2. **Update documents.yaml** - Populate missing metadata in \`documents.yaml\`:
17123
17125
  - \`documentDate\`: Invoice/receipt date (YYYY-MM-DD)
17124
17126
  - \`description\`: Vendor or document name
17125
17127
  - \`totalAmount\`: With \`amount\` (string) and \`currency\` (e.g., EUR, SEK)
17126
- 3. **Look for similar entries** - Search \`journal-entries/\` and \`drafts/\` for entries from the same vendor or similar transaction types to learn which accounts and tax codes were used previously
17128
+ 3. **Look for similar entries** - Search \`journal-entries/\` for entries from the same vendor or similar transaction types to learn which accounts and tax codes were used previously
17127
17129
  4. **Check accounts** - Review \`accounts.yaml\` for appropriate expense/revenue accounts
17128
- 5. **Determine tax code** - Based on vendor location and transaction type (see Tax Codes below). Explain your reasoning and describe the tax code meaning to the user
17129
- 6. **Ask for confirmation** - Before creating, confirm with the user: vendor, amount, accounts (with names), and tax code (with description)
17130
- 7. **Create entry** - Run \`npx ledgit-cli create-entry\` with the appropriate parameters
17131
- 8. **Files moved to drafts** - The inbox item is automatically moved to \`drafts/\` with \`entry.yaml\`
17130
+ 5. **Determine tax code** - Based on vendor location and transaction type (see Tax Codes below)
17131
+ 6. **Create entry** - Run \`npx ledgit-cli create-entry\` with the appropriate parameters
17132
+ 7. **Review and sync** - The entry is created in \`journal-entries/\`. Review with \`git diff\`, commit, and run \`npx ledgit-cli sync-journal\` to post to {{PROVIDER}}
17133
+
17134
+ ### GitHub Actions / CI Mode
17135
+
17136
+ When running in GitHub Actions (automated bookkeeping):
17137
+ - **Always proceed** with creating entries using your best judgment
17138
+ - **Always end** by creating or updating a PR
17139
+ - If anything is unclear, include your questions in the PR description
17140
+ - The user will respond via PR comments, which triggers another workflow run
17141
+ - Group related entries (same vendor, same week) in one PR when sensible
17142
+
17143
+ **Never stop and wait for confirmation in CI mode** - the user can't respond until you create a PR.
17132
17144
 
17133
17145
  To discard unwanted inbox items:
17134
17146
  \`\`\`bash
@@ -17136,22 +17148,6 @@ npx ledgit-cli discard inbox/2025-01-15-spam-document
17136
17148
  \`\`\`
17137
17149
  This removes the directory and marks the item for deletion from the provider on next sync.
17138
17150
 
17139
- ## Posting Entries
17140
-
17141
- **Important:** Moving entries to \`journal-entries/\` posts them to the real ledger. Always confirm with the user before posting.
17142
-
17143
- When the user confirms draft entries are ready to post:
17144
-
17145
- 1. **Determine entry number** - Check existing entries in \`journal-entries/FY-YYYY/\` for the series to find the next available number
17146
- 2. **Move to journal-entries** - Rename the draft directory to the proper format:
17147
- \`\`\`
17148
- drafts/2025-01-15-anthropic/
17149
- → journal-entries/FY-2025/A-042-2025-01-15-anthropic/
17150
- \`\`\`
17151
- Format: \`{SERIES}-{NUM}-{DATE}-{DESC}/\`
17152
- 3. **Update entry.yaml** - Ensure \`entryNumber\` matches the directory and \`status\` is set appropriately
17153
- 4. **Sync to provider** - Run \`npx ledgit-cli sync-journal\` to post the entries to {{PROVIDER}}
17154
-
17155
17151
  ## Tax Codes
17156
17152
 
17157
17153
  ### Common Tax Code Patterns
@@ -17252,9 +17248,9 @@ function renderAgentsTemplate(options) {
17252
17248
  }
17253
17249
  // ../bookkeeping/dist/utils/paths.js
17254
17250
  import * as path3 from "node:path";
17255
- var KVITTON_DIR = ".kvitton";
17251
+ var LEDGIT_DIR = ".ledgit";
17256
17252
  function getTokensDir(cwd) {
17257
- return path3.join(cwd, KVITTON_DIR, "tokens");
17253
+ return path3.join(cwd, LEDGIT_DIR, "tokens");
17258
17254
  }
17259
17255
  // ../bookkeeping/dist/services/journal.service.js
17260
17256
  class JournalService {
@@ -18370,7 +18366,7 @@ async function loginFortnox(options) {
18370
18366
  onStatus("Exchanging authorization code for token...");
18371
18367
  const tokenResponse = await exchangeCodeForToken(config, callbackResult.code);
18372
18368
  const storedToken = saveFortnoxToken(cwd, tokenResponse);
18373
- onStatus("Token saved to .kvitton/tokens/fortnox.json");
18369
+ onStatus("Token saved to .ledgit/tokens/fortnox.json");
18374
18370
  return storedToken;
18375
18371
  } finally {
18376
18372
  stop();
@@ -22027,6 +22023,9 @@ import { join as join6 } from "node:path";
22027
22023
  import { homedir } from "node:os";
22028
22024
  var config;
22029
22025
  var client = null;
22026
+ function initialize(options) {
22027
+ config = options;
22028
+ }
22030
22029
  function setVersion(version2) {
22031
22030
  if (config) {
22032
22031
  config.version = version2;
@@ -22271,7 +22270,14 @@ async function syncChartOfAccounts2(client2, repoPath) {
22271
22270
  }
22272
22271
 
22273
22272
  // src/commands/create.ts
22274
- setVersion("0.4.5");
22273
+ var require2 = createRequire2(import.meta.url);
22274
+ var pkg = require2("../../package.json");
22275
+ initialize({
22276
+ apiKey: "phc_BGMrllb0D2P9DCq7ZEeLp9VYhAK0lof2eTL524dEXoU",
22277
+ host: "https://eu.i.posthog.com",
22278
+ appName: "ledgit"
22279
+ });
22280
+ setVersion(pkg.version);
22275
22281
  var __filename2 = fileURLToPath2(import.meta.url);
22276
22282
  var __dirname3 = path8.dirname(__filename2);
22277
22283
  async function createAgentsFile(targetDir, options) {
@@ -22466,8 +22472,8 @@ async function createBookkeepingRepo(name, options = {}) {
22466
22472
  await createEnvFile(targetDir, {
22467
22473
  PROVIDER: "fortnox"
22468
22474
  });
22469
- const sourcePath = path8.join(fortnoxTempDir, KVITTON_DIR, "tokens");
22470
- const targetPath = path8.join(targetDir, KVITTON_DIR, "tokens");
22475
+ const sourcePath = path8.join(fortnoxTempDir, LEDGIT_DIR, "tokens");
22476
+ const targetPath = path8.join(targetDir, LEDGIT_DIR, "tokens");
22471
22477
  await fs11.mkdir(path8.dirname(targetPath), { recursive: true });
22472
22478
  await fs11.cp(sourcePath, targetPath, { recursive: true });
22473
22479
  await fs11.rm(fortnoxTempDir, { recursive: true, force: true });
@@ -22591,7 +22597,14 @@ Examples:
22591
22597
  $ create-ledgit my-company-books
22592
22598
  $ create-ledgit -p fortnox
22593
22599
  $ create-ledgit my-repo -p bokio -c abc-123 -y
22594
- `).action((name, options) => {
22595
- createBookkeepingRepo(name, options);
22600
+ `).action(async (name, options) => {
22601
+ try {
22602
+ await createBookkeepingRepo(name, options);
22603
+ } catch (error) {
22604
+ if (error instanceof ExitPromptError) {
22605
+ process.exit(130);
22606
+ }
22607
+ throw error;
22608
+ }
22596
22609
  });
22597
22610
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ledgit-repo",
3
- "version": "0.1.1",
3
+ "version": "0.2.2",
4
4
  "description": "Create a new ledgit bookkeeping repository",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,10 +20,11 @@
20
20
  "type-check": "tsc --noEmit"
21
21
  },
22
22
  "dependencies": {
23
- "@moatless/bookkeeping": "^0.1.0",
24
- "@moatless/telemetry": "^0.1.0",
25
- "@moatless/bokio-client": "^0.1.0",
26
- "@moatless/fortnox-client": "^0.1.0",
23
+ "@moatless/bookkeeping": "^0.1.2",
24
+ "@moatless/telemetry": "^0.1.2",
25
+ "@moatless/bokio-client": "^0.1.2",
26
+ "@moatless/fortnox-client": "^0.1.2",
27
+ "@inquirer/core": "^10.0.0",
27
28
  "@inquirer/prompts": "^7.0.0",
28
29
  "commander": "^12.1.0",
29
30
  "ora": "^8.1.1",