@luzzle/cli 0.0.142 → 0.0.143
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 +72 -5
- package/dist/src/lib/commands/command/attach.d.ts +7 -0
- package/dist/src/lib/commands/command/attach.js +44 -0
- package/dist/src/lib/commands/command/attach.js.map +1 -0
- package/dist/src/version.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +4 -4
- package/dist/src/lib/cli.test.d.ts +0 -1
- package/dist/src/lib/cli.test.js +0 -197
- package/dist/src/lib/cli.test.js.map +0 -1
- package/dist/src/lib/commands/command/assistant.test.d.ts +0 -1
- package/dist/src/lib/commands/command/assistant.test.js +0 -161
- package/dist/src/lib/commands/command/assistant.test.js.map +0 -1
- package/dist/src/lib/commands/command/config.test.d.ts +0 -1
- package/dist/src/lib/commands/command/config.test.js +0 -113
- package/dist/src/lib/commands/command/config.test.js.map +0 -1
- package/dist/src/lib/commands/command/create.test.d.ts +0 -1
- package/dist/src/lib/commands/command/create.test.js +0 -126
- package/dist/src/lib/commands/command/create.test.js.map +0 -1
- package/dist/src/lib/commands/command/field.test.d.ts +0 -1
- package/dist/src/lib/commands/command/field.test.js +0 -449
- package/dist/src/lib/commands/command/field.test.js.map +0 -1
- package/dist/src/lib/commands/command/init.test.d.ts +0 -1
- package/dist/src/lib/commands/command/init.test.js +0 -84
- package/dist/src/lib/commands/command/init.test.js.map +0 -1
- package/dist/src/lib/commands/command/sync.test.d.ts +0 -1
- package/dist/src/lib/commands/command/sync.test.js +0 -117
- package/dist/src/lib/commands/command/sync.test.js.map +0 -1
- package/dist/src/lib/commands/command/validate.test.d.ts +0 -1
- package/dist/src/lib/commands/command/validate.test.js +0 -59
- package/dist/src/lib/commands/command/validate.test.js.map +0 -1
- package/dist/src/lib/commands/index.test.d.ts +0 -1
- package/dist/src/lib/commands/index.test.js +0 -31
- package/dist/src/lib/commands/index.test.js.map +0 -1
- package/dist/src/lib/commands/utils/pieces.test.d.ts +0 -1
- package/dist/src/lib/commands/utils/pieces.test.js +0 -97
- package/dist/src/lib/commands/utils/pieces.test.js.map +0 -1
- package/dist/src/lib/config.test.d.ts +0 -1
- package/dist/src/lib/config.test.js +0 -110
- package/dist/src/lib/config.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -1,9 +1,76 @@
|
|
|
1
1
|
# @luzzle/cli 💻
|
|
2
2
|
|
|
3
|
-
A terminal companion for the human side of Luzzle.
|
|
3
|
+
A terminal companion for the human side of Luzzle. The CLI offers commands to
|
|
4
|
+
manage, validate, and query your piece archive directly from your terminal.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## Installation 🚀
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
Install the CLI globally:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g @luzzle/cli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Configuration ⚙️
|
|
15
|
+
|
|
16
|
+
The CLI is configured via a YAML file. By default, it reads from the OS-specific
|
|
17
|
+
standard user config path. You can customize settings like storage paths, SQLite
|
|
18
|
+
database locations, and Gemini API keys.
|
|
19
|
+
|
|
20
|
+
For detailed options, see the [CLI Configuration Reference](./docs/config.md).
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Commands Reference 🛠️
|
|
25
|
+
|
|
26
|
+
All commands support a `--dry-run` flag to run without making permanent changes
|
|
27
|
+
to your disk or database, and a `--verbose` flag for detailed logs.
|
|
28
|
+
|
|
29
|
+
### 1. `init <dir>`
|
|
30
|
+
|
|
31
|
+
Initializes a new Luzzle repository inside the specified directory. This sets up
|
|
32
|
+
the database client and runs Kysely schema migrations.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
luzzle init ./my-archive
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 2. `sync`
|
|
39
|
+
|
|
40
|
+
Scans your archive directory, parses new or updated piece files, and updates the local SQLite cache index.
|
|
41
|
+
|
|
42
|
+
- **`--force`** (`-f`): Force updates on all items, ignoring file modification times.
|
|
43
|
+
- **`--prune`** (`-p`): Delete orphaned assets from disk that are no longer referenced by any piece.
|
|
44
|
+
|
|
45
|
+
### 3. `create <title> [fields]`
|
|
46
|
+
|
|
47
|
+
Creates a new piece file with the proper extension and schema layout.
|
|
48
|
+
|
|
49
|
+
- **`--piece`** (`-p`): Piece type name (e.g. `books`, `films`). (Required)
|
|
50
|
+
- **`--directory`** (`-d`): Directory path where the piece should be created. (Required)
|
|
51
|
+
- **`--input`** (`-i`): Input format of the `[fields]` argument (`yaml` or `json`). Defaults to `yaml`.
|
|
52
|
+
|
|
53
|
+
### 4. `field <piece-path> [field] [value]`
|
|
54
|
+
|
|
55
|
+
Gets, edits, or removes a frontmatter field for a specific piece file.
|
|
56
|
+
|
|
57
|
+
- **`--remove`** (`-r`): Remove the specified field from the piece.
|
|
58
|
+
|
|
59
|
+
### 5. `validate <piece-path>`
|
|
60
|
+
|
|
61
|
+
Validates a specific piece file's YAML frontmatter against its registered JSON schema.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
luzzle validate ./archive/books/dune.books.md
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 6. `assistant`
|
|
68
|
+
|
|
69
|
+
Prompts the Gemini AI assistant to generate or update piece metadata based on a natural language prompt or attached files.
|
|
70
|
+
|
|
71
|
+
- **`--prompt`**: A sentence describing the piece or where to find info. (Required)
|
|
72
|
+
- **`--piece`** (`-p`): Target piece type. (Required)
|
|
73
|
+
- **`--update`** (`-u`): Path to an existing piece to modify.
|
|
74
|
+
- **`--directory`** (`-d`): Folder to write a new piece file.
|
|
75
|
+
- **`--title`**: Title of the new piece.
|
|
76
|
+
- **`--file`**: Path to reference documents/images (can be specified multiple times).
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import log from '../../../lib/log.js';
|
|
2
|
+
import { createReadStream } from 'fs';
|
|
3
|
+
import { stat } from 'fs/promises';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { savePieceAsset } from '@luzzle/core';
|
|
6
|
+
import { PiecePositional, makePiecePathPositional, parsePiecePathPositionalArgv, } from '../utils/pieces.js';
|
|
7
|
+
const command = {
|
|
8
|
+
name: 'attach',
|
|
9
|
+
command: `attach ${PiecePositional} <file>`,
|
|
10
|
+
describe: 'attach a local file to a piece',
|
|
11
|
+
builder: (yargs) => {
|
|
12
|
+
return makePiecePathPositional(yargs).positional('file', {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: 'path to the local file to attach',
|
|
15
|
+
demandOption: 'local file path is required',
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
run: async function (ctx, args) {
|
|
19
|
+
const { file } = args;
|
|
20
|
+
const { markdown } = await parsePiecePathPositionalArgv(ctx, args);
|
|
21
|
+
// Resolve local file path
|
|
22
|
+
const localFilePath = path.resolve(file);
|
|
23
|
+
const fileStat = await stat(localFilePath).catch(() => null);
|
|
24
|
+
if (!fileStat || !fileStat.isFile()) {
|
|
25
|
+
log.error(`local file [${file}] not found or is not a valid file`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (ctx.flags.dryRun) {
|
|
29
|
+
log.info(`[dry-run] would attach ${file} to ${markdown.filePath}`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const stream = createReadStream(localFilePath);
|
|
34
|
+
const filename = path.basename(localFilePath);
|
|
35
|
+
const relativePath = await savePieceAsset(markdown.filePath, filename, stream, ctx.storage);
|
|
36
|
+
console.log(relativePath);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
log.error(`failed to attach file: ${error.message}`);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
export default command;
|
|
44
|
+
//# sourceMappingURL=attach.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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