@akanjs/cli 3.1.1-rc.16 → 3.1.1-rc.18
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/.build-stamp +1 -1
- package/{CodeAgent-23ewzxqa.js → CodeAgent-fbcq8vks.js} +2 -2
- package/{CodeTui-kc99fk78.js → CodeTui-0626gxqd.js} +1 -1
- package/TunnelShare-2p24xxza.js +14 -0
- package/agent.command-hpza0pg9.js +46 -0
- package/akanCode.js +5 -3
- package/{application.command-bvfd1680.js → application.command-3a7q1hs2.js} +11 -10
- package/{applicationBuildRunner-4ajaesk1.js → applicationBuildRunner-s7yt71j4.js} +5 -5
- package/buildBatch.proc.js +6 -6
- package/{cloud.command-f2w40fyy.js → cloud.command-4vg0pcea.js} +15 -14
- package/cloud.script-nkmeyhet.js +25 -0
- package/{code.command-dbhhnahn.js → code.command-fbntb67p.js} +6 -6
- package/commandManifest.json +1 -1
- package/{context.command-yswjwv6y.js → context.command-31rm54v0.js} +18 -18
- package/context.runner-w01a32ph.js +26 -0
- package/{guideline.command-ztx6dkpk.js → guideline.command-cv3by2ng.js} +3 -3
- package/guidelines/conventions/core.md +104 -0
- package/guidelines/conventions/rules/app.md +83 -0
- package/guidelines/conventions/rules/auth.md +45 -0
- package/guidelines/conventions/rules/config.md +56 -0
- package/guidelines/conventions/rules/constant.md +24 -0
- package/guidelines/conventions/rules/gates.md +31 -0
- package/guidelines/conventions/rules/layer.md +25 -0
- package/guidelines/conventions/rules/migration.md +27 -0
- package/guidelines/conventions/rules/module.md +90 -0
- package/guidelines/conventions/rules/page.md +56 -0
- package/guidelines/conventions/rules/sensitive.md +16 -0
- package/guidelines/conventions/rules/server.md +86 -0
- package/guidelines/conventions/rules/ssr.md +47 -0
- package/guidelines/conventions/rules/style.md +43 -0
- package/guidelines/conventions/rules/test.md +34 -0
- package/guidelines/conventions/rules/ts.md +95 -0
- package/guidelines/conventions/rules/tsx.md +75 -0
- package/guidelines/mcpRule/mcpRule.instruction.md +1 -1
- package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +3 -3
- package/incrementalBuilder.proc.js +6 -6
- package/{index-xjwcp91m.js → index-05nxx4m5.js} +43 -12
- package/{index-k9k18vq9.js → index-0ht91675.js} +37 -59
- package/{index-er16p89s.js → index-0zwznvv1.js} +1 -1
- package/{index-76jwsm3g.js → index-0zyatd10.js} +2 -2
- package/{index-97fsvy66.js → index-12kzwak1.js} +3 -3
- package/{index-005dqc83.js → index-1dhf8ymv.js} +2 -2
- package/{index-00ke4phc.js → index-3gccwenr.js} +1 -1
- package/{index-2epb3wgh.js → index-3txrjt6n.js} +2 -2
- package/{index-7ndgffg4.js → index-57q1ayd2.js} +18 -1240
- package/index-5kh9scvs.js +514 -0
- package/index-5n5hds19.js +1246 -0
- package/{index-9sa6abze.js → index-6269mf2s.js} +10 -9
- package/{index-921cxqrd.js → index-64g9fsjy.js} +41 -12
- package/index-7zeb5r1p.js +653 -0
- package/{index-s4c2y5gs.js → index-8s8b4eba.js} +45 -4
- package/{index-4332q6yj.js → index-922k2zwq.js} +3 -3
- package/{index-m6qgr1rx.js → index-9ndw5d8j.js} +7 -7
- package/{index-xfp4dcnx.js → index-et6ce601.js} +1 -1
- package/{index-saj9cx3a.js → index-f5adsa58.js} +4 -4
- package/{index-vgt25eh1.js → index-fbewhg4g.js} +7 -32
- package/{index-ysyt782g.js → index-hm7x0c11.js} +4 -4
- package/{index-2p1brf5e.js → index-hvv5rnaq.js} +2 -2
- package/index-jje9qzyq.js +27 -0
- package/{index-rxse80x6.js → index-js1gj6f6.js} +12 -10
- package/{index-p2pahmsa.js → index-kjrvwzav.js} +3 -3
- package/index-m6r88hhr.js +3582 -0
- package/{index-mk391h0z.js → index-mt0wa941.js} +4 -4
- package/{index-m93qg20j.js → index-mwj9q2ya.js} +1 -1
- package/{index-5nd1wtkv.js → index-p6x5b7hr.js} +1 -1
- package/index-r2wedvqn.js +138 -0
- package/{index-gxj80jz7.js → index-rvynj5gz.js} +1 -1
- package/{index-m54n0v29.js → index-tdv66eah.js} +4 -4
- package/{index-vq77g679.js → index-w134p86k.js} +1 -1
- package/{index-deeskxjh.js → index-wfczhj1z.js} +14 -36
- package/{index-dy0jx9ay.js → index-wwe9rsrx.js} +14 -0
- package/{index-qx4r4cj2.js → index-x5ecanqh.js} +2 -2
- package/{index-nzfgyw3b.js → index-zre4m2ce.js} +4 -4
- package/index.js +23 -22
- package/{library.command-hmbkcwzw.js → library.command-sh70fyvy.js} +3 -3
- package/{localRegistry.command-sq5p4c9x.js → localRegistry.command-2nbyy84d.js} +14 -13
- package/{module.command-n4z29zcv.js → module.command-n0bmtzwy.js} +5 -5
- package/{package.command-20025dy3.js → package.command-7h9r51bz.js} +3 -3
- package/package.json +2 -2
- package/{page.command-q8fvpjer.js → page.command-vjtpfbb1.js} +3 -3
- package/{pipeline.command-8j97fq88.js → pipeline.command-c93se3ar.js} +2 -2
- package/{primitive.command-e5y6dqp1.js → primitive.command-a3075qp2.js} +6 -6
- package/{projectTypecheck-tbdye9k3.js → projectTypecheck-sf9xwaga.js} +1 -1
- package/{prompter-76k56b37.js → prompter-hgcta8pb.js} +1 -1
- package/quality.command-dw1y9hmy.js +76 -0
- package/{repair.command-dq1gckth.js → repair.command-tg57d8yt.js} +5 -5
- package/{scalar.command-5vwf152w.js → scalar.command-cwzge353.js} +4 -4
- package/skills/akan-agent/SKILL.md +36 -0
- package/skills/akan-debug/SKILL.md +3 -3
- package/skills/akan-deps/SKILL.md +1 -2
- package/skills/akan-mcp/SKILL.md +40 -0
- package/skills/akan-page/SKILL.md +44 -0
- package/skills/akan-query/SKILL.md +38 -0
- package/skills/akan-runtime/SKILL.md +40 -0
- package/skills/akan-scaffold/SKILL.md +16 -6
- package/skills/akan-transport/SKILL.md +40 -0
- package/skills/akan-validate/SKILL.md +13 -11
- package/{subspace.command-182be8vj.js → subspace.command-3h03c7kc.js} +8 -8
- package/templates/workspaceRoot/.gitignore.template +3 -0
- package/templates/workspaceRoot/AGENTS.md.template +4 -10
- package/{tunnel.command-bfzj7xkb.js → tunnel.command-czaz6ys4.js} +7 -7
- package/{typeChecker-px49mezc.js → typeChecker-j2jdnqsr.js} +1 -1
- package/typecheck.proc.js +6 -1
- package/verify.command-nzwhtz71.js +91 -0
- package/{workflow.command-3g53242s.js → workflow.command-srhky88x.js} +23 -13
- package/{workspace.command-h7399jwv.js → workspace.command-9stchcd2.js} +31 -29
- package/TunnelShare-dk2gw78d.js +0 -14
- package/agent.command-knp5j7bq.js +0 -25
- package/cloud.script-2r82sv0f.js +0 -24
- package/context.runner-c3wsh2jw.js +0 -26
- package/guidelines/conventions/conventions.instruction.md +0 -663
- package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +0 -291
- package/index-4t4qb8jg.js +0 -279
- package/index-hvg3esm0.js +0 -1844
- package/index-zzvvc845.js +0 -74
- package/quality.command-168pt5vm.js +0 -1788
- package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +0 -69
- package/templates/workspaceRoot/docs/GENERATED.md.template +0 -55
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import {
|
|
3
3
|
Workspace,
|
|
4
4
|
command
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-3gccwenr.js";
|
|
6
6
|
import"./index-52w0fvh8.js";
|
|
7
|
-
import"./index-
|
|
7
|
+
import"./index-64g9fsjy.js";
|
|
8
8
|
import {
|
|
9
9
|
renderPrimitiveReport
|
|
10
|
-
} from "./index-
|
|
11
|
-
import"./index-
|
|
12
|
-
import"./index-
|
|
10
|
+
} from "./index-05nxx4m5.js";
|
|
11
|
+
import"./index-rvynj5gz.js";
|
|
12
|
+
import"./index-tdv66eah.js";
|
|
13
13
|
import {
|
|
14
14
|
PrimitiveScript
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-hm7x0c11.js";
|
|
16
16
|
|
|
17
17
|
// pkgs/@akanjs/cli/primitive/primitive.command.ts
|
|
18
18
|
import { Logger } from "akanjs/common";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
Workspace,
|
|
4
|
+
script,
|
|
5
|
+
command
|
|
6
|
+
} from "./index-3gccwenr.js";
|
|
7
|
+
import"./index-52w0fvh8.js";
|
|
8
|
+
import {
|
|
9
|
+
AppExecutor,
|
|
10
|
+
LibExecutor
|
|
11
|
+
} from "./index-64g9fsjy.js";
|
|
12
|
+
import {
|
|
13
|
+
MaintainabilityBaseline,
|
|
14
|
+
WorkspaceRunner,
|
|
15
|
+
AkanQualityScanner,
|
|
16
|
+
formatQualityScanResult,
|
|
17
|
+
formatSsrScanResult
|
|
18
|
+
} from "./index-m6r88hhr.js";
|
|
19
|
+
import"./index-62md4dwy.js";
|
|
20
|
+
import"./index-hj6w4ka1.js";
|
|
21
|
+
import"./index-fbewhg4g.js";
|
|
22
|
+
|
|
23
|
+
// pkgs/@akanjs/cli/quality/quality.script.ts
|
|
24
|
+
import { Logger } from "akanjs/common";
|
|
25
|
+
class QualityScript extends script("quality", [WorkspaceRunner]) {
|
|
26
|
+
async scan(workspace, format = "text") {
|
|
27
|
+
const spinner = workspace.spinning("Scanning Akan code quality...");
|
|
28
|
+
const result = await new AkanQualityScanner().scan(workspace.workspaceRoot);
|
|
29
|
+
spinner.succeed(`Quality scan completed (${result.scannedFiles} files, ${result.warnings.length} warnings)`);
|
|
30
|
+
Logger.rawLog(format === "json" ? JSON.stringify(result, null, 2) : formatQualityScanResult(result));
|
|
31
|
+
}
|
|
32
|
+
async ssr(workspace, format = "text") {
|
|
33
|
+
const spinner = workspace.spinning("Measuring Akan server/client render balance...");
|
|
34
|
+
const scanned = await new AkanQualityScanner().scan(workspace.workspaceRoot);
|
|
35
|
+
const result = { ...scanned, warnings: scanned.warnings.filter((warning) => warning.scope === "ssr") };
|
|
36
|
+
spinner.succeed(`SSR scan completed (${result.scannedFiles} files, ${result.warnings.length} warnings)`);
|
|
37
|
+
Logger.rawLog(format === "json" ? JSON.stringify(result, null, 2) : formatSsrScanResult(result));
|
|
38
|
+
}
|
|
39
|
+
async baseline(workspace, { force = false } = {}) {
|
|
40
|
+
const [appNames, libNames] = await workspace.getExecs();
|
|
41
|
+
const execs = [
|
|
42
|
+
...appNames.map((appName) => AppExecutor.from(workspace, appName)),
|
|
43
|
+
...libNames.map((libName) => LibExecutor.from(workspace, libName))
|
|
44
|
+
];
|
|
45
|
+
const { fileName } = MaintainabilityBaseline;
|
|
46
|
+
for (const exec of execs) {
|
|
47
|
+
const contract = await this.workspaceRunner.maintainabilityContractOf(exec);
|
|
48
|
+
const { result, violations } = await contract.seed({ force });
|
|
49
|
+
const outcome = {
|
|
50
|
+
written: `wrote ${fileName} with ${violations.length} entries`,
|
|
51
|
+
kept: `kept the existing ${fileName} (${violations.length} current violations); --force rewrites it`,
|
|
52
|
+
removed: `no violations, removed ${fileName}`,
|
|
53
|
+
clean: "no violations"
|
|
54
|
+
}[result];
|
|
55
|
+
Logger.rawLog(`${contract.sysPath}: ${outcome}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// pkgs/@akanjs/cli/quality/quality.command.ts
|
|
61
|
+
class QualityCommand extends command("quality", [QualityScript], ({ public: target }) => ({
|
|
62
|
+
quality: target({ desc: "Scan apps and libs for Akan code quality warnings" }).arg("action", String, { desc: "quality action", default: "scan", enum: ["scan", "ssr", "baseline"] }).option("format", String, { desc: "output format", default: "text", enum: ["text", "json"] }).option("force", Boolean, { flag: "F", desc: "baseline: rewrite an existing akan.baseline.json", default: false }).with(Workspace).exec(async function(action, format, force, workspace) {
|
|
63
|
+
if (action === "scan")
|
|
64
|
+
await this.qualityScript.scan(workspace, format);
|
|
65
|
+
else if (action === "ssr")
|
|
66
|
+
await this.qualityScript.ssr(workspace, format);
|
|
67
|
+
else if (action === "baseline")
|
|
68
|
+
await this.qualityScript.baseline(workspace, { force });
|
|
69
|
+
else
|
|
70
|
+
throw new Error(`Unknown quality action: ${action}. Use "scan", "ssr" or "baseline".`);
|
|
71
|
+
})
|
|
72
|
+
})) {
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
QualityCommand
|
|
76
|
+
};
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
Workspace,
|
|
4
4
|
script,
|
|
5
5
|
command
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-3gccwenr.js";
|
|
7
7
|
import"./index-52w0fvh8.js";
|
|
8
|
-
import"./index-
|
|
8
|
+
import"./index-64g9fsjy.js";
|
|
9
9
|
import"./index-hj6w4ka1.js";
|
|
10
|
-
import"./index-
|
|
11
|
-
import"./index-
|
|
10
|
+
import"./index-05nxx4m5.js";
|
|
11
|
+
import"./index-8s8b4eba.js";
|
|
12
12
|
import {
|
|
13
13
|
RepairRunner
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-922k2zwq.js";
|
|
15
15
|
|
|
16
16
|
// pkgs/@akanjs/cli/repair/repair.script.ts
|
|
17
17
|
import { Logger } from "akanjs/common";
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
import {
|
|
3
3
|
Sys,
|
|
4
4
|
command
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-3gccwenr.js";
|
|
6
6
|
import"./index-52w0fvh8.js";
|
|
7
|
-
import"./index-
|
|
7
|
+
import"./index-64g9fsjy.js";
|
|
8
8
|
import {
|
|
9
9
|
renderPrimitiveReport
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-05nxx4m5.js";
|
|
11
11
|
import {
|
|
12
12
|
ScalarScript
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-x5ecanqh.js";
|
|
14
14
|
|
|
15
15
|
// pkgs/@akanjs/cli/scalar/scalar.command.ts
|
|
16
16
|
import { Logger, lowerlize } from "akanjs/common";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: akan-agent
|
|
3
|
+
description: "Build the in-page agent: mounting Agent.Chat, setAgentAccess and the request policy, the LLM, publishing st.tool actions and cards, forms, readable state, zones, route guidance and slash commands."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Akan in-page agent
|
|
7
|
+
|
|
8
|
+
**The surface is what components declare, exactly.** `st.tool` publishes one action and `st.use` / `st.sel` /
|
|
9
|
+
`st.ref` make one store key readable while the reading component is mounted. A method on a store class gives an
|
|
10
|
+
agent nothing, and only the current page's declarations are live.
|
|
11
|
+
|
|
12
|
+
## Mount it
|
|
13
|
+
|
|
14
|
+
1. Mount `<Agent.Chat />` once, in a layout. It never executes tools: every tool runs in the caller's browser,
|
|
15
|
+
gated by guards and the approval card.
|
|
16
|
+
2. It refuses every call until `option.setAgentAccess(<guard>)` in `lib/option.ts` names who may use it
|
|
17
|
+
(`SignedIn` for a product with accounts). What a turn may ask is `option.setAgentRequestPolicy`.
|
|
18
|
+
3. The LLM is `option.setLlm({ apiKey, model, host })`, never env.
|
|
19
|
+
|
|
20
|
+
## Publish actions
|
|
21
|
+
|
|
22
|
+
- Declare the tool beside the control that already does it, and hand the result to the control:
|
|
23
|
+
`st.tool("x").desc("…").arg("id", ID).exec((id) => st.do.removeX(id))`. One handler serves the person and the
|
|
24
|
+
agent; `.desc()` is required and first.
|
|
25
|
+
- `.card(({ submit, cancel }) => <Form … />)` parks the call in the chat for an answer that is the user's to give.
|
|
26
|
+
- Store-driven forms publish themselves: `onChange={st.do.setFieldOnX}` by reference emits the `data-akan-action`
|
|
27
|
+
the agent drives. A pass-through arrow publishes nothing and fails lint.
|
|
28
|
+
- Every `st.tool(…).exec()` / `.card()` is a hook: never behind a condition.
|
|
29
|
+
|
|
30
|
+
## Reads and guidance
|
|
31
|
+
|
|
32
|
+
- `st.use.x({ agent: false })` hides a key; `hidden`, `secret` and `visual` fields are stripped from every read.
|
|
33
|
+
- A tool value is capped at 20,000 characters.
|
|
34
|
+
- Route guidance is `<Agent.Guide instructions="…" />`; model-facing text is English.
|
|
35
|
+
|
|
36
|
+
Full detail: `get_guideline` with `agentRule`.
|
|
@@ -22,7 +22,7 @@ what survives in the scrollback is bordered and truncated to the pane.
|
|
|
22
22
|
|
|
23
23
|
## Which loop you are in
|
|
24
24
|
|
|
25
|
-
- **A type or lint failure** is the `akan-validate` loop
|
|
25
|
+
- **A type or lint failure** is the `akan-validate` loop: `akan verify`.
|
|
26
26
|
- **A runtime or SSR failure** is the dev log. The page renders blank, an overlay appears, or a request
|
|
27
27
|
500s — none of that shows up in a typecheck.
|
|
28
28
|
|
|
@@ -38,5 +38,5 @@ reads like its own level is not one.
|
|
|
38
38
|
|
|
39
39
|
## Before you conclude
|
|
40
40
|
|
|
41
|
-
A change that renders is not a change that passed. Run `
|
|
42
|
-
|
|
41
|
+
A change that renders is not a change that passed. Run `akan verify`; for a `.tsx` change it also runs the
|
|
42
|
+
SSR check, since a UI edit that moves markup into a client bundle typechecks perfectly.
|
|
@@ -46,5 +46,4 @@ the package client path — `import { cnst, fetch, st, usePage } from "@apps/<ap
|
|
|
46
46
|
|
|
47
47
|
## Validate
|
|
48
48
|
|
|
49
|
-
`
|
|
50
|
-
generated barrels and reports false errors.
|
|
49
|
+
`akan verify`. Raw `tsc` misses the generated barrels and reports false errors.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: akan-mcp
|
|
3
|
+
description: "Expose an app to MCP clients: what /mcp publishes from guards, mcp: false curation, option.setMcp settings, OAuth, refusals, page prompts and MCP Apps, and the exposure test."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Akan MCP
|
|
7
|
+
|
|
8
|
+
Every app serves its signals as an MCP server on `POST /mcp`, mounted by default. **Exposure follows the guards**:
|
|
9
|
+
an endpoint with a real guard is published, one with none is refused, and so is a mutation guarded only by
|
|
10
|
+
`Public`. There is no per-endpoint opt-in.
|
|
11
|
+
|
|
12
|
+
## Curation is not authorization
|
|
13
|
+
|
|
14
|
+
- `mcp: false` on an endpoint, or a `slice()` `mcp` map mirroring `guards`, keeps a perfectly guarded step (a UI
|
|
15
|
+
state-machine step a model would only call by mistake) off the shelf. It is an opt-out; everything else still
|
|
16
|
+
publishes.
|
|
17
|
+
- `guards: [Every, Person]` reserves an act for a person; `.with(AgentCall)` narrows what an agent's call may do.
|
|
18
|
+
- A guard's `static scope` decides whether a listing can hide the entry: `"account"` guards are evaluated per
|
|
19
|
+
caller, `"resource"` guards stay visible and stop the call.
|
|
20
|
+
|
|
21
|
+
## Settings
|
|
22
|
+
|
|
23
|
+
- `option.setMcp({ … })` in the app's `lib/option.ts`, never `main.ts`; `AKAN_MCP=false` takes the surface off.
|
|
24
|
+
- `JWT_SECRET` is required outside `local`.
|
|
25
|
+
- Every published entry needs a `.desc()`; model-facing text is English.
|
|
26
|
+
- Never make a refusal message more helpful.
|
|
27
|
+
|
|
28
|
+
## Pages for the host
|
|
29
|
+
|
|
30
|
+
- `page().prompt(name, description)` briefs a screen as an MCP prompt.
|
|
31
|
+
- `page().app(name, description, load)` publishes one component a host draws in the chat, as a read-only tool
|
|
32
|
+
whose `load` may only query.
|
|
33
|
+
|
|
34
|
+
## Verify
|
|
35
|
+
|
|
36
|
+
- One exposure test per app in `srvkit/mcpExposure.signal.test.ts`: list the tools with a user token, pin the names
|
|
37
|
+
with `toEqual`, and assert the curated and admin-only ones are absent. A guard change fails it first.
|
|
38
|
+
- Then `akan verify <app>` and the boot log.
|
|
39
|
+
|
|
40
|
+
Full detail: `get_guideline` with `mcpRule`, or `transportRule` for guards and rate limits.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: akan-page
|
|
3
|
+
description: "Add or change a route under page/: the one page()/layout() chain, typed params and search, guards, heads, loading and errors, overrides, and lib pages."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Akan pages
|
|
7
|
+
|
|
8
|
+
A route file exports one chain and nothing else. Every setting is a stage of it.
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
export default page()
|
|
12
|
+
.param("orgId", ID)
|
|
13
|
+
.guard(() => signedIn())
|
|
14
|
+
.render(({ orgId }) => {
|
|
15
|
+
const { l } = usePage();
|
|
16
|
+
const { taskInitInOrg } = fetch.initTaskInOrg(orgId);
|
|
17
|
+
return <Task.Zone.Card init={taskInitInOrg} prefix={`/org/${orgId}`} />;
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Steps
|
|
22
|
+
|
|
23
|
+
1. Place the file: `<route>.tsx` or `<dir>/_index.tsx` serves the path, `_layout.tsx` nests a layout (`layout()`;
|
|
24
|
+
the root one is `rootLayout()`), `[id]` is a dynamic segment, `(group)` groups without a segment. `page/` holds
|
|
25
|
+
route modules only — no helpers, no `.ts` files.
|
|
26
|
+
2. Name every `[x]` segment with `.param("x", Type)` and read a query key only with `.search("k", Type)`. Values
|
|
27
|
+
arrive typed; `lang` reaches every stage and is never declared.
|
|
28
|
+
3. Gate with `.guard(() => signedIn())` on the `_layout.tsx` (a real redirect before anything renders), and repeat
|
|
29
|
+
a stricter guard on a page that needs more. The endpoint guards are still the real gate.
|
|
30
|
+
4. In `.render()`: `usePage()`, then fetch, then return. Hand `fetch.init*` / `view*` / `edit*` fields to sections
|
|
31
|
+
unawaited; await only what the shell reads, in one `Promise.all`.
|
|
32
|
+
5. `.head()` takes JSX (or a function returning it), never a metadata object. A canonical link comes only from the
|
|
33
|
+
page's own head.
|
|
34
|
+
6. Re-skin an `akanjs/ui` component for a subtree with `_overrides.tsx`:
|
|
35
|
+
`export default override({ Slot: AppComponent })`, no logic.
|
|
36
|
+
|
|
37
|
+
## Never
|
|
38
|
+
|
|
39
|
+
- A `fetch.<mutation>()` while rendering — it throws `base.error.mutationInRender`, because opening a link would
|
|
40
|
+
perform it. Send writes from a user action.
|
|
41
|
+
- `useState`, `useEffect`, comments, a named export beside the chain, or the legacy `export default async function`.
|
|
42
|
+
- Editing a lib page through its link in `page/(libs)/` — edit the lib's own `page/` source.
|
|
43
|
+
|
|
44
|
+
Full detail: `get_guideline` with `pageRule`, or `ssrRule` for what may render on the server.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: akan-query
|
|
3
|
+
description: "Write filters, slices and list loading: query descriptors, init paging and loadMoreOf, soft removal and hookless writes, q.search text search, and the cascade direction."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Akan queries and slices
|
|
7
|
+
|
|
8
|
+
## Filters and slices
|
|
9
|
+
|
|
10
|
+
- A filter in `<model>.document.ts` declares its args; a slice in `<model>.signal.ts` serves it to stores. A slice
|
|
11
|
+
`exec` returns a `query<Filter>(…)` descriptor — never a `list<Filter>` array — and you cannot chain sort or
|
|
12
|
+
limit on it.
|
|
13
|
+
- Page through the store: `initX(…, { sort, page, limit })`, then `st.do.loadMoreOf<Model>()` while
|
|
14
|
+
`hasMoreOf<Model>`. Never compare `count > page * limit`.
|
|
15
|
+
- Never ask for more than 500 rows: the server serves at most 500 per request and drops the rest silently.
|
|
16
|
+
A figure over the whole set belongs in an insight or an endpoint.
|
|
17
|
+
- The root slice takes a filter name and its args, never a raw query, and its `root:` guard is always `Admin`.
|
|
18
|
+
- No value is `q.empty`, never `q.missing`.
|
|
19
|
+
- A projection is bare on the facade (`pickById(id, { secret: true })`) and under `select` on a filter accessor —
|
|
20
|
+
the only way to read a `field.secret` value.
|
|
21
|
+
|
|
22
|
+
## Writes and removal
|
|
23
|
+
|
|
24
|
+
- Removal is soft: reads see live rows unless `{ withRemoved: true }`. The one hard delete is `purge<Filter>` /
|
|
25
|
+
`purgeMany`, for data past retention.
|
|
26
|
+
- A filter's `remove*` / `update*`, `updateById` and `removeById` run no hooks and no cascade. A model with a
|
|
27
|
+
cascade or `_postRemove` removes through `remove<Model>(id)`.
|
|
28
|
+
- Load a set once (`load<Model>Many`, one filter query) instead of one call per item in a loop — lint fails a
|
|
29
|
+
per-item service call an endpoint reaches.
|
|
30
|
+
|
|
31
|
+
## Search and cascade
|
|
32
|
+
|
|
33
|
+
- `q.search(text, { prefix: true })` sits in a filter at an AND position, over fields with the `text` role. Blank
|
|
34
|
+
input matches nothing — never a passthrough. A search slice only over data safe to enumerate.
|
|
35
|
+
- `cascade` names a direction, and the wrong one loses data: `removeRef` on the owner's relation, `removeWith` on
|
|
36
|
+
the child's reference to its owner.
|
|
37
|
+
|
|
38
|
+
Full detail: `get_guideline` with `queryRule`, and `workspaceRecipes` for a worked slice.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: akan-runtime
|
|
3
|
+
description: "Configure how an app runs: web surfaces, route prefixes, gateway vs solo, akan start and logs, the Docker image, native and desktop apps, database modes, ops, assets and the build pipeline."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Akan runtime
|
|
7
|
+
|
|
8
|
+
Runtime and build settings are declared in `akan.config.ts` and narrowed — never widened — by an env at boot.
|
|
9
|
+
Domain code reaches none of them.
|
|
10
|
+
|
|
11
|
+
## Where each setting lives
|
|
12
|
+
|
|
13
|
+
| Want | Setting |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| API only, or no CSR bundle for native apps | `web: false`, `web: { csr: false }` |
|
|
16
|
+
| Move the API or websocket mount | `new AkanApp({ prefix, websocketPrefix })` in `main.ts`, mirrored in `api: { … }`; read with `getApiPrefix()` / `getWsPrefix()` |
|
|
17
|
+
| The production image | `docker: string \| { image, preRuns, postRuns, command }` |
|
|
18
|
+
| iOS, Android, desktop | the `native` section; `desktop: { server: true }` carries the server |
|
|
19
|
+
| SQLite, several databases, a cluster | `database: { modes: [...] }`, picked by `AKAN_DATABASE_MODE` |
|
|
20
|
+
|
|
21
|
+
- `main.ts` imports `AkanApp` from `akanjs/server/akanApp`, never the barrel.
|
|
22
|
+
- Never write `/api` or `/ws` literally, and never pass a prefix as a prop.
|
|
23
|
+
- The generated image installs only `ca-certificates` and `tzdata`; add the rest in `preRuns`.
|
|
24
|
+
- An app running in two database modes avoids `q.raw`.
|
|
25
|
+
|
|
26
|
+
## Running and logs
|
|
27
|
+
|
|
28
|
+
- `akan start <app>` (`a,b` or `all` for several) runs the dev server; `akan build <app>` checks the production
|
|
29
|
+
build. A supervised session writes `local/apps/<app>/runtime/dev.log` — hand over that path, not a paste of the
|
|
30
|
+
live view. Tail with `akan logs <app>`.
|
|
31
|
+
- Give every log sink a floor (`Logger.addSink(sink, { minLevel })`) and never log once per delivered record.
|
|
32
|
+
|
|
33
|
+
## Native and desktop
|
|
34
|
+
|
|
35
|
+
- `akan start-desktop <app>`, `akan start-ios <app>`, `akan start-android <app>` load pages from a running
|
|
36
|
+
`akan start`; a desktop app carrying its server starts it itself.
|
|
37
|
+
- A desktop app's carried server listens on a loopback port any local program can call — guard it like a network
|
|
38
|
+
server. Read runtime files from `AKAN_APP_DIR`, and keep a user's secret with `NativeSecret`, never in a file.
|
|
39
|
+
|
|
40
|
+
Full detail: `get_guideline` with `runtimeRule`.
|
|
@@ -43,8 +43,8 @@ Each result names the next call in `next.tool`. Follow it; do not improvise.
|
|
|
43
43
|
and each workflow's inputs.)
|
|
44
44
|
2. `apply_workflow({ planPath })` — writes the scaffold and syncs the generated barrels. Returns
|
|
45
45
|
`validationTarget`.
|
|
46
|
-
3. `run_validation({ runIdOrPlan: <validationTarget> })`, or
|
|
47
|
-
|
|
46
|
+
3. `run_validation({ runIdOrPlan: <validationTarget> })`, or run `akan verify` (`akan_verify` in akan code);
|
|
47
|
+
both are the whole chain in one process.
|
|
48
48
|
4. **Read each scaffolded file before editing it.** They are a few lines each and they extend base classes
|
|
49
49
|
that already generated the CRUD surface. Read the `akan-store` skill before touching a store or adding
|
|
50
50
|
signal endpoints, or you will redeclare `create<Model>` and hit an "already exists" typecheck error.
|
|
@@ -60,9 +60,19 @@ Each result names the next call in `next.tool`. Follow it; do not improvise.
|
|
|
60
60
|
- Hand-writing files is the fallback, used only when no workflow matches, or when apply reports
|
|
61
61
|
unsupported / no-op / failed diagnostics telling you to act manually. Say which case applied.
|
|
62
62
|
- Never hand-edit a generated file to "finish" a scaffold — use `repair_generated` or `akan sync <app>`.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
|
|
64
|
+
## No workflow tools? The CLI is the same chain
|
|
65
|
+
|
|
66
|
+
The tools come from `akan mcp` (`--mode plan` reads, `--mode apply` writes). When they are not connected, each
|
|
67
|
+
has a command that prints the same report:
|
|
68
|
+
|
|
69
|
+
| tool | command |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `list_workflows` / `explain_workflow` | `akan workflow list` / `akan workflow explain <name>` |
|
|
72
|
+
| `plan_workflow` | `akan workflow plan create-module --app <app> --module comment --format json --out <path>` |
|
|
73
|
+
| `apply_workflow` | `akan workflow apply <path> --format json` (`--dry-run` previews) |
|
|
74
|
+
| `run_validation` | `akan verify <app>` |
|
|
75
|
+
| `repair_generated` / `repair_imports` / `repair_module_shape` | `akan repair generated\|imports\|module-shape --app <app>` |
|
|
66
76
|
|
|
67
77
|
## Worked example — "an intro page, two detail pages, and a comment zone with a database"
|
|
68
78
|
|
|
@@ -73,4 +83,4 @@ Each result names the next call in `next.tool`. Follow it; do not improvise.
|
|
|
73
83
|
leave the store body empty unless you need extra state.
|
|
74
84
|
4. Write the pages and the comment UI against the generated actions — `st.do.createComment`,
|
|
75
85
|
`st.do.initCommentInPublic`, `st.use.commentListInPublic`.
|
|
76
|
-
5. `
|
|
86
|
+
5. `akan verify` until it prints `verify ok`.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: akan-transport
|
|
3
|
+
description: "Guard and tune endpoints on the wire: writing a Can<Verb><Model> guard, deadlines, cache, idempotency, rate limits, server-to-server calls, body types, bytes and HTTP verbs."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Akan transport
|
|
7
|
+
|
|
8
|
+
## Guards
|
|
9
|
+
|
|
10
|
+
- Every custom `query` / `mutation` / `pubsub` / `message` names its own `guards: [...]`; every `slice()` takes an
|
|
11
|
+
explicit guard map with `root: Admin`. `Public` belongs on a slice `get:`, and on a mutation only for an act that
|
|
12
|
+
must work signed out (sign-up, sign-in, token refresh, an OAuth route), which also declares a `rateLimit`.
|
|
13
|
+
- A resource guard is a `Can<Verb><Model>` class in the model library's `srvkit/guards.ts` that fails closed:
|
|
14
|
+
no resource named, or a load that throws, is `false` (after a `logger.warn`). Admin bypass goes first.
|
|
15
|
+
- Every guard declares `static scope`: `"account"` reads only the caller (`SignedIn`, `Admin`, roles), and
|
|
16
|
+
`"resource"` needs the call's arguments (every `Can<Verb><Model>`). Keep `static name = "User";` with a comment.
|
|
17
|
+
- Guards read `context.get<T>("account")`, serve HTTP and websocket alike, and stay side-effect free. The acting
|
|
18
|
+
user comes from `.with(Self)` / `.with(CurrentUserId)` / `.with(Me)`, the address from `.with(Ip)` — never a
|
|
19
|
+
client-supplied id. The service re-checks ownership: two independent gates.
|
|
20
|
+
|
|
21
|
+
## Endpoint options
|
|
22
|
+
|
|
23
|
+
- `{ timeout: <ms> }` is the deadline on both ends; undeclared, the client quits at 30 s and the handler is not
|
|
24
|
+
cancelled.
|
|
25
|
+
- `{ cache }` only on a `query` with no internal argument, capped at one day; `invalidate(endpoint, args?)` drops
|
|
26
|
+
it early through a plugged `EndpointCacheControl`.
|
|
27
|
+
- `{ rateLimit: { calls, windowMs?, by? } }` per endpoint, `option.setRateLimit` per app, `plug(RateLimit)` for a
|
|
28
|
+
business key.
|
|
29
|
+
- A mutation repeated under one `Idempotency-Key` header runs once and replays its first answer.
|
|
30
|
+
- `{ method: "PATCH" | "PUT" | "DELETE" }` moves a mutation off `POST` — only when a foreign protocol forces it.
|
|
31
|
+
- `errors: { 409: ["ticket.error.locked"] }` names the errors an endpoint throws on purpose.
|
|
32
|
+
|
|
33
|
+
## Bodies and other servers
|
|
34
|
+
|
|
35
|
+
- `.body()` / `.param()` take scalars, model refs or `enumOf(...)`; `Int` / `Float`, never `Number`; bytes are
|
|
36
|
+
`Binary`, never `Any`; `Upload` only in a `fileUpload: true` mutation.
|
|
37
|
+
- Server to server, `fetch.clone({ origin })` opens no socket without `connect: true`, retries through `retry`,
|
|
38
|
+
and rethrows a remote `Err` as it is — never wrap or re-key it.
|
|
39
|
+
|
|
40
|
+
Full detail: `get_guideline` with `transportRule`, or `mcpRule` for what a guard's scope does to an MCP listing.
|
|
@@ -7,17 +7,19 @@ description: "Run the akan check loop after editing and fix each failure class t
|
|
|
7
7
|
|
|
8
8
|
## One call does the whole chain
|
|
9
9
|
|
|
10
|
-
`
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
- `akan
|
|
19
|
-
- `akan
|
|
20
|
-
- `akan build
|
|
10
|
+
`akan verify` (the `akan_verify` tool in akan code) syncs, lints with fixes, typechecks, fast-builds each
|
|
11
|
+
changed app, and runs the SSR check for a `.tsx` change — over everything the working tree has changed, in one
|
|
12
|
+
process. It prints one line when it passes and one line per problem when it fails. **Run it after editing,
|
|
13
|
+
before you say you are done.** In akan code it also runs itself at the end of a turn that changed source.
|
|
14
|
+
|
|
15
|
+
Never run `akan lint`, `akan typecheck` and `akan build` in turn: that is the same work three times over, at
|
|
16
|
+
three times the output. Narrow the one command instead:
|
|
17
|
+
|
|
18
|
+
- `akan verify <app-or-lib-or-pkg>` — that target whole, changed or not.
|
|
19
|
+
- `akan verify --lint-only` — the quick pass between edits.
|
|
20
|
+
- `akan verify --no-build` — leave the app build out.
|
|
21
|
+
- `akan verify --max 0` — every line, when the report ends in `+N more`.
|
|
22
|
+
- `fixed N files` in the header means lint rewrote them on disk: re-read before editing them again.
|
|
21
23
|
|
|
22
24
|
Raw `tsc` misses the generated barrels and reports false errors. Do not reach for it.
|
|
23
25
|
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
runner,
|
|
6
6
|
script,
|
|
7
7
|
command
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-3gccwenr.js";
|
|
9
9
|
import {
|
|
10
10
|
FileSys2
|
|
11
11
|
} from "./index-52w0fvh8.js";
|
|
@@ -14,20 +14,20 @@ import {
|
|
|
14
14
|
Executor,
|
|
15
15
|
WorkspaceExecutor,
|
|
16
16
|
AppExecutor
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-64g9fsjy.js";
|
|
18
18
|
import {
|
|
19
19
|
GlobalConfig
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-0zyatd10.js";
|
|
21
21
|
import"./index-m9jj544v.js";
|
|
22
|
-
import"./index-
|
|
23
|
-
import"./index-
|
|
24
|
-
import"./index-
|
|
22
|
+
import"./index-kjrvwzav.js";
|
|
23
|
+
import"./index-1dhf8ymv.js";
|
|
24
|
+
import"./index-0zwznvv1.js";
|
|
25
25
|
import {
|
|
26
26
|
SubspaceConfig
|
|
27
27
|
} from "./index-4pf8g7ff.js";
|
|
28
28
|
import {
|
|
29
29
|
SlicePlanner
|
|
30
|
-
} from "./index-
|
|
30
|
+
} from "./index-mwj9q2ya.js";
|
|
31
31
|
|
|
32
32
|
// pkgs/@akanjs/devkit/subspace.ts
|
|
33
33
|
import { mkdir as mkdir2 } from "fs/promises";
|
|
@@ -816,7 +816,7 @@ class SubspaceRunner extends runner("subspace") {
|
|
|
816
816
|
if (!asked)
|
|
817
817
|
return { name: subspace.name, workspaceId, host, apps, libs: [], outcome: "cancelled", files: [] };
|
|
818
818
|
const { libs } = await subspace.slice();
|
|
819
|
-
const { CloudScript } = await import("./cloud.script-
|
|
819
|
+
const { CloudScript } = await import("./cloud.script-nkmeyhet.js");
|
|
820
820
|
const { files } = await CommandContainer.get(CloudScript).uploadEnv(workspace, {
|
|
821
821
|
host,
|
|
822
822
|
workspaceId,
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
This is an Akan.js workspace. Akan is convention-driven: keep business intent in the expected place and let
|
|
4
4
|
the framework generate the repeated surfaces.
|
|
5
5
|
|
|
6
|
-
For agent-neutral documentation that Claude Code, Codex, Devin, GitHub Copilot Coding Agent, and other tools can
|
|
7
|
-
also read, see `docs/AI-DEVELOPMENT.md` and `docs/GENERATED.md`.
|
|
8
|
-
|
|
9
6
|
## Framework Bugs And Feature Requests
|
|
10
7
|
|
|
11
8
|
If you hit an Akan.js bug, or a fix that one framework change would solve more easily than app-level workarounds,
|
|
@@ -14,13 +11,10 @@ the user before filing it. Keep any interim workaround small and marked `// TODO
|
|
|
14
11
|
|
|
15
12
|
## Generated Context
|
|
16
13
|
|
|
17
|
-
The section below is regenerated by `akan agent install` (run `bun run setup:agent`)
|
|
18
|
-
|
|
19
|
-
markers freely; content between them is overwritten on the next
|
|
20
|
-
|
|
21
|
-
It carries the rules only. The reasoning behind each area lives in deep-dive guidelines fetched on demand —
|
|
22
|
-
`akan guideline list` names them, `akan guideline show <name>` prints one, and an agent wired to `akan mcp`
|
|
23
|
-
calls `get_guideline` instead.
|
|
14
|
+
The section below is regenerated by `akan agent install` (run `bun run setup:agent`), together with the path
|
|
15
|
+
rules in `.claude/rules/akan/` and `.cursor/rules/akan-*.mdc` and the skills in `.claude/skills/` and
|
|
16
|
+
`.agents/skills/`. Edit anything outside the markers freely; content between them is overwritten on the next
|
|
17
|
+
install, and so is a generated file that still carries its `<!-- akan:generated -->` marker.
|
|
24
18
|
|
|
25
19
|
<!-- akan:agent:start -->
|
|
26
20
|
<!-- Populated by `akan agent install`. Run `bun run setup:agent` to refresh. -->
|
|
@@ -4,22 +4,22 @@ import {
|
|
|
4
4
|
runner,
|
|
5
5
|
script,
|
|
6
6
|
command
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-3gccwenr.js";
|
|
8
8
|
import"./index-52w0fvh8.js";
|
|
9
9
|
import {
|
|
10
10
|
AppExecutor
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-64g9fsjy.js";
|
|
12
12
|
import {
|
|
13
13
|
GlobalConfig,
|
|
14
14
|
CloudApi
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-0zyatd10.js";
|
|
16
16
|
import"./index-m9jj544v.js";
|
|
17
|
-
import"./index-
|
|
18
|
-
import"./index-
|
|
19
|
-
import"./index-
|
|
17
|
+
import"./index-kjrvwzav.js";
|
|
18
|
+
import"./index-1dhf8ymv.js";
|
|
19
|
+
import"./index-0zwznvv1.js";
|
|
20
20
|
import {
|
|
21
21
|
TunnelShare2
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-et6ce601.js";
|
|
23
23
|
import {
|
|
24
24
|
writeClipboard
|
|
25
25
|
} from "./index-p6pbz9n5.js";
|