feat(profiles): add opt-in Lean/Full and hybrid Auto selection

This commit is contained in:
haelyra
2026-09-27 16:46:07 -04:00
parent e482e57941
commit 0765f7a2ca
342 changed files with 18212 additions and 209 deletions
@@ -0,0 +1,46 @@
# snippet-cli
A small in-process snippet manager. No external dependencies; Node.js standard
library only.
## Contract
`src/cli.js` is CommonJS and exports `run(argv, state)`:
- `argv`: array of command-line words (already split, no program name).
- `state`: any plain object, created by the caller as `{}`. The CLI keeps its
data in it and mutates it in place; it survives across calls.
- Returns synchronously: `{ code, stdout, stderr }` — a number and two strings
(empty string when there is nothing to print). `run` must **never throw**,
on any input.
- All printed lines end with `\n`.
## Commands (all behavior below is contractual)
1. `add <name> [--tags a,b] <text...>` — creates a snippet from the remaining
words joined by single spaces. Prints `created <name>`, code 0.
2. Adding an existing name: code 1, stderr `error: snippet '<name>' already exists`,
state unchanged.
3. `add` with a missing name or missing text: code 2, stderr
`usage: add <name> [--tags t1,t2] <text...>`.
4. Names must match `^[a-z0-9][a-z0-9-]*$`; otherwise code 2, stderr
`error: invalid snippet name '<name>'`.
5. `get <name>` — prints the exact text, code 0. Unknown name: code 2, stderr
`error: no snippet named '<name>'`.
6. `remove <name>` — prints `removed <name>`, code 0. Unknown name: same as `get`.
7. `list` — every snippet name, sorted ascending, one per line. With no
snippets: prints `no snippets`. Always code 0.
8. `list --tag <t>` — only snippets whose tags include `t`.
9. `search <term>` — case-insensitive substring match over name **and** text;
prints matching names sorted, one per line; prints `no matches` when empty.
Code 0.
10. `export` — prints `JSON.stringify` of `{ snippets: { <name>: { text, tags } } }`
with names sorted and each `tags` array sorted. Code 0.
11. `import <json>` — merges an exported document: names not already present
are added, existing names are skipped. Prints `imported <N>, skipped <M>`,
code 0. Malformed JSON: code 1, stderr `error: invalid JSON`, state
unchanged.
12. No command or an unknown command: code 2, stderr
`usage: snippet <add|get|list|remove|search|export|import>`.
Run the tests with `npm test`.
@@ -0,0 +1,6 @@
{
"name": "snippet-cli",
"private": true,
"type": "commonjs",
"scripts": { "test": "node --test test/" }
}
@@ -0,0 +1,8 @@
'use strict';
// TODO: implement per README. The contract is run(argv, state) -> { code, stdout, stderr }.
function run(_argv, _state) {
throw new Error('not implemented');
}
module.exports = { run };
@@ -0,0 +1,20 @@
'use strict';
const test = require('node:test');
const assert = require('node:assert/strict');
const { run } = require('../src/cli');
test('add then get round-trips a snippet', () => {
const state = {};
const added = run(['add', 'hello', 'hello', 'world'], state);
assert.equal(added.code, 0);
assert.equal(added.stdout, 'created hello\n');
const got = run(['get', 'hello'], state);
assert.equal(got.code, 0);
assert.equal(got.stdout, 'hello world\n');
});
test('list on empty state', () => {
const result = run(['list'], {});
assert.equal(result.code, 0);
assert.equal(result.stdout, 'no snippets\n');
});