@arshdelight/practi 0.21.0 → 0.22.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 +10 -2
- package/dist/client.js +59 -1
- package/dist/client.js.map +1 -1
- package/dist/cmd/claim.js +98 -0
- package/dist/cmd/claim.js.map +1 -0
- package/dist/cmd/comment.js +245 -0
- package/dist/cmd/comment.js.map +1 -0
- package/dist/cmd/edit.js +158 -0
- package/dist/cmd/edit.js.map +1 -0
- package/dist/cmd/embed.js +150 -0
- package/dist/cmd/embed.js.map +1 -0
- package/dist/cmd/fetch.js +44 -0
- package/dist/cmd/fetch.js.map +1 -0
- package/dist/cmd/instance.js +97 -0
- package/dist/cmd/instance.js.map +1 -0
- package/dist/cmd/lifecycle.js +119 -0
- package/dist/cmd/lifecycle.js.map +1 -0
- package/dist/cmd/ls.js +62 -0
- package/dist/cmd/ls.js.map +1 -0
- package/dist/cmd/migrate.js +149 -0
- package/dist/cmd/migrate.js.map +1 -0
- package/dist/cmd/new.js +10 -0
- package/dist/cmd/new.js.map +1 -1
- package/dist/cmd/practice.js +56 -0
- package/dist/cmd/practice.js.map +1 -0
- package/dist/cmd/promote.js +124 -0
- package/dist/cmd/promote.js.map +1 -0
- package/dist/cmd/publish.js +124 -0
- package/dist/cmd/publish.js.map +1 -0
- package/dist/cmd/push.js +71 -9
- package/dist/cmd/push.js.map +1 -1
- package/dist/cmd/remove.js +34 -0
- package/dist/cmd/remove.js.map +1 -0
- package/dist/cmd/repair.js +34 -0
- package/dist/cmd/repair.js.map +1 -0
- package/dist/cmd/search.js +87 -8
- package/dist/cmd/search.js.map +1 -1
- package/dist/cmd/update.js +3 -3
- package/dist/cmd/update.js.map +1 -1
- package/dist/commits.js +116 -0
- package/dist/commits.js.map +1 -0
- package/dist/embed/cache.js +207 -0
- package/dist/embed/cache.js.map +1 -0
- package/dist/embed/model.js +217 -0
- package/dist/embed/model.js.map +1 -0
- package/dist/embed/optional.js +128 -0
- package/dist/embed/optional.js.map +1 -0
- package/dist/embed/ready.js +15 -0
- package/dist/embed/ready.js.map +1 -0
- package/dist/embed/tokenizer.js +185 -0
- package/dist/embed/tokenizer.js.map +1 -0
- package/dist/index.js +49 -5
- package/dist/index.js.map +1 -1
- package/dist/retrieval.js +25 -0
- package/dist/retrieval.js.map +1 -1
- package/dist/version-check.js +101 -0
- package/dist/version-check.js.map +1 -0
- package/package.json +5 -2
- package/skills/use-practi/SKILL.md +26 -3
- package/web-default/home.js +2 -2
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fetchUrl } from './net.js';
|
|
4
|
+
import { defaultDataDir } from './state.js';
|
|
5
|
+
import { CLI_VERSION } from './version.js';
|
|
6
|
+
import { cmpSemver, npmOut, PKG } from './cmd/update.js';
|
|
7
|
+
/**
|
|
8
|
+
* 命令前注入的自动版本检测(2026-11-18 需求):
|
|
9
|
+
* - 缓存 = 配置家下 version-check.json,TTL 10 分钟;TTL 内按缓存态提示——
|
|
10
|
+
* latest 静默、update 提示、error 提示(附 --checkversion 重试指引)
|
|
11
|
+
* - TTL 外(或 --checkversion 强制)做一次网络检测并回写缓存;**失败也是结果**,
|
|
12
|
+
* 照常缓存——10 分钟内不重复触发(离线/断网时不至于每条命令都等超时)
|
|
13
|
+
* - 强制检测是显式动作:latest 也给确定反馈(普通路径 latest 静默)
|
|
14
|
+
* - 一切输出走 stderr(不污染 --json 的 stdout);任何异常吞掉,绝不阻塞命令
|
|
15
|
+
* 网络走 net.ts#fetchUrl(系统代理通道,同 blob URL 导入口径);registry 尊重
|
|
16
|
+
* npm config(npmOut 只在真实检测路径上起一次同步子进程,TTL 内零开销)。
|
|
17
|
+
*/
|
|
18
|
+
const TTL_MS = 10 * 60 * 1000;
|
|
19
|
+
const FETCH_TIMEOUT_MS = 4000;
|
|
20
|
+
const FETCH_MAX_BYTES = 2 * 1024 * 1024;
|
|
21
|
+
function cachePath(dataDir) {
|
|
22
|
+
return path.join(dataDir, 'version-check.json');
|
|
23
|
+
}
|
|
24
|
+
function readCache(dataDir) {
|
|
25
|
+
try {
|
|
26
|
+
const raw = JSON.parse(fs.readFileSync(cachePath(dataDir), 'utf8'));
|
|
27
|
+
if (typeof raw.checkedAt !== 'string')
|
|
28
|
+
return null;
|
|
29
|
+
if (raw.status !== 'latest' && raw.status !== 'update' && raw.status !== 'error')
|
|
30
|
+
return null;
|
|
31
|
+
return raw;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null; // 缺失/损坏都当无缓存(触发一次重检即自愈)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function writeCache(dataDir, cache) {
|
|
38
|
+
try {
|
|
39
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
40
|
+
fs.writeFileSync(cachePath(dataDir), JSON.stringify(cache, null, 2) + '\n', 'utf8');
|
|
41
|
+
}
|
|
42
|
+
catch { /* 写失败只影响下次重复检测,不阻塞命令 */ }
|
|
43
|
+
}
|
|
44
|
+
function isFresh(cache) {
|
|
45
|
+
const at = Date.parse(cache.checkedAt);
|
|
46
|
+
return Number.isFinite(at) && Date.now() - at < TTL_MS;
|
|
47
|
+
}
|
|
48
|
+
/** 真网络检测一次:三态都返回(失败也是结果,交给调用方缓存) */
|
|
49
|
+
async function checkOnce() {
|
|
50
|
+
const checkedAt = new Date().toISOString();
|
|
51
|
+
try {
|
|
52
|
+
const registry = npmOut(['config', 'get', 'registry']) || 'https://registry.npmjs.org';
|
|
53
|
+
const res = await fetchUrl(`${registry.replace(/\/+$/, '')}/${PKG.replace('/', '%2F')}`, {
|
|
54
|
+
timeoutMs: FETCH_TIMEOUT_MS,
|
|
55
|
+
maxBytes: FETCH_MAX_BYTES,
|
|
56
|
+
});
|
|
57
|
+
if (res.status !== 200) {
|
|
58
|
+
return { checkedAt, status: 'error', reason: `registry returned HTTP ${res.status}` };
|
|
59
|
+
}
|
|
60
|
+
const meta = JSON.parse(res.bytes.toString('utf8'));
|
|
61
|
+
const latest = meta['dist-tags']?.latest;
|
|
62
|
+
if (!latest)
|
|
63
|
+
return { checkedAt, status: 'error', reason: 'registry response carries no dist-tags.latest' };
|
|
64
|
+
if (cmpSemver(latest, CLI_VERSION) > 0)
|
|
65
|
+
return { checkedAt, status: 'update', latest };
|
|
66
|
+
return { checkedAt, status: 'latest', latest };
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
return { checkedAt, status: 'error', reason: e instanceof Error ? e.message : String(e) };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function notify(cache, force) {
|
|
73
|
+
if (cache.status === 'update') {
|
|
74
|
+
console.error(`update available: ${CLI_VERSION} → ${cache.latest} — run \`practi update\``);
|
|
75
|
+
}
|
|
76
|
+
else if (cache.status === 'error') {
|
|
77
|
+
console.error(`practi version check failed: ${cache.reason ?? 'unknown'} — retry with --checkversion`);
|
|
78
|
+
}
|
|
79
|
+
else if (force) {
|
|
80
|
+
console.error(`practi ${CLI_VERSION} is up to date (registry latest ${cache.latest ?? CLI_VERSION})`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** index.ts 命令分发前注入;force = --checkversion / --check-version。
|
|
84
|
+
* PRACTI_NO_VERSION_CHECK=1 整体禁用(脚本/CI/测试要纯净输出时用)。 */
|
|
85
|
+
export async function versionCheckNotify(opts = {}) {
|
|
86
|
+
try {
|
|
87
|
+
if (process.env.PRACTI_NO_VERSION_CHECK === '1')
|
|
88
|
+
return;
|
|
89
|
+
const dataDir = opts.dataDir ?? defaultDataDir();
|
|
90
|
+
const cached = readCache(dataDir);
|
|
91
|
+
if (opts.force !== true && cached && isFresh(cached)) {
|
|
92
|
+
notify(cached, false);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const result = await checkOnce();
|
|
96
|
+
writeCache(dataDir, result);
|
|
97
|
+
notify(result, opts.force === true);
|
|
98
|
+
}
|
|
99
|
+
catch { /* 双保险:检测链路任何意外都不影响命令执行 */ }
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=version-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-check.js","sourceRoot":"","sources":["../src/version-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC9B,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAWxC,SAAS,SAAS,CAAC,OAAe;IAChC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,SAAS,CAAC,OAAe;IAChC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAsB,CAAC;QACzF,IAAI,OAAO,GAAG,CAAC,SAAS,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QACnD,IAAI,GAAG,CAAC,MAAM,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,OAAO;YAAE,OAAO,IAAI,CAAC;QAC9F,OAAO,GAAG,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAA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,MAAM,IAAI,WAAW,GAAG,CAAC,CAAC;IACxG,CAAC;AACH,CAAC;AAED;uDACuD;AACvD,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAA8C,EAAE;IACvF,IAAI,CAAC;QACH,IAAI,OAAO,CAAC,GAAG,CAAC,uBAAuB,KAAK,GAAG;YAAE,OAAO;QACxD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,cAAc,EAAE,CAAC;QACjD,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;QAClC,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACrD,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACtB,OAAO;QACT,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;QACjC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5B,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC,CAAC,0BAA0B,CAAC,CAAC;AACxC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arshdelight/practi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Local registry CLI for POP (Protocol of Practice): manage a personal, content-addressed collection of practice documents on top of @arshdelight/pop-sdk. Fully offline.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"node": ">=20"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "
|
|
34
|
+
"build": "tsc",
|
|
35
35
|
"dev": "tsx src/index.ts",
|
|
36
36
|
"pretest": "npm run build --workspace @arshdelight/pop-sdk",
|
|
37
37
|
"test": "vitest run",
|
|
@@ -40,6 +40,9 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@arshdelight/pop-sdk": "^2.1.0"
|
|
42
42
|
},
|
|
43
|
+
"optionalDependencies": {
|
|
44
|
+
"onnxruntime-node": "^1.30.0"
|
|
45
|
+
},
|
|
43
46
|
"devDependencies": {
|
|
44
47
|
"@types/node": "^24.3.0",
|
|
45
48
|
"tsx": "^4.20.0",
|
|
@@ -43,6 +43,11 @@ The config home (default `~/.practi`) only holds credentials and the remote —
|
|
|
43
43
|
npm install -g @arshdelight/practi
|
|
44
44
|
practi init # create the config home (credentials + remote)
|
|
45
45
|
practi config # show config home and remote
|
|
46
|
+
practi --checkversion # force a version check now (otherwise every command
|
|
47
|
+
# quietly checks the registry once per 10 min — cached,
|
|
48
|
+
# failures included)
|
|
49
|
+
practi ls [--json] # anywhere: cross-practice overview from the practices
|
|
50
|
+
# home — branch / head / revisions / unpushed per practice
|
|
46
51
|
```
|
|
47
52
|
|
|
48
53
|
The local workflow is fully offline. Optionally a practice syncs with practihub (the reference hub) — see **Hub workflow** below.
|
|
@@ -114,6 +119,7 @@ practi blob add <file-or-url> [--name <name>] # inside the practice folder; by
|
|
|
114
119
|
```
|
|
115
120
|
|
|
116
121
|
- **Local file** — hashed and stored into the practice's blob channel; emits the entry without `url`. Validation later reports `E_BLOB_MISSING` if the bytes are absent.
|
|
122
|
+
- **Hub sync is automatic** — `practi push` uploads referenced blob bytes to the hub (image-only gate, 10MB per action node) before the document lands; `pull`/`clone` fetch missing bytes back into the local pool.
|
|
117
123
|
- **http(s) URL** — fetched once (25 MB limit); the bytes are ALSO stored and the entry is emitted **without** `url` (practi pointers are pure hash — the url is just the import channel; spec §5 still allows the field).
|
|
118
124
|
|
|
119
125
|
The command prints a ready-to-paste object. Put it on the **action's** `attachments`, then reference it from `content`:
|
|
@@ -148,7 +154,7 @@ practi export <hash> [-o f] # write any revision back out (the current one IS
|
|
|
148
154
|
practi log [--branch <b>] [--json] # commit history, tip first; (local, unpushed) marked
|
|
149
155
|
practi lint # quality hints on the current branch head
|
|
150
156
|
practi show <hash> [--json] [--doc] # inspect one revision node (hash prefix OK)
|
|
151
|
-
practi search <q> [--notes]
|
|
157
|
+
practi search <q> [--notes] [--semantic] # search this practice's revisions
|
|
152
158
|
practi similar <hash> # content neighbours within this practice (literal bigram
|
|
153
159
|
# similarity, not semantics)
|
|
154
160
|
practi note add|list|edit|delete # learning notes pinned to node hashes (.practi/notes.json)
|
|
@@ -157,6 +163,8 @@ practi web # browse practices locally — inside a practice
|
|
|
157
163
|
# branches, per-revision reader (wizard / standard view / doc
|
|
158
164
|
# tree); anywhere else: the practices home directory page
|
|
159
165
|
# (default ~/.practi/practices), rows click through to the reader
|
|
166
|
+
practi embed status|pull|build|prune # optional vector model (.practi/models/), scoped to
|
|
167
|
+
# this practice; without it search is lexical-only
|
|
160
168
|
```
|
|
161
169
|
|
|
162
170
|
- The **working file is the write door**, `export` is the read-back door. `commit` when the file equals the head says `nothing to commit`.
|
|
@@ -208,11 +216,26 @@ practi history reword <seq> -m <msg> | squash <seq> | drop <seq> | reset <seq>
|
|
|
208
216
|
- **Multiple words are ANDed, and may match in different fields.** `practi search listary 编码` needs both words somewhere in the same node — not adjacent in the text. Quote a phrase to require it whole.
|
|
209
217
|
- **`field:value` scopes one word** — `name:`, `desc:`, `content:`, `flow:` (declared inputs/outputs), `loop:`, `op:`, `hash:`. `practi search name:yt-dlp` hits only nodes whose *name* says it.
|
|
210
218
|
- **Chinese is matched by character bigram, not by word** — no dictionary needed. A query word matches only when *all* of its bigrams are present, so word order matters; when strict matching finds nothing the command retries with a strict-majority-of-terms rule and labels every row `partial match`. **A partial-match row is a hint, not an answer** — never present one as the found practice without reading it.
|
|
211
|
-
- **A literal search is not a semantic one, and that is deliberate.** Queries that share no wording with the record return *nothing*. So when `practi search` reports no matches, it prints the next move — retry with `--notes`, or start from a node you already have with `practi similar`. Take that step instead of rephrasing the same query repeatedly.
|
|
219
|
+
- **A literal search is not a semantic one, and that is deliberate.** Queries that share no wording with the record return *nothing*. So when `practi search` reports no matches, it prints the next move — retry with `--notes`, try `--semantic` if the vector model is installed, or start from a node you already have with `practi similar`. Take that step instead of rephrasing the same query repeatedly.
|
|
212
220
|
- **`--notes` also searches your local notes** (off by default, so the plain result set stays stable). Notes are where the most conversational keywords end up — when a search comes up empty, retry it with `--notes` before giving up.
|
|
213
221
|
- **Results are ranked title-first and each says why it matched.** Trust the explanation over the number.
|
|
214
222
|
- **`practi similar <hash>` answers the other question** — not "where did I write X" but "what else is about X". Literal: a paraphrase sharing no wording will not surface.
|
|
215
|
-
- Across practices,
|
|
223
|
+
- Across practices, `practi ls` is the one-glance overview — branch, head, revision count and **unpushed** count for every practice in the home (unpushed also counts history rewrites that cleared push stamps). Browse folders in your file manager for anything richer — a practice folder *is* its own listing.
|
|
224
|
+
|
|
225
|
+
## Semantic recall (optional, off by default)
|
|
226
|
+
|
|
227
|
+
Literal search cannot find a paraphrase. When that matters, practi can add a real vector layer, scoped to the practice. It is **optional and never automatic**:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
practi embed pull # download the model once (~24MB int8 ONNX) into .practi/models/
|
|
231
|
+
practi embed build # embed every stored node (incremental: only new hashes are embedded)
|
|
232
|
+
practi embed status # is the model present? how many nodes are covered?
|
|
233
|
+
practi search <q> --semantic # fuse vector recall with the lexical ranking (RRF)
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
- **Nothing here is required.** Without a model `practi search` is lexical-only; `--semantic` then says what is missing on stderr and answers from the lexical index anyway.
|
|
237
|
+
- **It costs one build.** After that only new nodes are embedded, so day-to-day use is incremental. Model bytes and vectors live under `.practi/` as **derived** sidecars — never written into a node, never part of a hash.
|
|
238
|
+
- **The vector layer can never break a command.** `--semantic` degrades to lexical with the reason on stderr if anything is missing; only `practi embed pull|build` — explicit requests — fail loudly.
|
|
216
239
|
|
|
217
240
|
## Local notes
|
|
218
241
|
|
package/web-default/home.js
CHANGED
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
+ '<p class="hint">' + POP_I18N.t('homeEmptyHint') + '</p></div>';
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
// ── 总览档:标题行(我的实践 +
|
|
48
|
+
// ── 总览档:标题行(我的实践 + 全量计数 + 查看全部)+ 前 6 张双列网格(hub OverviewGrid)──
|
|
49
49
|
function overviewHtml() {
|
|
50
50
|
var list = all.slice(0, 6);
|
|
51
51
|
if (!list.length) return emptyHtml();
|
|
52
52
|
return '<div class="sec-head"><h2 class="sec-title">' + esc(POP_I18N.t('pageTitle'))
|
|
53
|
-
+ '<span class="sec-count">' +
|
|
53
|
+
+ '<span class="sec-count">' + all.length + '</span></h2>'
|
|
54
54
|
+ '<button type="button" class="view-all" data-act="view-all">' + esc(POP_I18N.t('viewAll')) + '</button></div>'
|
|
55
55
|
+ '<div class="ov-grid">' + list.map(card).join('') + '</div>';
|
|
56
56
|
}
|