@arshdelight/practi 0.18.0 → 0.19.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/README.md +76 -136
- package/dist/client.js +6 -6
- package/dist/client.js.map +1 -1
- package/dist/cmd/blob.js +21 -24
- package/dist/cmd/blob.js.map +1 -1
- package/dist/cmd/branch.js +5 -7
- package/dist/cmd/branch.js.map +1 -1
- package/dist/cmd/clone.js +29 -23
- package/dist/cmd/clone.js.map +1 -1
- package/dist/cmd/commit.js +97 -0
- package/dist/cmd/commit.js.map +1 -0
- package/dist/cmd/config.js +1 -17
- package/dist/cmd/config.js.map +1 -1
- package/dist/cmd/edit.js +18 -4
- package/dist/cmd/edit.js.map +1 -1
- package/dist/cmd/embed.js +30 -25
- package/dist/cmd/embed.js.map +1 -1
- package/dist/cmd/export.js +43 -0
- package/dist/cmd/export.js.map +1 -0
- package/dist/cmd/fix.js +9 -153
- package/dist/cmd/fix.js.map +1 -1
- package/dist/cmd/gc.js +6 -5
- package/dist/cmd/gc.js.map +1 -1
- package/dist/cmd/history.js +73 -70
- package/dist/cmd/history.js.map +1 -1
- package/dist/cmd/init.js +10 -5
- package/dist/cmd/init.js.map +1 -1
- package/dist/cmd/lint.js +23 -20
- package/dist/cmd/lint.js.map +1 -1
- package/dist/cmd/log.js +2 -4
- package/dist/cmd/log.js.map +1 -1
- package/dist/cmd/merge.js +13 -10
- package/dist/cmd/merge.js.map +1 -1
- package/dist/cmd/new.js +56 -54
- package/dist/cmd/new.js.map +1 -1
- package/dist/cmd/note.js +27 -42
- package/dist/cmd/note.js.map +1 -1
- package/dist/cmd/pull.js +17 -13
- package/dist/cmd/pull.js.map +1 -1
- package/dist/cmd/push.js +27 -12
- package/dist/cmd/push.js.map +1 -1
- package/dist/cmd/search.js +30 -44
- package/dist/cmd/search.js.map +1 -1
- package/dist/cmd/show.js +5 -4
- package/dist/cmd/show.js.map +1 -1
- package/dist/cmd/similar.js +7 -20
- package/dist/cmd/similar.js.map +1 -1
- package/dist/cmd/skill.js +16 -16
- package/dist/cmd/skill.js.map +1 -1
- package/dist/cmd/switch.js +11 -6
- package/dist/cmd/switch.js.map +1 -1
- package/dist/index.js +243 -447
- package/dist/index.js.map +1 -1
- package/dist/practice.js +120 -97
- package/dist/practice.js.map +1 -1
- package/dist/quality.js +2 -2
- package/dist/quality.js.map +1 -1
- package/dist/state.js +13 -73
- package/dist/state.js.map +1 -1
- package/dist/sync.js +6 -48
- package/dist/sync.js.map +1 -1
- package/dist/web.js +156 -492
- package/dist/web.js.map +1 -1
- package/dist/workspace.js +10 -52
- package/dist/workspace.js.map +1 -1
- package/package.json +1 -1
- package/skills/use-practi/SKILL.md +121 -125
- package/web-default/chain.html +39 -0
- package/web-default/chain.js +54 -0
- package/web-default/app.js +0 -132
- package/web-default/index.html +0 -28
package/dist/index.js
CHANGED
|
@@ -3,12 +3,10 @@ import { parseArgs } from 'node:util';
|
|
|
3
3
|
import { PracticeError } from '@arshdelight/pop-sdk';
|
|
4
4
|
import { runInit } from './cmd/init.js';
|
|
5
5
|
import { runConfig } from './cmd/config.js';
|
|
6
|
-
import { runRepair } from './cmd/repair.js';
|
|
7
|
-
import { runMigrate } from './cmd/migrate.js';
|
|
8
|
-
import { runLs } from './cmd/ls.js';
|
|
9
6
|
import { runLint } from './cmd/lint.js';
|
|
10
7
|
import { runNew } from './cmd/new.js';
|
|
11
|
-
import {
|
|
8
|
+
import { runCommit } from './cmd/commit.js';
|
|
9
|
+
import { runExport } from './cmd/export.js';
|
|
12
10
|
import { runGc } from './cmd/gc.js';
|
|
13
11
|
import { runShow } from './cmd/show.js';
|
|
14
12
|
import { runWeb } from './web.js';
|
|
@@ -17,20 +15,15 @@ import { runSearch } from './cmd/search.js';
|
|
|
17
15
|
import { runSimilar } from './cmd/similar.js';
|
|
18
16
|
import { runEmbed } from './cmd/embed.js';
|
|
19
17
|
import { runNote } from './cmd/note.js';
|
|
20
|
-
import {
|
|
21
|
-
import { runClaim, runUnclaim } from './cmd/claim.js';
|
|
18
|
+
import { runSkill } from './cmd/skill.js';
|
|
22
19
|
import { runFix } from './cmd/fix.js';
|
|
23
20
|
import { runUpdate } from './cmd/update.js';
|
|
24
21
|
import { runSpec } from './cmd/spec.js';
|
|
25
|
-
import { runSkill } from './cmd/skill.js';
|
|
26
22
|
import { runLogin, runLogout, runMe } from './cmd/login.js';
|
|
27
23
|
import { runRemote } from './cmd/remote.js';
|
|
28
24
|
import { runPush } from './cmd/push.js';
|
|
29
25
|
import { runPull } from './cmd/pull.js';
|
|
30
26
|
import { runClone } from './cmd/clone.js';
|
|
31
|
-
import { runFetch } from './cmd/fetch.js';
|
|
32
|
-
import { runPractice } from './cmd/practice.js';
|
|
33
|
-
import { runPublish } from './cmd/publish.js';
|
|
34
27
|
import { runHistory } from './cmd/history.js';
|
|
35
28
|
import { runBranch } from './cmd/branch.js';
|
|
36
29
|
import { runSwitch } from './cmd/switch.js';
|
|
@@ -42,122 +35,69 @@ function printVersion() {
|
|
|
42
35
|
console.log(`pop-spec ${POP_SPEC_VERSION} (via @arshdelight/pop-sdk)`);
|
|
43
36
|
return 0;
|
|
44
37
|
}
|
|
45
|
-
const USAGE = `practi —
|
|
38
|
+
const USAGE = `practi — practice folders for POP (Protocol of Practice), with a practihub bridge
|
|
39
|
+
|
|
40
|
+
a practice is a self-contained folder:
|
|
41
|
+
<name>.json the pop — a plain document, edit it with any editor
|
|
42
|
+
.practi/ the history (like .git): chain.json (commits + branches)
|
|
43
|
+
and the content-addressed pool of every revision
|
|
46
44
|
|
|
47
|
-
usage:
|
|
48
|
-
practi
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
practi
|
|
45
|
+
usage (run inside a practice folder unless noted):
|
|
46
|
+
practi new <name> [--base <file.json>] [-m <msg>] birth a practice folder in cwd;
|
|
47
|
+
--base seeds the first revision from a pop document
|
|
48
|
+
(hub-side copy is born by the first push)
|
|
49
|
+
practi commit [-m <msg>] [--amend] snapshot the working file as a new revision
|
|
50
|
+
(local only; nothing to commit when it matches the
|
|
51
|
+
head; --amend replaces the head instead)
|
|
52
|
+
practi export <hash> [-o <file>] write any revision back out as a document
|
|
53
|
+
(the current one is the working file already)
|
|
54
|
+
practi push [--force] sync the practice to the hub (first push creates it;
|
|
55
|
+
divergence errors, --force overwrites and the hub
|
|
56
|
+
drops unreachable objects)
|
|
57
|
+
practi pull reconcile with the hub: fetch missing revisions,
|
|
58
|
+
fast-forward the branch, update the working file
|
|
55
59
|
practi clone <owner>/<name>[@branch] [--dir <path>]
|
|
56
|
-
clone a hub practice into a local practice
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
practi
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
[--message <text>] [--keep] practice; the practice keeps its own history
|
|
64
|
-
practi embed status|pull|build|prune optional offline vector model (bge-small-zh-v1.5,
|
|
65
|
-
~24MB int8 ONNX). pull fetches it, build embeds every
|
|
66
|
-
stored node (incrementally), status reports coverage.
|
|
67
|
-
Nothing here is required: without a model practi is
|
|
68
|
-
lexical-only, and search --semantic says so
|
|
69
|
-
practi gc [--apply] free orphan blobs — attachment bytes on disk that no
|
|
70
|
-
stored node references (dry-run by default; --apply removes)
|
|
71
|
-
practi fetch <owner>/<name> <hash>
|
|
72
|
-
pull one revision of that instance into your local registry
|
|
73
|
-
(direct; full sha256 hash — no prefix guessing). Content
|
|
74
|
-
access is repo-scoped: public instances are fetchable by
|
|
75
|
-
anyone, private ones only by their owners
|
|
76
|
-
practi fix <file.json> | <hash> | --all
|
|
77
|
-
migrate POP 1.x documents to 2.0: strip the removed history
|
|
78
|
-
fields (revisions/refines), re-validate, report the new hash.
|
|
79
|
-
<hash> re-stores a workspace node and re-binds direct/claims;
|
|
80
|
-
--all sweeps every direct pop; --dry-run previews
|
|
81
|
-
practi history amend [<pop|file>] [-m <msg>] | reword <seq> -m <msg>
|
|
82
|
-
| practi history squash <seq> | drop <seq> | reset <seq>
|
|
83
|
-
rewrite the practice's local commit chain (git-style);
|
|
84
|
-
push reconciles with the hub — divergence needs --force
|
|
85
|
-
practi instance … RETIRED: practice new <name> creates a local
|
|
86
|
-
practice (the hub copy is born by the first push);
|
|
87
|
-
commands locate it by cwd / --dir / --practice
|
|
60
|
+
clone a hub practice into a local practice folder
|
|
61
|
+
practi branch [name] [-d <name>] [--from <hash>]
|
|
62
|
+
list / create / delete branches (* marks the current one)
|
|
63
|
+
practi switch <branch> switch branches (working file follows the head; refuses
|
|
64
|
+
when it has uncommitted changes)
|
|
65
|
+
practi merge <branch> fast-forward, else a pointer move (same-tree commits
|
|
66
|
+
are identical)
|
|
88
67
|
practi log [--branch <b>] [--limit N] [--json]
|
|
89
|
-
the
|
|
90
|
-
practi
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
practi
|
|
97
|
-
practi
|
|
98
|
-
practi
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
practi
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
practi
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
practi
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
practi
|
|
114
|
-
|
|
115
|
-
hub in one call (the hub copy is born if needed); --keep
|
|
116
|
-
keeps the pop in the workspace, default removes it
|
|
117
|
-
practi pull [--dir <path> | --practice <name>]
|
|
118
|
-
reconcile the practice with the hub: fetch missing
|
|
119
|
-
revisions, fast-forward the branch pointer
|
|
120
|
-
practi remote set <url> | remove point practi at a hub (no implicit default; hub commands
|
|
121
|
-
need a remote)
|
|
122
|
-
practi remove <hash> take a direct pop out of the local directory (registry op;
|
|
123
|
-
GCs nodes unreachable from the rest — shared indirect nodes survive)
|
|
124
|
-
practi repair backfill missing claim timestamps from node file times
|
|
125
|
-
(idempotent; stamped claims are never touched)
|
|
126
|
-
practi search [query...] search the local workspace: every stored node is
|
|
127
|
-
[--limit N] [--json] indexed (name / description / content / declared
|
|
128
|
-
[--notes] [--semantic] inputs+outputs / loop prose), ranked title-first, each hit
|
|
129
|
-
showing why it was recalled. Multiple words are AND (each
|
|
130
|
-
must match, possibly in a different field); field:value
|
|
131
|
-
scopes one word. Pure-hex queries also match hash prefixes.
|
|
132
|
-
--notes also indexes local notes; --semantic fuses vector
|
|
133
|
-
recall (needs practi embed pull + embed build first, else
|
|
134
|
-
it says so and is ignored). Empty query = browse roots
|
|
135
|
-
practi show <hash> [--json] [--doc] inspect one node (hash prefix OK)
|
|
136
|
-
practi similar <hash> content neighbours of a node: same topic, other wording
|
|
137
|
-
[--limit N] [--json] (literal character-bigram similarity — no semantics;
|
|
138
|
-
the subtree is what gets compared)
|
|
139
|
-
practi skill install install the bundled use-practi skill (default: ~/.agents/skills)
|
|
140
|
-
practi skill update refresh the installed use-practi skill (--dir to override)
|
|
141
|
-
practi skill uninstall remove the installed use-practi skill
|
|
142
|
-
practi skill import <dir> replay a practi skill export directory back into a POP (sidecar required;
|
|
143
|
-
foreign skills enter POP by authoring, not import)
|
|
144
|
-
practi skill export <ref> [--dir] project a POP as an installable skill directory (SKILL.md + sidecar)
|
|
145
|
-
practi spec print pop-spec.md (bundled with the SDK; no network)
|
|
146
|
-
practi switch <branch> switch the bound instance's current branch (local pointer;
|
|
147
|
-
bring the content into the workspace with 'practi pull')
|
|
148
|
-
practi unclaim <hash> take a referenced direct pop back to indirect (fails when
|
|
149
|
-
unreferenced — that would orphan it; delete with "remove")
|
|
150
|
-
practi update self-update via npm (checks the registry's latest)
|
|
151
|
-
practi version | --version show CLI + pop-spec versions
|
|
152
|
-
practi web [--port 4317] [--no-open] browse direct pops in a local web UI
|
|
68
|
+
the commit history (tip first)
|
|
69
|
+
practi history reword <seq> -m <msg> | squash <seq> | drop <seq> | reset <seq>
|
|
70
|
+
rewrite the local commit chain (git-style);
|
|
71
|
+
push reconciles with the hub — divergence needs --force
|
|
72
|
+
practi export is the read-back door; the working file is the write door
|
|
73
|
+
|
|
74
|
+
inside a practice folder also:
|
|
75
|
+
practi show <hash> [--json] [--doc] inspect one revision node (hash prefix OK)
|
|
76
|
+
practi search [query...] [--json] search this practice's revisions
|
|
77
|
+
practi note add|list|edit|delete local learning notes pinned to node hashes
|
|
78
|
+
(.practi/notes.json, never uploaded)
|
|
79
|
+
practi lint quality hints on the current branch head
|
|
80
|
+
practi blob add <file-or-url> store an attachment's bytes in the pool
|
|
81
|
+
practi gc [--apply] free orphan blobs (dry-run by default)
|
|
82
|
+
practi web [--port 4317] browse this practice in a local web UI
|
|
83
|
+
|
|
84
|
+
anywhere:
|
|
85
|
+
practi init [path] create the config home (credentials + remote)
|
|
86
|
+
practi login [--no-open] OAuth sign-in to the hub (browser consent)
|
|
87
|
+
practi logout | me | remote set <url> | remove
|
|
88
|
+
practi config show config home and remote
|
|
89
|
+
practi fix <file.json> [--dry-run] migrate a POP 1.x document file to 2.0
|
|
90
|
+
practi spec print pop-spec.md (bundled with the SDK)
|
|
91
|
+
practi skill install | update | uninstall | import <dir> | export <ref>
|
|
92
|
+
practi update self-update via npm
|
|
93
|
+
practi version | --version show CLI + pop-spec versions
|
|
153
94
|
|
|
154
95
|
options:
|
|
155
|
-
--
|
|
96
|
+
--dir <path> target a practice folder from outside it
|
|
156
97
|
|
|
157
|
-
the
|
|
158
|
-
practi.json
|
|
159
|
-
|
|
160
|
-
'practi login' + 'practi remote set'.
|
|
98
|
+
the config home (default ~/.practi) keeps practi.json (remote) and
|
|
99
|
+
practi.auth.json (OAuth credentials) — practices themselves are plain
|
|
100
|
+
folders, wherever you keep your documents.
|
|
161
101
|
`;
|
|
162
102
|
const COMMON = {
|
|
163
103
|
'data-dir': { type: 'string' },
|
|
@@ -166,6 +106,25 @@ const COMMON = {
|
|
|
166
106
|
function str(v) {
|
|
167
107
|
return v;
|
|
168
108
|
}
|
|
109
|
+
/** 退役命令统一存根:说清去哪了 */
|
|
110
|
+
function retired(cmd) {
|
|
111
|
+
const pointers = {
|
|
112
|
+
edit: 'the working file IS the edit — open <name>.json with any editor, then `practi commit -m "..."`',
|
|
113
|
+
ls: 'practices are folders — use your file manager; `practi log` shows a practice\'s revisions',
|
|
114
|
+
list: 'practices are folders — browse them in your file manager',
|
|
115
|
+
remove: 'a practice folder is self-contained — deleting the folder removes the practice (the hub copy stays)',
|
|
116
|
+
claim: 'the pops registry retired — content lives in practice folders now',
|
|
117
|
+
unclaim: 'the pops registry retired — content lives in practice folders now',
|
|
118
|
+
publish: 'two steps now: `practi commit -m "..."` then `practi push`',
|
|
119
|
+
fetch: 'clone brings the full chain; fetch retired',
|
|
120
|
+
repair: 'the claims ledger retired — nothing to repair',
|
|
121
|
+
migrate: 'the config home is tiny — move the folder and point $PRACTI_HOME at it',
|
|
122
|
+
instance: 'retired by the practice-folder model (2026-10-20)',
|
|
123
|
+
practice: 'commands are flat now: `practi new <name>` / `practi log` / ... (the practice prefix retired)',
|
|
124
|
+
};
|
|
125
|
+
console.error(`\`practi ${cmd}\` was retired — ${pointers[cmd] ?? 'see practi --help'}`);
|
|
126
|
+
return 1;
|
|
127
|
+
}
|
|
169
128
|
async function main(argv) {
|
|
170
129
|
const cmd = argv[0] ?? 'help';
|
|
171
130
|
const rest = argv.slice(1);
|
|
@@ -176,19 +135,19 @@ async function main(argv) {
|
|
|
176
135
|
case 'gc': {
|
|
177
136
|
const { values } = parseArgs({
|
|
178
137
|
args: rest,
|
|
179
|
-
options: { ...COMMON, apply: { type: 'boolean' } },
|
|
138
|
+
options: { ...COMMON, apply: { type: 'boolean' }, dir: { type: 'string' } },
|
|
180
139
|
allowPositionals: true,
|
|
181
140
|
});
|
|
182
141
|
if (values.help) {
|
|
183
142
|
console.log('usage: practi gc [--apply] (free orphan blobs; dry-run by default)');
|
|
184
143
|
return 0;
|
|
185
144
|
}
|
|
186
|
-
return runGc({
|
|
145
|
+
return runGc({ dir: str(values.dir), apply: values.apply === true });
|
|
187
146
|
}
|
|
188
147
|
case 'init': {
|
|
189
148
|
const { values, positionals } = parseArgs({ args: rest, options: COMMON, allowPositionals: true });
|
|
190
149
|
if (values.help) {
|
|
191
|
-
console.log('usage: practi init [path]');
|
|
150
|
+
console.log('usage: practi init [path] (create the config home: credentials + remote)');
|
|
192
151
|
return 0;
|
|
193
152
|
}
|
|
194
153
|
return runInit({ dataDir: str(values['data-dir']), positional: positionals });
|
|
@@ -201,127 +160,62 @@ async function main(argv) {
|
|
|
201
160
|
}
|
|
202
161
|
return runConfig({ dataDir: str(values['data-dir']) });
|
|
203
162
|
}
|
|
204
|
-
case 'repair': {
|
|
205
|
-
const { values } = parseArgs({ args: rest, options: COMMON, allowPositionals: true });
|
|
206
|
-
if (values.help) {
|
|
207
|
-
console.log('usage: practi repair (backfill missing claim timestamps; idempotent)');
|
|
208
|
-
return 0;
|
|
209
|
-
}
|
|
210
|
-
return runRepair({ dataDir: str(values['data-dir']) });
|
|
211
|
-
}
|
|
212
|
-
case 'migrate': {
|
|
213
|
-
const { values, positionals } = parseArgs({
|
|
214
|
-
args: rest,
|
|
215
|
-
options: { ...COMMON, keep: { type: 'boolean' } },
|
|
216
|
-
allowPositionals: true,
|
|
217
|
-
});
|
|
218
|
-
if (values.help) {
|
|
219
|
-
console.log('usage: practi migrate [path] [--keep] (cut: the old directory is removed after per-file verification; --keep retains it as <dir>.bak-<timestamp>; no arg = ~/.practi, a path is recorded in ~/.practi-home as the default)');
|
|
220
|
-
return 0;
|
|
221
|
-
}
|
|
222
|
-
return runMigrate({ dataDir: str(values['data-dir']), positional: positionals, keep: values.keep === true });
|
|
223
|
-
}
|
|
224
163
|
case 'lint': {
|
|
225
164
|
const { values } = parseArgs({
|
|
226
165
|
args: rest,
|
|
227
|
-
options: { ...COMMON, json: { type: 'boolean' },
|
|
166
|
+
options: { ...COMMON, json: { type: 'boolean' }, dir: { type: 'string' } },
|
|
228
167
|
allowPositionals: true,
|
|
229
168
|
});
|
|
230
169
|
if (values.help) {
|
|
231
|
-
console.log('usage: practi lint
|
|
232
|
-
console.log(' audit recording quality across every direct pop: the same W_* hints');
|
|
233
|
-
console.log(' `practi new` prints once, but for the whole workspace, on demand.');
|
|
234
|
-
console.log(' read-only and never blocking (exit code is always 0) — it is a to-do');
|
|
235
|
-
console.log(' list, not a gate. --limit caps how many nodes are listed (default 20).');
|
|
170
|
+
console.log('usage: practi lint (quality hints on the current branch head; read-only, exit 0)');
|
|
236
171
|
return 0;
|
|
237
172
|
}
|
|
238
|
-
|
|
239
|
-
return runLint({
|
|
240
|
-
dataDir: str(values['data-dir']),
|
|
241
|
-
json: values.json === true,
|
|
242
|
-
limit: Number.isInteger(lintLimit) && lintLimit > 0 ? Math.min(lintLimit, 200) : 20,
|
|
243
|
-
});
|
|
173
|
+
return runLint({ dir: str(values.dir), json: values.json === true });
|
|
244
174
|
}
|
|
245
|
-
case '
|
|
175
|
+
case 'new': {
|
|
246
176
|
const { values, positionals } = parseArgs({
|
|
247
177
|
args: rest,
|
|
248
|
-
options: { ...COMMON,
|
|
178
|
+
options: { ...COMMON, base: { type: 'string' }, message: { type: 'string', short: 'm' }, dir: { type: 'string' } },
|
|
249
179
|
allowPositionals: true,
|
|
250
180
|
});
|
|
251
181
|
if (values.help) {
|
|
252
|
-
console.log('usage: practi
|
|
182
|
+
console.log('usage: practi new <name> [--base <file.json>] [-m <msg>] (birth a practice folder in cwd)');
|
|
253
183
|
return 0;
|
|
254
184
|
}
|
|
255
|
-
return
|
|
185
|
+
return await runNew({ positional: positionals, base: values.base, message: values.message });
|
|
256
186
|
}
|
|
257
|
-
case '
|
|
187
|
+
case 'commit': {
|
|
258
188
|
const { values, positionals } = parseArgs({
|
|
259
189
|
args: rest,
|
|
260
|
-
options: {
|
|
261
|
-
...COMMON,
|
|
262
|
-
message: { type: 'string', short: 'm' },
|
|
263
|
-
json: { type: 'boolean' },
|
|
264
|
-
out: { type: 'string' },
|
|
265
|
-
},
|
|
190
|
+
options: { ...COMMON, message: { type: 'string', short: 'm' }, amend: { type: 'boolean' }, dir: { type: 'string' } },
|
|
266
191
|
allowPositionals: true,
|
|
267
192
|
});
|
|
268
193
|
if (values.help) {
|
|
269
|
-
console.log('usage: practi
|
|
194
|
+
console.log('usage: practi commit [-m <msg>] [--amend] (snapshot the working file; local only)');
|
|
270
195
|
return 0;
|
|
271
196
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
message: values.message,
|
|
276
|
-
json: values.json === true,
|
|
277
|
-
out: values.out,
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
case 'new': {
|
|
281
|
-
const { values, positionals } = parseArgs({
|
|
282
|
-
args: rest,
|
|
283
|
-
options: {
|
|
284
|
-
...COMMON,
|
|
285
|
-
json: { type: 'string' },
|
|
286
|
-
file: { type: 'string' },
|
|
287
|
-
},
|
|
288
|
-
allowPositionals: true,
|
|
289
|
-
});
|
|
290
|
-
if (values.help) {
|
|
291
|
-
console.log('usage: practi new <file.json> | practi new --json \'<text>\' | practi new < file.json');
|
|
292
|
-
return 0;
|
|
197
|
+
if (positionals.length > 0) {
|
|
198
|
+
console.error('error: commit takes no arguments — the working file <name>.json is what gets committed');
|
|
199
|
+
return 1;
|
|
293
200
|
}
|
|
294
|
-
return await
|
|
201
|
+
return await runCommit({ positional: positionals, message: values.message, amend: values.amend === true, dir: values.dir });
|
|
295
202
|
}
|
|
296
|
-
case '
|
|
203
|
+
case 'export': {
|
|
297
204
|
const { values, positionals } = parseArgs({
|
|
298
205
|
args: rest,
|
|
299
|
-
options: {
|
|
300
|
-
...COMMON,
|
|
301
|
-
json: { type: 'string' },
|
|
302
|
-
file: { type: 'string' },
|
|
303
|
-
message: { type: 'string', short: 'm' },
|
|
304
|
-
keep: { type: 'boolean' },
|
|
305
|
-
},
|
|
206
|
+
options: { ...COMMON, out: { type: 'string', short: 'o' }, dir: { type: 'string' } },
|
|
306
207
|
allowPositionals: true,
|
|
307
208
|
});
|
|
308
209
|
if (values.help) {
|
|
309
|
-
console.log('usage: practi
|
|
210
|
+
console.log('usage: practi export <hash> [-o <file>] (write a revision back out as a document)');
|
|
310
211
|
return 0;
|
|
311
212
|
}
|
|
312
|
-
return
|
|
313
|
-
dataDir: str(values['data-dir']),
|
|
314
|
-
json: values.json,
|
|
315
|
-
file: values.file,
|
|
316
|
-
message: values.message,
|
|
317
|
-
keep: values.keep === true,
|
|
318
|
-
positional: positionals,
|
|
319
|
-
});
|
|
213
|
+
return runExport({ positional: positionals, out: values.out, dir: values.dir });
|
|
320
214
|
}
|
|
321
215
|
case 'show': {
|
|
322
216
|
const { values, positionals } = parseArgs({
|
|
323
217
|
args: rest,
|
|
324
|
-
options: { ...COMMON, json: { type: 'boolean' }, doc: { type: 'boolean' } },
|
|
218
|
+
options: { ...COMMON, json: { type: 'boolean' }, doc: { type: 'boolean' }, dir: { type: 'string' } },
|
|
325
219
|
allowPositionals: true,
|
|
326
220
|
});
|
|
327
221
|
if (values.help) {
|
|
@@ -332,7 +226,7 @@ async function main(argv) {
|
|
|
332
226
|
console.error('usage: practi show <hash> [--json] [--doc]');
|
|
333
227
|
return 1;
|
|
334
228
|
}
|
|
335
|
-
return runShow({
|
|
229
|
+
return runShow({ hash: positionals[0], json: values.json === true, doc: values.doc === true, dir: values.dir });
|
|
336
230
|
}
|
|
337
231
|
case 'web': {
|
|
338
232
|
const { values } = parseArgs({
|
|
@@ -342,159 +236,30 @@ async function main(argv) {
|
|
|
342
236
|
port: { type: 'string' },
|
|
343
237
|
open: { type: 'boolean', default: true },
|
|
344
238
|
'no-open': { type: 'boolean' },
|
|
239
|
+
dir: { type: 'string' },
|
|
345
240
|
},
|
|
346
241
|
allowPositionals: true,
|
|
347
242
|
});
|
|
348
243
|
if (values.help) {
|
|
349
|
-
console.log('usage: practi web [--port 4317] [--no-open]');
|
|
244
|
+
console.log('usage: practi web [--port 4317] [--no-open] (browse this practice locally)');
|
|
350
245
|
return 0;
|
|
351
246
|
}
|
|
352
247
|
const port = values.port ? Number(values.port) : 4317;
|
|
353
|
-
return runWeb({
|
|
354
|
-
}
|
|
355
|
-
case 'remove': {
|
|
356
|
-
const { values, positionals } = parseArgs({
|
|
357
|
-
args: rest,
|
|
358
|
-
options: COMMON,
|
|
359
|
-
allowPositionals: true,
|
|
360
|
-
});
|
|
361
|
-
if (values.help) {
|
|
362
|
-
console.log('usage: practi remove <hash> (local directory; unreachable nodes are GCed)');
|
|
363
|
-
return 0;
|
|
364
|
-
}
|
|
365
|
-
if (positionals.length === 0) {
|
|
366
|
-
console.error('usage: practi remove <hash> (local directory; unreachable nodes are GCed)');
|
|
367
|
-
return 1;
|
|
368
|
-
}
|
|
369
|
-
return runRemove({
|
|
370
|
-
dataDir: str(values['data-dir']),
|
|
371
|
-
positional: positionals,
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
case 'claim': {
|
|
375
|
-
const { values, positionals } = parseArgs({ args: rest, options: COMMON, allowPositionals: true });
|
|
376
|
-
if (values.help) {
|
|
377
|
-
console.log('usage: practi claim <hash> (register an existing stored node as a direct pop)');
|
|
378
|
-
return 0;
|
|
379
|
-
}
|
|
380
|
-
if (positionals.length === 0) {
|
|
381
|
-
console.error('usage: practi claim <hash>');
|
|
382
|
-
return 1;
|
|
383
|
-
}
|
|
384
|
-
return runClaim({ dataDir: str(values['data-dir']), positional: positionals });
|
|
385
|
-
}
|
|
386
|
-
case 'unclaim': {
|
|
387
|
-
const { values, positionals } = parseArgs({ args: rest, options: COMMON, allowPositionals: true });
|
|
388
|
-
if (values.help) {
|
|
389
|
-
console.log('usage: practi unclaim <hash> (take a referenced direct pop back to indirect)');
|
|
390
|
-
return 0;
|
|
391
|
-
}
|
|
392
|
-
if (positionals.length === 0) {
|
|
393
|
-
console.error('usage: practi unclaim <hash>');
|
|
394
|
-
return 1;
|
|
395
|
-
}
|
|
396
|
-
return runUnclaim({ dataDir: str(values['data-dir']), positional: positionals });
|
|
397
|
-
}
|
|
398
|
-
case 'embed': {
|
|
399
|
-
const { values, positionals } = parseArgs({
|
|
400
|
-
args: rest,
|
|
401
|
-
options: { ...COMMON, json: { type: 'boolean' }, notes: { type: 'boolean' } },
|
|
402
|
-
allowPositionals: true,
|
|
403
|
-
});
|
|
404
|
-
if (values.help) {
|
|
405
|
-
console.log('usage: practi embed status|pull|build|prune [--json] [--notes]');
|
|
406
|
-
console.log(' optional offline vector model (bge-small-zh-v1.5, ~24MB int8 ONNX).');
|
|
407
|
-
console.log(' pull downloads it into <data-dir>/models/, build embeds every stored node');
|
|
408
|
-
console.log(' (incrementally — only new hashes are embedded), status reports coverage.');
|
|
409
|
-
console.log(' nothing here is required: without a model practi is lexical-only.');
|
|
410
|
-
return 0;
|
|
411
|
-
}
|
|
412
|
-
return await runEmbed({
|
|
413
|
-
dataDir: str(values['data-dir']),
|
|
414
|
-
positional: positionals,
|
|
415
|
-
json: values.json === true,
|
|
416
|
-
notes: values.notes === true,
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
case 'search': {
|
|
420
|
-
const { values, positionals } = parseArgs({
|
|
421
|
-
args: rest,
|
|
422
|
-
options: {
|
|
423
|
-
...COMMON,
|
|
424
|
-
limit: { type: 'string' },
|
|
425
|
-
json: { type: 'boolean' },
|
|
426
|
-
notes: { type: 'boolean' },
|
|
427
|
-
semantic: { type: 'boolean' },
|
|
428
|
-
},
|
|
429
|
-
allowPositionals: true,
|
|
430
|
-
});
|
|
431
|
-
if (values.help) {
|
|
432
|
-
console.log('usage: practi search [query...] [--limit N] [--json] [--notes] [--semantic]');
|
|
433
|
-
console.log(' words are ANDed — every word must match somewhere, and the words may');
|
|
434
|
-
console.log(' match in different fields (name / description / content / declared');
|
|
435
|
-
console.log(' inputs+outputs / loop). Quote a phrase to search it whole.');
|
|
436
|
-
console.log(' field:value scopes one word — name: desc: content: flow: loop: op: hash:');
|
|
437
|
-
console.log(' pure-hex queries also match node hash prefixes;');
|
|
438
|
-
console.log(' if strict matching finds nothing, results fall back to partial match (labeled).');
|
|
439
|
-
console.log(' --notes also indexes your local notes (off by default); hits show "note".');
|
|
440
|
-
console.log(' --semantic fuses vector recall with the lexical ranking (needs');
|
|
441
|
-
console.log(' `practi embed pull` + `practi embed build`; otherwise it says so and is ignored).');
|
|
442
|
-
console.log(' empty query = browse direct roots');
|
|
443
|
-
return 0;
|
|
444
|
-
}
|
|
445
|
-
const limit = values.limit ? Number(values.limit) : 20;
|
|
446
|
-
return await runSearch({
|
|
447
|
-
dataDir: str(values['data-dir']),
|
|
448
|
-
positional: positionals,
|
|
449
|
-
limit: Number.isInteger(limit) && limit > 0 ? Math.min(limit, 50) : 20,
|
|
450
|
-
json: values.json === true,
|
|
451
|
-
notes: values.notes === true,
|
|
452
|
-
semantic: values.semantic === true,
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
case 'similar': {
|
|
456
|
-
const { values, positionals } = parseArgs({
|
|
457
|
-
args: rest,
|
|
458
|
-
options: {
|
|
459
|
-
...COMMON,
|
|
460
|
-
limit: { type: 'string' },
|
|
461
|
-
json: { type: 'boolean' },
|
|
462
|
-
},
|
|
463
|
-
allowPositionals: true,
|
|
464
|
-
});
|
|
465
|
-
if (values.help) {
|
|
466
|
-
console.log('usage: practi similar <hash> [--limit N] [--json]');
|
|
467
|
-
console.log(' content neighbours: the target subtree is treated as a query and every');
|
|
468
|
-
console.log(' stored node is scored against it (character-bigram + latin-word relevance,');
|
|
469
|
-
console.log(' literal — not semantics, so a paraphrase sharing no wording will not surface).');
|
|
470
|
-
console.log(' score 1.0 = identical content; each hit lists the shared terms that carried it.');
|
|
471
|
-
return 0;
|
|
472
|
-
}
|
|
473
|
-
if (positionals.length === 0) {
|
|
474
|
-
console.error('usage: practi similar <hash> [--limit N] [--json]');
|
|
475
|
-
return 1;
|
|
476
|
-
}
|
|
477
|
-
const simLimit = values.limit ? Number(values.limit) : 10;
|
|
478
|
-
return runSimilar({
|
|
479
|
-
dataDir: str(values['data-dir']),
|
|
480
|
-
ref: positionals[0],
|
|
481
|
-
limit: Number.isInteger(simLimit) && simLimit > 0 ? Math.min(simLimit, 50) : 10,
|
|
482
|
-
json: values.json === true,
|
|
483
|
-
});
|
|
248
|
+
return runWeb({ dir: str(values.dir), port: Number.isInteger(port) && port > 0 ? port : 4317, open: values['no-open'] !== true });
|
|
484
249
|
}
|
|
485
250
|
case 'blob': {
|
|
486
251
|
const sub = rest[0];
|
|
487
252
|
const { values, positionals } = parseArgs({
|
|
488
253
|
args: rest.slice(1),
|
|
489
|
-
options: { ...COMMON, name: { type: 'string' } },
|
|
254
|
+
options: { ...COMMON, name: { type: 'string' }, dir: { type: 'string' } },
|
|
490
255
|
allowPositionals: true,
|
|
491
256
|
});
|
|
492
257
|
if (values.help) {
|
|
493
|
-
console.log('usage: practi blob add <file-or-url> [--name <name>]');
|
|
258
|
+
console.log('usage: practi blob add <file-or-url> [--name <name>] (store attachment bytes in this practice)');
|
|
494
259
|
return 0;
|
|
495
260
|
}
|
|
496
261
|
if (sub === 'add') {
|
|
497
|
-
return runBlobAdd({
|
|
262
|
+
return runBlobAdd({ name: values.name, dir: values.dir, positional: positionals });
|
|
498
263
|
}
|
|
499
264
|
console.error('usage: practi blob add <file-or-url> [--name <name>]');
|
|
500
265
|
return 1;
|
|
@@ -510,17 +275,15 @@ async function main(argv) {
|
|
|
510
275
|
const action = known.find((k) => k === sub);
|
|
511
276
|
if (values.help) {
|
|
512
277
|
console.log('usage: practi skill install|update|uninstall [--dir <skills-dir>] (default dir: ~/.agents/skills)');
|
|
513
|
-
console.log(' practi skill import <skill-dir>
|
|
514
|
-
console.log(' practi skill export <ref> [--dir <out-dir>]
|
|
278
|
+
console.log(' practi skill import <skill-dir> replay a `practi skill export` directory (sidecar required)');
|
|
279
|
+
console.log(' practi skill export <ref> [--dir <out-dir>] project a revision as an installable skill directory');
|
|
515
280
|
return 0;
|
|
516
281
|
}
|
|
517
282
|
if (action === undefined) {
|
|
518
283
|
console.error('usage: practi skill install|update|uninstall [--dir <skills-dir>] (default dir: ~/.agents/skills)');
|
|
519
|
-
console.error(' practi skill import <skill-dir> [--data-dir <dir>] replay a `practi skill export` directory (sidecar required)');
|
|
520
|
-
console.error(' practi skill export <ref> [--dir <out-dir>] [--data-dir <dir>] POP → skill directory');
|
|
521
284
|
return 1;
|
|
522
285
|
}
|
|
523
|
-
return runSkill({ action, dir: values.dir,
|
|
286
|
+
return runSkill({ action, dir: values.dir, positional: positionals[0] });
|
|
524
287
|
}
|
|
525
288
|
case 'spec': {
|
|
526
289
|
const { values } = parseArgs({ args: rest, options: COMMON, allowPositionals: true });
|
|
@@ -528,7 +291,7 @@ async function main(argv) {
|
|
|
528
291
|
console.log('usage: practi spec (print the bundled pop-spec.md)');
|
|
529
292
|
return 0;
|
|
530
293
|
}
|
|
531
|
-
return runSpec({
|
|
294
|
+
return runSpec({});
|
|
532
295
|
}
|
|
533
296
|
case 'update': {
|
|
534
297
|
const { values } = parseArgs({ args: rest, options: COMMON, allowPositionals: true });
|
|
@@ -536,7 +299,7 @@ async function main(argv) {
|
|
|
536
299
|
console.log('usage: practi update (self-update via npm; checks the registry\'s latest)');
|
|
537
300
|
return 0;
|
|
538
301
|
}
|
|
539
|
-
return await runUpdate({
|
|
302
|
+
return await runUpdate({});
|
|
540
303
|
}
|
|
541
304
|
case 'login': {
|
|
542
305
|
const { values } = parseArgs({
|
|
@@ -581,203 +344,223 @@ async function main(argv) {
|
|
|
581
344
|
...COMMON,
|
|
582
345
|
force: { type: 'boolean' },
|
|
583
346
|
dir: { type: 'string' },
|
|
584
|
-
practice: { type: 'string' },
|
|
585
347
|
},
|
|
586
348
|
allowPositionals: true,
|
|
587
349
|
});
|
|
588
350
|
if (values.help) {
|
|
589
|
-
console.log('usage: practi push [--force] [--dir <path>
|
|
351
|
+
console.log('usage: practi push [--force] [--dir <path>] (practice → hub; first push creates it; divergence errors, --force overwrites)');
|
|
590
352
|
return 0;
|
|
591
353
|
}
|
|
592
|
-
return await runPush({
|
|
354
|
+
return await runPush({ dir: values.dir, force: values.force === true });
|
|
593
355
|
}
|
|
594
|
-
case '
|
|
595
|
-
const { values
|
|
356
|
+
case 'pull': {
|
|
357
|
+
const { values } = parseArgs({
|
|
596
358
|
args: rest,
|
|
597
|
-
options: {
|
|
598
|
-
...COMMON,
|
|
599
|
-
to: { type: 'string' },
|
|
600
|
-
dir: { type: 'string' },
|
|
601
|
-
message: { type: 'string', short: 'm' },
|
|
602
|
-
keep: { type: 'boolean' },
|
|
603
|
-
},
|
|
359
|
+
options: { ...COMMON, dir: { type: 'string' } },
|
|
604
360
|
allowPositionals: true,
|
|
605
361
|
});
|
|
606
362
|
if (values.help) {
|
|
607
|
-
console.log('usage: practi
|
|
363
|
+
console.log('usage: practi pull [--dir <path>] (reconcile with the hub: fetch missing revisions, fast-forward)');
|
|
608
364
|
return 0;
|
|
609
365
|
}
|
|
610
|
-
return await
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
366
|
+
return await runPull({ dir: values.dir });
|
|
367
|
+
}
|
|
368
|
+
case 'clone': {
|
|
369
|
+
const { values, positionals } = parseArgs({
|
|
370
|
+
args: rest,
|
|
371
|
+
options: { ...COMMON, dir: { type: 'string' } },
|
|
372
|
+
allowPositionals: true,
|
|
617
373
|
});
|
|
374
|
+
if (values.help) {
|
|
375
|
+
console.log('usage: practi clone <owner>/<name>[@branch] [--dir <path>] (clone a hub practice into a local folder)');
|
|
376
|
+
return 0;
|
|
377
|
+
}
|
|
378
|
+
return await runClone({ positional: positionals, dir: values.dir });
|
|
618
379
|
}
|
|
619
|
-
case '
|
|
380
|
+
case 'branch': {
|
|
620
381
|
const { values, positionals } = parseArgs({
|
|
621
382
|
args: rest,
|
|
622
383
|
options: {
|
|
623
384
|
...COMMON,
|
|
385
|
+
from: { type: 'string' },
|
|
386
|
+
delete: { type: 'string', short: 'd' },
|
|
624
387
|
dir: { type: 'string' },
|
|
625
|
-
practice: { type: 'string' },
|
|
626
|
-
message: { type: 'string', short: 'm' },
|
|
627
|
-
file: { type: 'string' },
|
|
628
|
-
json: { type: 'string' },
|
|
629
388
|
},
|
|
630
389
|
allowPositionals: true,
|
|
631
390
|
});
|
|
632
391
|
if (values.help) {
|
|
633
|
-
console.log('usage: practi
|
|
392
|
+
console.log('usage: practi branch [name] [-d <name>] (list / create / delete branches; * marks the current branch)');
|
|
634
393
|
return 0;
|
|
635
394
|
}
|
|
636
|
-
return
|
|
637
|
-
dataDir: str(values['data-dir']),
|
|
638
|
-
positional: positionals,
|
|
639
|
-
dir: values.dir,
|
|
640
|
-
practice: values.practice,
|
|
641
|
-
message: values.message,
|
|
642
|
-
file: values.file,
|
|
643
|
-
json: values.json,
|
|
644
|
-
});
|
|
395
|
+
return runBranch({ positional: positionals, from: values.from, deleteBranch: values.delete, dir: values.dir });
|
|
645
396
|
}
|
|
646
|
-
case '
|
|
397
|
+
case 'switch': {
|
|
647
398
|
const { values, positionals } = parseArgs({
|
|
648
399
|
args: rest,
|
|
649
400
|
options: { ...COMMON, dir: { type: 'string' } },
|
|
650
401
|
allowPositionals: true,
|
|
651
402
|
});
|
|
652
403
|
if (values.help) {
|
|
653
|
-
console.log('usage: practi
|
|
404
|
+
console.log('usage: practi switch <branch> (switch branches; the working file follows the head)');
|
|
654
405
|
return 0;
|
|
655
406
|
}
|
|
656
|
-
return
|
|
407
|
+
return runSwitch({ positional: positionals, dir: values.dir });
|
|
657
408
|
}
|
|
658
|
-
case '
|
|
409
|
+
case 'merge': {
|
|
659
410
|
const { values, positionals } = parseArgs({
|
|
660
411
|
args: rest,
|
|
661
|
-
options: { ...COMMON,
|
|
412
|
+
options: { ...COMMON, dir: { type: 'string' } },
|
|
662
413
|
allowPositionals: true,
|
|
663
414
|
});
|
|
664
415
|
if (values.help) {
|
|
665
|
-
console.log('usage: practi
|
|
416
|
+
console.log('usage: practi merge <branch> (fast-forward, else pointer move)');
|
|
666
417
|
return 0;
|
|
667
418
|
}
|
|
668
|
-
return
|
|
419
|
+
return runMerge({ positional: positionals, dir: values.dir });
|
|
669
420
|
}
|
|
670
|
-
case '
|
|
421
|
+
case 'log': {
|
|
671
422
|
const { values } = parseArgs({
|
|
672
423
|
args: rest,
|
|
673
|
-
options: {
|
|
424
|
+
options: {
|
|
425
|
+
...COMMON,
|
|
426
|
+
branch: { type: 'string' },
|
|
427
|
+
limit: { type: 'string' },
|
|
428
|
+
json: { type: 'boolean' },
|
|
429
|
+
dir: { type: 'string' },
|
|
430
|
+
},
|
|
674
431
|
allowPositionals: true,
|
|
675
432
|
});
|
|
676
433
|
if (values.help) {
|
|
677
|
-
console.log('usage: practi
|
|
434
|
+
console.log('usage: practi log [--branch <b>] [--limit N] [--json] (the commit history, tip first)');
|
|
678
435
|
return 0;
|
|
679
436
|
}
|
|
680
|
-
|
|
437
|
+
const logLimit = values.limit ? Number(values.limit) : undefined;
|
|
438
|
+
return runLog({
|
|
439
|
+
branch: values.branch,
|
|
440
|
+
limit: logLimit !== undefined && Number.isInteger(logLimit) && logLimit > 0 ? logLimit : undefined,
|
|
441
|
+
json: values.json === true,
|
|
442
|
+
dir: values.dir,
|
|
443
|
+
});
|
|
681
444
|
}
|
|
682
|
-
case '
|
|
445
|
+
case 'history': {
|
|
683
446
|
const { values, positionals } = parseArgs({
|
|
684
447
|
args: rest,
|
|
685
|
-
options: {
|
|
448
|
+
options: {
|
|
449
|
+
...COMMON,
|
|
450
|
+
dir: { type: 'string' },
|
|
451
|
+
message: { type: 'string', short: 'm' },
|
|
452
|
+
},
|
|
686
453
|
allowPositionals: true,
|
|
687
454
|
});
|
|
688
455
|
if (values.help) {
|
|
689
|
-
console.log('usage: practi
|
|
456
|
+
console.log('usage: practi history reword <seq> -m <msg> | squash <seq> | drop <seq> | reset <seq> (rewrite the local chain; push reconciles)');
|
|
690
457
|
return 0;
|
|
691
458
|
}
|
|
692
|
-
return await
|
|
459
|
+
return await runHistory({ positional: positionals, dir: values.dir, message: values.message });
|
|
693
460
|
}
|
|
694
|
-
case '
|
|
695
|
-
const { values, positionals } = parseArgs({
|
|
461
|
+
case 'fix': {
|
|
462
|
+
const { values, positionals } = parseArgs({
|
|
463
|
+
args: rest,
|
|
464
|
+
options: { ...COMMON, 'dry-run': { type: 'boolean' } },
|
|
465
|
+
allowPositionals: true,
|
|
466
|
+
});
|
|
696
467
|
if (values.help) {
|
|
697
|
-
console.log('usage: practi
|
|
468
|
+
console.log('usage: practi fix <file.json> [--dry-run] (strip POP 1.x history fields — revisions/refines — from a document file)');
|
|
698
469
|
return 0;
|
|
699
470
|
}
|
|
700
|
-
return
|
|
471
|
+
return runFix({ positional: positionals, dryRun: values['dry-run'] === true });
|
|
701
472
|
}
|
|
702
|
-
case '
|
|
703
|
-
if (rest.join(' ').includes('help')) {
|
|
704
|
-
console.log('practi instance was retired by the two-software model (2026-10-20):');
|
|
705
|
-
console.log(' instance create → `practi practice new <name>` (local first; the hub copy is born by the first push)');
|
|
706
|
-
console.log(' instance bind → retired: commands locate the practice by cwd / --dir / --practice');
|
|
707
|
-
console.log(' instance show → `practi practice list` and `practi log`');
|
|
708
|
-
return 0;
|
|
709
|
-
}
|
|
710
|
-
console.error('error: `practi instance` was retired — use `practi practice new <name>` (local instances), --practice <name> / --dir <path> to locate, `practi push` to put one on the hub');
|
|
711
|
-
return 1;
|
|
712
|
-
}
|
|
713
|
-
case 'branch': {
|
|
473
|
+
case 'search': {
|
|
714
474
|
const { values, positionals } = parseArgs({
|
|
715
475
|
args: rest,
|
|
716
476
|
options: {
|
|
717
477
|
...COMMON,
|
|
718
|
-
|
|
719
|
-
|
|
478
|
+
limit: { type: 'string' },
|
|
479
|
+
json: { type: 'boolean' },
|
|
480
|
+
notes: { type: 'boolean' },
|
|
481
|
+
semantic: { type: 'boolean' },
|
|
720
482
|
dir: { type: 'string' },
|
|
721
|
-
practice: { type: 'string' },
|
|
722
483
|
},
|
|
723
484
|
allowPositionals: true,
|
|
724
485
|
});
|
|
725
486
|
if (values.help) {
|
|
726
|
-
console.log('usage: practi
|
|
487
|
+
console.log('usage: practi search [query...] [--limit N] [--json] [--notes] [--semantic] (search this practice\'s revisions)');
|
|
727
488
|
return 0;
|
|
728
489
|
}
|
|
729
|
-
|
|
490
|
+
const limit = values.limit ? Number(values.limit) : 20;
|
|
491
|
+
return await runSearch({
|
|
492
|
+
positional: positionals,
|
|
493
|
+
limit: Number.isInteger(limit) && limit > 0 ? Math.min(limit, 50) : 20,
|
|
494
|
+
json: values.json === true,
|
|
495
|
+
notes: values.notes === true,
|
|
496
|
+
semantic: values.semantic === true,
|
|
497
|
+
dir: values.dir,
|
|
498
|
+
});
|
|
730
499
|
}
|
|
731
|
-
case '
|
|
500
|
+
case 'similar': {
|
|
732
501
|
const { values, positionals } = parseArgs({
|
|
733
502
|
args: rest,
|
|
734
|
-
options: {
|
|
503
|
+
options: {
|
|
504
|
+
...COMMON,
|
|
505
|
+
limit: { type: 'string' },
|
|
506
|
+
json: { type: 'boolean' },
|
|
507
|
+
dir: { type: 'string' },
|
|
508
|
+
},
|
|
735
509
|
allowPositionals: true,
|
|
736
510
|
});
|
|
737
511
|
if (values.help) {
|
|
738
|
-
console.log('usage: practi
|
|
512
|
+
console.log('usage: practi similar <hash> [--limit N] [--json] (content neighbours within this practice)');
|
|
739
513
|
return 0;
|
|
740
514
|
}
|
|
741
|
-
|
|
515
|
+
if (positionals.length === 0) {
|
|
516
|
+
console.error('usage: practi similar <hash> [--limit N] [--json]');
|
|
517
|
+
return 1;
|
|
518
|
+
}
|
|
519
|
+
const simLimit = values.limit ? Number(values.limit) : 10;
|
|
520
|
+
return runSimilar({
|
|
521
|
+
ref: positionals[0],
|
|
522
|
+
limit: Number.isInteger(simLimit) && simLimit > 0 ? Math.min(simLimit, 50) : 10,
|
|
523
|
+
json: values.json === true,
|
|
524
|
+
dir: values.dir,
|
|
525
|
+
});
|
|
742
526
|
}
|
|
743
|
-
case '
|
|
527
|
+
case 'note': {
|
|
744
528
|
const { values, positionals } = parseArgs({
|
|
745
529
|
args: rest,
|
|
746
|
-
options: {
|
|
530
|
+
options: {
|
|
531
|
+
...COMMON,
|
|
532
|
+
message: { type: 'string', short: 'm' },
|
|
533
|
+
json: { type: 'boolean' },
|
|
534
|
+
dir: { type: 'string' },
|
|
535
|
+
},
|
|
747
536
|
allowPositionals: true,
|
|
748
537
|
});
|
|
749
538
|
if (values.help) {
|
|
750
|
-
console.log('usage: practi
|
|
539
|
+
console.log('usage: practi note add|list|edit|delete (local notes pinned to node hashes; see `practi note` help)');
|
|
751
540
|
return 0;
|
|
752
541
|
}
|
|
753
|
-
return
|
|
542
|
+
return runNote({
|
|
543
|
+
positional: positionals,
|
|
544
|
+
message: values.message,
|
|
545
|
+
json: values.json === true,
|
|
546
|
+
dir: values.dir,
|
|
547
|
+
});
|
|
754
548
|
}
|
|
755
|
-
case '
|
|
756
|
-
const { values } = parseArgs({
|
|
549
|
+
case 'embed': {
|
|
550
|
+
const { values, positionals } = parseArgs({
|
|
757
551
|
args: rest,
|
|
758
|
-
options: {
|
|
759
|
-
...COMMON,
|
|
760
|
-
branch: { type: 'string' },
|
|
761
|
-
limit: { type: 'string' },
|
|
762
|
-
json: { type: 'boolean' },
|
|
763
|
-
dir: { type: 'string' },
|
|
764
|
-
practice: { type: 'string' },
|
|
765
|
-
},
|
|
552
|
+
options: { ...COMMON, json: { type: 'boolean' }, notes: { type: 'boolean' }, dir: { type: 'string' } },
|
|
766
553
|
allowPositionals: true,
|
|
767
554
|
});
|
|
768
555
|
if (values.help) {
|
|
769
|
-
console.log('usage: practi
|
|
556
|
+
console.log('usage: practi embed status|pull|build|prune [--json] [--notes] (optional offline vector model, scoped to this practice)');
|
|
770
557
|
return 0;
|
|
771
558
|
}
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
dataDir: str(values['data-dir']),
|
|
775
|
-
positional: [],
|
|
776
|
-
branch: values.branch,
|
|
777
|
-
limit: logLimit !== undefined && Number.isInteger(logLimit) && logLimit > 0 ? logLimit : undefined,
|
|
559
|
+
return await runEmbed({
|
|
560
|
+
positional: positionals,
|
|
778
561
|
json: values.json === true,
|
|
562
|
+
notes: values.notes === true,
|
|
779
563
|
dir: values.dir,
|
|
780
|
-
practice: values.practice,
|
|
781
564
|
});
|
|
782
565
|
}
|
|
783
566
|
case 'help':
|
|
@@ -785,6 +568,19 @@ async function main(argv) {
|
|
|
785
568
|
case '-h':
|
|
786
569
|
console.log(USAGE);
|
|
787
570
|
return 0;
|
|
571
|
+
case 'edit':
|
|
572
|
+
case 'ls':
|
|
573
|
+
case 'list':
|
|
574
|
+
case 'remove':
|
|
575
|
+
case 'claim':
|
|
576
|
+
case 'unclaim':
|
|
577
|
+
case 'publish':
|
|
578
|
+
case 'fetch':
|
|
579
|
+
case 'repair':
|
|
580
|
+
case 'migrate':
|
|
581
|
+
case 'instance':
|
|
582
|
+
case 'practice':
|
|
583
|
+
return retired(cmd);
|
|
788
584
|
default:
|
|
789
585
|
console.error(`unknown command: ${cmd}`);
|
|
790
586
|
console.error(USAGE);
|