@goodpeanuts/dsh-sui 0.1.2-fix.3 → 0.1.2-fix.4
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 +7 -7
- package/apps/cli/dist/packages/sdk/src/config.mjs +1 -1
- package/bundles/sui-ledger/dist/client.js +69 -47
- package/bundles/sui-ledger/dist/index.mjs +3 -2
- package/bundles/sui-ledger/dist/packages/finance-module/src/routes.mjs +12 -1
- package/bundles/sui-ledger/dist/packages/finance-module/src/service.mjs +5 -8
- package/bundles/sui-ledger/dist/packages/sdk/src/config.mjs +1 -1
- package/bundles/sui-ledger/dist/remote-write-policy.mjs +14 -3
- package/bundles/sui-ledger/dist/style.css +46 -1
- package/bundles/sui-ledger/locale/en.json +1 -1
- package/bundles/sui-ledger/locale/zh-CN.json +1 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-sui DSH 插件
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
DeepSeek Harness 的个人账本插件,提供本地账本页面、会话流水草稿、订阅与服务,以及独立命令行工具。
|
|
4
4
|
|
|
5
5
|
需要 Node.js 24+、pnpm 和 DeepSeek Harness(DSH)。插件声明宿主下限 `>= 0.2.1-rc.2`,已在 `0.2.1-rc.2` 与 `0.2.2-rc.1` 验证。
|
|
6
6
|
|
|
@@ -18,12 +18,12 @@ dsh plugin --profile web add @goodpeanuts/dsh-sui
|
|
|
18
18
|
|
|
19
19
|
### 首次登录与同步
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
首次打开本地账本时,可直接填写账本账号和密码并登录。单账本会自动同步最近两个月;多个账本可选择其中一个同步,更早的数据可在“数据与同步”选择全量同步。凭据保存在系统钥匙串。
|
|
22
22
|
|
|
23
23
|
也可先停止使用同一数据目录的宿主,在终端执行:
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
|
-
npx --yes --package=@goodpeanuts/dsh-sui feidee auth set '
|
|
26
|
+
npx --yes --package=@goodpeanuts/dsh-sui feidee auth set '你的账本账号'
|
|
27
27
|
npx --yes --package=@goodpeanuts/dsh-sui feidee auth status
|
|
28
28
|
npx --yes --package=@goodpeanuts/dsh-sui feidee books --pretty
|
|
29
29
|
npx --yes --package=@goodpeanuts/dsh-sui feidee sync recent --book '上一步返回的账本ID'
|
|
@@ -31,7 +31,7 @@ npx --yes --package=@goodpeanuts/dsh-sui feidee sync recent --book '上一步返
|
|
|
31
31
|
|
|
32
32
|
按隐藏提示输入密码;同步完成后启动宿主。插件和命令默认共用 `$DSH_HOME/sui-ledger`(默认 `~/.dsh/sui-ledger`);若修改了插件数据目录,运行命令时请将环境变量 `SUI_LEDGER_DATA_DIR` 设为相同目录。
|
|
33
33
|
|
|
34
|
-
打开宿主后,从左侧 `sui-ledger`
|
|
34
|
+
打开宿主后,从左侧 `sui-ledger` 进入账本。生产安装默认允许发起远端提交,本地源码开发默认禁用。写入须由已登录 DSH 的操作者确认,并通过远端会话校验和提交前检查。实际策略通过 `/api/sui-ledger/finance/write-policy` 核对。模型服务在 DSH 设置中配置。
|
|
35
35
|
|
|
36
36
|
## 账本功能
|
|
37
37
|
|
|
@@ -51,7 +51,7 @@ npx --yes --package=@goodpeanuts/dsh-sui feidee sync recent --book '上一步返
|
|
|
51
51
|
|
|
52
52
|
非空草稿在输入框上方显示单个图标,点击打开工作台,关闭后保留编辑。完整条目可加入“待入账”,原批次冻结为只读存档;部分加入时剩余条目继续使用原入口,整批加入后入口收起,后续记账另开批次。其他会话的 open 草稿不共享,已加入同一账本的待入账记录可读。
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
“待入账”支持审阅、暂存、人工确认、提交历史和结果回读。若本次暂存范围内有不兼容的备注,整次暂存会被拒绝,问题流水留在待审阅区修改。候选编辑采用独立审阅版本;真实候选变化时提示重新读取并保留未保存输入。“全部移除”只作用于确认时的候选集合。模型无法直接暂存或确认远端交易。
|
|
55
55
|
|
|
56
56
|
### 余额确认点
|
|
57
57
|
|
|
@@ -71,7 +71,7 @@ npx --yes --package=@goodpeanuts/dsh-sui feidee sync recent --book '上一步返
|
|
|
71
71
|
|
|
72
72
|
- 个人偏好支持有序文本编辑、保存确认与并发冲突检查。
|
|
73
73
|
- 在“数据与同步”中备份和恢复本地数据集;独立维护命令可通过 `npx --yes --package=@goodpeanuts/dsh-sui sui-ledger-data --help` 查看。
|
|
74
|
-
-
|
|
74
|
+
- 流水命令行工具支持凭据管理、同步、查询、报表与审计。使用 `npx --yes --package=@goodpeanuts/dsh-sui feidee --help` 查看。
|
|
75
75
|
|
|
76
76
|
## 开发(私有仓库成员)
|
|
77
77
|
|
|
@@ -85,7 +85,7 @@ pnpm run check
|
|
|
85
85
|
| 目录 | 职责 |
|
|
86
86
|
| --- | --- |
|
|
87
87
|
| `bundles/sui-ledger` | DSH 工具、HTTP、会话和页面适配 |
|
|
88
|
-
| `apps/cli` |
|
|
88
|
+
| `apps/cli` | 独立流水命令行出口 |
|
|
89
89
|
| `packages/*` | 出口无关的业务、存储、维护、契约及 UI;包职责见架构 |
|
|
90
90
|
| `scripts` | 构建检查、启动、迁移和隔离验收 |
|
|
91
91
|
| `docs/conventions` | 当前开发、部署及产物规则 |
|
|
@@ -13,9 +13,9 @@ function loadConfig(env = process.env, overrides = {}) {
|
|
|
13
13
|
financeDatabasePath: join(dataDir, "finance.db"),
|
|
14
14
|
credentialService: FEIDEE_KEYCHAIN_SERVICE,
|
|
15
15
|
recentSyncMonths: Number(env.SUI_LEDGER_RECENT_SYNC_MONTHS ?? 2),
|
|
16
|
-
remoteWritesDisabled: parseBooleanEnvironment("SUI_LEDGER_REMOTE_WRITES_DISABLED", env.SUI_LEDGER_REMOTE_WRITES_DISABLED, true),
|
|
17
16
|
...writeCanaryBookId ? { writeCanaryBookId } : {},
|
|
18
17
|
...overrides,
|
|
18
|
+
remoteWritesDisabled: overrides.remoteWritesDisabled ?? parseBooleanEnvironment("SUI_LEDGER_REMOTE_WRITES_DISABLED", env.SUI_LEDGER_REMOTE_WRITES_DISABLED, true),
|
|
19
19
|
dataDir
|
|
20
20
|
};
|
|
21
21
|
if (!Number.isInteger(config.recentSyncMonths) || config.recentSyncMonths < 1) throw new Error("SUI_LEDGER_RECENT_SYNC_MONTHS must be a positive integer");
|
|
@@ -10152,7 +10152,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
10152
10152
|
role: "status",
|
|
10153
10153
|
"aria-live": "polite",
|
|
10154
10154
|
children: [
|
|
10155
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: "
|
|
10155
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: "备注需修改后才能暂存" }),
|
|
10156
10156
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", { children: issues.slice(0, 3).map((issue) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
10157
10157
|
type: "button",
|
|
10158
10158
|
onClick: () => onSelect(issue),
|
|
@@ -12116,13 +12116,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
12116
12116
|
const invalidEntryIds = new Set(categoryValidation?.issues.map((issue) => issue.entryId) ?? []);
|
|
12117
12117
|
const categoryBlockedReason = categoryValidation && !categoryValidation.valid ? `有 ${categoryValidation.issues.length} 条旧草稿使用了一级分类。请改选具体二级分类后再暂存或提交。` : void 0;
|
|
12118
12118
|
const remoteCommitBlockedReason = remoteWritePolicy?.enabled ? void 0 : remoteWritePolicy?.reason === "environment" ? "当前远端提交已关闭;你仍可暂存和审阅流水。" : writePolicyUnavailable ? "无法确认远端写入策略,提交保持禁用。" : "正在确认远端写入策略…";
|
|
12119
|
-
const
|
|
12120
|
-
const
|
|
12119
|
+
const invalidMemoIds = new Set([...changed, ...staged].filter((entry) => worksetMemoIssues(entry, presentations.get(entry.id)).length > 0).map((entry) => entry.id));
|
|
12120
|
+
const invalidStagedMemoCount = readyStagedEntries.filter((entry) => invalidMemoIds.has(entry.id)).length;
|
|
12121
|
+
const memoBlockedReason = invalidStagedMemoCount ? `有 ${invalidStagedMemoCount} 条暂存流水的备注需修改后才能提交。请取消暂存,在待审阅区编辑;原文已保留。` : void 0;
|
|
12121
12122
|
const commitBlockedReason = stageBlockedReason ?? categoryBlockedReason ?? memoBlockedReason ?? remoteCommitBlockedReason ?? sessionBlockedReason;
|
|
12123
|
+
const reviewStageEntries = changed.filter((entry) => !invalidEntryIds.has(entry.id));
|
|
12124
|
+
const bulkStageBlockedReason = stageBlockedReason ?? (reviewStageEntries.some((entry) => invalidMemoIds.has(entry.id)) ? STAGE_MEMO_BLOCKED : void 0);
|
|
12122
12125
|
const groupMutation = async (entries, operation) => {
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
return mutate(eligible.map((entry) => ({
|
|
12126
|
+
if (!entries.length) return void 0;
|
|
12127
|
+
return mutate(entries.map((entry) => ({
|
|
12126
12128
|
operation,
|
|
12127
12129
|
entryId: entry.id,
|
|
12128
12130
|
expectedEntryVersion: entry.version
|
|
@@ -12154,8 +12156,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
12154
12156
|
setToast(removeRequest.kind === "all" ? `已从待审阅中移除全部 ${count} 条候选流水` : "已从待审阅中移除候选流水");
|
|
12155
12157
|
};
|
|
12156
12158
|
const stageAll = async () => {
|
|
12157
|
-
|
|
12158
|
-
if (await groupMutation(
|
|
12159
|
+
if (bulkStageBlockedReason) return;
|
|
12160
|
+
if (await groupMutation(reviewStageEntries, "stage")) setToast(`已暂存 ${reviewStageEntries.length} 条分类有效的候选流水`);
|
|
12159
12161
|
};
|
|
12160
12162
|
const bulkActions = activeState === "changed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
12161
12163
|
className: "workset-review-bulk-actions",
|
|
@@ -12180,8 +12182,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
12180
12182
|
type: "button",
|
|
12181
12183
|
className: "workset-bulk-icon workset-bulk-stage",
|
|
12182
12184
|
"aria-label": "全部暂存",
|
|
12183
|
-
title:
|
|
12184
|
-
disabled: Boolean(
|
|
12185
|
+
title: bulkStageBlockedReason ?? "暂存分类有效的流水",
|
|
12186
|
+
disabled: Boolean(bulkStageBlockedReason) || hydrating || conflict || mutationIds.size > 0 || reviewStageEntries.length === 0,
|
|
12185
12187
|
onClick: () => void stageAll(),
|
|
12186
12188
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { name: "plus" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "全部暂存" })]
|
|
12187
12189
|
})]
|
|
@@ -12364,6 +12366,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
12364
12366
|
disabled: hydrating || conflict,
|
|
12365
12367
|
stageBlockedReason,
|
|
12366
12368
|
invalidEntryIds,
|
|
12369
|
+
invalidMemoIds,
|
|
12367
12370
|
mutationIds,
|
|
12368
12371
|
registry,
|
|
12369
12372
|
presentations,
|
|
@@ -12672,7 +12675,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
12672
12675
|
})
|
|
12673
12676
|
})] });
|
|
12674
12677
|
}
|
|
12675
|
-
function PendingSection({ tone, grouped, groups, total, visible, hydrating, worksetVersion, disabled, stageBlockedReason, invalidEntryIds, mutationIds, registry, presentations, onEdit, onView, onRemove, onPatch, onReceipt, onMore }) {
|
|
12678
|
+
function PendingSection({ tone, grouped, groups, total, visible, hydrating, worksetVersion, disabled, stageBlockedReason, invalidEntryIds, invalidMemoIds, mutationIds, registry, presentations, onEdit, onView, onRemove, onPatch, onReceipt, onMore }) {
|
|
12676
12679
|
const [collapsed, setCollapsed] = (0, react.useState)(() => /* @__PURE__ */ new Set());
|
|
12677
12680
|
const sentinelRef = (0, react.useRef)(null);
|
|
12678
12681
|
(0, react.useEffect)(() => {
|
|
@@ -12688,31 +12691,37 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
12688
12691
|
className: "pending-empty",
|
|
12689
12692
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: hydrating ? "正在读取流水…" : tone === "staged" ? "暂无已暂存流水" : "暂无待审阅流水" })
|
|
12690
12693
|
});
|
|
12691
|
-
const card = (entry) =>
|
|
12692
|
-
|
|
12693
|
-
|
|
12694
|
-
|
|
12695
|
-
|
|
12696
|
-
|
|
12697
|
-
|
|
12698
|
-
|
|
12699
|
-
|
|
12700
|
-
entry,
|
|
12701
|
-
|
|
12702
|
-
|
|
12703
|
-
|
|
12704
|
-
|
|
12705
|
-
|
|
12706
|
-
|
|
12707
|
-
|
|
12708
|
-
|
|
12709
|
-
|
|
12694
|
+
const card = (entry) => {
|
|
12695
|
+
const presentation = presentations.get(entry.id);
|
|
12696
|
+
const memoBlocked = invalidMemoIds.has(entry.id);
|
|
12697
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OperationCardOutlet, {
|
|
12698
|
+
registry,
|
|
12699
|
+
envelope: {
|
|
12700
|
+
id: entry.id,
|
|
12701
|
+
type: "finance.transaction.operation",
|
|
12702
|
+
title: entryTitle(entry, presentation),
|
|
12703
|
+
status: entry.state,
|
|
12704
|
+
version: worksetVersion,
|
|
12705
|
+
payload: {
|
|
12706
|
+
entry,
|
|
12707
|
+
presentation,
|
|
12708
|
+
memoBlocked,
|
|
12709
|
+
categoryBlocked: invalidEntryIds.has(entry.id),
|
|
12710
|
+
disabled: disabled || mutationIds.has(entry.id) || tone === "staged" && Boolean(stageBlockedReason),
|
|
12711
|
+
stageBlockedReason: stageBlockedReason ?? (memoBlocked ? STAGE_MEMO_BLOCKED : void 0),
|
|
12712
|
+
onEdit: () => onEdit(entry),
|
|
12713
|
+
onView: () => onView(entry),
|
|
12714
|
+
onRemove: () => onRemove(entry),
|
|
12715
|
+
onPatch,
|
|
12716
|
+
onReceipt
|
|
12717
|
+
}
|
|
12710
12718
|
}
|
|
12711
|
-
}
|
|
12712
|
-
}
|
|
12719
|
+
}, entry.id);
|
|
12720
|
+
};
|
|
12713
12721
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [grouped ? groups.map((group) => {
|
|
12714
12722
|
const closed = collapsed.has(group.key);
|
|
12715
12723
|
const eligible = group.allEntries.filter((entry) => tone === "review" ? entry.state === "changed" && !invalidEntryIds.has(entry.id) : entry.state === "staged" && !entry.lockedCommitId);
|
|
12724
|
+
const groupBlockedReason = stageBlockedReason ?? (tone === "review" && eligible.some((entry) => invalidMemoIds.has(entry.id)) ? STAGE_MEMO_BLOCKED : void 0);
|
|
12716
12725
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
12717
12726
|
className: "workset-account-group",
|
|
12718
12727
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
@@ -12741,8 +12750,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
12741
12750
|
type: "button",
|
|
12742
12751
|
className: `workset-account-action${tone === "staged" ? " workset-account-unstage" : ""}`,
|
|
12743
12752
|
"aria-label": `${tone === "review" ? "暂存" : "取消暂存"}${group.label}全部可操作流水`,
|
|
12744
|
-
title:
|
|
12745
|
-
disabled: disabled || Boolean(
|
|
12753
|
+
title: groupBlockedReason ?? (tone === "review" ? "暂存本账户" : "取消暂存本账户可操作流水"),
|
|
12754
|
+
disabled: disabled || Boolean(groupBlockedReason) || mutationIds.size > 0 || eligible.length === 0,
|
|
12746
12755
|
onClick: () => onPatch(eligible.map((entry) => ({
|
|
12747
12756
|
operation: tone === "review" ? "stage" : "unstage",
|
|
12748
12757
|
entryId: entry.id,
|
|
@@ -13013,7 +13022,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13013
13022
|
"family"
|
|
13014
13023
|
][hash % 6] ?? "alipay";
|
|
13015
13024
|
}
|
|
13016
|
-
function TransactionTitleLine({ facts }) {
|
|
13025
|
+
function TransactionTitleLine({ facts, trailing }) {
|
|
13017
13026
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("strong", {
|
|
13018
13027
|
className: "entry-title-line transaction-title-line",
|
|
13019
13028
|
children: [
|
|
@@ -13044,7 +13053,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13044
13053
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
13045
13054
|
className: `account-chip account-${accountKind(facts.accountKindName ?? facts.account)}`,
|
|
13046
13055
|
children: facts.account
|
|
13047
|
-
})
|
|
13056
|
+
}),
|
|
13057
|
+
trailing
|
|
13048
13058
|
]
|
|
13049
13059
|
});
|
|
13050
13060
|
}
|
|
@@ -13081,18 +13091,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13081
13091
|
]
|
|
13082
13092
|
});
|
|
13083
13093
|
}
|
|
13084
|
-
function WorksetEntryTitleLine({ entry, presentation }) {
|
|
13094
|
+
function WorksetEntryTitleLine({ entry, presentation, trailing }) {
|
|
13085
13095
|
const direction = presentation?.type === "income" ? "income" : presentation?.type === "transfer" ? "transfer" : entry.proposal.operation === "create" && entry.proposal.transaction.type === "income" ? "income" : entry.proposal.operation === "create" && entry.proposal.transaction.type === "transfer" ? "transfer" : "expense";
|
|
13086
13096
|
const sourceAccount = presentation?.accountName ?? presentation?.accountId ?? "未指定账户";
|
|
13087
13097
|
const account = direction === "transfer" ? `${sourceAccount} → ${presentation?.destinationAccountName ?? presentation?.destinationAccountId ?? (entry.proposal.operation === "create" ? entry.proposal.transaction.destinationAccountId : void 0) ?? "未指定转入账户"}` : sourceAccount;
|
|
13088
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TransactionTitleLine, {
|
|
13089
|
-
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
|
|
13098
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TransactionTitleLine, {
|
|
13099
|
+
facts: {
|
|
13100
|
+
occurredAt: compactDateTime(presentation?.occurredAt),
|
|
13101
|
+
amount: entryAmount(entry, presentation),
|
|
13102
|
+
direction,
|
|
13103
|
+
category: direction === "transfer" ? "转账" : transactionCategoryLabel(presentation),
|
|
13104
|
+
account,
|
|
13105
|
+
accountKindName: sourceAccount
|
|
13106
|
+
},
|
|
13107
|
+
trailing
|
|
13108
|
+
});
|
|
13096
13109
|
}
|
|
13097
13110
|
function WorksetEntrySecondaryLine({ entry, presentation }) {
|
|
13098
13111
|
const store = presentation?.storeName?.trim();
|
|
@@ -13109,13 +13122,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13109
13122
|
const payload = envelope.payload;
|
|
13110
13123
|
const entry = payload.entry;
|
|
13111
13124
|
const presentation = payload.presentation;
|
|
13125
|
+
const memoWarningId = (0, react.useId)();
|
|
13112
13126
|
const locked = Boolean(entry.lockedCommitId) || entry.state === "commit_locked" || entry.state === "readback_pending" || entry.state === "unknown";
|
|
13113
13127
|
const direction = presentation?.type === "income" ? "income" : presentation?.type === "transfer" ? "transfer" : "expense";
|
|
13114
13128
|
const operationIcon = direction === "income" ? "plus" : direction === "transfer" ? "arrow" : "arrow";
|
|
13115
13129
|
const title = worksetEntryFacts(entry, presentation);
|
|
13116
13130
|
const operationStateText = entry.proposal.operation === "update" ? "待更新" : entry.proposal.operation === "delete" ? "待删除" : "待创建";
|
|
13117
13131
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
13118
|
-
className: `operation-card operation-${entry.proposal.operation}`,
|
|
13132
|
+
className: `operation-card operation-${entry.proposal.operation}${payload.memoBlocked ? " operation-memo-blocked" : ""}`,
|
|
13119
13133
|
children: [
|
|
13120
13134
|
entry.state === "changed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
13121
13135
|
className: "operation-state-rail",
|
|
@@ -13129,6 +13143,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13129
13143
|
disabled: locked || entry.state !== "changed" && payload.disabled,
|
|
13130
13144
|
onClick: payload.onView,
|
|
13131
13145
|
"aria-label": `查看${title}`,
|
|
13146
|
+
"aria-describedby": payload.memoBlocked ? memoWarningId : void 0,
|
|
13132
13147
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
13133
13148
|
className: `operation-direction operation-direction-${direction}`,
|
|
13134
13149
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { name: operationIcon })
|
|
@@ -13137,7 +13152,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13137
13152
|
children: [
|
|
13138
13153
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorksetEntryTitleLine, {
|
|
13139
13154
|
entry,
|
|
13140
|
-
...presentation ? { presentation } : {}
|
|
13155
|
+
...presentation ? { presentation } : {},
|
|
13156
|
+
trailing: payload.memoBlocked && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
13157
|
+
className: "operation-memo-warning",
|
|
13158
|
+
id: memoWarningId,
|
|
13159
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { name: "warning" }), "备注需修改"]
|
|
13160
|
+
})
|
|
13141
13161
|
}),
|
|
13142
13162
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorksetEntrySecondaryLine, {
|
|
13143
13163
|
entry,
|
|
@@ -14636,6 +14656,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14636
14656
|
function formatTypedCurrencyCents(type, cents, currency) {
|
|
14637
14657
|
return formatCurrencyCents(type === "expense" ? -Math.abs(cents) : type === "income" ? Math.abs(cents) : cents, currency);
|
|
14638
14658
|
}
|
|
14659
|
+
var STAGE_MEMO_BLOCKED;
|
|
14639
14660
|
var init_src = __esmMin((() => {
|
|
14640
14661
|
init_src$2();
|
|
14641
14662
|
init_web_contracts();
|
|
@@ -14653,6 +14674,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14653
14674
|
init_draft_card();
|
|
14654
14675
|
init_book_grant();
|
|
14655
14676
|
init_ledger_route();
|
|
14677
|
+
STAGE_MEMO_BLOCKED = "请先修改暂存范围内的备注";
|
|
14656
14678
|
}));
|
|
14657
14679
|
//#endregion
|
|
14658
14680
|
//#region ../../packages/finance-ui/src/ledger-sync-progress.tsx
|
|
@@ -25,7 +25,7 @@ const Config = Schema.object({
|
|
|
25
25
|
financeDbPath: Schema.string().description("已停止支持,请改用 dataDir"),
|
|
26
26
|
preferencesFilePath: Schema.string().description("已停止支持,请改用 dataDir"),
|
|
27
27
|
attachmentsRoot: Schema.string().description("已停止支持,附件通过宿主 attachments 服务读取"),
|
|
28
|
-
remoteWrites: Schema.union([Schema.boolean(), Schema.const("auto")]).default("auto")
|
|
28
|
+
remoteWrites: Schema.union([Schema.boolean(), Schema.const("auto")]).default("auto").description("远端交易写入权限。auto 按安装形态选择,生产安装启用,本地开发禁用。")
|
|
29
29
|
});
|
|
30
30
|
/**
|
|
31
31
|
* Fail with the exact host method we call instead of a TypeError deep in a callback.
|
|
@@ -52,6 +52,7 @@ async function apply(ctx, config) {
|
|
|
52
52
|
configValue: config.remoteWrites,
|
|
53
53
|
onWarn: (message) => ctx.logger.warn(message)
|
|
54
54
|
});
|
|
55
|
+
ctx.logger.info(`sui-ledger: remote writes ${writePolicy.enabled ? "enabled" : "disabled"} (form=${writePolicy.installForm}, source=${writePolicy.source})`);
|
|
55
56
|
let attachments;
|
|
56
57
|
ctx.inject(["attachments"], (host) => {
|
|
57
58
|
requireHostMethod(host.attachments?.readFileStream, "attachments.readFileStream", "附件读取");
|
|
@@ -148,7 +149,7 @@ async function apply(ctx, config) {
|
|
|
148
149
|
path: "/api/sui-ledger",
|
|
149
150
|
handler: async (req, res) => {
|
|
150
151
|
const url = new URL(req.url ?? "/", "http://localhost"), path = url.pathname.slice(15);
|
|
151
|
-
if (path === "/maintenance" || path.startsWith("/maintenance/") || path === "/finance/services" || path.startsWith("/finance/services/") || path === "/finance/session" || path.startsWith("/finance/session/") || path === "/finance/default-book" || /^\/finance\/subjects\/[^/]+\/grant(?:\/|$)/.test(path)) {
|
|
152
|
+
if (req.method === "POST" && (path.startsWith("/finance/commits/") || /^\/finance\/worksets\/[^/]+\/commits$/.test(path)) || path === "/maintenance" || path.startsWith("/maintenance/") || path === "/finance/services" || path.startsWith("/finance/services/") || path === "/finance/session" || path.startsWith("/finance/session/") || path === "/finance/default-book" || /^\/finance\/subjects\/[^/]+\/grant(?:\/|$)/.test(path)) {
|
|
152
153
|
const rejection = web.connection.requestRejection(req);
|
|
153
154
|
if (rejection !== void 0) {
|
|
154
155
|
res.statusCode = rejection;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MemoPolicyViolationError } from "../../finance/src/errors.mjs";
|
|
2
|
+
import "../../finance/src/index.mjs";
|
|
1
3
|
import { FinanceInteractionTypes } from "./web-contracts.mjs";
|
|
2
4
|
import { FinanceCheckError, commitFailure } from "./commit-failure.mjs";
|
|
3
5
|
import { FINANCE_REMOTE_WRITES_DISABLED_ERROR } from "./service.mjs";
|
|
@@ -278,7 +280,15 @@ function createFinanceTrustedControlRoute(finance, interaction, preferences) {
|
|
|
278
280
|
const workset = request.pathname.match(/^\/v1\/finance\/worksets\/([A-Za-z0-9._-]+)$/);
|
|
279
281
|
if (request.method === "PATCH" && workset) {
|
|
280
282
|
const input = validatePatchWorksetRequest(await request.body());
|
|
281
|
-
|
|
283
|
+
try {
|
|
284
|
+
await financeCall(() => finance.patchWorkset(workset[1], input));
|
|
285
|
+
} catch (error) {
|
|
286
|
+
if (!(error instanceof MemoPolicyViolationError)) throw error;
|
|
287
|
+
return json(400, {
|
|
288
|
+
error: "本次暂存范围内有备注需修改,请在待审阅区编辑后再暂存。",
|
|
289
|
+
failure: commitFailure(error, "checking", "not_sent")
|
|
290
|
+
});
|
|
291
|
+
}
|
|
282
292
|
return json(200, { workset: await financeCall(() => finance.getWorksetView(workset[1])) });
|
|
283
293
|
}
|
|
284
294
|
const prepare = request.pathname.match(/^\/v1\/finance\/worksets\/([A-Za-z0-9._-]+)\/commits$/);
|
|
@@ -430,6 +440,7 @@ async function financeCall(operation) {
|
|
|
430
440
|
try {
|
|
431
441
|
return await operation();
|
|
432
442
|
} catch (error) {
|
|
443
|
+
if (error instanceof MemoPolicyViolationError) throw error;
|
|
433
444
|
const message = error instanceof Error ? error.message : "";
|
|
434
445
|
if (message === "finance_read_operation_in_progress" || message === "finance_sync_operation_conflict") throw new FinanceRouteError(409, message);
|
|
435
446
|
if (errorCode(error) === "WRITE_DISABLED") throw new FinanceRouteError(403, message === "finance_remote_writes_disabled" ? FINANCE_REMOTE_WRITES_DISABLED_ERROR : "finance_remote_writes_not_enabled");
|
|
@@ -697,7 +697,7 @@ var FinanceApplicationService = class {
|
|
|
697
697
|
if (change.operation === "stage") {
|
|
698
698
|
const entry = workset.entries.find((candidate) => candidate.id === change.entryId);
|
|
699
699
|
if (!entry) throw new Error("finance_entry_not_found");
|
|
700
|
-
|
|
700
|
+
assertEntryReadyForWrite(entry, metadata, this.options.ledger);
|
|
701
701
|
}
|
|
702
702
|
return change;
|
|
703
703
|
});
|
|
@@ -832,12 +832,7 @@ var FinanceApplicationService = class {
|
|
|
832
832
|
}).sort(compareCommitEntries);
|
|
833
833
|
if (!selected.length || new Set(requestedIds).size !== requestedIds.length) throw new Error("finance_commit_entries_invalid");
|
|
834
834
|
const metadata = financeBookMetadata(this.options.ledger.cachedMetadata(workset.bookId));
|
|
835
|
-
for (const entry of selected)
|
|
836
|
-
assertEntryProposalValid(entry, metadata, this.options.ledger);
|
|
837
|
-
const current = entry.proposal.operation === "update" ? this.options.ledger.getTransaction(entry.bookId, entry.proposal.remoteId) : void 0;
|
|
838
|
-
const target = proposalFinancialPayload(entry.proposal, current);
|
|
839
|
-
if (target) assertMemoPolicy(target.memo);
|
|
840
|
-
}
|
|
835
|
+
for (const entry of selected) assertEntryReadyForWrite(entry, metadata, this.options.ledger);
|
|
841
836
|
const remoteIds = selected.flatMap((entry) => entry.proposal.operation === "create" ? [] : [entry.proposal.remoteId]);
|
|
842
837
|
const readScope = [...new Map(selected.flatMap((entry) => {
|
|
843
838
|
const proposal = entry.proposal;
|
|
@@ -2294,9 +2289,11 @@ function entryCategoryValidation(entries, presentations, metadata) {
|
|
|
2294
2289
|
function assertProposalValid(proposal, metadata, current) {
|
|
2295
2290
|
assertProposalValidation(proposalValidation("proposal", proposal, metadata, current));
|
|
2296
2291
|
}
|
|
2297
|
-
function
|
|
2292
|
+
function assertEntryReadyForWrite(entry, metadata, ledger) {
|
|
2298
2293
|
const current = entry.proposal.operation !== "create" ? ledger.getTransaction(entry.bookId, entry.proposal.remoteId) : void 0;
|
|
2299
2294
|
assertProposalValidation(proposalValidation(entry.id, entry.proposal, metadata, current));
|
|
2295
|
+
const target = proposalFinancialPayload(entry.proposal, current);
|
|
2296
|
+
if (target) assertMemoPolicy(target.memo);
|
|
2300
2297
|
}
|
|
2301
2298
|
function assertProposalValidation(validation) {
|
|
2302
2299
|
const issue = validation.issues[0];
|
|
@@ -13,9 +13,9 @@ function loadConfig(env = process.env, overrides = {}) {
|
|
|
13
13
|
financeDatabasePath: join(dataDir, "finance.db"),
|
|
14
14
|
credentialService: FEIDEE_KEYCHAIN_SERVICE,
|
|
15
15
|
recentSyncMonths: Number(env.SUI_LEDGER_RECENT_SYNC_MONTHS ?? 2),
|
|
16
|
-
remoteWritesDisabled: parseBooleanEnvironment("SUI_LEDGER_REMOTE_WRITES_DISABLED", env.SUI_LEDGER_REMOTE_WRITES_DISABLED, true),
|
|
17
16
|
...writeCanaryBookId ? { writeCanaryBookId } : {},
|
|
18
17
|
...overrides,
|
|
18
|
+
remoteWritesDisabled: overrides.remoteWritesDisabled ?? parseBooleanEnvironment("SUI_LEDGER_REMOTE_WRITES_DISABLED", env.SUI_LEDGER_REMOTE_WRITES_DISABLED, true),
|
|
19
19
|
dataDir
|
|
20
20
|
};
|
|
21
21
|
if (!Number.isInteger(config.recentSyncMonths) || config.recentSyncMonths < 1) throw new Error("SUI_LEDGER_RECENT_SYNC_MONTHS must be a positive integer");
|
|
@@ -3,6 +3,7 @@ import { dirname, join } from "node:path";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
//#region src/remote-write-policy.ts
|
|
5
5
|
const REMOTE_WRITE_ENV = "SUI_LEDGER_REMOTE_WRITES";
|
|
6
|
+
const REMOTE_WRITE_DISABLED_ENV = "SUI_LEDGER_REMOTE_WRITES_DISABLED";
|
|
6
7
|
const DEV_BUNDLE_MARKER = "DEV-BUNDLE";
|
|
7
8
|
/** In unbundle builds this module lands at dist/remote-write-policy.mjs, so the bundle root is dist/.. */
|
|
8
9
|
function defaultBundleRoot() {
|
|
@@ -19,12 +20,22 @@ function parseEnvSpellings(raw) {
|
|
|
19
20
|
function resolveRemoteWritePolicy(input = {}) {
|
|
20
21
|
const warn = input.onWarn ?? ((message) => console.warn(`[sui-ledger] ${message}`));
|
|
21
22
|
const installForm = detectInstallForm(input.bundleRoot ?? defaultBundleRoot());
|
|
23
|
+
const env = input.env ?? { get: (name) => process.env[name] };
|
|
24
|
+
const disabled = env.get(REMOTE_WRITE_DISABLED_ENV)?.trim();
|
|
25
|
+
if (disabled && disabled !== "false") {
|
|
26
|
+
if (disabled !== "true") warn(`${REMOTE_WRITE_DISABLED_ENV} must be true or false. Remote writes are disabled.`);
|
|
27
|
+
return {
|
|
28
|
+
enabled: false,
|
|
29
|
+
source: "kill-switch",
|
|
30
|
+
installForm
|
|
31
|
+
};
|
|
32
|
+
}
|
|
22
33
|
if (input.configValue === true || input.configValue === false) return {
|
|
23
34
|
enabled: input.configValue,
|
|
24
35
|
source: "config",
|
|
25
36
|
installForm
|
|
26
37
|
};
|
|
27
|
-
const raw =
|
|
38
|
+
const raw = env.get(REMOTE_WRITE_ENV);
|
|
28
39
|
if (raw !== void 0 && raw.trim() !== "") {
|
|
29
40
|
const parsed = parseEnvSpellings(raw);
|
|
30
41
|
if (parsed === void 0) {
|
|
@@ -42,10 +53,10 @@ function resolveRemoteWritePolicy(input = {}) {
|
|
|
42
53
|
};
|
|
43
54
|
}
|
|
44
55
|
return {
|
|
45
|
-
enabled: installForm === "
|
|
56
|
+
enabled: installForm === "published",
|
|
46
57
|
source: "install-form",
|
|
47
58
|
installForm
|
|
48
59
|
};
|
|
49
60
|
}
|
|
50
61
|
//#endregion
|
|
51
|
-
export { REMOTE_WRITE_ENV, detectInstallForm, resolveRemoteWritePolicy };
|
|
62
|
+
export { REMOTE_WRITE_DISABLED_ENV, REMOTE_WRITE_ENV, detectInstallForm, resolveRemoteWritePolicy };
|
|
@@ -2806,6 +2806,16 @@ button:disabled {
|
|
|
2806
2806
|
background: #f8faff;
|
|
2807
2807
|
}
|
|
2808
2808
|
|
|
2809
|
+
.finance-workset .operation-card.operation-memo-blocked {
|
|
2810
|
+
--operation-card-background: color-mix(in srgb, var(--danger) 9%, var(--ledger-surface, var(--surface)));
|
|
2811
|
+
background: var(--operation-card-background);
|
|
2812
|
+
box-shadow: inset 4px 0 0 var(--danger);
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
.finance-workset .operation-card.operation-memo-blocked:hover, .finance-workset .operation-card.operation-memo-blocked:has(.operation-main:focus-visible) {
|
|
2816
|
+
background: color-mix(in srgb, var(--danger) 13%, var(--ledger-surface, var(--surface)));
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2809
2819
|
.finance-workset .operation-main {
|
|
2810
2820
|
width: 100%;
|
|
2811
2821
|
min-width: 0;
|
|
@@ -2870,6 +2880,32 @@ button:disabled {
|
|
|
2870
2880
|
display: flex;
|
|
2871
2881
|
}
|
|
2872
2882
|
|
|
2883
|
+
.finance-workset .operation-memo-blocked .transaction-title-line {
|
|
2884
|
+
flex-wrap: wrap;
|
|
2885
|
+
row-gap: 2px;
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2888
|
+
.operation-memo-warning {
|
|
2889
|
+
color: var(--danger);
|
|
2890
|
+
white-space: nowrap;
|
|
2891
|
+
border: 1px solid;
|
|
2892
|
+
border-radius: 4px;
|
|
2893
|
+
flex: none;
|
|
2894
|
+
align-self: center;
|
|
2895
|
+
align-items: center;
|
|
2896
|
+
gap: 4px;
|
|
2897
|
+
padding: 0 5px;
|
|
2898
|
+
font-size: 11px;
|
|
2899
|
+
font-weight: 650;
|
|
2900
|
+
line-height: 15px;
|
|
2901
|
+
display: inline-flex;
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
.operation-memo-warning > svg {
|
|
2905
|
+
width: 12px;
|
|
2906
|
+
height: 12px;
|
|
2907
|
+
}
|
|
2908
|
+
|
|
2873
2909
|
.finance-workset .operation-title strong {
|
|
2874
2910
|
color: #252823;
|
|
2875
2911
|
font-variant-numeric: tabular-nums;
|
|
@@ -3047,6 +3083,10 @@ button:disabled {
|
|
|
3047
3083
|
background: #d8a09d;
|
|
3048
3084
|
}
|
|
3049
3085
|
|
|
3086
|
+
.finance-workset .operation-memo-blocked .operation-state-rail {
|
|
3087
|
+
background: var(--danger);
|
|
3088
|
+
}
|
|
3089
|
+
|
|
3050
3090
|
.finance-workset .operation-actions {
|
|
3051
3091
|
grid-area: 1 / 2;
|
|
3052
3092
|
justify-content: flex-end;
|
|
@@ -15357,11 +15397,16 @@ button:disabled {
|
|
|
15357
15397
|
border-color: var(--dsw-alias-border-l3, #c8bdb2);
|
|
15358
15398
|
}
|
|
15359
15399
|
|
|
15360
|
-
.sui-ledger-panel .category-branches, .sui-ledger-panel .category-inspector, .sui-ledger-panel .category-leaf-head, .sui-ledger-panel .spending-data-table thead, .sui-ledger-panel .
|
|
15400
|
+
.sui-ledger-panel .category-branches, .sui-ledger-panel .category-inspector, .sui-ledger-panel .category-leaf-head, .sui-ledger-panel .spending-data-table thead, .sui-ledger-panel .workset-toolbar, .sui-ledger-panel .workset-view-toggle, .sui-ledger-panel .workset-view-toggle button.active, .sui-ledger-panel .workset-loading {
|
|
15361
15401
|
background: var(--ledger-surface);
|
|
15362
15402
|
border-color: var(--ledger-line);
|
|
15363
15403
|
}
|
|
15364
15404
|
|
|
15405
|
+
.sui-ledger-panel .finance-workset .operation-card {
|
|
15406
|
+
background: var(--operation-card-background, var(--ledger-surface));
|
|
15407
|
+
border-color: var(--ledger-line);
|
|
15408
|
+
}
|
|
15409
|
+
|
|
15365
15410
|
.sui-ledger-panel .account-groups > button.active, .sui-ledger-panel .report-nav > button.active, .sui-ledger-panel .category-branches > button[aria-pressed="true"], .sui-ledger-panel .category-leaves > button.selected {
|
|
15366
15411
|
color: var(--ledger-accent);
|
|
15367
15412
|
background: var(--ledger-accent-soft);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Ledger",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "A personal ledger with 29 finance tools, draft review and confirmation, and a full-page ledger interface."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodpeanuts/dsh-sui",
|
|
3
|
-
"version": "0.1.2-fix.
|
|
3
|
+
"version": "0.1.2-fix.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "Personal finance tools and a ledger workspace for DeepSeek Harness",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"deepseek-harness",
|
|
9
9
|
"dsh",
|
|
10
10
|
"dsh-plugin",
|
|
11
11
|
"ledger",
|
|
12
|
-
"
|
|
13
|
-
"随手记"
|
|
12
|
+
"personal-finance"
|
|
14
13
|
],
|
|
15
14
|
"publishConfig": {
|
|
16
15
|
"access": "public"
|