ais6-app 0.0.0-stage → 0.2.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.
@@ -0,0 +1,66 @@
1
+ // What must never be published: credentials, local machine paths and private
2
+ // files. The desk's release scan imports the same patterns and adds its own
3
+ // list of private names, which is not part of this package.
4
+
5
+ import { readFileSync, statSync } from "node:fs";
6
+ import { relative, sep } from "node:path";
7
+ import { listFiles } from "./files.mjs";
8
+
9
+ export const credentialPatterns = [
10
+ { name: "Anthropic API key", pattern: /\bsk-ant-[A-Za-z0-9_-]{16,}/g },
11
+ { name: "OpenAI-style API key", pattern: /\bsk-(?!ant-)[A-Za-z0-9]{20,}/g },
12
+ { name: "GitHub token", pattern: /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/g },
13
+ { name: "GitHub fine-grained token", pattern: /\bgithub_pat_[A-Za-z0-9_]{20,}/g },
14
+ { name: "AWS access key id", pattern: /\bAKIA[0-9A-Z]{16}\b/g },
15
+ { name: "Slack token", pattern: /\bxox[baprs]-[A-Za-z0-9-]{10,}/g },
16
+ { name: "Google API key", pattern: /\bAIza[0-9A-Za-z_-]{35}\b/g },
17
+ { name: "private key block", pattern: /-----BEGIN (?:RSA |EC |OPENSSH |PGP )?PRIVATE KEY-----/g },
18
+ { name: "DeepSeek-style key", pattern: /\bsk-[a-f0-9]{32}\b/g },
19
+ ];
20
+
21
+ export const localPathPatterns = [
22
+ { name: "local user home path", pattern: /(?<![\w/.])\/(?:Users|home)\/[A-Za-z0-9._-]+(?:\/[^\s"'`()<>\[\],;:]*)*/g },
23
+ { name: "temporary local path", pattern: /(?<![\w/.])\/(?:private\/)?var\/(?:folders|tmp)\/[^\s"'`()<>\[\],;:]*/g },
24
+ { name: "Windows user path", pattern: /\b[A-Z]:\\Users\\[^\\\s"'`]+/g },
25
+ { name: "private AI conversation link", pattern: /https?:\/\/(?:chatgpt\.com|chat\.openai\.com)\/(?:c|backend-api)\/[^\s"'`()<>\[\]]+|https?:\/\/claude\.ai\/chat\/[^\s"'`()<>\[\]]+/g },
26
+ ];
27
+
28
+ export const forbiddenPathPatterns = [
29
+ { name: "environment file with real values", pattern: /(?:^|\/)\.env(?!\.example$)(?:\.|$)/ },
30
+ { name: "private key / certificate", pattern: /\.(?:pem|key|p12|pfx|keystore|jks)$/i },
31
+ { name: "SSH material", pattern: /(?:^|\/)(?:id_rsa|id_ed25519|id_ecdsa|\.ssh)(?:\/|$)/ },
32
+ { name: "npm/yarn credentials", pattern: /(?:^|\/)\.(?:npmrc|yarnrc)$/ },
33
+ { name: "git metadata", pattern: /(?:^|\/)\.git(?:\/|$)/ },
34
+ { name: "local database", pattern: /\.(?:sqlite|sqlite3|db)$/i },
35
+ { name: "agent/editor config", pattern: /(?:^|\/)\.(?:claude|vscode|idea)(?:\/|$)/ },
36
+ { name: "working notes not meant to publish", pattern: /(?:^|\/)(?:drafts|codex-snapshots|memory)(?:\/|$)/ },
37
+ // An app may ship these on purpose (a GPL app's corresponding source, a
38
+ // source map); `ais6-app check` reports them as warnings, the desk's own
39
+ // release scan refuses them.
40
+ { name: "archive", pattern: /\.(?:zip|tar|tgz|gz|rar|7z)$/i, appWarning: true },
41
+ { name: "source map", pattern: /\.map$/i, appWarning: true },
42
+ ];
43
+
44
+ const TEXT = /\.(?:m?[jt]sx?|json|html?|css|svg|md|txt|ya?ml|toml|xml|sh|py|cfg|ini|csv)$/i;
45
+ const MAX_TEXT_BYTES = 4 * 1024 * 1024;
46
+
47
+ /** Findings in a tree about to be published: [{ file, line?, kind, name }]. */
48
+ // `skipFiles`: generated engine glue (Emscripten), whose virtual file system
49
+ // paths (/home/web_user) are not anyone's machine.
50
+ export function scanForPublishing(dir, { skip = ["node_modules", "dist"], skipFiles = [] } = {}) {
51
+ const findings = [];
52
+ for (const file of listFiles(dir, { ignore: [...skip, ".git"] })) {
53
+ const rel = relative(dir, file).split(sep).join("/");
54
+ if (skipFiles.some((name) => rel === name || rel.endsWith(`/${name}`))) continue;
55
+ for (const rule of forbiddenPathPatterns) if (rule.pattern.test(rel)) findings.push({ file: rel, kind: rule.appWarning ? "warning" : "path", name: rule.name });
56
+ if (!TEXT.test(rel) || statSync(file).size > MAX_TEXT_BYTES) continue;
57
+ const lines = readFileSync(file, "utf8").split("\n");
58
+ lines.forEach((text, index) => {
59
+ for (const rule of [...credentialPatterns, ...localPathPatterns]) {
60
+ rule.pattern.lastIndex = 0;
61
+ if (rule.pattern.test(text)) findings.push({ file: rel, line: index + 1, kind: credentialPatterns.includes(rule) ? "credential" : "local", name: rule.name });
62
+ }
63
+ });
64
+ }
65
+ return findings;
66
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) __YEAR__ __AUTHOR__
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # __NAME__
2
+
3
+ An app for AI System 6, made from the `ais6-app create` template
4
+ (TypeScript + Preact). It runs in a window of the desk, and on its own page.
5
+
6
+ [中文说明](README.zh-CN.md)
7
+
8
+ ## Run it
9
+
10
+ ```bash
11
+ npm install
12
+ npm run dev # its own page, with the kit's standalone adapter
13
+ npm run check # types, lint, tests, build, then ais6-app check
14
+ ```
15
+
16
+ `npm run build` writes `dist/`, the folder a desk installs.
17
+
18
+ ## Where things are
19
+
20
+ | Path | What it holds |
21
+ | --- | --- |
22
+ | `public/app.manifest.json` | id, version, window, capabilities, menus, the window title in both languages |
23
+ | `public/ais6-bridge.js`, `public/kit.css` | the app kit: the bridge client and the shared controls. Do not edit; update them from the kit |
24
+ | `src/bridge/` | the one connection to the desk, typed |
25
+ | `src/strings/` | every string, in English and Chinese; a missing key does not compile |
26
+ | `src/ui/`, `src/styles/` | the window's content, drawn with the kit's classes and tokens |
27
+
28
+ ## Rules a desk enforces
29
+
30
+ - Everything outside the frame goes through the bridge: no `window.parent`,
31
+ no desk globals, no `localStorage` of your own.
32
+ - The version in `app.manifest.json`, `package.json` and `APP_VERSION` in
33
+ `src/bridge/bridge.ts` is one number. Raise all three together.
34
+ - A capability or service the manifest does not list is refused.
35
+
36
+ The full SDK: https://aisystem6.aaronlau.me/sdk/
37
+
38
+ ## Licence
39
+
40
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,37 @@
1
+ # __NAME_ZH__
2
+
3
+ 一个 AI System 6 应用,由 `ais6-app create` 模板生成(TypeScript + Preact)。它在桌面的窗口里运行,也能在自己的页面上单独运行。
4
+
5
+ [English](README.md)
6
+
7
+ ## 运行
8
+
9
+ ```bash
10
+ npm install
11
+ npm run dev # 独立页面,由套件的独立适配器应答
12
+ npm run check # 类型、lint、测试、构建,最后跑 ais6-app check
13
+ ```
14
+
15
+ `npm run build` 生成 `dist/`,也就是桌面安装的文件夹。
16
+
17
+ ## 文件在哪里
18
+
19
+ | 路径 | 内容 |
20
+ | --- | --- |
21
+ | `public/app.manifest.json` | id、版本、窗口、能力、菜单,以及两种语言的窗口标题 |
22
+ | `public/ais6-bridge.js`、`public/kit.css` | 应用套件:桥接客户端和共用控件。不要改,从套件更新 |
23
+ | `src/bridge/` | 与桌面之间唯一的连接,带类型 |
24
+ | `src/strings/` | 所有文字,英文和中文各一份;少一个键就编译不过 |
25
+ | `src/ui/`、`src/styles/` | 窗口内容,用套件的类和令牌绘制 |
26
+
27
+ ## 桌面会检查的规则
28
+
29
+ - 框架之外的一切都经过桥接:不碰 `window.parent`,不碰桌面的全局对象,不自己用 `localStorage`。
30
+ - `app.manifest.json`、`package.json` 和 `src/bridge/bridge.ts` 里的 `APP_VERSION` 是同一个版本号,要一起改。
31
+ - 清单没列出的能力或服务一律拒绝。
32
+
33
+ 完整 SDK:https://aisystem6.aaronlau.me/sdk/
34
+
35
+ ## 许可
36
+
37
+ MIT,见 [LICENSE](LICENSE)。
@@ -0,0 +1,4 @@
1
+ node_modules/
2
+ dist/
3
+ *.log
4
+ .DS_Store
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3
+ "files": {
4
+ "includes": ["**", "!dist", "!node_modules", "!public", "!**/*.md"]
5
+ },
6
+ "formatter": { "indentStyle": "space", "indentWidth": 2, "lineWidth": 120 },
7
+ "linter": { "enabled": true, "rules": { "preset": "recommended" } }
8
+ }
@@ -0,0 +1,14 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>__NAME__</title>
7
+ <link rel="stylesheet" href="./kit.css" />
8
+ <script src="./ais6-bridge.js"></script>
9
+ </head>
10
+ <body>
11
+ <div id="app"></div>
12
+ <script type="module" src="./src/main.tsx"></script>
13
+ </body>
14
+ </html>
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "__APP_ID__",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "scripts": {
8
+ "dev": "vite",
9
+ "build": "tsc -b && vite build",
10
+ "preview": "vite preview",
11
+ "typecheck": "tsc -b",
12
+ "lint": "biome check .",
13
+ "test": "vitest run",
14
+ "check": "npm run typecheck && npm run lint && npm run test && npm run build && ais6-app check ."
15
+ },
16
+ "dependencies": {
17
+ "preact": "11.2.0"
18
+ },
19
+ "devDependencies": {
20
+ "@biomejs/biome": "2.6.7",
21
+ "@preact/preset-vite": "2.10.6",
22
+ "ais6-app": "^__CHECKER_VERSION__",
23
+ "typescript": "7.0.2",
24
+ "vite": "8.3.8",
25
+ "vitest": "5.1.0"
26
+ }
27
+ }